Upvote Upvoted 2 Downvote Downvoted
linux pingsweeper script
posted in Off Topic
1
#1
0 Frags +

I need to create a pingsweep script in bash (.sh) for linux, but I have no idea how to start creating one. It would read your current ip and perform one in the last octet of the network, so a possible output would be
Host 192.168.0.1 is down.
Host 192.168.0.2 is down.
Host 192.168.0.3 is up.
Host 192.168.0.4 is up.
Host 192.168.0.5 is down.
Host 192.168.0.6 is up.
...

I don't want to copy anything but help would be appreciated. Can reward helpful posts/good advice with virtual headgear, if you wish

also general tips for someone who's new to linux command prompt are cool too

I need to create a pingsweep script in bash (.sh) for linux, but I have no idea how to start creating one. It would read your current ip and perform one in the last octet of the network, so a possible output would be
Host 192.168.0.1 is down.
Host 192.168.0.2 is down.
Host 192.168.0.3 is up.
Host 192.168.0.4 is up.
Host 192.168.0.5 is down.
Host 192.168.0.6 is up.
...

I don't want to copy anything but help would be appreciated. Can reward helpful posts/good advice with virtual headgear, if you wish

also general tips for someone who's new to linux command prompt are cool too
2
#2
1 Frags +

for i in `seq 0 255`; do
ping -c 1 192.168.1.$i
done

This will just ping each address between 192.168.1.0 and 225 once and give normal output. From there, you can parse the output and decide if it's up or down.

for i in `seq 0 255`; do
ping -c 1 192.168.1.$i
done

This will just ping each address between 192.168.1.0 and 225 once and give normal output. From there, you can parse the output and decide if it's up or down.
3
#3
serveme.tf
5 Frags +

nmap -sn 192.168.1.0/24

nmap -sn 192.168.1.0/24
4
#4
0 Frags +

you can also use nmap to do this, just use /24 to scan all the addresses (192.168.0.0/24)

Edit: Arie is faster than me.

you can also use nmap to do this, just use /24 to scan all the addresses (192.168.0.0/24)

Edit: Arie is faster than me.
5
#5
0 Frags +
Arienmap -sn 192.168.1.0/24

Damn, that is nice. I'll have to remember that.

[quote=Arie]nmap -sn 192.168.1.0/24[/quote]
Damn, that is nice. I'll have to remember that.
6
#6
-3 Frags +

I'm assuming if you're new to Linux command line stuff, that includes scripting, so

Open Pico
Add #!/bin/bash or /usr/local/bin/bash or wherever bash is to the first line
then add

mr64bit_for i in `seq 0 255`; do
ping -c 1 192.168.1.$i
done

Save as [script name].sh
chmod +x [script name].sh to add execute permissions (if need be)

Run with ./[script name].sh

I'm assuming if you're new to Linux command line stuff, that includes scripting, so

Open Pico
Add #!/bin/bash or /usr/local/bin/bash or wherever bash is to the first line
then add
[quote=mr64bit_]for i in `seq 0 255`; do
ping -c 1 192.168.1.$i
done[/quote]

Save as [script name].sh
chmod +x [script name].sh to add execute permissions (if need be)

Run with ./[script name].sh
7
#7
3 Frags +

vim master race

vim master race
8
#8
1 Frags +
sandwiches_timevim master race

fuck that, nano owns for simple shit like that

[quote=sandwiches_time]vim master race[/quote]

fuck that, nano owns for simple shit like that
9
#9
0 Frags +
hpqoeusandwiches_timevim master race
fuck that, nano owns for simple shit like that

Agreed. I can use vim, but I'm still more used to nano.
Vim for long configs or logs, nano for simple scripts/text files.

[quote=hpqoeu][quote=sandwiches_time]vim master race[/quote]

fuck that, nano owns for simple shit like that[/quote]
Agreed. I can use vim, but I'm still more used to nano.
Vim for long configs or logs, nano for simple scripts/text files.
10
#10
-1 Frags +

Am I the only one using desktop editor (Sublime Text) as my main?

Am I the only one using desktop editor (Sublime Text) as my main?
11
#11
0 Frags +

I use "ne" which gives the best of both worlds.

I use "ne" which gives the best of both worlds.
12
#12
0 Frags +
CHERRYAm I the only one using desktop editor (Sublime Text) as my main?

have sublime on the desktop
vim/ee/nano + tmux over ssh

[quote=CHERRY]Am I the only one using desktop editor (Sublime Text) as my main?[/quote]

have sublime on the desktop
vim/ee/nano + tmux over ssh
13
#13
-1 Frags +

#!/bin/bash

