|
    |
|
|
Introduction to Network Programming with Scapy + Python
Scapy is a toolkit for python that allows you to construct and send packets and includes some extra functions such as arp poisoning and host fingerprinting Its a brilliant for allowing you to control exact network communication and its so easy to use! Here is (kind of) a port scanner, the thing about scapy is, that its primary use and purpose, is that many programs written for networking tasks will make assumptions as to the information they receive, whereas when you have full control over the information you can send and receive down the line like with a toolkit like scapy, you don't have to make assumptions about the data but rather get the full picture to see whats going on. E.g. some might say this script is a port scanner as it displays what ports on a system will return an ack when sent a syn packet. This is alright in theory, but many of us know that the os might decide to drop this packet due to certain criteria, and although the port might be open, the software would return that the port is closed. Don't trust what you read! #/bin/use/python import sys from scapy import * if len(sys.argv) != 4: print “usage: pscan.py <target> <start-port> <end-port>” sys.exit(1) target=sys.argv[1] startport=sys.argv[2] endport=sys.argv[3] print “Basic python port scanner” print “By welshywoo\n\n” print “Scanning: ” + target print “Start port: “, print startport print “End port: “, print endport for count in range(int(startport),int(endport)): synp = IP(dst=target)/TCP(dport=count, flags=”S”) ans,noans = sr(synp, timeout=9, verbose=0) ports = [target] for a in ans : if a[1].flags == 2: cport = a[1].sport ports.append(int(cport)) print “\n\nFound ports:” for item in ports: print item This line here constructs our syn packet: synp = IP(dst=target)/TCP(dport=count, flags=”S”) This line sends our packet on the line and saves the answer: ans,noans = sr(synp, timeout=9, verbose=0) |
Scapy HomePage
No reactions yet.
Please login or sign up to rate this intel.
Please login or sign up to add a comment.
The copyright for this content entitled "Introduction to Network Programming with Scapy + Python" has been specified by the contributor as:
All Rights Reserved
This content may not be copied, distributed or adapted by anyone under any circumstances.
|
 |
May, 2012
2008
January, February, March, April, May, June, July, August, September, October, November, December
2009
January, February, March, April, May, June, July, August, September, October, November, December
2010
January, February, March, April, May, June, July, August, September, October, November, December
2011
January, February, March, April, May, June, July, August, September, October, November, December
2012
January, February, March, April, May
|
|
Not a member yet?
Qondio is a powerful network for making it online. If you have a website to
promote, we can help.
Sign up and get in on the action.
|
|
Welcome to Qondio! Discover the awesome power this network can deliver by going to our About page. Or you could skip straight to the Sign Up form.
|
|