pyth0n3 Posted September 20, 2011 Report Posted September 20, 2011 Description:Makes port-hits by sending a TCP packet with syn flag set .#!/usr/bin/python#Author: pyth0n3 #Date:19.09.2011#Purpose:Knock client (SYN-sequence) from __future__ import print_functionimport logginglogging.getLogger('scapy.runtime').setLevel(logging.ERROR)import sysimport sockettry: from scapy.all import IP,TCP,sr1except ImportError: print('[+] Need to install python-scapy first') print('[+] http://www.secdev.org/projects/scapy/') sys.exit()def display(): print('#'*50) hand = '\n# Usage: myknock.py <ip> <seq 1> <seq 2> <seq n> #\n#' print('#',' '*47 + '#',hand ,' '*47 +'#') print('#'*50) sys.exit()if len(sys.argv) < 3: display()seq = sys.argv[2:]addr = sys.argv [1]try: socket.inet_aton(addr) except socket.error: print ('[+] You have entered an ilegal address') sys.exit()def getinteger(n): try: return int(n) except ValueError: print ('[+] Bad sequence numbers') sys.exit()ports = map(getinteger,seq)hand = range(1,65536)for sq in ports: if sq in hand: pass else: print('[+] Sequence out of range') sys.exit()def session(): i = IP() i.dst=addr t = TCP() t.dport = ports t.flags = 'S' get = sr1(i/t,timeout=1) print('[+] Knock done!')if __name__ == '__main__': session()Download:wget http://sprunge.us/QNDJ -O mycknock.py Quote