Shell Scripting - Ping Sweep Script

HackerSploit · Intermediate ·📰 AI News & Updates ·7y ago

Key Takeaways

This video demonstrates how to create a shell script for ping sweep using tools like shell scripting, ping sweep script, sequence function, ping, bash, and nmap, to scan for active computers on a network.

Full Transcript

hey guys hackersploit here back again with another video and welcome back to the shell scripting series in this video we're going to be looking at how to create our first uh official working and useful script which is essentially a simple ping sweep script this is probably what i started off with and you know just going over it it brings back a lot of memories because it really makes you understand um you know the advantages of scripting languages and how they can be used uh you know for day-to-day tasks that being said uh the main component of this script is going to be using the loops and that's primarily the reason i had to cover it before i started making uh these videos in regards to creating your own scripts all right all right so essentially the purpose or the function of this script is to ping or you know you can customize the the the ping sweep to whatever you want but its purpose is to ping a set a subnet or a set of ip addresses of your choice and to check whether they are online or not now of course as i said this is really simple to do it on one but what if you had to do it on your entire network what if you had an entire range or a subnet in which you had to scan it of about you know 100 computers and you wanted to perform some diagnosis on them and you wanted to know which one is up and which one is not this is a very important one one that you think you'll never use but uh has helped me a lot anyway so i've created uh the script it's called pink sweep dot shell and i have already created my shebang here and we are ready to go alright so the first thing i'm going to do um is let me let me just add a comment here so i can say simple uh ping sweep uh script all right something just really really simple so i can document these uh and maybe if you want these scripts up on github i can do that as well so you can check them out for yourself all right so that's a simple ping sweep uh script and what we need to do now is we need to ask the we are going to be asking the user to enter a subnet uh and i'll explain what this means so i'm going to say uh please uh enter the uh please enter the subnet um or your subnet or let's just keep it at subnet because you might not be performing this test on your own on your own network so please enter subnet and we're going to read and store this variable in the subnet variable now of course that's really not how you'd go about it but the reason i'm doing this is because i want you to understand exactly what's going on here all right so i'm just gonna have that like that so uh read subnet and now we can get started with our loop so uh remember we are dealing with ip addresses and a range that uh you know you can specify within the script depending on the on on the amount of ip addresses i'll explain how to do this using the sequence uh function that comes in shell scripting so uh we're going to use a loop so we're going to say 4 and we're going to use the variable name ip all right and i'm going to uh you can use when you in a loop you can when you're declaring the the variable inside the loop you can you don't need to specify the exact uh you don't need to use an uppercase specification it really isn't needed but if you want to you can as well sorry so for ip in um and you we can say for ip in uh in the list now in the list this is where uh you would specify the range in terms of the subnet so uh you can have an ip if you're in scanning the entire subnet you're scanning ips from 1 to 254 so we use the sequence the sequence can use characters uh keywords and also numbering which is what we're doing so i'm specifying the sequence of 1 to 2 to 254 okay so the sequence of 1 to 254 and we want to do we essentially now want to ping so we can now start our pinging here so i'm going to say ping now when we talk about pinging the thing people don't understand is if we ping here for example google.com what happens is it will keep on pinging uh google.com recursively okay so what i'm gonna do is i'm just gonna hit ctrl c there and i'm gonna clear that out okay so you you you get what i'm doing so when we talk about pinging if i open the the ping manual here uh and we look for where's the command or the up yeah here uh c the c uh the c count or the c command allows you to specify the amount of times you want to ping so you can see stop after sending count and you specify the the count uh the syntax is quite simple it's count and then the amount of times you want to ping that whole so again something that you can play with as well so uh we're going to specify that so i'm going to say uh the count is going to be one we want to ping each iip address once okay and of course you can customize that if you want now we need to use uh so we're saying ping ah let's see we are saying we want to ping um the we are pinging it once but we've already specified yeah now let me explain what why i have two variables here because you might be saying well why don't i just enter the ip well remember specifying a range so we're going to prompt the user to enter the subnet the subnet is the first three digits or denominations that determine uh the the starting ip denomination and then the subnet being either 1 2 all the way to 10 right so what do i mean by this is what we will prompt the user to enter is the first three digits so for those of you using cisco routers that will be 10.10 point maybe one so you enter that and then the rest here is sequenced from 1 to 24 as i p addresses are okay so i'll show you how that works in a second so uh we we have already said that the first three are going to be in terms of the sub and of course we don't have any error checking because someone can enter the entire subnet but that's not how it's designed okay so we'll say for uh for ip in the uh in the sequence here of 1 to 254 that's the variable ip so we can say uh we specify the the variable subnet dot ip right sub subnet dot ip so that will be the first three digits plus the sequence here from one to one uh from one to 254 so from 192.168.1 0.1 to 192.168.1.254 you get you get what i'm saying and again you can change the sequence here depending on the size of the network um and that's pretty much it i think that's all for now so let's save this and i'm going to launch this so i'm going to say ping sweep uh sorry ping sweep and i'm going to enter all right so you can see now it's prompting the user to enter the subnet so the subnet is the first three so i can say 192.168.1 that's my subnet now it is automatically going to use the sequencing and it's going to ping every address from 1 to 254 even the even though they might not exist all right so i'm going to hit enter and as you can see it started the pinging and there you are now i know for my network uh that my ips start at the 100 range and that's because i i have dhcp enabled and i've customized it like that um you can see that we are not getting any hosts up so what we need to do is uh we can edit this again so i'm going to edit this again and uh we can change my range from 1 to 100 sorry 100 so that will scan ips from 100 to 254 and hopefully that holds up now this might not seem very complicated but if you're a systems administrator or if you are in penetration testing this script allows you to know uh a lot in terms of how or what computers are currently active on the network especially if you're talking about the network the size of again as mentioned entire range or entire subnets okay so i'm gonna hit enter and you can customize the ping sweep to whatever you want now the exciting thing as we'll look in the next video is we'll be looking at how to create our own nmap scanner and customizing it again and also showing you how to output the data okay so let's exit here and let's run that again or actually let me clear my terminal and uh oops sorry my bad um we can run that right now and i'm going to enter the subnet 68.1 i'm gonna hit enter and there you are it's gonna start scanning from the ip182.168.1.100 and that is probably up yes it is did it get uh uh yes it received uh one there we are zero packet loss and uh there we are so it's going through all the ips on my subnet now of course not all of them occupied so it's going to scan and it's going to go through all that might be active now you can see the potential problem here is that uh the data being displayed is really not displayed in a way that we can read very easily so in the next part of set of videos we'll be looking at customizing how data is output to the user and how it can be output in a way that we understand you know whether what's going on here so for example in this case we would like to customize it and print out the ip and display whether a host the host is up or not something like that that being said guys that's going to be it for this video i just really wanted to cover how you can utilize all that we've learned so far and how exciting it really is so uh if you found value in this video please leave a like down below if you have any questions or suggestions let me know in the comment section on my social networks or on my website i'll be sure to get back to you and i'll be seeing you in the next video [Music] peace

