Security Basics mailing list archives
Re: Secure Port Testing
From: Tyler Reguly <htregz () gmail com>
Date: Fri, 22 Oct 2004 15:15:28 -0400
Hey Hey,
This is sample code I made, originally.. to demonstrate simple SMTP
honeypot, then later I hacked it up into an echo server... I've added
a prompt for port number, unfortunately it doesn't do multiple
ports... but it'll send you a banner and echo back any text you pass
to it... 'quit' will close the connection.. It may serve your
purpose...
Being that it's python you can use it on either Win or *nix, you
simply need python installed... It comes with most *nix distros and
can be easily obtained for Win32.
Peace,
HT
------CODE------
# Demonstrates various methods of importing modules.
from socket import *
import string
import time
import shlex
# create a socket of the basic type.
s = socket(AF_INET, SOCK_STREAM)
# Query the user for their IP Address and set that and the port
# Edit either of this variables to make them static and remove the prompt
# Example:
# HOST = "192.168.1.1"
# PORT = "23"
HOST = raw_input("Enter IP Address to bind socket to: ")
PORT = raw_input("Enter Port to Listen on: ")
s.bind((HOST, PORT)) # Bind the socket to an IP Address and Port
while 1:
s.listen(5) # Have the socket listen for a connection
(incomingsocket, address) = s.accept() # Accept an incoming connection
straddress = str(address) # Convert incoming address to a string
testlist = string.split(straddress, ",") # Split the tuple into lists
gethost = string.split(testlist[0], "'") # Split the host portion
of the list
getaddr = string.split(testlist[1], ")") # Split the port portion
of the list
host = gethost[1] # Remove just the address from the list
incomingport = int(getaddr[0]) # Remove just the port from the list
data = ""
# Print connection information to stdout
logdata = "Connection attempt on port " + str(PORT) + " from " +
str(host) + ":" + str(incomingport) + " @ " + time.strftime("%H:%M:%S
- %d %b %Y")
print logdata
#Send a Banner
incomingsocket.send("Welcome to HT's Simple Echo Server - RFC 862\r\n")
# Listen for incoming data
while 1 :
while 1:
lastchar = incomingsocket.recv(1024)
if lastchar == "\n": break
elif lastchar == "\r\n": break
else: data = data + lastchar
incomingsocket.send(data)
incomingsocket.send("\r\n")
if data == "quit\r\n" : break
if data == "quit\n" : break
data = ""
# Close the socket
incomingsocket.close
s.close
------END CODE------
On Fri, 22 Oct 2004 14:49:36 -0400, Mailing Lists <itmaillist () gmail com> wrote:
Hello List, I am responsible for testing connectivity between customers and vendor sites and often need to verify and test firewall settings for extranet connections before the data link is available. In the past I would just set up a test box on a test LAN on the external interface of the Firewall and pick a service and run it on whatever port I need to test. I am looking for something more secure and configurable that wont put an actual service out in the open. Hopefully a tool that will allow me to open ports on a windows / or *nix box without actually having a particular service running there. Maybe a banner, or just something that will allow me to determine if the connection was successful. Preferably I would like the ability to open multiple ports at a time and be able to make quick to changes. My methodology is that if I get a positive connection I know the firewall is allowing me through and routing properly. Any recommendations for tools or different perspectives on how to test this will be greatly appreciated! Thanks.
Current thread:
- Secure Port Testing Mailing Lists (Oct 22)
- Re: Secure Port Testing Tyler Reguly (Oct 22)
- <Possible follow-ups>
- Re:Secure Port Testing Ghaith Nasrawi (Oct 22)
- Re: Secure Port Testing David Roman Esteban (Oct 25)
