学习笔记

kali linux教程

linux命令大全
查看文件:
cat,more,less,tail(默认显示文件的最后 10 行):

grep 命令用于查找文件里符合条件的字符串
查找文件:
find,whereis

b站学习笔记

1.前提准备,我们首先需要一个僵尸主机。 僵尸主机是一台可作为欺骗IP地址使用提供可预设的IP ID序列号的机器。
nmap -p80 --script ipidseq <your ip>/24 <全网段>
nmap -p80 --script ipidseq -iR 1000 < 随机选择>
2.开启扫描
nmap -Pn -sI <zombie host> <target>

探测waf:
Nmap给我们提供了探测的waf脚本:
nmap -p 80,443 --script=http-waf-detect <目标>
识别度更加精确:
nmap -p 80,443 --script=http-waf-fingerprint <目标>

200 OK:文件存在
404 File not found:文件不存在
301 Moverd permanently:301适合永久重定向
302 :临时重定向
401 Unauthorized:需要权限来访问这个文件
403 Firbidden:请求有效但是服务器拒绝访问

python黑客编程

python正则表达式

正则表达式匹配
正则表达式(regular expression)描述了一种字符串匹配的模式(pattern),可以用来检查一个串是否含有某种子串、将匹配的子串替换或者从某个串中取出符合某个条件的子串等。

一般字符 匹配
. 匹配除换行符 \n 之外的任何单字符。要匹配 . ,请使用 . 。
\ 转义字符,是最后一个字符改变原来的意思。如果字符串中有字符*需要匹配,可以使用\*或者字符集[*]
[...] 字符集(字符类)。对应的位置可以使字符集中任意字符。字符集中的字符可以逐个列出,也可以给出范围,如[abc]或[a-c],第一个字符如果是^则表示取反,如[^abc]表示不是abc的其他字符。所有的特殊字符在字符集中都失去原有的特殊含义。在字符集中如果要使用 ]、- 或^,可以在前面加上反斜杠。
\d 数字:[0-9]
\D 非数字:[^\d]
\s 非空字符:[<空格>\t\r\f\v]
\S 非空白字符:[^\s]
\w 单词字符:[A-Za-z0-9]
\W 非单词字符:[^\w]
  • | 匹配前面的子表达式0次或多次
  • | 匹配前一个字符1次或多次
    ? | 匹配前一个字符0次或1次
    {m} | 匹配前一个字符m次
    {m,n} | 匹配前一个字符m至n次。m和n可以省略

* 、+限定符都是贪婪的,因为它们会尽可能多的匹配文字,只有在它们的后面加上一个?就可以实现非贪婪或最小匹配

搜索课程标题的脚本:

#conding=utf-8
import re
html = '''

'''
title = re.findall(r'<p class="coursename" title="(.*?)" onclick=',html)

for i in title:
	print i

python requests

1.安装requests
pip install requests
2.发送网络请求

r = requests.get('http://www.baidu.com')
r = requests.post('http://www.baidu.com')
r = requests.put('http://www.baidu.com')

3.为url传递参数

playlaod = {'key':'value1','key2':'value2'}
r = requests.get("http://httpbin.org/get",params=playload)
print(r.url)
http://httpbin.org/get?key2=value&key1=value1

4.响应内容

r = requests.get('http://www.baidu.com')
r.text
r.encoding = 'utf-8'
r.encoding = 'ISO-8869-1'

5.二进制响应内容

r = requests.get('http://www.baidu.com')
r.content

6.定制请求头

url = 'http://www.baidu.com'
headers = {'content-type':'application/json'}
r = requests.get(url,headers=headers)

注:headers中可以加入cookies
7.复杂的POST请求

playload = {'key1':'value1','key2':'value2'}
r = requests.post("http://httpbin.org/post",data=playload)

8.响应状态码

r = requests.get("http://www.baidu.com")
r.status_code
200

9.响应头
r.headers

10.Cookies

r.cookies
r.cookies['example cookie name']

11.超时
requests.get('http://www.baidu.com',timeout=0.001)

python threading模板