Original Description

Hey guys! HackerSploit here back again with another video, in this series we will be looking at how to create shell scripts. A shell script is a computer program designed to be run by the Unix shell, a command-line interpreter. The various dialects of shell scripts are considered to be scripting languages ⭐Help Support HackerSploit by using the following links: 🔗 NordVPN: https://nordvpn.org/hacker Use the link above or the code below for 77% Off your order Promo Code: hacker Patreon: http://patreon.com/hackersploit I Hope you enjoy/enjoyed the video. If you have any questions or suggestions feel free to ask them in the comments section or on my social networks. 🔗 HackerSploit Website: https://hsploit.com/ 🔗 HackerSploit Android App: https://play.google.com/store/apps/details?id=com.hsploitnews.hsploit&hl=en 🔹 Support The Channel NordVPN Affiliate Link: https://nordvpn.org/hacker Patreon: http://patreon.com/hackersploit 🔹 Get Our Courses Get a special discount on our courses: The Complete Deep Web Course 2018: https://www.udemy.com/the-complete-deep-web-course-2017/?couponCode=DWCBP2017 🔹 SOCIAL NETWORKS - Connect With Us! ------------------------------- Facebook: https://www.facebook.com/HackerSploit/ Twitter: https://twitter.com/HackerSploit Patreon: http://patreon.com/hackersploit -------------------------------- Thanks for watching! Благодаря за гледането Kiitos katsomisesta 感谢您观看 Merci d'avoir regardé Grazie per la visione Gracias por ver شكرا للمشاهدة دیکھنے کے لیے شکریہ देखने के लिए धन्यवाद
Watch on YouTube ↗ (saves to browser)
Sign in to unlock AI tutor explanation · ⚡30

