0x10 Simple Injection:

0 25
0x00 Preface:A good CTF platform I encountered recently, just for fun.0x01 RE? :...

0x00 Preface:

A good CTF platform I encountered recently, just for fun.

0x01 RE? :

This question is somewhat esoteric, first download the attachment, named udf.so. (a lot of characters).

0x10 Simple Injection:

1647400237_6231552d03cf5f0b0f7f1.png!small?1647400236536

Udf is an extended interface of mysql, which is通俗来讲 is a user-defined function. And when the suffix is .so, it can be known that the environment of the website built is a Linux environment. Udf files can be used with this statement.

CREATE FUNCTION [Custom Function Name] RETURNS [Return Type]{STRING|INTEGER|REAL} SONAME ["Filename"];

Firstly, we need to find a folder called plugin under the mysql of the local Linux machine.

1647400294_623155666c0db0f8178bb.png!small?1647400293958

(Remote connection to Linux mysql in windows environment)

You can see the absolute path of the directory, and the next step will be to put the downloaded file in this directory.

1647400330_6231558acf0b9645eb243.png!small?1647400330355

According to the hints of the question (help_me), execute the SQL statement to query the value of this function.

1647400356_623155a428537ce6e5d24.png!small?1647400355664

Use the getflag method to obtain the flag,

1647400365_623155ad8a2e4857ee743.png!small?1647400365077

PS: I already have this method here, not a statement problem

0x02 PORT51:

Question link:http://web.jarvisoj.com:32770/

Enter the question, requiring access to the site using port 51. After obtaining the guidance, access it directly using the curl command.

1647400392_623155c8234b652465972.png!small?1647400391701

This question is not very difficult, and the test point is also relatively single, just one command to solve it. But there may be errors, and I think it may be because the network at home is not allocated a public network address. If you access it with a server, there will be no such problem.

0x03 LOCALHOST:

Problem entry:http://web.jarvisoj.com:32774/

After opening the question, it tells us that we can only access the local host.

1647400418_623155e2bdda5a7b4c498.png!small?1647400418283

This question tests something called XFF (X-Forwarded-For), which is an HTTP extension header. In simple terms, XFF is used to identify the original IP address and request header fields of the client that connects to the web server through an HTTP proxy.

This question allows you to intercept and modify the HTTP request header, setting the XFF value to 127.0.0.1.

1647400430_623155ee44e9c7d5f9864.png!small?1647400430010

0x04 The Secret of the Shield Bureau:

Question gateway:web.jarvisoj.com:32768

Firstly, after opening the question, it is a habit to take a look at the source code.

1647400445_623155fd7f30909ba1d90.png!small?1647400445051

Access showimg.php and pass the parameters given in the source code.

1647400460_6231560c8769ce88079c1.png!small?1647400460357

Decode the parameter values with base64, and the decoded parameter value is shieid.jpg. It is guessed that there is a file read vulnerability at this location. Encode showimg.php with base64 and pass it as a parameter.

1647400478_6231561e02e89ef2cb0cc.png!small?1647400477545

Indeed, the source code of showimg.php was read, this file has done some filtering, and prohibited access to the upper directory. Let's read the code of index.php next.

1647400487_623156277b6262f0d6157.png!small?1647400487052

Index.php imports shield.php, read directly.

1647400504_6231563831f4faa5b2ef0.png!small?1647400503780

This file tells us the location of the flag, and in showing.php, pctf is filtered, so we cannot access it directly through showimg.php. But there is a file_get_contents() function, which can be used in conjunction with unserialize() in index.php to obtain the flag.

Construct the serialized string.

1647400516_623156448e7587ecf681f.png!small?1647400516121

Access index.php, pass the serialized string into the class, view the source code to get the flag.

1647400537_623156595cc54ac94eeb4.png!small?1647400536933

没想到直接访问还会有个假的flag,草率了。

0x05 Login:

Problem entry:web.jarvisoj.com:32772

Enter the question and capture and analyze it.

1647419550_6231a09e522c20499d38b.png!small?1647419549863

