<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Titoot on Medium]]></title>
        <description><![CDATA[Stories by Titoot on Medium]]></description>
        <link>https://medium.com/@Titoot?source=rss-4a27ff859bd4------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*4cGzfZlkl7QlFiq1Ayp34g.jpeg</url>
            <title>Stories by Titoot on Medium</title>
            <link>https://medium.com/@Titoot?source=rss-4a27ff859bd4------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 05 Dec 2026 10:36:24 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@Titoot/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Analyzing Video Encryption Algorithm]]></title>
            <link>https://medium.com/@Titoot/analyzing-video-encryption-algorithm-84928565d1c1?source=rss-4a27ff859bd4------2</link>
            <guid isPermaLink="false">https://medium.com/p/84928565d1c1</guid>
            <category><![CDATA[reverse-engineering]]></category>
            <category><![CDATA[video-encryption]]></category>
            <category><![CDATA[dotnet]]></category>
            <category><![CDATA[obfuscation]]></category>
            <category><![CDATA[cybersecurity]]></category>
            <dc:creator><![CDATA[Titoot]]></dc:creator>
            <pubDate>Thu, 28 Dec 2023 20:24:20 GMT</pubDate>
            <atom:updated>2024-01-06T19:43:19.740Z</atom:updated>
            <content:encoded><![CDATA[<h3>Analyzing and Decrypting Video Encryption Player</h3><p>A friend of mine found a video player, but a unique one, which only runs custom encrypted videos. I have been interested in video encryption for a while, but this one is different!</p><p>It&#39;s A dotNET player that takes an encrypted video file and plays it. It has other mechanisms to prevent screen recording, but from my experience, <a href="https://learn.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-setwindowdisplayaffinity">it’s just a flag and can be bypassed effortlessly</a>, and <a href="https://stackoverflow.com/a/42351731">even hardware acceleration can go through it.</a></p><p>Enough talking. Let’s reverse!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/631/1*kNIiBE4OHPujxW7dVrMfXg.png" /><figcaption>Detect it easy on the main executable.</figcaption></figure><p>As stated in the image, it’s a dotNET app, which is an interpreted language with a lot of info, so let’s decompile it using <a href="https://github.com/dnSpyEx/dnSpy/">dnspy </a>(or any other dotNET decompiler “<a href="https://www.jetbrains.com/decompiler/">dotpeek</a>” for example)</p><p>By looking through it, we find a function that handles video data</p><p>It parses a custom header to get the video info (length, name, etc..)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*R6HJw22t3s1rgu975xumtA.png" /></figure><p>Then, it decrypts the video header (100 bytes), but the rest of the video is unencrypted.</p><p>It creates a hash of a constant string and XORs the header with it.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*SmtYHJaC0Iyc9iPb_1g40A.png" /></figure><h4>But wait, there’s more!</h4><p>In an updated version, they edited the algorithm, so lets take a look</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/859/1*mbcwYUdwWZDpC37TrvVF3w.png" /></figure><p>It now passed the file path to an unmanaged DLL</p><p>loading it through IDA and tracing the close, we find the following</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/727/0*5NUldWNoCAoLoWgv.png" /></figure><p>for simplicity purposes, the DLL has an MD5 hashing function I named MD5Hash and it gets the packageID as before and hash it and then concat random strings to it and then hash it again</p><p>and it does that until it gets to the final hash</p><p>that’s so boring, actually, so I&#39;m using another method</p><p>since both versions use XOR cipher that doesn&#39;t stop me from doing XOR brute force of the known MP4 iso base media file format (isobmff) to get the key</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*VNI5f3Bt4dW8aHP3dCTucw.png" /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=84928565d1c1" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[CyCTF 2023 Reverse Engineering Writeup]]></title>
            <link>https://medium.com/@Titoot/cyctf-2023-reverse-engineering-writeup-cad8bbb9a06e?source=rss-4a27ff859bd4------2</link>
            <guid isPermaLink="false">https://medium.com/p/cad8bbb9a06e</guid>
            <category><![CDATA[ctf-writeup]]></category>
            <category><![CDATA[cybersecurity]]></category>
            <category><![CDATA[reverse-engineering]]></category>
            <category><![CDATA[ctf]]></category>
            <dc:creator><![CDATA[Titoot]]></dc:creator>
            <pubDate>Sun, 05 Nov 2023 01:41:44 GMT</pubDate>
            <atom:updated>2023-11-05T17:31:36.498Z</atom:updated>
            <content:encoded><![CDATA[<p>only the first three challenges :)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/526/0*cTCoLIWj0wVucA2n" /></figure><h3>Init:</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/522/1*r21J-1cuDXLOR4s4kPzxvA.png" /></figure><p>It’s a pretty easy challenge, so I started by loading the file in <a href="https://java-decompiler.github.io/">jd-gui</a></p><pre>import java.net.URI;<br>import java.net.http.HttpClient;<br>import java.net.http.HttpRequest;<br>import java.net.http.HttpResponse;<br><br>public class Init {<br><br>    private static final String 信息网址 = &quot;https://ipinfo.io/country&quot;;<br><br>    public static String 使用密钥异或(byte[] 输入, int 密钥) {<br>        byte[] 输出 = new byte[输入.length];<br>        <br>        for (int 计数器 = 0; 计数器 &lt; 输入.length; 计数器++) {<br>            输出[计数器] = (byte) (输入[计数器] ^ 密钥);<br>        }<br>        <br>        return new String(输出);<br>    }<br><br>    public static void main(String[] 参数) {<br>        System.out.println(&quot;欢迎来到 CyCTF 2023。您准备好成为下一个埃及顶级黑客了吗？&quot;);<br>        if (参数.length &lt; 1 || !&quot;旗&quot;.equals(参数[0])) {<br>            System.out.println(&quot;你想要什么？&quot;);<br>        } else {<br>            try {<br>                HttpClient 客户端 = HttpClient.newHttpClient();<br>                HttpRequest 请求 = HttpRequest.newBuilder()<br>                        .uri(new URI(信息网址))<br>                        .build();<br><br>                HttpResponse&lt;String&gt; 响应 = 客户端.send(请求, HttpResponse.BodyHandlers.ofString());<br>                String 国家代码 = 响应.body().trim();<br><br>                System.out.println(&quot;您基于 IP 的国家/地区代码是：&quot; + 国家代码);<br>                System.out.println(&quot;解码标志...&quot;);<br>                <br>                int 加结果 = (国家代码.charAt(0) + 国家代码.charAt(1)) - 80;<br>                byte[] 加密标志 = {34, 56, 34, 53, 39, 58, 50, 113, 44, 114, 30, 45, 117, 15, 120, 20, 117, <br>                                  120, 114, 18, 30, 2, 117, 47, 30, 121, 114, 30, 12, 113, 19, 114, 30, 34,<br>                                  113, 15, 39, 52, 18, 112, 15, 120, 30, 118, 41, 117, 47, 30, 34, 113, 37,<br>                                  114, 30, 113, 121, 7, 52, 18, 2, 117, 118, 112, 113, 15, 60};<br>                System.out.println(&quot;标志是：&quot; + 使用密钥异或(加密标志, 加结果));<br><br>            } catch (Exception 异常) {<br>                异常.printStackTrace();<br>            }<br>        }<br>    }<br>}</pre><p>It’s a simple code, and this is a refactored version</p><pre>import java.net.URI;<br>import java.net.http.HttpClient;<br>import java.net.http.HttpRequest;<br>import java.net.http.HttpResponse;<br><br>public class Init {<br><br>    private static final String ipurl = &quot;https://ipinfo.io/country&quot;;<br><br>    public static String deserialize(byte[] bytearray, int xorkey) {<br>        byte[] arr = new byte[bytearray.length];<br>        <br>        for (int i = 0; i &lt; bytearray.length; i++) {<br>            arr[i] = (byte) (bytearray[i] ^ xorkey);<br>        }<br>        <br>        return new String(arr);<br>    }<br><br>    public static void main(String[] args) {<br>        System.out.println(&quot;欢迎来到 CyCTF 2023。您准备好成为下一个埃及顶级黑客了吗？&quot;);<br>        if (args.length &lt; 1 || !&quot;旗&quot;.equals(args[0])) {<br>            System.out.println(&quot;你想要什么？&quot;);<br>        } else {<br>            try {<br>                HttpClient client = HttpClient.newHttpClient();<br>                HttpRequest httpclient = HttpRequest.newBuilder()<br>                        .uri(new URI(ipurl))<br>                        .build();<br><br>                HttpResponse&lt;String&gt; req = client.send(httpclient, HttpResponse.BodyHandlers.ofString());<br>                String body = req.body().trim();<br><br>                System.out.println(&quot;您基于 IP 的国家/地区代码是：&quot; + body);<br>                System.out.println(&quot;解码标志...&quot;);<br>                <br>                int xorkey = (body.charAt(0) + body.charAt(1)) - 80;<br>                byte[] bytearray = {34, 56, 34, 53, 39, 58, 50, 113, 44, 114, 30, 45, 117, 15, 120, 20, 117, <br>                                  120, 114, 18, 30, 2, 117, 47, 30, 121, 114, 30, 12, 113, 19, 114, 30, 34,<br>                                  113, 15, 39, 52, 18, 112, 15, 120, 30, 118, 41, 117, 47, 30, 34, 113, 37,<br>                                  114, 30, 113, 121, 7, 52, 18, 2, 117, 118, 112, 113, 15, 60};<br>                System.out.println(&quot;标志是：&quot; + deserialize(bytearray, xorkey));<br><br>            } catch (Exception brr) {<br>                brr.printStackTrace();<br>            }<br>        }<br>    }<br>}</pre><p>it just gets a country code from ipinfo (and based on the language used, the country code is ‘CN’), and then xored the bytearray with it, which is the flag!</p><p>So the solution is:</p><pre>public class Main<br>{<br> public static void main(String[] args) {<br>  byte[] bytearray = {34, 56, 34, 53, 39, 58, 50, 113, 44, 114, 30, 45, 117, 15, 120, 20, 117, <br>                                  120, 114, 18, 30, 2, 117, 47, 30, 121, 114, 30, 12, 113, 19, 114, 30, 34,<br>                                  113, 15, 39, 52, 18, 112, 15, 120, 30, 118, 41, 117, 47, 30, 34, 113, 37,<br>                                  114, 30, 113, 121, 7, 52, 18, 2, 117, 118, 112, 113, 15, 60};<br>        String Ccode = &quot;CN&quot;;<br>        int xorkey = (Ccode.charAt(0) + Ccode.charAt(1)) - 80;<br>        <br>        System.out.println(deserialize(bytearray, xorkey));<br> }<br> <br> public static String deserialize(byte[] bytearray, int xorkey) {<br>        byte[] arr = new byte[bytearray.length];<br>        <br>        for (int i = 0; i &lt; bytearray.length; i++) {<br>            arr[i] = (byte) (bytearray[i] ^ xorkey);<br>        }<br>        <br>        return new String(arr);<br>    }<br>}</pre><p>And with that, it prints the flag</p><blockquote>cyctf{s0m3_l4N9U493S_C4n_83_M0R3_c0NfuS1N9_7h4n_c0d3_08FuSC4710N}</blockquote><h3>Spaghetti:</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/517/1*wrML8StpGeEt0nxHqYFW8g.png" /></figure><p>It’s a pattern checker with an obfuscated javascript file.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/1*UjLdC0bsJQEM1UgUiAigZA.png" /></figure><p>This is our target function.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*iH6FhPRL6Bcw6TXqJapRxQ.png" /></figure><p>that function takes an array, which is the selected points on the pattern; if the selected first row is from left to right, that array will have [0, 1, 2] and when selected from right to left, it&#39;ll be [2, 1, 0]</p><p>so after putting this function in <a href="https://obf-io.deobfuscate.io/">https://obf-io.deobfuscate.io/</a> and refactoring, we get this:</p><pre>function arrayCheck(inputArray) {<br>  if (inputArray[6] + inputArray[2] + (inputArray[3] + inputArray[4]) != 15) {<br>    return false;<br>  }<br>  if ((inputArray[5] + inputArray[6] ^ inputArray[2] + inputArray[5]) != 8) {<br>    return false;<br>  }<br>  if ((inputArray[2] + inputArray[7]) * (inputArray[1] + inputArray[2]) != 165) {<br>    return false;<br>  }<br>  if (inputArray[7] + inputArray[4] + (inputArray[0] ^ inputArray[5]) != 20) {<br>    return false;<br>  }<br>  if ((inputArray[3] ^ inputArray[5]) * (inputArray[6] + inputArray[3]) != 4) {<br>    return false;<br>  }<br>  if ((inputArray[1] + inputArray[3] ^ inputArray[7] + inputArray[3]) != 12) {<br>    return false;<br>  }<br>  if (inputArray[0] + inputArray[3] + (inputArray[4] + inputArray[6]) != 9) {<br>    true;<br>    return false;<br>  }<br>  if ((inputArray[3] + inputArray[0]) * (inputArray[5] * inputArray[1]) != 45) {<br>    return false;<br>  }<br>  if ((inputArray[4] ^ inputArray[1]) + (inputArray[3] + inputArray[0]) != 8) {<br>    return false;<br>  }<br>  if (inputArray[5] * inputArray[6] + inputArray[2] * inputArray[5] != 40) {<br>    return false;<br>  }<br>  if (inputArray[2] * inputArray[7] + inputArray[1] * inputArray[2] != 80) {<br>    return false;<br>  }<br>  if (inputArray[7] * inputArray[4] + inputArray[0] * inputArray[5] != 52) {<br>    return false;<br>  }<br>  if (inputArray[3] * inputArray[5] + inputArray[6] * inputArray[3] != 5) {<br>    return false;<br>  }<br>  if (inputArray[1] * inputArray[3] + inputArray[7] * inputArray[3] != 10) {<br>    return false;<br>  }<br>  if (inputArray[0] * inputArray[3] + inputArray[4] * inputArray[6] != 2) {<br>    return false;<br>  }<br>  if (inputArray[3] * inputArray[0] + inputArray[5] * inputArray[1] != 17) {<br>    return false;<br>  }<br>  if (inputArray[4] * inputArray[1] + inputArray[3] * inputArray[0] != 20) {<br>    return false;<br>  }<br>  return true;<br>}</pre><p>It’s just a couple of checks to make sure the pattern selected is correct, and that pattern is used to decrypt the flag</p><p>With the help of a friend, I was able to create a checker to bruteforce this</p><pre>import itertools<br><br>arr = list(itertools.permutations([0,1,2,3,4,5,6,7,8]))<br><br>def checker():<br>    for i in arr:<br><br>        if (i[6] + i[2] + i[3] + i[4]) != 15:<br>            print(i)<br>            continue<br>checker()</pre><p>although in the above arrayCheck function, it doesn’t check for the 9th pattern, but it’s included as a number, and if the rest of the 8 positions are correct, the 9th position has to be correct</p><p>to test it, the above Python code checks for one condition and prints a huge list of possible patterns</p><p>and after writing the other checks, we get this</p><pre>import itertools<br><br>arr = list(itertools.permutations([0,1,2,3,4,5,6,7,8]))<br><br>length = len(arr)<br><br>print(length)<br><br>def checker():<br>    for i in arr:<br><br>        if (i[6] + i[2] + i[3] + i[4]) != 15:<br>            continue<br><br>        if (i[5] + i[6] ^ i[2] + i[5]) != 8:<br>            continue<br><br>        if (i[2] + i[7]) * (i[1] + i[2]) != 165:<br>            continue<br><br>        if i[7] + i[4] + (i[0] ^ i[5]) != 20:<br>            continue<br><br>        if (i[3] ^ i[5]) * (i[6] + i[3]) != 4:<br>            continue<br><br>        if (i[1] + i[3] ^ i[7] + i[3]) != 12:<br>            continue<br><br>        if i[0] + i[3] + (i[4] + i[6]) != 9:<br>            continue<br><br>        if (i[3] + i[0]) * (i[5] * i[1]) != 45:<br>            continue<br><br>        if (i[4] ^ i[1]) + (i[3] + i[0]) != 8:<br>            continue<br><br>        if i[5] * i[6] + i[2] * i[5] != 40:<br>            continue<br><br>        if i[2] * i[7] + i[1] * i[2] != 80:<br>            continue<br><br>        if i[7] * i[4] + i[0] * i[5] != 52:<br>            continue<br><br>        if i[3] * i[5] + i[6] * i[3] != 5:<br>            continue<br><br>        if i[1] * i[3] + i[7] * i[3] != 10:<br>            continue<br><br>        if i[0] * i[3] + i[4] * i[6] != 2:<br>            continue<br><br>        if i[3] * i[0] + i[5] * i[1] != 17:<br>            continue<br><br>        if i[4] * i[1] + i[3] * i[0] != 20:<br>            continue<br>        <br>        print(i)<br><br>checker()        <br><br></pre><p>and it prints the one pattern</p><blockquote>(2, 3, 8, 1, 6, 5, 0, 7, 4)</blockquote><p>and then we get our flag, with a star!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/727/1*Z180DM1gJwE0MMw4JekeMQ.png" /></figure><h3>Undercover:</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/523/1*ke2YFSKkkjmxxaYqgeA20g.png" /></figure><p>Based on the description and file structure, it looks like it’s JIT Compiled, but that can’t stop us!</p><p>loading the undercover.dll through <a href="https://github.com/dnSpyEx/dnSpy/">dnspy</a>, we get this</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*FsAeiRmRqz7sbhW37lsNtw.png" /></figure><p>after renaming functions</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*PTO7ff8IxZWtC-j5qi6-fw.png" /></figure><p>To sum it up, it has encrypted resources and double decrypts them, but the AES key is stored in the JIT Compiled code, but with a simple breakpoint solved it.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/468/1*uK_zCdj8qHo6qa8mwYe_Eg.png" /></figure><p>From that, I got the key and IV and the decrypted text.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/919/1*gaEWfpqOpvk7PM_G0HYvjA.png" /></figure><p>And since then, it’s a DLL. I make the executable load it.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/517/1*5l99Pvf0iqoK7DIEuHnSTQ.png" /></figure><p>the decrypted text with strings and this PowerShell code</p><pre>$encodedScript = &#39;ZgB1AG4AYwB0A ... too long&#39;;<br>$decodedScript = [System.Text.Encoding]::Unicode.GetString([System.Convert]::FromBase64String($encodedScript));<br>Invoke-Expression $decodedScript</pre><p>so, just decoding it in PowerShell, we get this</p><pre>function Get-SHA256Hash($inputString) {<br>    $hasher = [System.Security.Cryptography.SHA256]::Create()<br>    $hashedBytes = $hasher.ComputeHash([System.Text.Encoding]::UTF8.GetBytes($inputString))<br>    return [BitConverter]::ToString($hashedBytes) -replace &#39;-&#39;<br>}<br><br># Complete hash array<br>$hashArray = @(<br>    &quot;3d30f595070e858a9573e432377bea27a7fb1a19aa298943e414d3c839d34783&quot;,<br>    &quot;f8dcb34308e5c69f46a33cafa62bd922476b18c78a114eb144e34a5e374f7d60&quot;,<br>    &quot;9c42dcda63f6dd3017236d464c080044f8f5fb37952ecdc8f3fc3b4bf0d2ccf5&quot;,<br>    &quot;1a6562590ef19d1045d06c4055742d38288e9e6dcd71ccde5cee80f1d5a774eb&quot;,<br>    &quot;8c8db88de5dd2ef16c4db42c1a93706ecb3526dee9cba2535276186be960de80&quot;,<br>    &quot;86b42384e3d11d08f33c9ed3cc6895c33762727194375d6d67b0e5c1f9789c8b&quot;,<br>    &quot;6131e3f4166d9d45b4d25bd1c1c0280d28bd559444fc0c1c973a7a1aa3333425&quot;,<br>    &quot;e8c169d57d68d78c0b402c6941498bce3f7beba1e7e0b876c656cec93198ae40&quot;,<br>    &quot;fffdff4b07a9d973fd1c3a6be443851bc13e82c4af94c88325244694e352aa31&quot;,<br>    &quot;c6c2f9b14de18f6ad69f2aaee58fcabe3e4b60677d8bfa0010d34c6756d8e8af&quot;,<br>    &quot;875d76572424862cad9c1af58ef3127a000070ff22dcb800698141a6a9fa31f2&quot;,<br>    &quot;96061e92f58e4bdcdee73df36183fe3ac64747c81c26f6c83aada8d2aabb1864&quot;,<br>    &quot;9fee91584bdc482b80e41f048ee3e9c3cf1940154792b62e2e6321d67f459aca&quot;,<br>    &quot;ff9792e81e3842dfa3a3ed5d088cde914428c69622ac203d3a2a837cdd2ab16f&quot;,<br>    &quot;e8b952a6f5c3f7b4ee9a0e9364f5e92f2d362a234c7d1a45ed2adf038fdba00a&quot;,<br>    &quot;3c4e417f8d4c5887e4c4057a5fdd69fde112e79ab991e765068848f1cefc3891&quot;,<br>    &quot;9e4f612e5ba19568e8c5434a0bae266307506733ef5249aac5b5aabfd339dea3&quot;,<br>    &quot;5ae66647841383101a158d9e0952674b9a2e08e721b3bad2ac3a3f6b1dc4124d&quot;,<br>    &quot;4bb48e76f19de6ebed7d59d46800508030aecea46ba56bd19855d94473e28bc0&quot;,<br>    &quot;69826369cc25437bd9a8676c58c079a0b4d92821b96393d62bf3333ebfd8a325&quot;,<br>    &quot;86b42384e3d11d08f33c9ed3cc6895c33762727194375d6d67b0e5c1f9789c8b&quot;,<br>    &quot;a44e662751835f2db8f1f97944ecea4d0c04462c46a1ea3424aae13c8d9366eb&quot;,<br>    &quot;426ec44f9f73ad7c8ce4a6ff368f628b944421c89694bb15d53b4eed6d4b04c3&quot;,<br>    &quot;3bfc269594ef649228e9a74bab00f042efc91d5acc6fbee31a382e80d42388fe&quot;,<br>    &quot;98bbad59c87d33178f5534418cadfca83c583a92844eea43c14ea434b6dfaee5&quot;,<br>    &quot;7e5c98e51d4e69e227ed69ebd4cc598fbfe2214450c79e6a7062af522d5a5d39&quot;,<br>    &quot;2c2db14ef0e372767da1d606ef758f23e1b4fa7205c2b1b8683b0b9349f09ac5&quot;,<br>    &quot;69f04a035b2396214cfab006612d992b2f4fa028876bc398e318ce2dff48c05a&quot;,<br>    &quot;f3a0cf50cea6b3df2dfeb52bd18559adcd507737ce73aca640a0596dd4675a46&quot;,<br>    &quot;e8180000fa67e824043aa522c6743de57dbc5de1d39d5483acb618b699a9dd00&quot;,<br>    &quot;aa1e3c55ba668a5302b701bc512a0a763e118e5007250c4a3611635415b0a6ca&quot;,<br>    &quot;2842de9d43a98b535ed75b3176a95e9bb11fd5c7f04979b329a35f578f7e0ba2&quot;,<br>    &quot;55eae50b75e2b2990f2c18be84ca079727a85f61b839c3359249801fe1ab9e9c&quot;,<br>    &quot;5eb242aeb68552862913d602cff36deb4cafc18a46cfdea393b4bc1c6917a669&quot;,<br>    &quot;b14c45d35f5032a467ef7f7772da89ef2acc4db220b59453ed53b93467fa285f&quot;,<br>    &quot;1b4b859b7daa2dc3b45f15c5293e3e80f7c1f7c5b8ab9a0390a1b5cd38e30604&quot;,<br>    &quot;7252b378f7597b475da57273813fb3c3f914aba9f58d83181e4c21801bb678b7&quot;<br>)<br><br>$inputString = $env:CYCTF2023_INPUT_FLAG<br><br># Check for odd-length input strings and if the input length matches the expected length<br>if ($inputString.Length % 2 -ne 0 -or $inputString.Length/2 -ne $hashArray.Length) {<br>    Write-Host &quot;Error: Please enter a string with the correct number of characters.&quot;<br>    exit<br>}<br><br>$chunks = @()<br><br># Split the string into two-character chunks<br>for ($i = 0; $i -lt $inputString.Length; $i += 2) {<br>    $chunks += $inputString.Substring($i, 2)<br>}<br><br># Validate each chunk against the corresponding hash in the hashArray<br>$isValid = $true<br>for ($i = 0; $i -lt $chunks.Length; $i++) {<br>    $hash = Get-SHA256Hash $chunks[$i]<br>    if ($hash -ne $hashArray[$i]) {<br>        $isValid = $false<br>        break<br>    }<br>}<br><br>if ($isValid) {<br>    $env:CYCTF2023_INPUT_FLAG_RESULT = &quot;Correct!&quot;<br>} else {<br>    $env:CYCTF2023_INPUT_FLAG_RESULT = &quot;Incorrect!&quot;<br>}$env:CYCTF2023_INPUT_FLAG</pre><p>$env:CYCTF2023_INPUT_FLAG is set to the flag input to check that it’s correct</p><p>and it does that by splitting it into two chars each and hashing them to compare them with the given hashArray</p><p>so I just got the array and loaded it into <a href="https://10015.io/tools/sha256-encrypt-decrypt">https://10015.io/tools/sha256-encrypt-decrypt</a></p><p>by that, we get the flag</p><blockquote>cyctf{50_y0u_C4N_3X3CU73_p0W3r5h3Ll_W17h0u7_H4v1N9_70_3X3cu73_P0w3r5H3lL!}</blockquote><p>I hope that my explanation is clear and I enjoyed this CTF. See you next time.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=cad8bbb9a06e" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[MSP CTF WriteUp 2023]]></title>
            <link>https://medium.com/@Titoot/msp-ctf-writeup-2023-cb9c61370a76?source=rss-4a27ff859bd4------2</link>
            <guid isPermaLink="false">https://medium.com/p/cb9c61370a76</guid>
            <category><![CDATA[android]]></category>
            <category><![CDATA[ctf-writeup]]></category>
            <category><![CDATA[reverse-engineering]]></category>
            <category><![CDATA[frida]]></category>
            <category><![CDATA[ctf]]></category>
            <dc:creator><![CDATA[Titoot]]></dc:creator>
            <pubDate>Mon, 04 Sep 2023 05:19:25 GMT</pubDate>
            <atom:updated>2023-09-06T09:59:34.517Z</atom:updated>
            <content:encoded><![CDATA[<p>Today, I’m only going to cover MSP CTF Challenges for 2023</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/957/1*bpH5njQw-YXW57Fpb3_ejg.png" /></figure><p>Which are these:</p><pre><br>| Warmup        | Easy           | Medium                 | Hard                    | Insane         |<br>|---------------|----------------|------------------------|-------------------------|----------------|<br>| Code Crackers | ActivityHunt   | Intent Infiltrator     | Function Hookmaster     | ADB PIN Hunter |<br>|               | Encoded Secret | Intent Choice Dilemma  | Function Invokers Quest | Code Conflux   |<br>|               | FlagMosaic     | Data Leakage Labyrinth |                         |                |</pre><p>Tools Used:</p><blockquote><a href="https://developer.android.com/tools/releases/platform-tools"><strong>Adb</strong></a>: command-line tool that lets you communicate with a android device.</blockquote><blockquote><a href="https://github.com/skylot/jadx/releases"><strong>Jadx-gui</strong></a><strong>: </strong>tools for producing decompiling Java bytecode from Android Dex and Apk files.</blockquote><blockquote><strong>Device: </strong>Android Device / Android Studio Emulator / Any other Emulator like <a href="https://www.genymotion.com/download/">GenyMotion</a> or <a href="https://www.ldplayer.net/versions">LDPlayer</a> (MUST BE ROOTED)</blockquote><blockquote><a href="https://learnfrida.info/java/"><strong>Frida</strong></a><strong>: </strong>dynamic code instrumentation toolkit</blockquote><blockquote><a href="https://gchq.github.io/CyberChef"><strong>CyberChef</strong></a><strong>: </strong>intuitive web app for carrying out all manner of “cyber” operations. include simple encoding like XOR and Base64, more complex encryption like AES, DES and Blowfish</blockquote><blockquote><strong>Each Challenge has a different way of solving it, but I’m following the intended way</strong></blockquote><h3>Warmup:</h3><h3>- Code Crackers</h3><blockquote>You’ve been given the “CodeCracker.apk” app, which presents itself as a locked enigma. Your task is to reverse engineer the app to understand its inner workings and identify the method to unlock its secrets. Your ultimate goal is to find the hidden flag that has been concealed within the app.</blockquote><p>It’s just a Warmup challenge, so we’ll find the flag in the class called e</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/521/1*9bMmSGsov38xh867pSX_Uw.png" /></figure><p>Another way to solve it is to invoke this activity.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/462/1*_v4D78IObSujqQshS8Xm9w.png" /></figure><h3>Easy:</h3><h3>- ActivityHunt</h3><blockquote>The journey begins with the “Activity Hunt” challenge. Upon opening the app, you are greeted with a simple welcome screen and a “Start” button. Clicking the button reveals the first activity. Your goal is to traverse through a series of activities by entering specific keywords to unlock the path to the hidden flag. Stay vigilant; not all paths are correct.</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/685/1*teS7CdvWQvetQJOaOVU2SQ.png" /></figure><p>This is a simple challenge. Just type the password in the text box and get the flag!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/617/1*0qS4Q1m0Nm2-mGJDwhejjg.png" /></figure><h3>- Encoded Secret</h3><blockquote>The next challenge, “Encoded Secret” dives into the app’s code. You encounter a function called “print_flag,” which seems innocent at first glance. However, the flag is cunningly encoded in base64 within the function’s code. Decode the flag to proceed, showcasing your static code analysis prowess.</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/822/1*J5bjGJ7Cz-00DVXn9JZcbA.png" /></figure><p>In the MainActivity, it checks for a password, and if it is correct, it starts MainActivity2</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/512/1*coBY5U0bFhDHUsX9U00JJw.png" /></figure><p>And in MainActivity2It gets the flag from Utilities.getFlag()</p><p>in Utilities.getFlag()</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/500/1*LD_Bj6y-0iV8QUL-PJZ_ug.png" /></figure><p>Looks like it’s encoded using base64. We can decode it using <a href="https://gchq.github.io/CyberChef">CyberChef</a>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*iaa0Nd-UYFWDkeaz036teA.png" /></figure><h3>- FlagMosaic</h3><blockquote>“Flag Mosaic” awaits those who crack the code of the previous challenge. In this task, the flag is divided into pieces and scattered among multiple activities. Each activity holds a part of the flag. As you explore, gather the pieces meticulously to reconstruct the flag. Attention to detail is key in solving this puzzle.</blockquote><p>We can find the divided flag in these classes.</p><p>Part 1:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/596/1*jP1Bo-zP0bhfHw2XaynvHQ.png" /></figure><p>Part 2:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/619/1*vLm4NK_9UGK17nwJmU_n9A.png" /></figure><p>Part 3:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/581/1*fgpwrD3zSiF-Kp4fXJKZeg.png" /></figure><p>So the full flag is MSPCTF{m461c4l_cl455_h4ck3r}</p><h3>Medium:</h3><h3>- Intent Infiltrator</h3><blockquote>Now it’s time to play with intents in the “Intent Infiltrator” challenge. The app’s intent handling mechanism has a vulnerability. Exploit it to manipulate intents without extras and uncover hidden functionality. Tread carefully; unintended side effects might hinder your progress.</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/444/1*0zhZHW8aPj3O5sNreJu3fg.png" /></figure><p>We find an uncalled activity called SecretActivity, so invoking is the solution!</p><blockquote>adb shell am start -n com.example.intentinfiltrator/.SecretActivity</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/601/1*XyaMEix2oF-qvQhnbJNJ7w.png" /></figure><h3>- Intent Choice Dilemma</h3><blockquote>You’ve been provided with the “Intent Choice Dilemma.apk” app, which offers two paths: user and admin. Your objective is to explore the app and find a way to manipulate it using intents with extras to grant yourself admin privileges.</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/681/1*nRrKhrahhJC2-mC0HvjXhw.png" /></figure><p>We find that it checks for username and password and sets the Role to User.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/486/1*-yxGYgf_3FcwgfEl5HMNvg.png" /></figure><p>So, we’ll invoke an intent with the admin Role as an extra.</p><blockquote>adb shell am start -n com.example.useroradminchoosewisely/.Profile — es Role admin</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/617/1*YaslHYKQJoVbGcgC_GT5WQ.png" /></figure><h3>- Data Leakage Labyrinth</h3><blockquote>You are provided with the “DataLeakageLabyrinth.apk” app, which claims to store confidential user information securely. However, rumor has it that the app contains a vulnerable content provider that leaks sensitive data without proper authentication.<br>Your goal is to exploit this content provider vulnerability and retrieve confidential data without using any unauthorized permissions or bypassing any security mechanisms. Your success will be measured by your ability to extract sensitive data using the app’s own features.</blockquote><p>As the description says, it has a vulnerable content provider</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/538/1*UDYcmmCwQHT26uTyvWjJiQ.png" /></figure><p>Which can be queried with this command</p><blockquote>adb shell content query — uri content://com.example.myapp.provider/data</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/891/1*A3_S2Wf9O8qVlKyyXb5BEQ.png" /></figure><h3>Hard:</h3><h3>- Function Hookmaster</h3><blockquote>Dynamic analysis takes center stage in the “Function Hookmaster” challenge. As you explore the app’s runtime behavior, you encounter opportunities to hook functions dynamically. Intercept and manipulate function calls to unlock secrets and advance further.</blockquote><p>Based on the name and description, it’s about dynamic hooking</p><p>by loading it into JADX</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/677/1*ZgoSSNYZ_QCrvZ3Nl9xM0A.png" /><figcaption>MainActivity</figcaption></figure><p>By looking into the MainActivity, we find an onclick function with an if statement checks if the user is admin, and if true the user gets the flag, else it says You are not the Admin 😎</p><p>and that check from Admin() just return false</p><p>Refactored code for easier understanding</p><pre>public void onClick(View v) {<br>                if (this.Admin()) {<br>                    this.textView.setText(Utilities.getFlag());<br>                }<br>                else<br>                {<br>                    this.textView.setText(&quot;You are not the Admin 😎&quot;);<br>                }<br>            }<br>public boolean Admin() {<br>        return false;<br>    }</pre><p>So, our goal here is to hook Admin() and make it return true</p><p>Let’s fire up <a href="https://learnfrida.info/java/">Frida</a>!</p><p>by using JADX frida snippet function, we make our job a lot easier</p><blockquote>Just right-click on the desired function name and choose Copy as frida snippet</blockquote><p>By doing this, we get this code:</p><pre>let MainActivity = Java.use(&quot;com.example.functionhookmaster.MainActivity&quot;);<br>MainActivity[&quot;Admin&quot;].implementation = function () {<br>    console.log(`MainActivity.Admin is called`);<br>    let result = this[&quot;Admin&quot;]();<br>    console.log(`MainActivity.Admin result=${result}`);<br>    return result;<br>};</pre><p>instead of return result We return true</p><pre>let MainActivity = Java.use(&quot;com.example.functionhookmaster.MainActivity&quot;);<br>MainActivity[&quot;Admin&quot;].implementation = function () {<br>    console.log(`MainActivity.Admin is called`);<br>    let result = this[&quot;Admin&quot;]();<br>    console.log(`MainActivity.Admin result=${result}`);<br>    return true;<br>};</pre><p>And then that’s the whole script</p><blockquote>frida -Uf com.example.functionhookmaster -l hook.js</blockquote><pre>Java.perform(function() {<br>  let MainActivity = Java.use(&quot;com.example.functionhookmaster.MainActivity&quot;);<br>  MainActivity[&quot;Admin&quot;].implementation = function () {<br>      console.log(`MainActivity.Admin is called`);<br>      let result = this[&quot;Admin&quot;]();<br>      console.log(`MainActivity.Admin result=${result}`);<br>      return true;<br>  };<br>});</pre><p>And that’s the result</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/636/1*zI4gfkWd4zr0CnKVRuVSlg.png" /></figure><p>That’s our flag!!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/590/1*-niLwld8pLfllKEr_iY7TQ.jpeg" /></figure><h3>- Function Invokers Quest</h3><blockquote>The journey concludes with the “Function Invoker’s Quest.” Your dynamic analysis skills are put to the ultimate test. Invoke functions dynamically to achieve specific objectives, uncover the final piece of the puzzle, and reveal the last hidden flag.</blockquote><p>As in the previous challenge, we load it into JADX</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/485/1*uayKSIn-IGk7BRfrpJ8hdw.png" /></figure><p>We find that the onCreate The function is rather empty, but there’s an uncalled function called getFlag</p><p>So, we’ll invoke it!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/601/1*W2SOGcFGh7uRkfTJ7sWOhQ.png" /></figure><p>Script:</p><blockquote>frida -Uf com.example.functioninvokersquest -l hook.js</blockquote><pre>Java.perform(function(){<br>    Java.choose(&quot;com.example.functioninvokersquest.MainActivity&quot;, {<br>        onMatch: function(instance){<br>            console.log(instance.getFlag())<br>        },<br>        onComplete: function(){<br>            console.log(&quot;Complete&quot;)<br>        }<br>    })<br>}) </pre><p>We just used the created instance (aka. object) to call getFlag function</p><h3>- ADB PIN Hunter</h3><blockquote>You’ve been given the “Get_Za_Pin.apk” app, which seems to contain an unusual arrangement of PINs within its activities. Your objective is to use ADB commands to interact with the app and navigate through its activities to uncover the hidden PIN. This PIN will serve as the password to access a secure login page within the app.</blockquote><p>loading it into JADX</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/786/1*ecWeEg1f4UhJW6JepbvX-g.png" /></figure><p>We aim to get the PIN to access the flag based on the description.</p><p>in the Login function, it checks if username is equal to Admin and the entered password is equal to the hashed PIN</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/481/1*7RKBdCoeaSbkTBs_ybA7pg.png" /></figure><p>By looking in the Classes, we find a Class that we’ll invoke using this command:</p><blockquote>adb shell am start -n com.example.get_za_pin/.Pins</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*5iM1VLL9oZZaUtJyxPDF_w.png" /></figure><p>We find a list of PINs, by testing each one of them, the correct PIN is: PA33W0RD</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/656/1*rVs_PAYGvrKfqDWPpdBU4A.png" /></figure><h3>- Code Conflux</h3><blockquote>Welcome to the ultimate test of dynamic analysis and reverse engineering in the “Dynamic Enigma: Code Conflux” challenge! In this formidable challenge, you will need to harness your expertise in both function hooking and invocation to navigate a complex maze of code. Are you ready to unravel the mysteries within the depths of the app’s runtime behavior?</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/562/1*oryxfiiHR2jT6AqAKKSjtA.png" /></figure><p>By looking into the MainActivity, we find that there’s an uncalled function named getFlag, but it has an admin check!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/193/1*ganBkw32yMgZ65WGRNt6hg.png" /></figure><p>Seems familiar?</p><p>Yes! This is just a merge of the hard challenges. Which can be solved with this simple script.</p><pre>Java.perform(function() {<br>  let MainActivity = Java.use(&quot;com.example.codeconflux.MainActivity&quot;);<br>  MainActivity[&quot;Admin&quot;].implementation = function () {<br>      console.log(`MainActivity.Admin is called`);<br>      let result = this[&quot;Admin&quot;]();<br>      console.log(`MainActivity.Admin result=${result}`);<br>      return true;<br>  };<br>  <br>  Java.choose(&quot;com.example.codeconflux.MainActivity&quot;, {<br>   onMatch: function(instance){<br>     console.log(instance.getFlag())<br>   },<br>   onComplete: function()<br>   {<br>    console.log(&quot;Done&quot;)<br>   } <br>  });<br>});</pre><p>The first part overrides the implementation of Admin function to set it to true, and then it calls getFlag .</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/805/1*KCYZHwK8s9j3om3H_V2MpA.png" /></figure><p>Thanks for Reading!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=cb9c61370a76" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Android App Reverse Eng. leads to accessing 4.7k+ premium educational videos.]]></title>
            <link>https://medium.com/@Titoot/android-app-reverse-engineering-leads-to-accessing-4-7k-premium-educational-videos-abbed5f6086d?source=rss-4a27ff859bd4------2</link>
            <guid isPermaLink="false">https://medium.com/p/abbed5f6086d</guid>
            <category><![CDATA[static-analysis]]></category>
            <category><![CDATA[reverse-engineering]]></category>
            <category><![CDATA[native-app]]></category>
            <category><![CDATA[android]]></category>
            <category><![CDATA[api]]></category>
            <dc:creator><![CDATA[Titoot]]></dc:creator>
            <pubDate>Sun, 12 Mar 2023 21:24:31 GMT</pubDate>
            <atom:updated>2023-09-06T09:51:34.606Z</atom:updated>
            <content:encoded><![CDATA[<p>My day started typically, but then I remembered that a friend asked me if he could run an Android App on a PC to watch educational videos on a bigger screen. Still, the app has security features preventing that.</p><p><strong>It’s easy</strong>; most apps can be patched and work just fine, and even integrity checks can be bypassed if they <em>even </em>existed.</p><p>Downloaded it (though <a href="https://apkcombo.com/">apkcombo</a>) and loaded it into <a href="https://github.com/skylot/jadx">jadx</a></p><p>I always start with static analysis to gather info and know how it works, and sometimes, it isn’t required to go into dynamic analysis. as in this app!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*tzVldaC5PM67q8QuZU-GQQ.png" /></figure><p>The first thing I noticed when I opened it was a native app. It made things easier. And up there are some endpoints related to an API. I will get into that later.<br>It loads native-lib, and declares stringFromJNISWB from that lib.</p><p>As you might have noticed, there’s an EncryptUtils class, so I will look into that later.</p><p>then searched by the term stringFromand found a couple of them</p><blockquote>stringFromJNIALGO</blockquote><blockquote>stringFromJNISPEC</blockquote><blockquote>stringFromJNIS</blockquote><blockquote><em>stringFromJNIT1</em></blockquote><p>and a few more</p><p>As it’s clear from the names, it gets strings from the JNI (native-lib)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/991/1*pt3jU0dFCQxvlUTQQM8-tg.png" /><figcaption>EncryptUtils Class</figcaption></figure><p>Looking through <strong>EncryptUtils </strong>reveals that <em>stringFromJNISPEC </em>is the Decryption Scheme, and<strong> </strong><em>stringFromJNIALGO </em>is the Algorithm used.</p><p>I am using jadx to trace back to see where this function is being used.</p><pre> public static String l(SettingDTO settingDTO) {<br>    return EncryptUtils.a(new XlmsUtils().stringFromJNIS(), settingDTO.getSettingvalue());<br>}</pre><p>It’s used in the function with a return value of our EncryptUtils and passed stringFromJNIS as the first parameter, the Encryption Key!</p><p>The second parameter is the data needed for decryption.</p><p>Following that data reveals something pretty intriguing!</p><pre>if (settingDTO.getSettingkey().contentEquals(&quot;VimeoToken&quot;)) {<br>                    str = XlmsUtils.l(settingDTO);<br>                    break;<br>}</pre><p><em>VimeoToken</em>? That could be a huge hit!</p><p>I examined where the settingsDTO gets its data from but could not find anything. I may need to look into it more, but I will leave it for <em>now</em>.</p><p>Let’s take a glimpse into <em>“</em>native-lib<em>”.</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*3UeIeV3p0LN0Vp4lXnAj-Q.png" /><figcaption>IDA</figcaption></figure><p>Loading it through <a href="https://en.wikipedia.org/wiki/Interactive_Disassembler">IDA</a> reveals that it’s just a function that returns a string, simple enough!</p><p>And looking into stringFromJNISWB, I found something rather interesting.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*dzE9HSQ-soA4tfb-YCbHGg.png" /></figure><p>It has if statements with string compare if “value” (passed as a parameter) is equal to a specific package ID, then it returns a URL.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/426/1*imDQT7se1x_Tks_x3Nov2w.png" /></figure><p>Pretty weird and damn lazy, he just created a single file (native-lib), used the same for every app he made, and exposed all his APIs, and we’ll get why that was a terrible idea!</p><p>So summing up</p><blockquote>stringFromJNIS = “AyXXXXXXXXXXXCN9”</blockquote><blockquote><em>stringFromJNIALGO = “</em>AES/CFB8/NOPADDING<em>”</em></blockquote><blockquote><em>stringFromJNISPEC = “AES”</em></blockquote><p>Now we have everything to decrypt that AES. But still, there’s no data to decrypt.</p><p>So now, let’s look into these APIs.</p><p>First. It’s the main one that is associated with our target’s package’s id</p><p>Let’s call it <a href="https://main.azurewebsites.net/">https://main.azurewebsites.net</a>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/609/1*LUlmpdpgmtiZC4QmpVV5RA.png" /></figure><p>Hmm, the help page is empty. I might try to fuzz it, but I will look into the other’s first.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/791/1*QkZbNPXctmsAtdWvgO4hcg.png" /></figure><p>Ahah! The second has some data, and it’s vast, with about 150 endpoints!</p><p>Well, it&#39;s more straightforward than fuzzing and has documentation. :)</p><p>hope it’s secure. “<em>Of course, it’s not.”</em></p><p>Looking into every single endpoint, I found a pretty interesting one called <strong>MetaData!</strong></p><p>It has a JSON object with promising data.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*2nx88Gi_R7lJy2Fwa31tHQ.png" /></figure><p>It’s an endpoint that returns metadata about the app, and it has a lot of Tokens and sensitive info which I needed to censor.<br>And it has our VimeoToken and password for the videos, both encrypted, but we have the key :)</p><p>That was from the second link.<br>Looking into the first, it returns similar values, but this time with plaintext and encrypted VimeoToken!<br>Checking the Token using Vimeo API reveals it’s not working, but I will test the others.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/934/1*eaRxE_YLHZOfrzwjrnTCbw.png" /></figure><p>Ok! The third is working just fine, with 2350 Videos!<br>And the fourth API is dead.</p><p>So with that, we need to decrypt the Token easily enough!</p><pre>public static byte[] a = {22, 97, 15, 58, 55, 61, 27, 81, 74, 57, 90, 121, 41, 8, 1, 34};<br>SecretKeySpec secretKeySpec = new SecretKeySpec(MessageDigest.getInstance(&quot;SHA-256&quot;).digest(str.getBytes(&quot;UTF-8&quot;)), stringFromJNISPEC());<br>Cipher cipher = Cipher.getInstance(stringFromJNIALGO());<br>cipher.init(2, secretKeySpec, new IvParameterSpec(a));<br>return new String(cipher.doFinal(Build.VERSION.SDK_INT &gt;= 26 ? Base64.getDecoder().decode(str2) : android.util.Base64.decode(str2, 0)));</pre><p>With cleaning and renaming.</p><pre>public static byte[] IV= {22, 97, 15, 58, 55, 61, 27, 81, 74, 57, 90, 121, 41, 8, 1, 34};<br>SecretKeySpec secretKeySpec = new SecretKeySpec(MessageDigest.getInstance(&quot;SHA-256&quot;).digest(&quot;AyXXXXXXXXXXXCN9&quot;.getBytes(&quot;UTF-8&quot;)), &quot;AES&quot;);<br>Cipher cipher = Cipher.getInstance(&quot;AES/CFB8/NOPADDING&quot;);<br>cipher.init(2, secretKeySpec, new IvParameterSpec(IV));<br>return new String(cipher.doFinal(Base64.getDecoder().decode(VimeoToken)));</pre><p>Much better, it converts the key into bytes, gets its SHA-256 digest “hash, &quot; and decrypts it.</p><p>Creating the same logic in Python.</p><pre>import base64<br>import hashlib<br>from Crypto.Cipher import AES<br><br>str = &quot;AyXXXXXXXXXXXCN9&quot;<br>str2 = &quot;ZDR0XXXXXXXXXXXXXXXXXXXXXXXXXXXXXX+OLw=&quot;<br>a = bytes([22, 97, 15, 58, 55, 61, 27, 81, 74, 57, 90, 121, 41, 8, 1, 34])<br><br>secretKeySpec = AES.new(hashlib.sha256(str.encode(&#39;utf-8&#39;)).digest(), AES.MODE_CFB, iv=a)<br>decrypted = secretKeySpec.decrypt(base64.b64decode(str2)).decode(&#39;utf-8&#39;)<br>print(decrypted)</pre><p>And we got the other Token!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/947/1*e2MFBGeYiS9DVzxMLN4x8g.png" /></figure><p>With 2394 videos, in total, we have access to 4744 videos!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=abbed5f6086d" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>