In-Depth ConceptsScriptingTechnology

Scripting for the Ambitious Hacker, Part 3 (Windows PowerShell)

23

Welcome back, my budding hackers!

As you know, I firmly believe that to be a true professional hacker, you need to be proficient in Linux. This is for a number of good reasons.

  1. Most hacker tools are developed in Linux (well over 90 percent).
  2. Linux offers us greater granularity of control.
  3. The terminal in Linux gives us complete control over the operating system, unlike cmd.exe in Windows that has only limited capabilities.
  4. Most importantly, Linux is open source and transparent. That means that we can actually see the source code and manipulate the operating system to a far greater degree than the closed source and opaque Windows operating system.

In recent years, Microsoft seems have gained religion is terms of the advantage of the command line and terminal in Linux. They now seem to understand the strengths and advantages of the command line, and as a response, introduced the Windows PowerShell.

PowerShell BackGround

Microsoft had recognized the limitations of their cmd.exe as early as the 1990s and attempted to remedy it with a bunch a workarounds. In 2002, Microsoft released a whitepaper on a product that was under development called MONAD, or Microsoft Shell. Eventually, Windows PowerShell was released as an add-on in 2007 and Windows PowerShell 2.0 was fully integrated into Windows 7 and Windows Server 2008 and all Windows operating systems since.

Windows PowerShell borrows much from the Linux environment including many Linux commands. It also includes the ability to pipe commands and link commands into a script.

With PowerShell capability, Windows becomes a more powerful hacking platform, but until Microsoft makes its source code open source (don’t hold your breath), Linux will still be the operating system of choice for hackers.

All that having been said, we should still explore and become familiar with the Windows PowerShell for when the Windows platform is appropriate, such as when using Cain and Abel and some of the other hacking tools developed for Windows.

mdlets

One of the key differences between Windows PowerShell and the BASH shell in Linux is that Microsoft has developed cmdlets (command lets) for PowerShell. They cmdlets are essentially single commands that accomplish sometimes more complex tasks similar to functions. These cmdlets take the form of verb-noun, such as “get-help”.

Step 1 – Open Powershell

Most system administrators and users are unaware that beneath that familiar Windows GUI lurks a powerful tool and engine for manipulating Windows. You can get to it by typing “powershell” into the search window at the Start or Windows button and click on “PowerShell”.

When it opens, you should get a screen that looks like this.

Step 2 – Get Help

Once we have the PowerShell terminal open, the first thing we want to explore is how we get help. PowerShell has a cmdlet for that called, unsurprisingly, “get-help”.


When we type “get-help”, we receive the help screen like that above. Microsoft has aliased this cmdlet so that “help” and the Linux command “man” accomplish the same thing.

Step 3 – Context Sensitive Help

As you remember from Linux, you can see the manual page for any command in Linux, by preceding the command with the keyword “man”. Likewise, in Windows PowerShell, you can use “get-help” followed by the cmdlet to see the manual page. Let’s get the manual page for a cmdlet named “Write-Output”.

  • > get-help Write-Output

You can see that PowerShell returns us a manual page for the cmdlet, “Write-Output”. As I mentioned above, “man” and “help” will both pull up the same context-sensitive information.

Step 4 – Run the Same Commands as Linux

Microsoft, recognizing that Linux system administrators are more accustomed to working from the command line and to encourage them to adopt and use the PowerShell, aliased many of the most common Linux commands into its PowerShell.

For instance, I can use the Windows command “dir” and the Linux command “ls” to get a directory listing in PowerShell.

Some of the other Linux commands that are available in PowerShell, include but aren’t limited to the following.

  • grep
  • cat
  • ps
  • mv
  • rm
  • echo
  • pwd
  • kill
  • export

Use the Integrated Scripting Environment

To create a script in PowerShell, similar to Linux, you can use Notepad or other text editor such as Notepad++. In addition, PowerShell comes with a Integrated Scripting Environment (ISE) that we can use.

There are numerous ways to get into the ISE, but probably the simplest is to create a file, right-click on it, and choose “Edit”. In this case, I created a file in Notepad called “Helloworld.ps1”. This will open the PowerShell ISE like that below.

Step 6 – Hello World

When starting out in ANY programming language, it’s requisite to write the ubiquitous “Hello World” program. We are not going to deviate from that path and we will create our own “Hello World” script here.

With the ISE open, we can type:

  • Write-Output “Hello World”

Just like in the Linux terminal, we enclose the string “Hello World” in double quotation marks to indicate that we want the string literals to be output (meaning we want these human language words and not computer commands).