The return header hints at a SQL statement, and there is no need to elaborate on SQL here. The controllable point in the statement is $pass wrapped in the md5 function. Here we need to understand the md5 function first. When the second parameter is true, it will return the original 16-character binary format. So can we use this problem to construct a universal key for login?

1647419565_6231a0ad1ba843d621fd0.png!small?1647419564480

Here we can see that aaaa is turned into alphanumeric + a lot of garbage code. So here we need to understand a special string -ffifdyopThis string becomes 'or'6[Garbled code] after being converted by the md5 function. Let's test it locally and see the result.

1647419573_6231a0b51decb6036d686.png!small?1647419572503

Local testing is ok, the question is solved in one go.

1647419584_6231a0c0645333fda27e6.png!small?1647419583953

0x06 IN A Mess:

Problem entry:http://web.jarvisoj.com:32780/

Capture the packet and access the question, and find that the comment hints at index.phps. We access it directly.

1647419593_6231a0c9ba199f19a5089.png!small?1647419593109

It can be seen that it needs three parameters a, b, and id.

First, here we can use php://input, and POST an 1112 is a nice lab!, or we can use data:,1112 is a nice lab! directly;

b only needs the number of characters to be greater than 5, and can bypass the eregi function with %00;

Id here is a very hasty weak comparison;

Finally, enter these three parameters for access.

1647419634_6231a0f2be0df34b859ff.png!small?1647419634283

He gave a rather confusing thing, at first thought it was a flag, but after half a day's submission, it turned out to be a directory, continue to visit.

1647419645_6231a0fd560b9d40f8aee.png!small?1647419644820

A simple test was done and it was found that spaces and /**/ are filtered. We use /*[any character]*/ to bypass, test the number of fields, and the number of fields is 3 and displayed normally. When the number of fields is 4, it is displayed abnormally.

1647419670_6231a1166675e97bae4f6.png!small?16474196698541647419675_6231a11b96b9c581c072a.png!small?1647419675177

After confirming the number of fields, start to leak the database name. Many wp on the Internet use double writing to bypass it, but it can also be bypassed by using other filtered characters.

1647419685_6231a12575cc8dc32e28e.png!small?1647419684996

It can be seen that from here, the restriction is bypassed by using from, and the echo is at position 3, querying the database name.

1647419689_6231a129618030c94955b.png!small?1647419688983

Query the table name, because the quotes are filtered, use the database function to get the table name first.

1647419693_6231a12d2da510eef4835.png!small?1647419692714

Query the column name, and use hex encoding to bypass quotes to execute statements here.

1647419698_6231a132d1d9628d17e37.png!small?1647419698337

Got the table and column names, and started to query the flag value.

1647419703_6231a137b80454b07e9b7.png!small?1647419703223

0x07 flag is in the administrator's hand:

Question link:http://web.jarvisoj.com:32778/

After entering the question, collect information, and find two set cookies in the corresponding header. From this, we can know that this question should be related to these two pieces of information, and then we will try to find the source code. Common ways to find source code include, and there are no hints in the source code, we can directly access robots.txt to try.

1647419716_6231a144b564a3d1e1f86.png!small?1647419716119

It is obviously not there, let's try the usual套路 that the question setter likes, visit index.php~download the source code. The file can be opened directly to see that the order of the source code is reversed, or the file can be restored using the linux vim-r command. Before restoring the file, you need to change the suffix to .swp. For convenience of viewing, let's use Kali to restore the file.

1647419770_6231a17aa261f8c7348c6.png!small?1647419770164

A simple analysis of the source code shows that the role parameter needs to pass a serialized admin here, while hsh needs to concatenate the md5 value of the reversed role with the $salt. This is a point of attack for hash length extension, simply put, we know the value given by the server in the cookie, called hash1, and it contains salt. We can do a hash1 and admin MD5 operation to get hash2, and then assign hash2 to hsh, which meets the requirements of the code.

Calculation can be done by writing a python script to run, or by using the hashpump tool.

1647419841_6231a1c1f23f5ccc50ec0.png!small?1647419841483

Get the final flag.

0x08 Chopper:

This question may have some problems, and the wp found on the Internet cannot be reproduced either. There will be no further elaboration here.

0x09 Easy Gallery:

Problem entry:http://web.jarvisoj.com:32785/

