下面是利用raw socket自己管理ip頭和udp頭的例子~~~~~udp隱藏自己的ip很容易,但是tcp就難了,因為必須和遠端主機建立連線~~~~~~~~`假的ip位址怎麼建立連線呢???
inte***ce
uses
windows, messages, sysutils, variants, classes, graphics, controls, forms,
dialogs, stdctrls, winsock2, yrecords;
type
tform1 = class(tform)
button1: tbutton;
edtdestip: tedit;
edtfromip: tedit;
edtdestport: tedit;
edtfromport: tedit;
listbox1: tlistbox;
procedure formcreate(sender: tobject);
procedure formclose(sender: tobject; var action: tcloseaction);
procedure button1click(sender: tobject);
private
public
end;
varform1: tform1;
implementation
function checksum( p: pu16; size: u16 ):u16;
varchksum : u32;
pbuf : pu16;
begin
pbuf := p;
chksum := 0;
while size > 1 do
begin
chksum := chksum + pbuf^;
inc( pbuf );
dec( size, sizeof(u16) );
end;
if size=1 then
chksum := chksum + pbyte(pbuf)^;
chksum := (chksum shr 16 )+(chksum and $ffff);
chksum := chksum + (chksum shr 16);
chksum := not chksum;
result := u16(chksum);
end;
//填充ip header
procedure fillipheader( pip: pipheader; ttl:u8; datalen: u32; proto: u8;
destip, fromip: u32 );
varb : u8;
w : u16;
begin
b := 4;
pip^.u8verlen := ( b shl 4 ) or (sizeof(yipheader) div sizeof(u32));
pip^.u8tos := 0;
w := u16( sizeof(yipheader) + sizeof(yudpheader) + datalen );
pip^.u16totallen := htons( w );
pip^.u16id := u16(getcurrentprocessid);
pip^.u16offset := htons(1 shl 14);//do not fragment
pip^.u8ttl := ttl;
pip^.u8protol := proto;
pip^.u16checksum := 0;
pip^.u32srcaddr := fromip;
pip^.u32destaddr := destip;
pip^.u16checksum := checksum( pu16(pip), sizeof(yipheader) );
end;
//填充udp頭
procedure filludpheader( pudp: pudpheader; datalen: u32; destport, fromport: u32 );
varb : u8;
w : u16;
begin
pudp^.u16srcport := fromport;
pudp^.u16destport := destport;
pudp^.u16len := htons( sizeof(yudpheader) + datalen );
pudp^.u16chksum := 0;
end;
procedure errmsg( msg: string );
begin
messagebox( 0, pchar(msg), 'ping program error', mb_iconerror );
end;
procedure tform1.formcreate(sender: tobject);
varwsa : twsadata;
begin
if wsastartup( $0202, wsa ) <> 0 then
errmsg( 'windows socket is not responed.' );
end;
procedure tform1.formclose(sender: tobject; var action: tcloseaction);
begin
if wsacleanup <> 0 then
errmsg( 'windows socket can not be closed.' );
end;
procedure tform1.button1click(sender: tobject);
varudpsock : tsocket;
opt : s32;
destadr,
fromadr : tsockaddr;
piphdr : pipheader;
pudphdr : pudpheader;
pdatabuf : pchar;
begin
//建立乙個udpsock傳送探測包
udpsock := socket( af_i***, sock_raw, ipproto_udp );
//設定socket選項--我們自己操作ip頭
opt := 1;
setsockopt( udpsock, ipproto_ip, ip_hdrincl, @opt, sizeof(opt));
//為ip header / udp header /data buf 分配記憶體
piphdr := allocmem( sizeof(yipheader) + sizeof(yudpheader) + packet_size );
pudphdr := pudpheader( pchar(piphdr) + sizeof(yipheader) );
pdatabuf := pchar(pudphdr) + sizeof(yudpheader);
//本地addr
fillchar( fromadr, sizeof(fromadr), 0 );
fromadr.sin_family := af_i***;
fromadr.sin_port := htons( strtoint(edtfromport.text) );
fromadr.sin_addr.s_addr := i***_addr( pchar(edtfromip.text) );
//遠端addr
fillchar( destadr, sizeof(destadr), 0 );
destadr.sin_family := af_i***;
destadr.sin_port := htons( strtoint(edtdestport.text) );
destadr.sin_addr.s_addr := i***_addr( pchar(edtdestip.text) );
//填充ip頭和udp頭
fillipheader( piphdr, 55, packet_size, ipproto_udp, destadr.sin_addr.s_addr,
fromadr.sin_addr.s_addr );
filludpheader( pudphdr, packet_size, destadr.sin_port, fromadr.sin_port );
fillchar( pdatabuf^, packet_size, 'y' );
//傳送udp包到host
sendto( udpsock, piphdr^, sizeof(yipheader) + sizeof(yudpheader) + packet_size,
0, destadr, sizeof(destadr) );
listbox1.items.add( '傳送了' +inttostr(ret)+ '位元組到:' + edtdestip.text );
closesocket(udpsock);
freemem( piphdr );
end;
end.
python 爬蟲2 隱藏自己
方法一 head user agent req urllib.request.request url,data,head response urllib.request.urlopen req 只能在request物件上加head,而urlopen url,data,head 是錯誤的 方法二 re...
URL重寫隱藏表單action真路徑的應用
完成以上步驟後你需要建立乙個類,我取名為formrewritercontroladapter.cs,他的功能作用是用於完成表單提交場景的url置換,換句話說,就是上面這些工作的重要收尾工作。using system using system.web using system.web.ui names...
windows在網路中隱藏自己的計算機
看到最近小夥伴們都在擔心蹭網被發現的問題,就分享給大家了 這個是在網上蒐集到的,具體效果還是要實際驗證。介紹一些常見的方法。一 dos命令隱藏 net命令是我們使用最廣泛的 網路命令 之一,在對隱藏區域網中的計算機,同樣發揮著不俗的作用。在研究了它的引數,只要使用 net config即可實現。單擊...