当前位置: 技术问答>linux和unix
虚心请教Linux Socket编程中如何根据指纹信息判断端口服务
来源: 互联网 发布时间:2016-03-02
本文导语: 如题:请教一下,像nmap一样可以通过开放的TCP端口获取的信息判断服务及版本号(FTP,WWW,,),想求具体实现细节(最好有源代码或者简要的代码也行,但具体细节请标识清楚,俺真的有点笨,,) 疑问:1.对远程主机端口...
如题:请教一下,像nmap一样可以通过开放的TCP端口获取的信息判断服务及版本号(FTP,WWW,,),想求具体实现细节(最好有源代码或者简要的代码也行,但具体细节请标识清楚,俺真的有点笨,,)
疑问:1.对远程主机端口送什么样的信息才能得到指纹信息,如何编写信息包,如何接收分解返回的信息,
2.需要建立的套接字类型,这个一直不懂希望能详解一下.
3.如果把指纹信息文件(nmap源代码中好像有这样的文件)与获取的指纹信息相匹配 (这个实在不懂如何匹配,nmap源代码都看得发晕了)
先谢谢各位大侠了啊,!~!!
疑问:1.对远程主机端口送什么样的信息才能得到指纹信息,如何编写信息包,如何接收分解返回的信息,
2.需要建立的套接字类型,这个一直不懂希望能详解一下.
3.如果把指纹信息文件(nmap源代码中好像有这样的文件)与获取的指纹信息相匹配 (这个实在不懂如何匹配,nmap源代码都看得发晕了)
先谢谢各位大侠了啊,!~!!
|
呵呵,你问了指纹,所以帮你找了一些资料。
如果要知道服务的信息,不同的服务会有不同的方法,最直接的是了解协议的内容。
比较简单的是HTTP,比如发一个GET命令过去,就会得到类似下面的典型信息:
[code=INIFile]
HTTP/1.0200OK
Date:Mon,31Dec200104:25:57GMT
Server:Apache/1.3.14(Unix)
Content-type:text/html
Last-modified:Tue,17Apr200106:46:28GMT
Etag:"a030f020ac7c01:1e9f"
Content-length:39725426
Content-range:bytes554554-40279979/40279980
[/code]
里面会有你需要的信息。
而ftp需要了解具体的命令,比如syst(system)命令可以得到系统类型:
ftp> syst
215 UNIX Type: L8
status命令可以得到服务器状态:
[code=INIFile]
ftp> status
Connected and logged into pub.kernel.org.
No proxy connection.
Gate ftp: off, server (none), port ftpgate.
Passive mode: on; fallback to active mode: on.
Mode: stream; Type: binary; Form: non-print; Structure: file.
Verbose: on; Bell: off; Prompting: on; Globbing: on.
Store unique: off; Receive unique: off.
Preserve modification times: on.
Case: off; CR stripping: on.
Ntrans: off.
Nmap: off.
Hash mark printing: off; Mark count: 1024; Progress bar: on.
Get transfer rate throttle: off; maximum: 0; increment 1024.
Put transfer rate throttle: off; maximum: 0; increment 1024.
Socket buffer sizes: send 16384, receive 87380.
Use of PORT cmds: on.
Use of EPSV/EPRT cmds for IPv4: on.
Command line editing: on.
Version: lukemftp 1.5
ftp> rstatus
211-FTP server status:
Connected to xx.xx.xx.xx
Logged in as ftp
TYPE: ASCII
No session bandwidth limit
Session timeout in seconds is 300
Control connection is plain text
Data connections will be plain text
At session startup, client count was 44
vsFTPd 2.0.4 - secure, fast, stable
211 End of status
[/code]
ftp命令介绍参考这里:
http://www.blueidea.com/computer/server/2003/112.asp
其他协议你可以自己研究。
如果要知道服务的信息,不同的服务会有不同的方法,最直接的是了解协议的内容。
比较简单的是HTTP,比如发一个GET命令过去,就会得到类似下面的典型信息:
[code=INIFile]
HTTP/1.0200OK
Date:Mon,31Dec200104:25:57GMT
Server:Apache/1.3.14(Unix)
Content-type:text/html
Last-modified:Tue,17Apr200106:46:28GMT
Etag:"a030f020ac7c01:1e9f"
Content-length:39725426
Content-range:bytes554554-40279979/40279980
[/code]
里面会有你需要的信息。
而ftp需要了解具体的命令,比如syst(system)命令可以得到系统类型:
ftp> syst
215 UNIX Type: L8
status命令可以得到服务器状态:
[code=INIFile]
ftp> status
Connected and logged into pub.kernel.org.
No proxy connection.
Gate ftp: off, server (none), port ftpgate.
Passive mode: on; fallback to active mode: on.
Mode: stream; Type: binary; Form: non-print; Structure: file.
Verbose: on; Bell: off; Prompting: on; Globbing: on.
Store unique: off; Receive unique: off.
Preserve modification times: on.
Case: off; CR stripping: on.
Ntrans: off.
Nmap: off.
Hash mark printing: off; Mark count: 1024; Progress bar: on.
Get transfer rate throttle: off; maximum: 0; increment 1024.
Put transfer rate throttle: off; maximum: 0; increment 1024.
Socket buffer sizes: send 16384, receive 87380.
Use of PORT cmds: on.
Use of EPSV/EPRT cmds for IPv4: on.
Command line editing: on.
Version: lukemftp 1.5
ftp> rstatus
211-FTP server status:
Connected to xx.xx.xx.xx
Logged in as ftp
TYPE: ASCII
No session bandwidth limit
Session timeout in seconds is 300
Control connection is plain text
Data connections will be plain text
At session startup, client count was 44
vsFTPd 2.0.4 - secure, fast, stable
211 End of status
[/code]
ftp命令介绍参考这里:
http://www.blueidea.com/computer/server/2003/112.asp
其他协议你可以自己研究。
|
这应该很复杂的
建议你看TCP/IP 卷1,2
有个tcpdump命令挺好用的
建议你看TCP/IP 卷1,2
有个tcpdump命令挺好用的