Get the App
SLTechnology News&Howtos  ›  Development  › 

How to implement shell code to prevent ARP attacks

Shulou Source: shulou.com Published: 2022-06-03 07:41:05 10月19日 Update

Editor to share with you how to achieve the shell code to prevent ARP attacks, I believe most people do not know much about it, so share this article for your reference, I hope you can learn a lot after reading this article, let's go to know it!

The code is as follows:

#! / bin/bash

Declare gw= `route-n | grep-e'^ 0.0.0.0`

Declare gwname= `echo $gw | grep-oe'\ walled echo'`

Declare gwip= `echo $gw | grep-oe'[0-9]\ {2Magne3\}\. [0-9]\ {1Magne3\}\. [0-9]\ {1Magne3\}\. [0-9]\ {1recover3\}'`

Declare gwmac= `arp-n | grep-e $gwip | grep-oe'[0-9A-F]\ {2\}: [0-9A-F]\ {2\}: [0-9A-F]\ {2\}: [0-9A-

F]\ {2\}: [0-9A-F]\ {2\}: [0-9A-F]\ {2\}'`

Echo "switch $gwname arp: $gwip-$gwmac to static"

Arp-s $gwip $gwmac

Echo "done, off arp reuqest..."

Ifconfig $gwname-arp

Echo "all done."

The method of solving ARP attack under linux

Users under Windows can use antiArp Firewall, which can basically solve the problem, but what about brothers and sisters who like linux? that's what bothers me today.

I use fedora core 6, I first hang up several image files, search with the keyword arp, and find arptables, and arpwatcher is first of all arpwatcher, it seems that it can only monitor the local ip/arp address change and so on, it does not seem to prevent arp attacks. When I looked at arptables, I immediately thought of iptables. When I installed it, sure enough, the command line was exactly the same. But here's the problem: it's easy to keep this machine free from arp attacks (just bind it with static arp), but other people's gateways will still be attacked, we are not network administrators, and I can only "watch from afar but not play with them"!

When the road was blocked, we changed our way, and arping caught my eye. When I returned to shell, I found that la had been installed:

"arping-send ARP REQUEST to a neighbour host" arping [- AbDfhqUV] [- c count] [- w deadline] [- s source]-I interface destination-U Unsolicited ARP mode to update neighbours' ARP caches. No replies are expected.

Key commands:

Arping-U-I network card interface for sending packets-s source ip destination ip

Example:

Suppose the ip corresponding to your eth0 interface is 192.168.1.1 and the gateway is 192.168.1.255, you can use it.

Arping-U-I eth0-s 192.168.1.1 192.168.1.255

The above is all the contents of the article "how to implement shell code to prevent ARP attacks". Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!

Tags: Attacks codes articles gateways keys content commands interfaces problems native machines annoyances exactly the same a search not much brothers keywords addresses most sisters Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno MySQL OPPO Reno Linux Redmi NVidia