How to sniff wireless networks in linux

Source: Internet
Author: User

Its not tough to Hijack/Capture/Sniff Wifi Traffic on almost any network as long as you are connected to it. once you apply all the correct tricks, all future traffic for Wifi clients I. e. laptops, mobiles will be routed from your PC, giving you every bit of information about what others are doing on the network.
 
How to hijack/capture/Sniff HTTP traffic
 
We will be using ARP and iptables on a Linux machine to accomplish most of the stuff. it makes too many practical examples  €************** an easy and fun way to harass your friends, family, or flatmates while loading ing the networking protocols.
 
Warning: Do not attempt to do this on a Public Wifi or a living ate Wifi. doing so cocould lead you to serous consequences. in no way is Taranfx or Hack Community responsible for any harms. this is solely intended for fun @ home.
 
Lets take 3 PCs into reference for our activity:
 
Real gateway router: IP address 192.168.0.1, MAC address 48: 5d: 34: aa: c6: aa
Fake gateway: A Laptop PC called hacker-laptop, IP address 192.168.0.200, MAC address c0: 30: 2b: 47: ef2: 74
Victim: a laptop on wireless called victim-laptop, IP address 192.168.0.111, MAC address 00: 23: 6c: 8f: 3f: 95
The gateway router, like most modern routers, is bridging between the wireless and wired domains, so ARP packets get broadcast to both domains.
 
Step 1: Enable IPv4 forwarding
 
Unless IP forwarding is enabled, hacker-laptop won commandid  zookeeper ***************** receive all the network traffic because the networking subsystem is going to ignore packets that aren has ƒ  ¢ â  €************* destined for us. so step 1 is to enable IP forwarding. to enable it, set a non zero value like:
 
Code:
Root @ hacker-laptop :~ # Echo 1 & gt;/proc/sys/net/ipv4/ip_forward
Step 2: Set routing rules
 
We want to set rules so that all traffic routes through hacker-laptop, acting like a NAT router. just like a typical NAT, it wocould rewrite the destination address in the IP packet headers to be its own IP address.
 
This can be done as follows:
 
Code:
Tarranfx @ hacker-laptop :~ $ Sudo iptables-t nat-A PREROUTING
& Gt; -p tcp packet ƒ Â ¢ Ã € â **************************************************** too many requests "to 192.168.0.200
The iptables command has 3 components: www.2cto.com
 
When to apply a rule (-a prerouting)
What packets get that rule (-p tcp packet ƒ Â ¢ Ã ~~~~~~â ‚ ddd“ dport 80)
The actual rule (-t nat packet ƒ Â ¢ Ã ‚ too many "to 192.168.0.200)
What ababove command does: If you have your own registrantâ ~~~~~~â {re a TCP packet destined for port 80 (HTTP traffic ), actually make my address, 192.168.0.200, the destination, NATting both ways so this is transparent to the source. à ƒ  ¢ â  š à   â  
 
Step 3: Adding IP adddress to interface
 
The networking subsystem will not allow you to ARP for a random IP address on an interface provided ~~~~~~~~~~~~~~~â it has to be IP address actually assigned to that interface:
 
Code:
Taranfx @ hacker-laptop :~ $ Sudo ip addr add 192.168.0.1/24 dev eth0
And verify that the original IP address 192.168.0.200, and the gateway address 192.168.0.1.
 
Code:
Taranfx @ hacker-laptop :~ $ Ip addr registrantâ zookeeper ******************************
3: eth0: mtu 1500 qdisc noqueue state UNKNOWN
Link/ether c0: 30: 2b: 47: ef2: 74 brd ff: ff
Inet 192.168.0.200/24 brd 192.168.1.255 scope global eth0
Inet 192.168.0.1/24 scope global secondary eth0
Inet6 fe80: 230: 1bff: fe47: f274/64 scope link
Valid_lft forever preferred_lft forever
à ƒ  ¢ â  š à  ¦ â  ¦
Step 4: Responding to HTTP requests
 
Hacker-laptop wowould need a HTTP server setup. t cocould be any damn server, I used Apache for usage of use. here you can get creative, e.g. respond with random pages for specific URLs or define a local URL e.g. http: // fun
 
Step 5: Test pretending to be the gateway
 
Most of the things are already done and our hacker-laptop is ready to pretend as the Wifi Gateway, but the trouble is convincing victim-laptop that the MAC address for the gateway has changed, to that of hacker-laptop.
 
The solution is to send a Gratuitous ARP, which says ~~â ~~~~~~~~~~~~~â... Â € I know nobody asked, but I have the MAC address for 192.168.0.1 ~~â ~~~~~~~~~~~~â. machines that hear that Gratuitous ARP will replace an existing mapping from 192.168.0.1 to a MAC address in their ARP caches with the mapping advertised in that Gratuitous ARP.
There are lots of command line utilities and bindings in varous programming language that make it easy to issue ARP packets. I used the arping tool:
 
Code:
Taranfx @ hacker-laptop :~ $ Sudo arping-c 3-A-I eth0 192.168.0.1
We strongly recommend that you send a Gratuitous ARP reply (-A), three times (-c-3 ), on the eth0 interface (-l eth0) for IP address 192.168.0.1.
 
This can be then verified on the victim has been transferred  ¢ à ¢ â € ************************************* else...  € œ arp-a à ƒ  ¢ à ******************* command
 
Bingo! Victim-laptop now thinks the MAC address for IP address 192.169.1.1 is 0: 30: 1b: 47: f2: 74, which is hacker-laptop ~~â ~~~~~~~~~~~â s address.
If I try to browse the web on victim-laptop, I am served the resource matching the rules in hacker-laptop ~~â ?~~~~~~~~~~~~â s web server.
 
That means all of the non-HTTP traffic associated with viewing a web page still happens as normal. in particle, when hacker-laptop gets the DNS resolution requests for Google.com, the test site I visited, it will follow its routing rules and forward them to the real router, which will send them out to the Internet:
 
The fact is that hacker-laptop has rerouted and served the request is totally transparent to the client at the IP layer and victim-laptop has no clue.
 
Undo the changes
 
So, you had enough fun and wish to revert? Here we go:
 
Code:
Taranfx @ hacker-laptop :~ $ Sudo ip addr delete 192.168.0.1/24 dev eth0taranfx @ hacker-laptop :~ $ Sudo iptables-t nat-d prerouting-p tcp packet ƒ Â ¢ Ã € â š Ã Â â Â ‚ ¬ Å d“ dport 80-j NETMAP Ã Â â ¢ Ã ***************** "to 192.168.0.200
To get the client machines to believe the router is the real gateway, you might have to clear the gateway entry from the ARP cache with arp-d 192.168.0.1, or bring your interfaces down and back up.
From: TzSec

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.