Free Essay

Jkjk

In:

Submitted By helloboy7
Words 831
Pages 4
Scapy
● ● ● ● ● ●

What is Scapy Why use Scapy? Important concepts to keep in mind Crafting your first packet Sending and Receiving Packets/Frames Basic examples and dealing with the OS's TCP/IP stack using iptables Quick discussion of the Super Socket



What is Scapy


A Python framework used for crafting and transmitting packets. Capable of Sniffing or replaying packets for troubleshooting or fuzzing network services. Can be used as the interactive Python interpreter or the framework can be imported as a python module and used for further coding Everything is an object!







Why use Scapy?


Blue Team
– – – –

Test IDS/IPS Test Firewall Learn more about TCP/IP (down and dirty) Application response(Fuzzing) Fire teh lazorz (DOS/DDOS) More Fuzzing Penetration Testing



Red Team
– – –

Important Concepts


Everything is an Object – treat it as such


IP(), TCP(), UDP(), ICMP() help() - displays help ls() - displays packet classes lsc() - displays commands available to you ip=IP(src=”1.2.3.4”, dst=”google.com”) ip=IP() ip.src=”1.2.3.4” ip.dst=”google.com”



Important commands to remember:
– – –



When assigning Field Values(either works)
– – – –

Important Concepts Continued


Displaying Values of Variables
– – –

ls(ip) – shows what you have set and default vaules ip – shows only what you have set ip.show() - omits variable classes and default values packet=IP(dst=”1.2.3.4”)/TCP(flags=”S”,dport=443) frame=Ether(type=0x8100)/Dot1Q(vlan=99)/packet Will Display all the layers after the initial



Assembling the Network Layers
– –



Payload attribute


Crafting your first packet


ICMP echo(type 8) request to dst – 192.168.1.103


send(IP(dst=”192.168.1.103”)/ICMP(type=8)) packet=IP(dst=”192.168.1.103”)/ICMP(type=8) send(packet)
#! /usr/bin/python from scapy.all import * i=IP(dst=”192.168.1.1”) t=TCP(dport=80, flags=”S”) packet = i/t send(packet)



Using Variables
– –



Inoking Scapy into a python script


Sending and Receiving


Frames (Layer 2)
– – –

sendp() - layer 2 sending srp() - send and receive on Layer 2 srp1() - send and receive a single response send() - layer 3 sending sr() - layer 3 send and receive sr1() - send and receive a single response



Packets (Layer 3)
– – –

Basic Examples


Start a TCP connection


sr1(IP(dst=”192.168.1.1”)/TCP(flags=”S”, dport=80,seq=100)) sr(IP(dst=[”192.168.1.1”, “192.168.1.2”])/ICMP()) sr(IP(dst=”192.168.1.1”)/TCP(dport=[80, 443, 22,445])) Then to view them: ans,unans=_ ans.summary()



Send to Multiple IPs and Listen for responses




Send to Multiple ports and see responses


– –

More useful features


Fuzzing Values


send(IP(dst=”192.168.1.1”)/fuzz(ICMP(code=0, seq=0, id=0)), loop=1)


This will fuzz all values what are not assigned and stay in a loop until you Ctrl+C out of it.



conf – allows you to modify default values and change scapy configurations


Conf.route – shows the routing table scapy will use wireshark(packet) – will launch a wireshark interface showing the packet you crafted



Wireshark Interface


Cooked Sockets / Raw Sockets and IP Tables


Cooked sockets uses Native TCP/IP Stack
– – –

Kernel builds packet Assigns correct IP/UDP/TCP header values You supply the payload You build packet You assign header values You supply the payload



Raw Sockets circumvents Native TCP/IP Stack
– – –

IP Tables helps us


Block TCP Outbound Resets


iptables -A OUTPUT -p tcp –tcp-flags RST RST -s 192.168.1.1 -d 192.168.1.2 –destination-port 80 -j DROP iptables -A OUTPUT -s 192.168.1.1 -d 192.168.1.2 -p ICMP –icmp-type port-unreachable Import subprocess cmd = [iptables rules] subprocess.call(cmd, shell=False)



Block UDP Outbound ICMP port unreachables




Call IPTables in your python script


A look at the Three-way Hand Shake
#!/usr/bin/python from scapy.all import * ip=IP(src="192.168.1.1", dst="192.168.1.2") SYN=TCP(sport=1030, dport=80, flags="S", seq=10) SYNACK=TCP(sr1(ip/SYN) my_ack =SYNACK.seq + 1

Super Socket


Network socket is a function that opens, reads, writes, and closes an instance of network communications Using both Scapy “sniff” to read DNS query and “send” to write new spoofed responses requires the use of two separate sockets




This method takes to longer and will never “beat” the DNS server



