Admin Task #4: Mastering DOS Scripting

Flex your DOS scripting muscles to create batch files to accomplish tasks. Doing something repetitive? DOS scripting will make it easier.

December 4, 2017

About This Challenge

Sometimes we miss DOS. We miss being able to delete a directory on our hard drive (not a “folder”), and the entire application was “uninstalled”. There was no registry! Ahh, those were the days. And so when we have a chance, we still flex my DOS scripting muscles to create batch files to accomplish tasks. And of course, there’s PowerShell, but sometimes the simplicity of DOS is just what’s needed. Yes, even with all it’s quirkiness.

We used a DOS script to determine whether or not an RTMP stream was running, check on several streams, and alert if a stream was currently active or not. And we’ve used DOS scripts, with a combination of built-in and 3rd party pieces, to see if any rogue laptops were on our network, examine disk space on critical servers and send us a text if drive space was running low, and alert us if there was a new user added into the Domain Admins, Enterprise Admins, or Scheme Admins groups. Definitely beneficial and efficient to learn!

Disclaimer: Ensure any activities undertaken on your work network are allowed by your corporate policy and approved by management at your organization.

Follow The Instructions To Complete Today’s Network Defender Task:

Feel free to download the PDF version of the directions for your review.

Download PDF

For this Network Defender task,there can be more than one “right answer.”

Create a DOS batch file: a text file ending with .bat, that performs the following:

1. Creates a file called “hostname_netstat.txt”, where “hostname” is the name of the computer.

2. Adds the date, and time into the file (and this can becombined with step 1.

3. Finds the listening ports on the computer, and adds onlythe listening ports into the file (not all the ports – just those in the “LISTENING” state)

What’s the use of such a file?

It creates a baseline, for a specific host, of the ports in the listening state. If this file is run every time the computer starts up, then you create a history.

And if a new port shows up in the listening state… why?

It may be a sign of a compromised PC, malware, or an unauthorized change. A listening port accepts traffic, and is therefore a potential security risk, and worth investigation.

4. Review how to scan a range vs a single host.

5. Repeat one of the scan types so that it scans the site even if the site doesn’t respond to a ping, a common security configuration.

For an advanced challenge:

Save these files for all hosts in your network, to a share, and set up the script to look for changes from the current state, and the last state, and if a new port is open, create an alert/text/email .

(check out blat.net for command line emailing, and don’t forget, your phone has an email address. Email that address, and the message will appear as a text to your phone – handy!)

Once you’ve followed these directions, scroll down to mark this challenge complete.

Once You’ve Completed This Task Click This Button.

I Completed This Task

If your company will not allow you to perform the above task. Please read this security article and click the button above.

IT Security Training To Prepare You For War

Loving The Challenge And Want More Great StormWind Content? Contact Us To Schedule A Security Training Consultation

First Name

Last Name

Email

Company

Job Role:

Phone Number

Why Over 100,000 Techs Believe In StormWind Studios

StormWind Studios is to IT training what George Lucas is to Star Wars. We take industry experts, add serious special effects, and deliver the most exciting, compelling live IT training on the planet – see for yourself during our Network Defender 5-Day Challenge

Signing up for Stormwind is one of the best education decisions I've made and I strongly recommend them to anyone interested in studying IT.

Jon Lincoln

One of the coolest parts about this course (CEH) was that lectures were recorded daily, so you could make up any missed time without a lot of headache or heartache. I just took the Certified Ethical Hacker test, and I’m pleased to say that I passed on the first try.

Dave Cork

I took StormWind classes and labs- absolutely OUTSTANDING! I did those just prior to going for my certification exam and passed it with a 923 out of 1000.

Ron Marx

It has made a sizable impact with our company, our offerings to our client base, and my personal career. I am looking forward to this new position with my employer in San Antonio, thanks to StormWind.

Mike Lind