.386
.model flat,stdcall
option casemap:none
include kernel32.inc
includelib kernel32.lib
include ws2_32.inc
includelib WS2_32.lib
include iphlpapi.inc
includelib iphlpapi.lib
.data? ;为节省空间这些变量不定义在.code里面。
hstdout dd ?
hstdin dd ?
x dd ?
y dd ?
pTcpTable dd ? ;要定义在.data?段,不然运行出错。输出不了字符。
dwSize DWORD ?
dwRetVal DWORD ?
buffer1 DB 20 DUP (?)
bufferl db 8+4 dup (?),?;0
.code
correy db "made by correy",0
entry db 13,10,0
;showformat db "%-20s%-20s-20s-20s",0
MIB_TCP_STATE_CLOSED db "MIB_TCP_STATE_CLOSED",0
MIB_TCP_STATE_LISTEN db "MIB_TCP_STATE_LISTEN",0
MIB_TCP_STATE_SYN_SENT db "MIB_TCP_STATE_SYN_SENT",0
MIB_TCP_STATE_SYN_RCVD db "MIB_TCP_STATE_SYN_RCVD",0
MIB_TCP_STATE_ESTAB db "MIB_TCP_STATE_ESTAB",0
MIB_TCP_STATE_FIN_WAIT1 db "MIB_TCP_STATE_FIN_WAIT1",0
MIB_TCP_STATE_FIN_WAIT2 db "MIB_TCP_STATE_FIN_WAIT2",0
MIB_TCP_STATE_CLOSE_WAIT db "MIB_TCP_STATE_CLOSE_WAIT",0
MIB_TCP_STATE_CLOSING db "MIB_TCP_STATE_CLOSING",0
MIB_TCP_STATE_LAST_ACK db "MIB_TCP_STATE_LAST_ACK",0
MIB_TCP_STATE_TIME_WAIT db "MIB_TCP_STATE_TIME_WAIT",0
MIB_TCP_STATE_DELETE_TCB db "MIB_TCP_STATE_DELETE_TCB",0
showeax proc ;坚决拒绝使用wsprintf等类似函数。
pushad ;坚决不使用msvcrt.dll等运行时库。
mov ecx,8 ;坚决杜绝.net与.frameset等环境。
xor esi,esi ;坚决杜绝java虚拟机。
againp: ;此函数在驱动及ring0中也可以运行哟!
dec ecx
rol eax,4
push eax
and eax,0Fh
cmp eax,9
jg big
add eax,30h
mov [bufferl+esi],al
pop eax
inc esi
cmp ecx,0
jne againp
je showp
big:
add eax,37h
mov [bufferl+esi],al
pop eax
inc esi
cmp ecx,0
jne againp
showp:
popad
ret
showeax endp
exbuffer proc ;可能端口的高位在前,所以才有此转换函数。
push eax ;其实用交换指令也可以完成。
mov ax,word ptr bufferl+4
mov bx,word ptr bufferl+6
mov word ptr bufferl + 6,ax
mov word ptr bufferl + 4,bx
pop eax
ret
exbuffer endp
sztitle db "Active (tcp) Connections (like netstat command)",13,10,0
la db "Local Address",0,0,0,0,0,0,0,0;补充一些数据,以防止垃圾的显示。
fa db "Foreign Address",0,0,0,0,0,0,0;补充空格为最好,这样重定向是不会显示乱码。
port db "port",0,0,0,0,0,0,0,0,0,0,0
state db "state",0
notice db "注释:端口为16位,为四个16进制数。",13,10,
"说明:端口是以16进制显示的。",13,10,
"不足之处,敬请指点:",13,10,
"QQ:112426112",13,10,
"Email:leguanyuan at 126 dot com",13,10,
"Homepage:http://correy.webs.com",13,10,
"按enter键退出!",13,10,0