Scapy uses a “super-socket” which takes care of both reading and writing with a single socket


Less time and can beat the server

In closing


Scapy is a very useful tool for:
– –

Gaining an in depth knowledge of the TCP/IP stack Great tool for security/network analysts and testers Cross Platform Easily read, write, craft packets on the fly Easily incorporate Scapy into an existing python script Replay pcaps back onto the network



Great features:
– – –



Sources


SANS Security Course: Power Packet Crafting with Scapy Research done on Wikipedia http://webstersprodigy.net/2012/07/06/some-practical-arp-poison-attacks-with-scapyiptables-and-burp/ ●

Similar Documents

Free Essay

Jkjk

...Elizabeth Bush Mrs. Nelson Rhetoric 2 10-28-13 Narration In Greek, the word modesty is "adios" meaning shyness or reverence. In the time of Adam and Eve, modesty did not exist until they sinned and became aware of their nakedness. The Victorian era was a time period filled with overly modest clothing. Women's dresses covered every inch of their body. Dresses had high necks and sleeves that only allowed a girl's hands to show. They flowed to the floor because showing your ankles was unheard. Modesty was a reflection of one's reputation, and one's reputation defined who he or she was in society. Even the showgirls did not show more than two inches of cleavage. Although modesty began to change and alter, there was an overall standard for girls on how they should present themselves. However, the 1950s changed this. Dresses were shorter and tighter than ever before. Shortly after World War 1, women's clothing began to shift towards a more "modern" standard. The 20's and 30's style of clothing helped shape the 50's by introducing dresses that had short sleeves and dresses that stopped mid-calf. However, these styles did not become trends until the 1950's. For the first time in history pantsuits were introduced. The high standard of modesty was slowly becoming more relaxed. Strapless gowns started being introduced. By the 1960's, dresses began stopping above the knee and thigh high slits became more and more common. By the late 1960's, the miniskirt was introduced. The 70's...

Words: 941 - Pages: 4

Free Essay

Case Report

...Ljkadsklj sdkaj aklak lsdk d djl;k dlk da jkjk;l dclk ld klj;lda kl ddj olkda l;kda’k Ljkadsklj sdkaj aklak lsdk d djl;k dlk da jkjk;l dclk ld klj;lda kl ddj olkda l;kda’k Ljkadsklj sdkaj aklak lsdk d djl;k dlk da jkjk;l dclk ld klj;lda kl ddj olkda l;kda’k Ljkadsklj sdkaj aklak lsdk d djl;k dlk da jkjk;l dclk ld klj;lda kl ddj olkda l;kda’k Ljkadsklj sdkaj aklak lsdk d djl;k dlk da jkjk;l dclk ld klj;lda kl ddj olkda l;kda’k Ljkadsklj sdkaj aklak lsdk d djl;k dlk da jkjk;l dclk ld klj;lda kl ddj olkda l;kda’k Ljkadsklj sdkaj aklak lsdk d djl;k dlk da jkjk;l dclk ld klj;lda kl ddj olkda l;kda’k Ljkadsklj sdkaj aklak lsdk d djl;k dlk da jkjk;l dclk ld klj;lda kl ddj olkda l;kda’k Ljkadsklj sdkaj aklak lsdk d djl;k dlk da jkjk;l dclk ld klj;lda kl ddj olkda l;kda’k Ljkadsklj sdkaj aklak lsdk d djl;k dlk da jkjk;l dclk ld klj;lda kl ddj olkda l;kda’k Ljkadsklj sdkaj aklak lsdk d djl;k dlk da jkjk;l dclk ld klj;lda kl ddj olkda l;kda’k Ljkadsklj sdkaj aklak lsdk d djl;k dlk da jkjk;l dclk ld klj;lda kl ddj olkda l;kda’k vvvv Ljkadsklj sdkaj aklak lsdk d djl;k dlk da jkjk;l dclk ld klj;lda kl ddj olkda l;kda’k Ljkadsklj sdkaj aklak lsdk d djl;k dlk da jkjk;l dclk ld klj;lda kl ddj olkda l;kda’k Ljkadsklj sdkaj aklak lsdk d djl;k dlk da jkjk;l dclk ld klj;lda kl ddj olkda l;kda’k Ljkadsklj sdkaj aklak lsdk d djl;k dlk da jkjk;l dclk ld klj;lda kl ddj olkda l;kda’k Ljkadsklj sdkaj aklak lsdk d djl;k dlk da jkjk;l dclk ld klj;lda kl ddj olkda l;kda’k Ljkadsklj...

Words: 2461 - Pages: 10

Free Essay

Killing Lizards