Playlist

Uploads from HackerSploit · HackerSploit · 0 of 60

← Previous Next →
1 How To Install Kali Linux 2.0 On Virtual Box
How To Install Kali Linux 2.0 On Virtual Box
HackerSploit
2 100 Subscriber Q&A! - How I Learned Ethical Hacking
100 Subscriber Q&A! - How I Learned Ethical Hacking
HackerSploit
3 BlackArch Linux Review - Better Than Kali Linux?
BlackArch Linux Review - Better Than Kali Linux?
HackerSploit
4 How to Access the Deep Web Safely | Deep Web Starter Guide 1.0
How to Access the Deep Web Safely | Deep Web Starter Guide 1.0
HackerSploit
5 Wireshark Tutorial for Beginners - Installation
Wireshark Tutorial for Beginners - Installation
HackerSploit
6 Wireshark Tutorial for Beginners - Overview of the environment
Wireshark Tutorial for Beginners - Overview of the environment
HackerSploit
7 Wireshark Tutorial for Beginners - Capture options
Wireshark Tutorial for Beginners - Capture options
HackerSploit
8 Wireshark Tutorial for Beginners - Filters
Wireshark Tutorial for Beginners - Filters
HackerSploit
9 Complete Ethical Hacking Course - Become a Hacker Today - #1 Hacking Terminology
Complete Ethical Hacking Course - Become a Hacker Today - #1 Hacking Terminology
HackerSploit
10 Complete Ethical Hacking Course #2 - Installing Kali Linux
Complete Ethical Hacking Course #2 - Installing Kali Linux
HackerSploit
11 Parrot OS 3.5 Review | The Best Kali Linux Alternative
Parrot OS 3.5 Review | The Best Kali Linux Alternative
HackerSploit
12 Nmap Tutorial For Beginners - 1 - What is Nmap?
Nmap Tutorial For Beginners - 1 - What is Nmap?
HackerSploit
13 Katoolin | How To Install Pentesting Tools On Any Linux Distro
Katoolin | How To Install Pentesting Tools On Any Linux Distro
HackerSploit
14 Nmap Tutorial For Beginners - 2 - Advanced Scanning
Nmap Tutorial For Beginners - 2 - Advanced Scanning
HackerSploit
15 Nmap Tutorial For Beginners - 3 - Aggressive Scanning
Nmap Tutorial For Beginners - 3 - Aggressive Scanning
HackerSploit
16 Zenmap Tutorial For Beginners
Zenmap Tutorial For Beginners
HackerSploit
17 How To Setup Proxychains In Kali Linux - #1 - Stay Anonymous
How To Setup Proxychains In Kali Linux - #1 - Stay Anonymous
HackerSploit
18 How To Setup Proxychains In Kali Linux - #2 - Change Your IP
How To Setup Proxychains In Kali Linux - #2 - Change Your IP
HackerSploit
19 How To Change Mac Address In Kali Linux | Macchanger
How To Change Mac Address In Kali Linux | Macchanger
HackerSploit
20 How To Setup And Use anonsurf On Kali Linux | Stay Anonymous
How To Setup And Use anonsurf On Kali Linux | Stay Anonymous
HackerSploit
21 Ubuntu 17.04 "Zesty Zapus" Review - Bye Unity
Ubuntu 17.04 "Zesty Zapus" Review - Bye Unity
HackerSploit
22 VPN And DNS For Beginners | Kali Linux
VPN And DNS For Beginners | Kali Linux
HackerSploit
23 Tails OS Installation And Review - Access The Deep Web/Dark Net
Tails OS Installation And Review - Access The Deep Web/Dark Net
HackerSploit
24 Steganography Tutorial - Hide Messages In Images
Steganography Tutorial - Hide Messages In Images
HackerSploit
25 The Lazy Script - Kali Linux 2017.1 - Automate Penetration Testing!
The Lazy Script - Kali Linux 2017.1 - Automate Penetration Testing!
HackerSploit
26 Best Linux Distributions For Penetration Testing
Best Linux Distributions For Penetration Testing
HackerSploit
27 Netcat Tutorial - The Swiss Army Knife Of Networking - Reverse Shell
Netcat Tutorial - The Swiss Army Knife Of Networking - Reverse Shell
HackerSploit
28 Gaining Access - Web Server Hacking - Metasploitable - #1
Gaining Access - Web Server Hacking - Metasploitable - #1
HackerSploit
29 Web Server Hacking - FTP Backdoor Command Execution With Metasploit - #2
Web Server Hacking - FTP Backdoor Command Execution With Metasploit - #2
HackerSploit
30 How To Install Kali Linux On VMware  - Complete Guide 2018
How To Install Kali Linux On VMware - Complete Guide 2018
HackerSploit
31 Q&A #1 - Best Cyber-security Certifications?
Q&A #1 - Best Cyber-security Certifications?
HackerSploit
32 Terminator - Kali Linux - Multiple Terminals
Terminator - Kali Linux - Multiple Terminals
HackerSploit
33 Shodan Search Engine Tutorial - Access Routers,Servers,Webcams + Install CLI
Shodan Search Engine Tutorial - Access Routers,Servers,Webcams + Install CLI
HackerSploit
34 Q&A #2 - Mr Robot?
Q&A #2 - Mr Robot?
HackerSploit
35 Metasploit Community Web GUI  - Installation And Overview
Metasploit Community Web GUI - Installation And Overview
HackerSploit
36 Linux Expl0rer - Forensics Toolbox - Installation & Configuration
Linux Expl0rer - Forensics Toolbox - Installation & Configuration
HackerSploit
37 QuasarRAT - The Best Windows RAT? - Remote Administration Tool for Windows
QuasarRAT - The Best Windows RAT? - Remote Administration Tool for Windows
HackerSploit
38 Metasploit For Beginners - #1 - The Basics - Modules, Exploits & Payloads
Metasploit For Beginners - #1 - The Basics - Modules, Exploits & Payloads
HackerSploit
39 Metasploit For Beginners - #2 - Understanding Metasploit Modules
Metasploit For Beginners - #2 - Understanding Metasploit Modules
HackerSploit
40 Kali Linux Quick Tips - #1 - Adding a non-root user
Kali Linux Quick Tips - #1 - Adding a non-root user
HackerSploit
41 Metasploit For Beginners - #3 - Information Gathering - Auxiliary Scanners
Metasploit For Beginners - #3 - Information Gathering - Auxiliary Scanners
HackerSploit
42 Spectre Meltdown Vulnerability  - How To Check Your System
Spectre Meltdown Vulnerability - How To Check Your System
HackerSploit
43 Metasploit For Beginners - #4 - Basic Exploitation
Metasploit For Beginners - #4 - Basic Exploitation
HackerSploit
44 ARP Spoofing With arpspoof - MITM
ARP Spoofing With arpspoof - MITM
HackerSploit
45 WordPress Vulnerability Scanning With WPScan
WordPress Vulnerability Scanning With WPScan
HackerSploit
46 Generating A PHP Backdoor with weevely
Generating A PHP Backdoor with weevely
HackerSploit
47 Nikto Web Vulnerability Scanner - Web Penetration Testing - #1
Nikto Web Vulnerability Scanner - Web Penetration Testing - #1
HackerSploit
48 How To Install Kali Linux On Windows 10 - Windows Subsystem For Linux
How To Install Kali Linux On Windows 10 - Windows Subsystem For Linux
HackerSploit
49 Stacer - System Optimizer And Monitoring Tool For Linux
Stacer - System Optimizer And Monitoring Tool For Linux
HackerSploit
50 Kali Linux 2018.1 - Kernel Updates & Patches
Kali Linux 2018.1 - Kernel Updates & Patches
HackerSploit
51 MITM With Ettercap - ARP Poisoning
MITM With Ettercap - ARP Poisoning
HackerSploit
52 Password Cracking With John The Ripper - RAR/ZIP & Linux Passwords
Password Cracking With John The Ripper - RAR/ZIP & Linux Passwords
HackerSploit
53 How To Detect Rootkits On Kali Linux - chkrootkit & rkhunter
How To Detect Rootkits On Kali Linux - chkrootkit & rkhunter
HackerSploit
54 Channel Updates - How To Post Questions & Video Suggestions
Channel Updates - How To Post Questions & Video Suggestions
HackerSploit
55 Web App Penetration Testing - #1 - Setting Up Burp Suite
Web App Penetration Testing - #1 - Setting Up Burp Suite
HackerSploit
56 Web App Penetration Testing - #2 - Spidering & DVWA
Web App Penetration Testing - #2 - Spidering & DVWA
HackerSploit
57 Cl0neMast3r - GitHub Repository Cloning Tool
Cl0neMast3r - GitHub Repository Cloning Tool
HackerSploit
58 Kali Linux On Windows 10 Official - WSL - Installation & Configuration
Kali Linux On Windows 10 Official - WSL - Installation & Configuration
HackerSploit
59 DoS/DDoS Protection - How To Enable ICMP, UDP & TCP Flood Filtering
DoS/DDoS Protection - How To Enable ICMP, UDP & TCP Flood Filtering
HackerSploit
60 Web App Penetration Testing - #3 - Brute Force With Burp Suite
Web App Penetration Testing - #3 - Brute Force With Burp Suite
HackerSploit