start_new_thread(function,args kwargs=None)
产生一个新的线程,在新的线程中用指定的参数和可选的kwargs来调用这个函数
注意:使用这种方法时,一定要加time.sleep(),否则线程将可能不执行

import thread
import time
from subprocess import Popen,PIPE

def ping_check(ip):
	check = Popen(['/bin/bash','-c','ping -c 2 '+ip],stdin=PIPE,stdout=PIPE)
	data = check.stdout.read()
	if 'ttl' in data:
		print '%s is UP'%ip

def main():
	for i in range(1,255):
		ip = '122.228.238.'+str(i)
		thread.start_new_thread(ping_check,(ip,))
		time.sleep(0.1)

if __name__ == '__main__':
	main()

Thread类

import threading
import time
import requests
import sys

def fun1():
	time_start = time.time()
	r = requests.get(url='http://www.baidu.com')
	times = time.time()-time_start
	sys.stdout.write('Status:%s---%s---%s\n'%(r.status_code,times,time.strftime('%H:%M:%S')))

def main():
	threads = []

	threads_count = 10

	for i in range(threads_count):
		t = threading.Thread(target=fun1,args=())
		threads.append(t)

	for i in range(threads_count):
		threads[i].start()

	for i in range(threads_count):
		threads[i].join()

if __name__ == '__main__':
	main()

解决了线程数可控的问题
生产者-消费者问题和Queue模板

import threading
import Queue
from subprocess import Popen,PIPE
import sys

class DoRun(threading.Thread):
	def __init__(self,queue):
		threading.Thread.__init__(self)
		self._queue = queue

	def run(self):
		while not self._queue.empty():
			ip = self._queue.get()
			check_ping = Popen(['/bin/bash','-c','ping -c 2 '+ip],stdin=PIPE,stdout=PIPE)
			data = check_ping.stdout.read()
			if 'ttl' in data:
				sys.stdout.write(ip+' is UP\n')

def main():
	threads = []
	threads_count = 100
	queue = Queue.Queue()
	
	for i in range(1,255):
		queue.put('14.215.177.'+str(i))

	for i in range(threads_count):
		threads.append(DoRun(queue))

	for i in threads:
		i.start()
	for i in threads:
		i.join()

if __name__ == '__main__':
	main()

解决了生产参数和计算结果时间都不确定的问题

高精度字典生成

思路:

  1. 常见账号:总结
  2. 常见密码:TOP密码字典
  3. 密码:以常见密码为母本,结合密码组合规则生成
  4. 扩展至BurpSuite

安装extre:pip install exrex
使用:

微信文章收集

干货技巧 | phpinfo信息利用
渗透基础 | 黑客常用端口利用总结
各种WAF绕过手法学习
PHP反序列化笔记
XSS备忘录
【Web安全干货分享】浅谈文件包含漏洞原理
内网攻防经典技术备忘录
常见的Web源码泄漏漏洞及其利用
php伪协议的常见利用方式
Linux终极渗透测试命令总结(收藏备用)
那些可以绕过WAF的各种特性
SQL注入速查表(上)
【好文推荐】各种提权姿势总结
Confluence 漏洞总结
Windows 权限提升
FUD101(连载): 一、shellcode免杀
红队攻防实践:闲谈Webshell在实战中的应用
实战中exe文件免杀
Office钓鱼之传世经典CVE-2017-11882分析学习
HackTheBox通关手记之October
关于linux权限提升的一些方法
Linux本地提权漏洞复现与检测思路
SSRF绕过方法总结
红队测试之Windows提权小结
反弹shell的各种姿势

PHP正则表达式的字符类

字符类(方括号)

字符类 含义
alnum 字母和数字
alpha 字母
ascii 0-127的ascii字符
blank 空格和水平制表符
cntrl 控制字符
digit 十进制数(same as \d)
graph 打印字符, 不包括空格
lower 小写字母
print 打印字符,包含空格
punct 打印字符, 不包括字母和数字
space 空白字符 (比\s多垂直制表符)
upper 大写字母
word 单词字符(same as \w)
xdigit 十六进制数字
posted @ 2020-04-21 11:19  白马探花666  阅读(219)  评论(0)    收藏  举报