Advertisement
Malic

server side -portknock

Oct 16th, 2019
117
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.01 KB | None | 0 0
  1. from scapy.all import *
  2. import time
  3. ip="192.168.1.28"
  4. #ip=input("enter ip address XXX.XXX.XXX.XXX")
  5.  
  6.  
  7.  
  8.  
  9.  
  10.  
  11. port=[11111,22222,33333]
  12. a=sniff(count=1,filter=ip)
  13. firstIndex=str(a[0])
  14. for i in firstIndex:
  15. li=list(firstIndex.split(" "))
  16. print(li)
  17. tcp_11111=sniff(count=1,filter=f"host{ip} and tcp port 11111")
  18. tcp_22222=sniff(count=1,filter=f"host{ip} and tcp port 22222")
  19. tcp_33333=sniff(count=1,filter=f"host{ip} and tcp port 33333")
  20.  
  21. if tcp_11111 and tcp_22222 and tcp_33333:
  22. print("very good knocking")
  23. # subprocess.call(f'["iptables", "-I", "INPUT", "-p", "tcp", "-s {ip}", "--dport", "22", "-j", "ACCEPT"])
  24. # subprocess.call(["iptables-save"])
  25. # a=2
  26. # while 1<2:
  27. # choose=int(input("if you want more than 240 second press 1"))
  28. # if choose == 1:
  29. # time.sleep(240)
  30. # else:
  31. # subprocess.call(f'["iptables", "-I", "INPUT", "-p", "tcp", "-s {ip}", "--dport", "22", "-j", "DROP"])
  32. # subprocess.call(["iptables-save"])
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement