




版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請進行舉報或認領(lǐng)
文檔簡介
1、百度質(zhì)量部面試筆試體驗之一三面1.有過什么實習經(jīng)歷?。?.1安天實驗室在哈爾濱安天實驗室,我在 CERT組實習,跟過兩個大神,一 個是胡哥,部門技術(shù)經(jīng)理,在異常分析方面很犀利。一個是swordlea, 對李哥的印象就是 C+大神,同時他也是 CERT老大。當時的項目 是做一個whois的查詢插件,VC+編寫。當然的組件功能是輸入一 個IP地址,能夠查詢出它的whois信息,因為有點久了,當時也是 借鑒網(wǎng)上代碼寫出來的,自己的代碼找不到了(當然怎么就沒備份呢),就拿網(wǎng)上的代碼湊合一下:/* brief* Whois clie nt program* details* This program s
2、hall fetch whois data for a IPv4 address.* author Silver Moon ( mOO n. silv3r )* */#in clude /sca nf , printf#i nclude /strtok#i nclude /realloc#in clude /socket#i nclude sockaddr_i n#in clude /getsock name#in clude /hoste nt#i nclude /closeint main (i nt argc , char *argv)char ip100 , *data = NULL;
3、printf( En ter ip address to whois :sca nf( %s , ip);get_whois(ip , data);printf(puts(data);free(data);return 0;Get the whois content of an ip by Selecti ng the correct server */void get_whois(char *ip , char *data)char *wch = NULL, *pch , *resp onse = NULL; if(whois_query( whois.ia , ip , re
4、sp on se) printf( Whois query failedpch = strtok(resp onse ,while(pch != NULL)/Check if whois linewch = strstr(pch , whois.if(wch != NULL)break;/Next line please pch = strtok(NULL ,if(wch != NULL)printf( Whois server is : %s , wch);whois_query(wch , ip , data);else*data = malloc(100);strcpy(*data ,
5、No whois datareturn;/*thechar* Perform a whois query to a server an d record resp onse* */int whois_query(char *server , char *query ,*resp on se)char ip32 , message100 , buffer1500;int sock , read_size , total_size = 0;struct sockaddr_i n dest;sock = socket(AF_INET , SOCK_STREAM , IPPROTO_TCP);/Pre
6、pare conn ecti on structures :)memset( dest , 0 , sizeof(dest);dest.sin_family = AF_INET;printf( Resol ving %s. , server);if(host name_t 0p(server , ip)printf( Failedreturn 1;printf( %s , ip);dest.s in _addr.s_addr = in et_addr( ip );dest.s in _port = htons( 43 );/Now connect to remote serverif(conn
7、 ect( sock , (const struct sockaddr*) dest sizeof(dest) ) 0)perror( connect failed/Now send some data or messageprintf( Query ing for . %s . , query);spri ntf(message , %s , query);if( sen d(sock , message , strle n( message) , 0) 0)perror( send failed/Now receive the resp onsewhile( (read_size = re
8、cv(sock , buffer , sizeof(buffer) , 0) *resp onse = realloc(*resp onse , read_size + total_size);if(*resp onse = NULL)printf( realloc failedmemcpy(*resp onse + total_size , buffer , read_size);total_size += read_size;printf( Donefflush(stdout);*resp onse = realloc(*resp onse , total_size + 1);*(*res
9、p onse + total_size)=”;close(sock);return 0;/* brief* Get the ip address of a give n host name* */int host name_t 0p(char * host name , char* ip)struct hoste nt *he;struct in _addr *addr_list;int i;if ( (he = gethostb yn ame( host name ) ) = NULL)/ get the host infoherror( gethostb yn amereturn 1;addr_list = (struct in _
溫馨提示
- 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請下載最新的WinRAR軟件解壓。
- 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
- 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會有圖紙預覽,若沒有圖紙預覽就沒有圖紙。
- 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
- 5. 人人文庫網(wǎng)僅提供信息存儲空間,僅對用戶上傳內(nèi)容的表現(xiàn)方式做保護處理,對用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對任何下載內(nèi)容負責。
- 6. 下載文件中如有侵權(quán)或不適當內(nèi)容,請與我們聯(lián)系,我們立即糾正。
- 7. 本站不保證下載資源的準確性、安全性和完整性, 同時也不承擔用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。
最新文檔
- 五年級數(shù)學(小數(shù)乘法)計算題專項練習及答案
- 2024年中考押題預測卷(江蘇蘇州卷)-數(shù)學(參考答案)
- 湖南工業(yè)職業(yè)技術(shù)學院《教育見習與研習二》2023-2024學年第二學期期末試卷
- 廣西科技大學《流行鋼琴(1)》2023-2024學年第二學期期末試卷
- 廣東汕頭幼兒師范高等??茖W?!蛾愒O與展示設計》2023-2024學年第二學期期末試卷
- 廣東科貿(mào)職業(yè)學院《水利工程施工》2023-2024學年第二學期期末試卷
- 江西婺源茶業(yè)職業(yè)學院《學前兒童音樂教育與活動指導》2023-2024學年第二學期期末試卷
- 長沙電力職業(yè)技術(shù)學院《工程結(jié)構(gòu)1》2023-2024學年第二學期期末試卷
- 武漢音樂學院《認識科學與科學素質(zhì)的培養(yǎng)》2023-2024學年第二學期期末試卷
- 南京財經(jīng)大學《臨床基本技能Ⅲ》2023-2024學年第二學期期末試卷
- 2025年北京市第一次普通高中學業(yè)水平合格性考試歷史試題(含答案)
- 甲醇的理化性質(zhì)及危險特性
- 2022年高考生物“強基計劃”模擬試題(全國甲卷)(共10套)(含解析)
- 公路質(zhì)量控制要點及質(zhì)量通病防治手冊(含圖)
- 中國天眼課件
- 球罐安裝工程施工技術(shù)方案
- 《民國人物大辭典》附名錄
- 裝修管理規(guī)則-城市綜合體---成都租戶指引
- 基于QuartusII的多功能數(shù)字鐘設計
- 國家開放大學《數(shù)學思想與方法》形考任務參考答案
- 第三屆全國中小學公開課電視展示活動的通知
評論
0/150
提交評論