We can run this script by either opening the PowerShell and navigating to this file and running Helloworld.ps1 or clicking on the green arrow on the ISE with the script open.

In my next PowerShell tutorial, we’ll delve a bit deeper into this powerful tool and use it to develop a port scanner, so keep coming back!

Lovepreet Singh
CEO & FOUNDER OF" FIVE RIVERS INCORPORATION - LEADING SOFTWARE & CYBER SECURITY DEVELOPMENT COMPANY" || CERTIFIED ETHICAL HACKER || FUTURE TRILLIONAIRE || FUTURISTIC || "DULL SCHOOL STUDENT" || (Follow this link to message me on WhatsApp: https://wa.me/13018426470)

Getting Started with Terms & Technologies

Previous article

Secure Your Identity & Become Anonymous Online This Year.

Next article

You may also like

23 Comments

  1. Sporanox Propecia Forehead Some [url=http://cialibuy.com]online pharmacy[/url] Kamagra Vente France Amoxicillin And Vitamin Isotretinoin tab internet pharmacy with free shipping

  2. These are actually enormous ideas in about blogging.
    You have touched some fastidious factors here.
    Any way keep up wrinting.

  3. I like the valuable info you provide in your articles.
    I will bookmark your weblog and take a look at again right
    here frequently. I am fairly sure I will be informed a lot of new stuff right here!
    Best of luck for the following!

  4. Viagra Wirkung Essen Doxycycline Hyclate 100mg Tablet [url=http://orderlevi.com]best prices for legal levitra[/url] Canadianhealthcaremall Acheter Levitra Sans Ordonnance Slimfast

  5. Viagra Udito [url=http://buyviaa.com]viagra[/url] Canadian Pharmacy Online

  6. It is not my first time to pay a visit this site, i am visiting
    this web site dailly and take good information from here all
    the time.

  7. Super Awesome Blog

    1. yeu5uteuuryuuuuuuuirfyu

  8. I could not refrain from commenting. Well written!

  9. Cialis Pas Cher A Paris [url=http://buygenericvia.com]viagra[/url] Kamagra Oral Jelly Sachets Costo Propecia Acquisto Doxycycline Online Canada No Prescription

  10. Wow, marvelous blog layout! How lengthy have you been running a blog for?
    you make running a blog look easy. The overall
    look of your site is great, as neatly as the content material!

  11. Hey there! Would you mind if I share your blog with my twitter group?
    There’s a lot of folks that I think would really enjoy your content.
    Please let me know. Thanks

  12. Please let me know if you’re looking for a article author
    for your blog. You have some really good articles and
    I feel I would be a good asset. If you ever want to take some of the load off,
    I’d really like to write some material for your blog in exchange for a link back to mine.
    Please blast me an email if interested. Regards!

  13. Yes! Finally someone writes about minecraft download
    mojang.

  14. I like the helpful info you supply to your articles.
    I’ll bookmark your blog and check again right here frequently.

    I’m rather sure I’ll learn lots of new stuff right here!
    Best of luck for the next!

  15. Hmm it seems like your blog ate my first comment (it was super long) so I guess
    I’ll just sum it up what I wrote and say, I’m thoroughly
    enjoying your blog. I as well am an aspiring blog writer but
    I’m still new to the whole thing. Do you have any suggestions for inexperienced blog writers?
    I’d definitely appreciate it.

  16. Pretty component to content. I simply stumbled upon your
    blog and in accession capital to assert that I acquire in fact enjoyed account your blog posts.

    Anyway I will be subscribing to your augment and even I achievement you get admission to consistently quickly.

  17. An impressive share! I have just forwarded this onto a co-worker who had been doing a
    little research on this. And he in fact bought me dinner simply because I found it for him…
    lol. So let me reword this…. Thank YOU for the meal!! But yeah, thanx for spending some
    time to discuss this issue here on your web page.

  18. Why visitors still make use of to read news papers when in this technological world the whole thing is existing on web?

  19. I am actually pleased to read this blog posts which contains lots of helpful information, thanks for providing
    such statistics.

  20. Remarkable! Its in fact amazing article, I have got much clear idea on the
    topic of from this piece of writing.

  21. Amazing! This blog looks exactly like my old one!
    It’s on a entirely different topic but it has
    pretty much the same layout and design. Outstanding choice of colors!

  22. Hey There. I found your blog the use of msn. That is a really neatly written article.
    I’ll be sure to bookmark it and come back to learn extra of your helpful information. Thank you for the post.
    I will definitely comeback.

Leave a reply

Your email address will not be published. Required fields are marked *