这是作者的系列网络安全自学教程,主要是关于安全工具和实践操作的在线笔记,特分享出来与博友们学习,希望您们喜欢,一起进步。前文详细讲解了hack the box在线渗透平台获取邀请码、注册过程。本文将分享Web渗透三道入门题目,它们包括Python编写md5加密发送Post、万能密码和URL路径猜测、BurpSuite和Hydra密码爆破等。基础性文章,希望对您有所帮助!同时,该网站题目细节不便于剧透,更希望大家去尝试,更多分享一些思想和工具用法。
host: docker.hackthebox.eu port:31060
打开网址显示如下图所示,MD5 encrypt this string(MD5加密这个字符串),并给出了“BK3ZuECdQYRyERJTXkpP”。
我们用在线md5加密,随便提交一串数字,其反馈结果为“Too slow”。
初始页面,不管怎么样点击Submit都会显示"Too slow!"
查看源代码如下图所示,也没有特别的隐藏或提示。
回头再看题目提示“Can you encrypt fast enough?”,这是一道常见的CTF题目。考察的是代码发送请求,而不是人为点击。我们试试Python代码,通过md5加密这个句子,然后发送post请求,它肯定比我们人为地访问网页再去加密速度快得多。
代码如下:
import requests
import hashlib
import re
# 访问目标网站
url ="http://docker.hackthebox.eu:31060/"
r = requests.session()
out = r.get(url)# 定位节点位置
con = re.compile(r"<h3 align='center'>(\S+)</h3>", re.I)# 获取MD5需要加密的字符串
str1 = con.findall(out.text)# MD5加密字符串
str2 = hashlib.md5(str1[0].encode('utf-8')).hexdigest()# 发送POST请求
data={'hash': str2}
out = r.post(url = url, data = data)# 输出结果print(out.text)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
输出结果如下所示:HTB{I Love CSDN!},成功完整。
二.万能密码SQL注入
[30 Points] Cartographer [by Arrexel]
Some underground hackers are developing a new command and control server. Can you break in and see what they are up to?
万能密码:用户名 ‘or’=‘or’、密码 ‘or’=‘or’
原理解释:假设用户登录对应的语句为:
select name, pwd from login where name=’’ and pwd=’’;
如果用户名输入正确则直接登录,否则提示用户名或密码错误,使用万能密码后的SQL语句如下:
select name, pwd from login where name=’‘or’=‘or’’ and pwd=’‘or’=‘or’’;
核心代码,两个单引号匹配,即name=’’,然后or连接,单引号等于单引号(’=’)这是恒成立的,紧接着or连接两个单引号(’’),同理密码pwd。这样or连接的(’=’)是恒成立的,故返回结果为真,导致直接登录。
万能密码:用户名 ‘or’’=’、密码’or’’=’
原理解释:此时对应的SQL语句如下:
select name, pwd from login where name=’‘or’’=’’ and pwd=’‘or’’=’’;
万能密码:用户名’or’=’–、密码’or’=’–
原理解释:此时对应的SQL语句如下:
select name, pwd from login where name=’‘or’=’–’ and pwd=’‘or’=’–’;
[20 Points] Lernaean [by Arrexel] [22624 solvers]
Your target is not very good with computers. Try and guess their password to see if they may be hiding anything.
你的目标看上去并不是特别擅长电脑,试着猜一下他的密码看看他到底藏着什么…
这个挑战20分,难度还行,由Arrexel编辑上传。
访问之后如下图所示:
Administrator Login(管理员登录)
— CONFIDENTIAL — (保密)
Please do not try to guess my password! (不要试图猜中我的密码)
Hydra (https://github.com/vanhauser-thc/thc-hydra) starting at 2020-01-1121:47:31
Syntax: hydra [[[-l LOGIN|-L FILE][-p PASS|-P FILE]]|[-C FILE]][-e nsr][-o FILE][-t TASKS][-M FILE [-T TASKS]][-w TIME][-W TIME][-f][-s PORT][-x MIN:MAX:CHARSET][-c TIME][-ISOuvVd46][service://server[:PORT][/OPT]]
Options:-l LOGIN or-L FILE login with LOGIN name,or load several logins from FILE
-p PASS or-P FILE try password PASS,or load several passwords from FILE
-C FILE colon separated "login:pass"format, instead of -L/-P options
-M FILE list of servers to attack, one entry per line,':' to specify port
-t TASKS run TASKS number of connects in parallel per target (default:16)-U service module usage details
-h more command line options (COMPLETE HELP)
server the target: DNS, IP or192.168.0.0/24(this OR the -M option)
service the service to crack (see below for supported protocols)
OPT some service modules support additional input(-U for module help)