Enter the question, and an upload point is found in index.php?page=submit.

1647419859_6231a1d38cf8b1168137c.png!small?1647419858942

Packet capture changes the filename for testing, first upload an empty file to try.

1647419865_6231a1d98d398d47a0051.png!small?1647419865265

The encoding format causes some minor ugliness, but overall, the problem is not big. Here, it is determined that it is the file header that is being checked.

1647419875_6231a1e35b30f81319cfd.png!small?1647419874947

We added a GIF89a and successfully bypassed the filter. The next step is to directly upload PHP code in it.

1647419884_6231a1ec5883bd2c8e00d.png!small?1647419883921

The uploaded PHP code is fine, and we can get the file path through the ID in the view. The file path is uploads/1646740311.jpg, and now we can use the page parameter in the URL to pass the path of the uploaded file.

1647419895_6231a1f7077fa18fb9c95.png!small?1647419894384

The code appends a .php suffix after the filename, so we use %00 to bypass it, but we still didn't get the flag.

1647420016_6231a27054e36f4797855.png!small?1647420015723

We can see that it still reports an error that there is no file. The initial guess is that the code filters characters like <?php, so we use another method to upload the file.

1647420031_6231a27fd5fc67f138dff.png!small?1647420031439

Access this file to get the flag.

1647420039_6231a287948d61e39d497.png!small?1647420038980

PS: We were originally afraid that eval would be filtered, so we tested with phpinfo, and unexpectedly got the flag directly.

0x10 Simple Injection:

Problem entry:http://web.jarvisoj.com:32787/

According to the hints in the question, it is a simple injection. Enter the account and password to capture packets for access.

1647420053_6231a295d345787a6307a.png!small?1647420053424

Here, when the username is admin, it will prompt password error. When assigned to other values, it will report username error, so this question should be about boolean blind injection. Let's test whether this injection point is in the username position.

1647420058_6231a29aef0c9e6a8dd4e.png!small?1647420058533

1647420086_6231a2b6d53fce60b4516.png!small?1647420086375

Successfully found the injection point, the code filters spaces, and this is the old style of the setter. The next step can be to carry out brute force attacks, and write a python script for injection.

1647420118_6231a2d6372922ecfe496.png!small?1647420117696

MD5 decryption.

1647420124_6231a2dc5d8f3a3ab2b99.png!small?1647420123743

Normal login to get the flag.

1647420128_6231a2e041b72c15ef81d.png!small?1647420127803

0x11 API call:

Problem entry:http://web.jarvisoj.com:9882/

Enter the question to view the source code, and we see XMLHttpRequest in the code, indicating that it should be related to XML. Click go to capture packets, and we can see the data sent in JSON format.

1647420138_6231a2eaae1d23948704d.png!small?1647420138246

Here, we change the content-Type to application/xml, and change the sent JSON data to our XML format data information. Read the information of /home/ctf/flag.txt indicated in the question.

1647420144_6231a2f0a8af461290fed.png!small?1647420144287

0x12 PHPINFO:

Problem entry:http://web.jarvisoj.com:32784/

Opening the file, at first glance there seems to be no problem, and the data passed in is also uncontrollable. However, in the second line, the statement ini_set('session.serialize_handler', 'php'); appears, and we immediately consider whether it is related to session deserialization in PHP. We pass in a parameter to check the settings in his phpinfo.

1647420157_6231a2fde9693992ba3b6.png!small?1647420157618

We directly jump to the settings about session.

1647420162_6231a3027332752ce775d.png!small?1647420162065

PHP has built-in processors for serialization and deserialization of $_SESSION data. Among them, the commonly used ones are three, among which the default before php 5.5.4 is php, and after 5.5.4 is php_serialize. If the session serialization selector is different from the default, it may cause vulnerabilities. Additionally, session.upload_progress.enabled is set to On, and this configuration item is enabled. When posting a variable with the same name as session.upload_progress.name,
PHP stores the filename in $_SESSION. The conditions for session deserialization are already in place. Now we just need to construct a form that starts with both upload and post and submit it.

1647420170_6231a30a23002b5ee0f6c.png!small?1647420169531

