473,406 Members | 2,745 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

Getting a service's banner by connect to a port

Hi,

Currently, I am trying to get different service banner by connecting
to different ports using python (code below). The versions I am
working with are python 4.2.1 and fedora core 4. I am trying to
reproduce a very small piece of nmap, since nmap has to get a port's
banner in order to figure out the version. However, I haven't been
entirely successful.

************************************************** *****
maxBannerLength = 1024
def probeScan(host, port, probeString):
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.settimeout(6)
try:
s.connect((host, port))
s.send(probeString)
data = s.recv(maxBannerLength)

except socket.timeout:
print "socket.timeout exception"
data = ""
except socket.error, (value, message):
print "socket.error " + message
data = ""

# Close connection and return banner/data
s.close()
return data

************************************************** *****

First off, the above code works fine for some ports. I was able to
get the correct banners for some ports, some using the probeString as
an empty string and others as a different probeString.

But I have been having issues with many others. The one I have tested
most recently was port 515 (services given from nmap on 2 ip addresses
are "printer" and "sdmsvc". Now, I pass in the variable probeString
to the function as an empty string "", some of the ports (including
515) should give me the banner right away without needing a specific
probeString. My python program is ending up in the socket.timeout
exception. I have increased the timeout a couple of times to check if
that may be the problem, but no such luck. I have been testing my
results from the above program with the results of netcat. Netcat
gives me the correct banner when I pass it an empty string "".

As far as I have been able to figure out, I just need to connect to a
port, and send it a probeString. As long as the correct probeString
is sent, the port(s) should give their banner. I am pulling the
probeStrings from the nmap-service-probes file, which is the file that
nmap keeps its probes. So, I am confident my probes are correct.

Has anyone ever run into this problem? Or have suggestions?
I would greatly appreciate any information.

Thanks in advance.

Mar 13 '07 #1
0 1400

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: Bob Garbados | last post by:
I have a .net website and I need to connect to a service listening on a specific port from that website. The service and website are on the same windows 03 server. I don't know where to start on...
4
by: joe bloggs | last post by:
I am writing a mobile application to interface with a legacy system and I am planning to use web services to communicate with this system. The legacy system receives data through a serial port. ...
2
by: Steve Gollery | last post by:
I installed Postgres 8 beta 3 on an XP box, with Postgres running as a service. TaskManager tells me that postgres and postmaster are both running. Using pgAdmin III, I can connect to the server...
0
by: ruju00 | last post by:
I am getting an error in Login() method of the following class FtpConnection public class FtpConnection { public class FtpException : Exception { public FtpException(string message) :...
11
by: kshetgar | last post by:
I am experiencing a wierd problem... I have a C#.Net application Server which uses Sockets. It listens on port 11000. and it runs as a Windows Service. If I run it as a consple Application,...
0
by: Kumar Shetgar | last post by:
I am experiencing a wierd problem... I have a C#.Net application Server which uses Sockets. It listens on port 11000. and it runs as a Windows Service. -- If I run it as a consple...
11
by: seb | last post by:
Hello, **************** What I need : **************** I need to write a scanner that test all the IP adresses that repond on a given port. The Ip list is of roughly of length 200. I need...
3
by: Grant Schenck | last post by:
I have a simple remoting sample using IPCChannel. If I run the server code as a console app my client can connect just fine. However, if I the same server code runs in a service, the client gets...
5
by: mivey4 | last post by:
Hi, First off, I am aware that this is a very heavily documented error and I have done my homework for throughly researching probable causes before deciding to post my problem here. At this point,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.