This video teaches how to create a shell script for ping sweep to scan for active computers on a network, and how to customize the script for better functionality. The script uses a sequence function to specify the range of IP addresses to scan, and allows the user to customize the range and sequence of IP addresses being pinged.

Key Takeaways
  1. Read user input for subnet variable
  2. Declare and initialize loop variable `ip`
  3. Use sequence function to specify range of IP addresses to scan
  4. Ping each IP address in the subnet using a loop
  5. Specify the subnet and sequence of IP addresses
  6. Use a loop to ping each IP address in the sequence
  7. Customize the range and sequence of IP addresses being pinged
  8. Hit enter to customize the ping sweep script
  9. Run the script and enter the subnet to scan
  10. Exit and re-run the script to demonstrate its functionality
💡 Customizing the data output for better readability is crucial for effective network scanning and penetration testing.

Related AI Lessons

When AI Asks for More Electricity Than a Country Can Imagine
AI's increasing power consumption is causing concerns, learn why it matters for data centers and energy supply
Medium · AI
You Are Not Behind. The World Is.
You're not behind, the world is still adapting to AI, and it's okay to take your time to learn and grow
Medium · AI
Career choice with the advent of AI - pure Computer Science or learn software with a background of core engineering area
Learn how to choose between a Computer Science and Engineering career path or combining programming with a core engineering background in the age of AI
Dev.to AI
The AI Hype Cycle: Calm Before the Next Breakthrough?
Understand the AI hype cycle to anticipate the next breakthrough and make informed decisions
Medium · Programming
Up next
Generative AI
Alea IT Solutions
Watch →