【Win32汇编】端口扫描器 细节问题
;超级简单多线程TCP服务器开放端口扫描器;无名侠
;2015.5.23
.386
.model flat,stdcall
option casemap:none
include ws2_32.inc
include user32.inc
include kernel32.inc
include windows.inc
include masm32.inc
include msvcrt.inc
includelib msvcrt.lib
includelib ws2_32.lib
includelib user32.lib
includelib kernel32.lib
includelib masm32.lib
;###############################################
;数据段
;###############################################
.data
szInitError db '加载套接字库失败!',0
;====================================用户配置区==============================================
;设置扫描IP
szIp db '127.0.0.1',0
;设置扫描范围
start_port equ 20
end_port equ 2000
;=============================================================================================
Myinfo db '-- 超级简单多线程TCP服务器开放端口扫描器 --',0dh,0ah,'made in China.....',0dh,0ah,0
format1 db '开放TCP端口:%d',0dh,0ah,0
ScannerIp DWORD ?
;###############################################
;代码段 A lovely girl named mooncake.
;###############################################
.code
Thread_scanner proc _port:dword
LOCAL @address:sockaddr_in
LOCAL @h_sock:dword
invoke RtlZeroMemory,addr @address,sizeof @address
invoke socket,AF_INET,SOCK_STREAM,0
cmp eax,INVALID_SOCKET
je _exit
mov @h_sock,eax
;初始化地址信息
invoke htons,_port
mov @address.sin_port,ax
mov @address.sin_family,AF_INET
mov eax,ScannerIp
mov @address.sin_addr,eax
invoke connect,@h_sock,addr @address,sizeof @address
.if eax==0
invoke crt_printf,addr format1,_port
;mov esi,offset OpenPortMap
;mov edi,_port
;mov byte ptr,1
.endif
invoke closesocket,@h_sock
_exit:
ret
Thread_scanner endp
main proc
LOCAL @wsadata:WSADATA
;来点广告信息吧~亲。
invoke crt_printf,addr Myinfo
;初始化套接字库
invoke RtlZeroMemory,addr @wsadata,sizeof @wsadata
invoke WSAStartup,202h,addr @wsadata
;初始化扫描IP
invoke inet_addr,addr szIp
mov ScannerIp,eax
;启动扫描线程
mov ecx,end_port-start_port
loop1:
push ecx
invoke CreateThread,NULL,0,offset Thread_scanner,ecx,0,NULL
pop ecx
loop loop1
invoke crt_getchar
ret
main endp
start:
invoke main
invoke ExitProcess,1
end start
原创地址
link /subsystem:console **.obj
发现一问题,如果把目标 IP改成 实际IP 程序只能检测出一个端口就退出来了, 我用OD看了一下(不熟练),但线程还是创建了,就是不能检测出其它的端口,是哪个地方有问题????
如果是127.0.0.1 就可以全部检测出来 @无名侠 侠侠写的程序呀` 楼上的亲,你看出是什么问题?请教{:10_298:}
页:
[1]