Here we upload a random file for packet capture, pre-construct the serialization string. There is a problem that double quotes will be escaped, we need to add \ in front of it, and also add | at the beginning.

1647420179_6231a3136271db1ce20ca.png!small?1647420179138

Here we change the filename to the deserialization string we have constructed. We can see that we have successfully obtained the location of the flag file. Here we need to go back and check the path stored in the session file.

1647420187_6231a31b5373ab542bdf8.png!small?1647420186690

Get this path, construct the next deserialization string. Here we use the file_get_contents() function to write the file into a string and finally echo it out.

1647420193_6231a321cca8dcb391ca1.png!small?1647420193580

0x13 admin:

Problem entry:http://web.jarvisoj.com:32792/

Enter the question environment. There are no hints in the source code. Consider the issue of information leakage and access robots.txt.

1647420204_6231a32c34b8f03972c93.png!small?1647420203607

Directly access to see.

1647420208_6231a330607b22cc26be5.png!small?1647420207774

Here is a fake flag. Combine the question and check the cookie.

1647420211_6231a333d15f7f81844fd.png!small?1647420211289

Directly change it to 1 to get the flag.

0x14 WEB?:

Problem entry:http://web.jarvisoj.com:9891/

After obtaining the question, check the source code. It is found that the password here is verified by JavaScript, and a file called app.js is introduced, which can be followed up.

1647420219_6231a33be1612f8219a98.png!small?1647420219314

First, online format it, since it's a password, let's search for 'password'.

1647420227_6231a343d1a14bef80592.png!small?1647420227467

Follow up checkpass.

1647420232_6231a348264502c3836e8.png!small?1647420231575

Follow up __checkpass__REACT_HOT_LOADER__

1647420237_6231a34dc8a7315a9da9e.png!small?1647420237323

Matrix?? Write a script to solve the flag.

1647420292_6231a384d65f3655bfe4d.png!small?1647420292236

0x15 inject:

Problem entry:http://web.jarvisoj.com:32794/

According to the hints in the problem, find the source code first. The robots.txt file does not exist. The setter uses the old套路 to access index.php~

1647420304_6231a3907ce08fc1bb180.png!small?1647420303883

Audit the code, where the role of ` ` is to prevent the error when the field is a keyword. Adding backticks to the statement will not cause the statement to fail. Here, just construct the desc `test` ` [union union injection statement] to perform SQL injection. But only the first result is displayed, so limit is used to make the data visible.

1647420309_6231a3952d474f1fe09a3.png!small?1647420308751

We have obtained the database, and we start to query the tables. The problem filters single quotes, so we don't use single quotes for injection. We query the data one by one.

1647420316_6231a39c29bbe75d3f17a.png!small?1647420315795

It is obvious that the first table among so many tables is the table where the flag is stored. Next, start querying the column names in the same way.

1647420325_6231a3a57fceb42d31829.png!small?1647420325109

The table and column names are all there, so we can directly query the data.

1647420329_6231a3a9edbf70bbd2122.png!small?1647420329544

0x16 babyphp:

Problem entry:http://web.jarvisoj.com:32798/

Enter the problem, and in the about interface, I found three similar hints, among which git is considered due to the possibility of git leakage, and the git directory is accessed.

1647420337_6231a3b1d5d48b264e442.png!small?1647420337283

There is no 404 error reported, indicating the existence of a git directory. Try to get the php source code using git scanning tools. View the key part.

<?php
if (isset($_GET['page'])) {
    $page = $_GET['page'];
}
    $page = "home";
}
$file = "templates/" . $page . ".php";
assert("strpos('$file', '..') === false") or die("Detected hacking attempt!");
assert("file_exists('$file')") or die("That file doesn't exist!");
?>

There is a dangerous function assert. Assert($assertion, [$description])——It checks the specified assertion and takes appropriate action if the result is false (if it is not false, this statement will be executed), after understanding this function, we can directly construct the payload?page='.system('cat templates/flag.php').' to view the source code and obtain the flag.

1647420342_6231a3b6df2434fb5e539.png!small?1647420342288

你可能想看:
最后修改时间:
admin
上一篇 2025年03月25日 05:21
下一篇 2025年03月25日 05:44

评论已关闭