Last active
February 17, 2023 04:03
-
-
Save tae0y/4b0101b131cf5982bf7b6775b2533630 to your computer and use it in GitHub Desktop.
tcptrace.py in python 310 with scapy
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import sys | |
import scapy.all as scapy | |
import os | |
class bcolors: | |
HEADER = '\033[95m' | |
OKBLUE = '\033[94m' | |
OKCYAN = '\033[96m' | |
OKGREEN = '\033[92m' | |
WARNING = '\033[93m' | |
FAIL = '\033[91m' | |
ENDC = '\033[0m' | |
BOLD = '\033[1m' | |
UNDERLINE = '\033[4m' | |
os.system('cls') | |
print(bcolors.OKBLUE + """ | |
======================================================================================================= | |
.--. .--. ____ .---. .---. .-'''-. _______ ____ ,---. .--. | |
| |_ | | .' __ `. | ,_| | ,_| / _ \ / __ \ .' __ `. | \ | | | |
| _( )_ | |/ ' \ \,-./ ) ,-./ ) (`' )/`--' | ,_/ \__) / ' \ \| , \ | | | |
|(_ o _) | ||___| / |\ '_ '`) \ '_ '`) (_ o _). ,-./ ) |___| / || |\_ \| | | |
| (_,_) \ | | _.-` | > (_) ) > (_) ) (_,_). '. \ '_ '`) _.-` || _( )_\ | | |
| |/ \| |.' _ |( . .-' ( . .-' .---. \ : > (_) ) __ .' _ || (_ o _) | | |
| ' /\ ` || _( )_ | `-'`-'|___`-'`-'|___ \ `-' |( . .-'_/ )| _( )_ || (_,_)\ | | |
| / \ |\ (_ o _) / | \| \ \ / `-'`-' / \ (_ o _) /| | | | | |
`---' `---` '.(_,_).' `--------``--------` `-...-' `._____.' '.(_,_).' '--' '--' | |
========================================================================================= 2023-01-26 === | |
""") | |
print(bcolors.OKBLUE + "※ 지점간 방화벽 확인을 위한 명령줄 도구입니다") | |
print("※ 지정된 IP/PORT로 1~22TTL TCP SYN요청을 보냅니다(포트 개방여부 상관없이 RST반환)") | |
print("※ 서비스포트 개방여부는 서버접속후 netstat으로 확인바랍니다") | |
print() | |
DEST_ADDR = input(bcolors.ENDC + "IP/HOSTNAME : ") | |
DEST_PORT = int(input("PORT : ")) | |
print() | |
ans, unans = scapy.sr(scapy.IP(dst=DEST_ADDR, ttl=(1,22), id=scapy.RandShort())/scapy.TCP(dport=[DEST_PORT],flags="S"), timeout=10) | |
print() | |
print("ttl num | response src | response payload") | |
for snd, rcv in ans: | |
print(snd.ttl, ' | ' , rcv.src, ' | ' , rcv.payload) | |
print() | |
input(bcolors.OKBLUE + "※ ENTER를 눌러서 종료하세요.") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
winpcap 또는 npcap을 사용해 tcptrace하는 파이썬코드입니다
더 좋은 방법이 있다면 알려주세요 감사합니다
코드설명
활용방법
참고사항
-Port
옵션으로 포트를 지정하는 경우 원격지서버에서Set-Item wsman:\localhost\listener\listener*\port –value <Port>
명령어로 포트오픈