(solved)Bad bash script

Need help with C, C++, perl, python, etc?

(solved)Bad bash script

Postby GarryRicketson » 2016-10-18 19:42

I have someone asking me about this on the spanish forum,
Ataque DoS, question

In a nut shell, a user , experimenting , started this script:

Code: Select all
 #!/bin/bash
# Ping multiple destinations at once
args=$#
interval=$1
shift;
pktsize=$1
shift;
for (( i=3; i<=$args; i++ )); do
        ping -i $interval -s $pktsize $1 > /dev/null &
        shift;
done

I do not know enough about bash scripts to even know what it does,
However, DO NOT run it, the problem it has caused is they can not stop
it, even killing the process, apparently, it starts up again even after re-booting
the server,
some additional info:
Code: Select all
 ps -ef | grep pingIP | grep -v 'grep pingIP'
lausan     3317  2649  0 10:23 pts/0    00:00:00 grep --color=auto pingIP
lausan     3318  2649  0 10:23 pts/0    00:00:00 grep --color=auto pingIP

and
Code: Select all
 pkill pingIP

I have told the person to try using
'top' and see what the P id number is, and instead of
"pkill"
Code: Select all
 kill "pid number"

Any way , if anyone has some ideas, any feed back or suggestion is
appreciated, and thanks.
P.S. I am also trying to do some searches, to see what more
I can find,
Last edited by GarryRicketson on 2017-01-29 18:53, edited 1 time in total.
"What we expect you have already Done"

Before doing anything, read the Debian documentation:
Debian Documentation
How to ask the smart way
Debian Foro Español
======================
For the Birds
User avatar
GarryRicketson
 
Posts: 4281
Joined: 2015-01-20 22:16
Location: Durango, Mexico

Re: Bad bash script

Postby bw123 » 2016-10-18 22:54

Any way , if anyone has some ideas, any feed back or suggestion is
appreciated, and thanks.


Tell the punk that DoS ain't funny, and grow up?
User avatar
bw123
 
Posts: 2378
Joined: 2011-05-09 06:02
Location: TN_USA

Re: Bad bash script

Postby GarryRicketson » 2016-10-18 23:11

Well, yes, I mean no it is not funny, But how to stop the script forever ?
User avatar
GarryRicketson
 
Posts: 4281
Joined: 2015-01-20 22:16
Location: Durango, Mexico

Re: Bad bash script

Postby bw123 » 2016-10-18 23:19

sheesh... these kids nowadays, how about this?

# rm pingIP
User avatar
bw123
 
Posts: 2378
Joined: 2011-05-09 06:02
Location: TN_USA

Re: Bad bash script

Postby GarryRicketson » 2016-10-19 00:06

OK thanks
User avatar
GarryRicketson
 
Posts: 4281
Joined: 2015-01-20 22:16
Location: Durango, Mexico

Re: Bad bash script

Postby csystem » 2017-01-29 16:27

All that that script appears to do is ping a bunch of host at the same time with the same interval and packet size
e.g. $bash pingIP.sh 1 56 192.168.1.1 google.com
Then it will send a 56 byte size packet to 192.168.1.1 and google.com every second indefinitely.
Yes, it can be used as a ddos by setting the packet size very high and the interval very low.

But your script is not running forever. It just stats as many ping commands as you have agruments and stops.
After a reboot, this will most definitely stop.

GarryRicketson wrote:
Code: Select all
 ps -ef | grep pingIP | grep -v 'grep pingIP'
lausan     3317  2649  0 10:23 pts/0    00:00:00 grep --color=auto pingIP
lausan     3318  2649  0 10:23 pts/0    00:00:00 grep --color=auto pingIP


Check the actual process you are seeing here: "grep --color=auto pingIP"
You are just seeing the grep process that is obviously running as you just started it.

Just check your running processes using htop and press f4 to filter the results
csystem
 
Posts: 4
Joined: 2016-08-20 12:47

Re: (solved)Bad bash script

Postby GarryRicketson » 2017-01-29 19:07

Thanks for explaining it more, this was so long ago, and I had forgotten
to mark it solved, but anyway the explanation will help others understand
it better.
Thanks
User avatar
GarryRicketson
 
Posts: 4281
Joined: 2015-01-20 22:16
Location: Durango, Mexico


Return to Programming

Who is online

Users browsing this forum: No registered users and 2 guests

fashionable