...bnfg njn.k kjhnl;j ;lkj lkj lkj kjn jn jkhnk. j kmn kj lkj kjl klj klj nb yg gf jh jh jhb jh h jh kjhkjhk jhkjhkj kjhkhkjh hkh poi p ;ik p;i k jhjioj oipoi jh ij i p jjkio ok ;okjklj;lo o uiuj kj m mkj k l klk j jk l l kl kj j l k jk k jk jh gyf axw s c e rv fhg uj jk hk k lk lkl l ;/ ' ;'l j ;l ;ljk klj jh jkh g jkguygh jhg ghjk hggh jhg hg hg ikujl; jkl jkl lk jlk jklj mnm kn k k jkj jk j kj o jo jo j hjk hk k jhkj kj kj k jkj k k jk jk jk jk jk j kj kj k jk jk j kj kj kj k jk j kj kj k jjk j kj kj kj k jkj jjk j k jk jk j kj kj k j k jkk jk j kj kj jk k kj jk jk jk jk jk jk jk jk jk jk jk jk jk jk jk jk jkjk jk jk jk jk jkjk jk jk jkjk jkjkjk jjk jk jkjk jk jk jkjk jkjk jk jk jkjk jkjk kj kj kj jk kj jk jk jk jk jk jk jk jk jk jk jk jk jk jkk jjk jk jk jk j joi oi oi o io io io io io iouiuo ouoi ouioiuoiu oiu o iuoiu oiu oiu oi u oiuio uio u iou iou oiu iou iu oiu iou io u iou iu iou iu i io imo io o oio kll jkl k jkk j k...

Words: 281 - Pages: 2

Free Essay

Asdff

...asdffasdddddddddddddddddddd asddddddddddddddddddd sadddddddddddddddddddddd saddddddddddddddddddddddddd saddddddddddddddddddd sdaaaaaaaaaaaaaaaaaaaaaaaa saddddddddddddddddddddddd asdddddddd d d d d d d d dd d d d d d d dkddkkdkdkd d dkdd kdkd dkdkd dkd dkdkkdk dkdkdkdkd dkdkkdkdk dkdddkk kkkk k k k kk kk k k k j kl ; j l kj lk j; lk j lkj ljj ;l kjj ;l kj ;lj l; kj kl kl kl kl k k l. l l jkl ;l kj lj lk ;l j l;j kl jl;k l/ / lj /lj /lkj lk lk lk llk / kl /l /kl / / j j / / /l j l/ kj l/k jkl kl klk k l lk kl kl lkkl lk l k/ / lk l/ kl kl lk kj kl j klj kl l l lj .. l l l l k jhh h h hj k. . kk k k kjk jkjjk jk jk kj.. k k kj k j jk jkjk jkjk jk jk kjgk lghlhkjljkhk klj hjl j . . . k . kjj hkjh h j hk hlkj . jh h jh kjh hj jk ;lkkjfddfgsfgsgf. . asdf . . .a .asds j jj j j j jj j j jj jj j jj j j j k kk k j j kj kj k jk jkjk kk kkkk kk kk kkk k . kk kk kk kkk . .k kkk kk k kk k kk . k k kk kk k kk k k . k k dkljfals;sdfjalsjf ajlsd;fja;s ld;kajsd fl;askdjf;ladjf al;sdkjfj ldskfjld lf;asdjf l alskdfjk lkdjkfj dlk;aljdf la;sdjf...

Words: 253 - Pages: 2

Free Essay

Ananas

...d sd ds ds d fs df ds f s g sdgg gds g sd g dsg ds ds vjddjvsjd kj j sj jj j j j j j nfvnfm nkf ni fn fk nfin i n nif nif n ifn m m kmk k kjk j jj j j jj j j j jj j j j j jj k k k jk n k kjbkj bk bk k jb j bnk nmk nkj n kn nk nknkjnk nknn u nk jkn njk njkn kn knkn nk nk nnk nk kn nknkj njknjk knj knjnjk njk knnk knj jknknj knj knjknj knj njk njknj kknj knj njk knjnjk kj nj kjk kj kj njkknj nkj knj knjknj njk jk njkknj knj knj knjknj knj knj kn njk njnjk njk knj njk njkjk jk jn jk jjkn nkjnjk jknknj knj jnknj jjk nkjn kjn jk nj nj n njnj nj knjnj kkjn jk jnnjk nknj jnk njk jkn njkjn j njkn nkj nkjnjk jn kjkn jkn kjn knj jnknj knjkj nkj jk knj kjj kjn jk jknjkn jkn njk knj knj jkjknjkn knj knj jknj kknj knjnj jkn njnkj jk kjknj n jn jk jkjk kj jjn kjk jk knjjkn jk jkjkn knj knjj kknj knj knjknj jk knj knjknj knj...

Words: 256 - Pages: 2