ip=$(ifconfig | grep "Bcast:" | cut -d: -f3 | cut -d' ' -f1 | cut -d'.' -f1-3)

for i in `seq 0 255`;

do
ping -c 1 $ip.$i
if []
then
echo "Host "$ip.$i" is up."
else
echo "Host "$ip.$i" is down."
fi
done

The pinging works but I can't seem to figure out how to get a return value for my if statement

If I wish to do it this way, what would I need to enter between the [] to check if the ping was succesful or not? Anything I should add?

this seems to work:
#!/bin/bash
ip=$(ifconfig | grep Bcast | cut -d: -f 3 | cut -d. -f 1,2,3)"."
for i in $(seq 1 254)
do
code=$(ping -c 1 "$ip$i" | grep received | cut -d, -f 2 | cut -d' ' -f $
if [ $code != 0 ]
then
echo "Host "$ip$i" is up."
else
echo "Host "$ip$i" is down."
fi
done

Probably an easier way to do this though :(

#!/bin/bash

ip=$(ifconfig | grep "Bcast:" | cut -d: -f3 | cut -d' ' -f1 | cut -d'.' -f1-3)

for i in `seq 0 255`;

do
ping -c 1 $ip.$i
if []
then
echo "Host "$ip.$i" is up."
else
echo "Host "$ip.$i" is down."
fi
done

The pinging works but I can't seem to figure out how to get a return value for my if statement


If I wish to do it this way, what would I need to enter between the [] to check if the ping was succesful or not? Anything I should add?


this seems to work:
#!/bin/bash
ip=$(ifconfig | grep Bcast | cut -d: -f 3 | cut -d. -f 1,2,3)"."
for i in $(seq 1 254)
do
code=$(ping -c 1 "$ip$i" | grep received | cut -d, -f 2 | cut -d' ' -f $
if [ $code != 0 ]
then
echo "Host "$ip$i" is up."
else
echo "Host "$ip$i" is down."
fi
done

Probably an easier way to do this though :(
14
#14
0 Frags +
Arienmap -sn 192.168.1.0/24

This was cool too, but not allowed to use nmap as it requires apt get. ty though

mr64bit_for i in `seq 0 255`; do
ping -c 1 192.168.1.$i
done

This will just ping each address between 192.168.1.0 and 225 once and give normal output. From there, you can parse the output and decide if it's up or down.

Ty for this

[quote=Arie]nmap -sn 192.168.1.0/24[/quote]
This was cool too, but not allowed to use nmap as it requires apt get. ty though

[quote=mr64bit_]for i in `seq 0 255`; do
ping -c 1 192.168.1.$i
done

This will just ping each address between 192.168.1.0 and 225 once and give normal output. From there, you can parse the output and decide if it's up or down.[/quote]
Ty for this
15
#15
0 Frags +
SchweppesArienmap -sn 192.168.1.0/24This was cool too, but not allowed to use nmap as it requires apt get. ty though

What do you mean it requires apt-get? Are you using a different distro that uses a different package manager? Every distro that I know of has nmap in its repos. Even if it doesn't you can always build from the source code.

Are you on a network without root access? IF yes, then why the hell are you trying to scan addresses of other people's computers without their permission?

[quote=Schweppes][quote=Arie]nmap -sn 192.168.1.0/24[/quote]
This was cool too, but not allowed to use nmap as it requires apt get. ty though[/quote]

What do you mean it requires apt-get? Are you using a different distro that uses a different package manager? Every distro that I know of has nmap in its repos. Even if it doesn't you can always build from the source code.

Are you on a network without root access? IF yes, then why the hell are you trying to scan addresses of other people's computers without their permission?
16
#16
1 Frags +
Stochast1cSchweppesArienmap -sn 192.168.1.0/24This was cool too, but not allowed to use nmap as it requires apt get. ty though
What do you mean it requires apt-get? Are you using a different distro that uses a different package manager? Every distro that I know of has nmap in its repos. Even if it doesn't you can always build from the source code.

Are you on a network without root access? IF yes, then why the hell are you trying to scan addresses of other people's computers without their permission?

Cause he wants to troll his classmates using nasty scripts found on the internet, hellooo? :D

To the OP: If that's what you want to do it's not a good idea.
Given that you needed help for that you won't cover tracks and your administrator will know who did it plus your colleagues certainly won't find it fun.
Please treat it more like an advice and don't take any offence. Play some 8Ball if you're bored during lessons since this won't take you anywhere.

[quote=Stochast1c][quote=Schweppes][quote=Arie]nmap -sn 192.168.1.0/24[/quote]
This was cool too, but not allowed to use nmap as it requires apt get. ty though[/quote]

What do you mean it requires apt-get? Are you using a different distro that uses a different package manager? Every distro that I know of has nmap in its repos. Even if it doesn't you can always build from the source code.

Are you on a network without root access? IF yes, then why the hell are you trying to scan addresses of other people's computers without their permission?[/quote]
Cause he wants to troll his classmates using nasty scripts found on the internet, hellooo? :D

To the OP: If that's what you want to do it's not a good idea.
Given that you needed help for that you won't cover tracks and your administrator will know who did it plus your colleagues certainly won't find it fun.
Please treat it more like an advice and don't take any offence. Play some 8Ball if you're bored during lessons since this won't take you anywhere.
17
#17
0 Frags +
Stochast1cSchweppesArienmap -sn 192.168.1.0/24This was cool too, but not allowed to use nmap as it requires apt get. ty though
What do you mean it requires apt-get? Are you using a different distro that uses a different package manager? Every distro that I know of has nmap in its repos. Even if it doesn't you can always build from the source code.

Are you on a network without root access? IF yes, then why the hell are you trying to scan addresses of other people's computers without their permission?

I'm using ubuntu (not updated) since that's the distribution we're using, might be possible it was already then but when I tried arie's command it said nmap was not installed

CHERRYStochast1cSchweppesArienmap -sn 192.168.1.0/24This was cool too, but not allowed to use nmap as it requires apt get. ty though
What do you mean it requires apt-get? Are you using a different distro that uses a different package manager? Every distro that I know of has nmap in its repos. Even if it doesn't you can always build from the source code.

Are you on a network without root access? IF yes, then why the hell are you trying to scan addresses of other people's computers without their permission?
Cause he wants to troll his classmates using nasty scripts found on the internet, hellooo? :D

To the OP: If that's what you want to do it's not a good idea.
Given that you needed help for that you won't cover tracks and your administrator will know who did it plus your colleagues certainly won't find it fun.
Please treat it more like an advice and don't take any offence. Play some 8Ball if you're bored during lessons since this won't take you anywhere.

I'm new to all of this so please explain why I can't do it like this, the task was to make a script that reads your ip from ifconfig and then using this pings every ip from 1-254 to see if they're up/down.

Keep in mind I'm just following orders here, I have no intention to use something like this myself. I don't even know what I could do with it, other than ping address with 1 packet

[quote=Stochast1c][quote=Schweppes][quote=Arie]nmap -sn 192.168.1.0/24[/quote]
This was cool too, but not allowed to use nmap as it requires apt get. ty though[/quote]

What do you mean it requires apt-get? Are you using a different distro that uses a different package manager? Every distro that I know of has nmap in its repos. Even if it doesn't you can always build from the source code.

Are you on a network without root access? IF yes, then why the hell are you trying to scan addresses of other people's computers without their permission?[/quote]
I'm using ubuntu (not updated) since that's the distribution we're using, might be possible it was already then but when I tried arie's command it said nmap was not installed
[quote=CHERRY][quote=Stochast1c][quote=Schweppes][quote=Arie]nmap -sn 192.168.1.0/24[/quote]
This was cool too, but not allowed to use nmap as it requires apt get. ty though[/quote]

What do you mean it requires apt-get? Are you using a different distro that uses a different package manager? Every distro that I know of has nmap in its repos. Even if it doesn't you can always build from the source code.

Are you on a network without root access? IF yes, then why the hell are you trying to scan addresses of other people's computers without their permission?[/quote]
Cause he wants to troll his classmates using nasty scripts found on the internet, hellooo? :D

To the OP: If that's what you want to do it's not a good idea.
Given that you needed help for that you won't cover tracks and your administrator will know who did it plus your colleagues certainly won't find it fun.
Please treat it more like an advice and don't take any offence. Play some 8Ball if you're bored during lessons since this won't take you anywhere.[/quote]
I'm new to all of this so please explain why I can't do it like this, the task was to make a script that reads your ip from ifconfig and then using this pings every ip from 1-254 to see if they're up/down.

Keep in mind I'm just following orders here, I have no intention to use something like this myself. I don't even know what I could do with it, other than ping address with 1 packet
18
#18
1 Frags +

Oh sorry I thought you wanted to SSH your classmates to open cd drives etc. :P
Anyways "for" way is the right one and if it was assignment someone gave you then he probably didn't want you to use nmap anyways

Oh sorry I thought you wanted to SSH your classmates to open cd drives etc. :P
Anyways "for" way is the right one and if it was assignment someone gave you then he probably didn't want you to use nmap anyways
Please sign in through STEAM to post a comment.