<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Hirushan Sajindra on Medium]]></title>
        <description><![CDATA[Stories by Hirushan Sajindra on Medium]]></description>
        <link>https://medium.com/@HirushanTech?source=rss-e28f43841b7f------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*Y0YbdkfDlFWszQ3XkpS5Ug.jpeg</url>
            <title>Stories by Hirushan Sajindra on Medium</title>
            <link>https://medium.com/@HirushanTech?source=rss-e28f43841b7f------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 21 Nov 2026 11:07:02 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@HirushanTech/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Application of K-Fold Cross Validation Method in MATLAB for Model Evaluation and Validation]]></title>
            <link>https://medium.com/@HirushanTech/application-of-k-fold-cross-validation-method-in-matlab-for-model-evaluation-and-validation-5a7b1d22cf0e?source=rss-e28f43841b7f------2</link>
            <guid isPermaLink="false">https://medium.com/p/5a7b1d22cf0e</guid>
            <category><![CDATA[k-fold-cross-validation]]></category>
            <category><![CDATA[matlab]]></category>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[artificial-intelligence]]></category>
            <category><![CDATA[crossvalidation]]></category>
            <dc:creator><![CDATA[Hirushan Sajindra]]></dc:creator>
            <pubDate>Tue, 08 Aug 2023 07:43:07 GMT</pubDate>
            <atom:updated>2023-08-08T07:43:07.254Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/920/1*63Y81PU8o5wABW0W2XlZrA.png" /></figure><h4>What is K-Fold Cross Validation and Why it use?</h4><p>K-Fold Cross Validation is a widely used technique in machine learning model evaluation to assess the performance of a model on a dataset. It is designed to mitigate potential issues related to overfitting and to provide a more reliable estimate of the model’s generalization ability.</p><p>The process involves partitioning the original dataset into K subsets of approximately equal size. Hence the K refers to the number of groups the data sample is split into. For example, if you see that the k-value is 5, we can call this a 5-fold cross-validation. Each fold is used as a testing set at one point in the process. In each iteration, the model’s performance metrics, such as accuracy or mean squared error, are recorded.</p><p>The final performance is computed as the average of the performance metrics from all K iterations. This approach allows for a more robust estimation of the model’s performance, as it uses different data subsets for training and testing at each step. It also makes it easier to comprehend how sensitive and stable the model is to changes in the training data.</p><p>When the dataset size is limited, K-Fold Cross Validation is advantageous since it makes the most of the data that is available for both training and testing. By offering a more thorough assessment of the model’s performance across several subsets of data, it also helps in the identification of potential model overfitting and underfitting problems.</p><p>Reference:</p><p><a href="https://www.kdnuggets.com/2022/07/kfold-cross-validation.html#:~:text=K-fold%20Cross-Validation%20is,data%20sample%20is%20split%20into">https://www.kdnuggets.com/2022/07/kfold-cross-validation.html#:~:text=K-fold%20Cross-Validation%20is,data%20sample%20is%20split%20into</a>.</p><h4>How does the K-Fold cross-validation method work?</h4><p>The general strategy for K-Fold cross-validation is as follows,</p><p>The dataset is shuffled and divided into K subsamples of equal size, ensuring that K is not greater than the dataset size.</p><p>In each iteration:</p><ul><li><em>One subset is taken as the test data.</em></li><li><em>The rest of the subsets are used as the training data.</em></li><li><em>The model is trained with the training data and evaluated using the test subset.</em></li><li><em>The evaluation score or error rate is recorded, and the model is discarded.</em></li><li><em>The process is repeated for all K subsets. Each subset is used as the test data once, and the others are utilized as the training data in different iterations.</em></li></ul><p>The average of all the individual evaluation scores is calculated, representing the total error rate.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Xu-oItK5ygAgyLJHJR9uVg.png" /><figcaption>Source — Cross-Validation: K Fold vs Monte Carlo | by Rebecca Patro | Towards Data Science</figcaption></figure><p>By following these steps, we can obtain a reliable estimate of the model’s performance on unseen data, which aids in selecting the best model for the given task.</p><h4>How can this method be applied without using code in MATLAB?</h4><p>Actually, we can apply the cross-validation method using the Regression Learner and Classification Learner apps in the Machine Learning apps of MATLAB without adding any code. For the process, I used the “Regression Learner” app.</p><p><em>Step 01:- </em>Open the Regression Learner app under Machine Learning apps (Figure 01).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*3qujjLfCHa5EsDQGkd2nXw.png" /><figcaption>Figure 01</figcaption></figure><p><em>Step 02:- </em>Afterward, you will be able to see the window below (Figure 02). Next, import the dataset using the “New Session” field. This field offers two ways to import the dataset:</p><ol><li><em>From the workplace of MATLAB.</em></li><li><em>Browse and select the file from your computer.</em></li></ol><p>I utilized the browsing method to import my dataset in CSV file format.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*8TMG4tAR5_Ltn5XdsQyS9A.png" /><figcaption>Figure 02</figcaption></figure><p><em>Step 03:- </em>After importing the dataset, you should select the response field (generally the label/output column) from the imported dataset (Figure 03).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/752/1*sVg6fr1dJYW2TB2xLTAjDg.png" /><figcaption>Figure 03</figcaption></figure><p><em>Step 04:- </em>Next, you should select the cross-validation field and the value of K (Figure 04). The imported dataset will be divided into subsets based on the chosen K value. For example:</p><p>If K = 5</p><p>The dataset will be divided into 5 subsets.</p><p>Then click “Start Session”</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/752/1*AmMAFGFb7rbTE9ZSA7zA_A.png" /><figcaption>Figure 04</figcaption></figure><p><em>Step 05:- </em>Afterward, if you have any idea about the best model to train with the objective of achieving the minimum mean squared error (MSE), you can directly choose that specific model.</p><p>In case you are uncertain about the best model, you have the option to select all (Figure 05) available models and execute them (Figure 06). During this process, MATLAB will train all the models it has and subsequently provide information about the model that yields the best results.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*eZVWwJNKIRgamOZC_Efrhg.png" /><figcaption>Figure 05</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*0QW3-9605MRQGHKf0tcjJw.png" /><figcaption>Figure 06</figcaption></figure><p><em>Step 06:- </em>I conducted the training process by selecting all available models, and the model that performed the best on the dataset was “Stepwise Linear Regression.” Notably, it exhibited the lowest Mean Squared Error (MSE) value of 0.0053, along with a Root Mean Squared Error (RMSE) of 0.07318 (Figure 07). These results demonstrate that “Stepwise Linear Regression” outperformed other trained models in terms of minimizing the MSE.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/794/1*0TxO0uXShDyf8F2h3MjB5Q.png" /><figcaption>Figure 07</figcaption></figure><p>Finally, upon completing the process, you will have access to various informative plots that pertain to the dataset. These include the “Response plot” (Figure 08), which provides insights into the relationship between the dependent and independent variables. Additionally, the “Predicted vs. Actual plot” (Figure 09) allows for a comparative analysis of the model’s predictions against the actual data points, facilitating an assessment of its accuracy and performance. Lastly, the “Residuals plot” (Figure 10) gives a graphical representation of the differences between the observed and predicted values, which aids in evaluating the model’s overall goodness-of-fit and the presence of any patterns or anomalies in the data. Having access to these comprehensive plots will help you understand the dataset’s characteristics and evaluate how well the model captures its underlying patterns.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/869/1*B27zEQz1qQPKXN-DT0q7tg.jpeg" /><figcaption>Figure 08</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/833/1*wyLV6Jy4KZ9V5c0uhFWlhA.jpeg" /><figcaption>Figure 09</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/889/1*mZFq7ObDZUEl0duq9g2bVw.jpeg" /><figcaption>Figure 10</figcaption></figure><p>Thank you for taking the time to read this blog post. Stay safe …. :)</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=5a7b1d22cf0e" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Creating Custom Decoders on Wazuh SIEM]]></title>
            <link>https://medium.com/@HirushanTech/creating-custom-decoders-on-wazuh-siem-67563dfe9aff?source=rss-e28f43841b7f------2</link>
            <guid isPermaLink="false">https://medium.com/p/67563dfe9aff</guid>
            <category><![CDATA[cybersecurity]]></category>
            <category><![CDATA[decoder]]></category>
            <category><![CDATA[siem]]></category>
            <category><![CDATA[wazuh]]></category>
            <dc:creator><![CDATA[Hirushan Sajindra]]></dc:creator>
            <pubDate>Sun, 03 Jul 2022 09:45:16 GMT</pubDate>
            <atom:updated>2023-05-23T03:41:13.805Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/728/1*by32VhVttYASjrfYOGdkOw.jpeg" /></figure><h3>What is Parser?</h3><p>Analysts may find the process of utilizing their SIEM for threat detection to be difficult. Log feeds exist in a variety of sizes and formats, and parsers are used to ingest and standardize the data. Parsers take a certain log format and transform it into normalized structured data, which is commonly referred to as a common information model (CIM). Hundreds or thousands of parsers can be created to process logs for popular systems in SIEMs.</p><h3>Why parser is important for SIEM?</h3><p>SIEM’s log parsing is an important tool for extracting data elements from a log. Parsing allows us to correlate data from various sources to conduct an analysis of incidents. Log aggregation is the location to which all created logs are routed.</p><h3>What is a Custom Parser?</h3><p>You may use the Custom Parser to display InsightIDR precisely what you want to extract from the logs by using an interface. It creates the patterns needed to extract the data automatically based on your input.</p><p><em>Normally the default parsers (Decoders) is located in </em><strong><em>/var/ossec/ruleset/decoders</em></strong><em>. But the custom parsers should be located in </em><strong><em>/var/ossec/etc/decoders.</em></strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/868/1*11Ob4vpMuCUM83jbE6ftFw.png" /><figcaption><em>Default Decoders</em></figcaption></figure><p>You can create a parser with any name. As well as, the extension of created parser should be <strong><em>.xml</em></strong>. After these things, you can start to write the content of the parser using <strong><em>vi</em></strong> text editor or nano text editor.</p><p>As well as you should know, how to test your created parser. First, you should change the directory into<strong><em> /var/ossec/bin</em></strong>, using the <em>cd</em> command for this task. After that, you can see the content of the bin directory using the <em>ls</em> command. After that execute the wazuh-logtest or ossec-logtest file. (<strong><em>./wazuh-logtest or ./ossec-logtest</em></strong>).</p><p>After executing that file, a particular log is put into the space, and press Enter.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*WggTWY6VtmpIxlZ0AGvOVA.png" /><figcaption>Output of Decoder</figcaption></figure><p>If the parser is matched, you can see the extracted data according to the log as above figure.</p><h3><strong>Related Tags For Parser Creation</strong></h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/692/1*kjOqby81TtiMk4xWNLjmWw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/698/1*6qgjDg1sorUes3Mpf6UkzQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/701/1*WWg7aJ-z_VB_e4Nl0BpjcA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/699/1*YJ10ewii_Y_fUxCtpVv0sg.png" /><figcaption>Table 01</figcaption></figure><p>— See order table → <a href="https://documentation.wazuh.com/current/user-manual/ruleset/ruleset-xml-syntax/decoders.html#order">For More Information</a></p><p>— See fts table → <a href="https://documentation.wazuh.com/current/user-manual/ruleset/ruleset-xml-syntax/decoders.html#fts">For More Information</a></p><p>— See plugin_decoder table →<a href="https://documentation.wazuh.com/current/user-manual/ruleset/ruleset-xml-syntax/decoders.html#plugin-decoder"> For More Information</a></p><p>— See type table → <a href="https://documentation.wazuh.com/current/user-manual/ruleset/ruleset-xml-syntax/decoders.html#type">For More Information</a></p><h3>What is Regex?</h3><p>Regular expressions or regex are sequences of characters that define a pattern. There are three types of regular expressions: regex (<em>OS_Regex</em>), sregex (<em>OS_Match</em>), and PCRE2.</p><h3>Regex (OS_Regex) syntax</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/555/1*iXkkI8eULzPF3rlvsK3xSg.png" /><figcaption>Table 02</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/556/1*kktTm-L_sMD3lGxbveOEzg.png" /><figcaption>Table 03</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/555/1*Q484PnJ1qaKI0IcdPxmIrA.png" /><figcaption>Table 04</figcaption></figure><p><a href="https://documentation.wazuh.com/current/user-manual/ruleset/ruleset-xml-syntax/decoders.html#accumulate">Decoders Syntax - Ruleset XML syntax · Wazuh documentation</a></p><p>.\+ = Get all the thing of the log</p><p>\S = Get a letter of word / Get a number of number series</p><p>\S+ = Get letters until met the word gap</p><p>\d = Get a number [192.168.2.1 ⇒ \d\d\d.\d\d\d.\d.\d ]</p><p>\d+ = Get numbers until met the number gap [192.168.2.1 ⇒ \d+.\d+.\d+.\d+]</p><h3>How to Create Custom Parser/Decoder</h3><p>I considered three logs related to the Hillstone firewall to create a parser. (when you create a parser, should be used different types of logs, of the related system). Here you want to decide what is the unique part of the considered log set. After identifying a unique part of the log set, you should convert it into regex and put it into the prematch section.</p><p>Another way, you can use the <strong><em>program_name </em></strong>section. Here you want to identify unique words. Then those words are put into the <strong><em>program_name</em></strong> section directly with <strong>^</strong> special character.</p><p>Ex:-</p><blockquote>&lt;decoder name=”wazuh-custom”&gt; &lt;program_name&gt;^abc&lt;/program_name&gt; &lt;/decoder&gt;</blockquote><p>(<strong>^)</strong>:- To specify the beginning of the text</p><h4>Considered Logs</h4><ol><li>June 10 09:35:51 2508349151001948(root) 460c9412 Threat@FLOW: From 10.10.100.100:6745(ethernet0/8) to 10.10.90.245:1031(-), threat name: syn-flood, threat type: DoS, threat subtype: DDoS Flood, App/Protocol: IPv4/TCP, action: DROP, defender: AD, severity: Medium, zone untrust: TCP SYN flood attack</li><li>June 9 16:02:47 2508349151001948(root) 44383613 Traffic@FLOW: WEB: IP 192.168.2.3:8666(10.10.90.245:8666)-&gt;151.102.0.81:443(151.101.0.81:443), user -, VR trust-vr, URL <a href="https://www.bbc.com/">https://www.bbc.com</a>, category News, method GET, action block, reason URL</li><li>June 9 13:31:48 2508349151001948(root) 4424363e Traffic@FLOW: SESSION: 192.168.2.3:9220(ethernet0/6)-&gt;34.102.193.95:443(ethernet0/8), Protocol TCP, vr trust-vr, policy 2, user -@-, host -, mac 0000.0000.0000, zone from trust to untrust, session start</li></ol><h4>The Created Decode</h4><blockquote>&lt;decoder name=”hillstone-custom”&gt; <strong>&lt;! — The name of the custom decoder — &gt;</strong><br>&lt;prematch&gt;\.+ \S+@FLOW: \S+&lt;/prematch&gt; <strong>&lt;! — Identifying the log using unique thing — &gt;</strong><br>&lt;/decoder&gt; <strong>&lt;! — close the decoder tag — &gt;</strong></blockquote><blockquote>&lt;decoder name=”hillstone-custom1&quot;&gt; <br>&lt;parent&gt;hillstone-custom&lt;/parent&gt;<br>&lt;prematch&gt;\.+ \S+@FLOW: \S+&lt;/prematch&gt;<br>&lt;regex&gt;\.+ \S+@FLOW: \S+ (\d+.\d+.\d+.\d+)&lt;/regex&gt; <strong>&lt;! — write regex commands and if you put brackets you can extract it — &gt;</strong><br>&lt;order&gt;src&lt;/order&gt; <strong>&lt;! — extracted thing can be put into src or what ever category — &gt;</strong><br>&lt;/decoder&gt; <strong>&lt;! — cloce the decoder tag — &gt;</strong></blockquote><blockquote>&lt;decoder name=”hillstone-custom1&quot;&gt;<br>&lt;parent&gt;hillstone-custom&lt;/parent&gt;<strong> &lt;! — put into parent decoder name — &gt;</strong><br>&lt;regex offset=”after_regex”&gt;threat type: (\S+)&lt;/regex&gt; <strong>&lt;! — offset=”after_regex” ⇒ This means start reading from the place you finished reading earlier — &gt;</strong><br>&lt;order&gt;ThreatType&lt;/order&gt;<br>&lt;/decoder&gt;</blockquote><blockquote>&lt;decoder name=”hillstone-custom1&quot;&gt;<br>&lt;parent&gt;hillstone-custom&lt;/parent&gt;<br>&lt;regex offset=”after_regex”&gt;threat subtype: (\S+ \S+)&lt;/regex&gt; <br>&lt;order&gt;ThreatSubtype&lt;/order&gt;<br>&lt;/decoder&gt;</blockquote><blockquote>&lt;decoder name=”hillstone-custom1&quot;&gt;<br>&lt;parent&gt;hillstone-custom&lt;/parent&gt;<br>&lt;regex offset=”after_regex”&gt;action: (\S+)&lt;/regex&gt; <strong>&lt;! — We can identify particular places of the log using the words — &gt;</strong><br>&lt;order&gt;action&lt;/order&gt;<br>&lt;/decoder&gt;</blockquote><blockquote>&lt;decoder name=”hillstone-custom1&quot;&gt;<br>&lt;parent&gt;hillstone-custom&lt;/parent&gt;<br>&lt;regex offset=”after_regex”&gt;App/Protocol: (\S+)&lt;/regex&gt;<br>&lt;order&gt;App/Protocol&lt;/order&gt;<br>&lt;/decoder&gt;</blockquote><blockquote>&lt;decoder name=”hillstone-custom1&quot;&gt;<br>&lt;parent&gt;hillstone-custom&lt;/parent&gt;<br>&lt;regex offset=”after_regex”&gt;defender: (\S+)&lt;/regex&gt;<br>&lt;order&gt;Defender&lt;/order&gt;<br>&lt;/decoder&gt;</blockquote><blockquote>&lt;decoder name=”hillstone-custom1&quot;&gt;<br>&lt;parent&gt;hillstone-custom&lt;/parent&gt;<br>&lt;regex offset=”after_regex”&gt;severity: (\S+)&lt;/regex&gt;<br>&lt;order&gt;Severity&lt;/order&gt;<br>&lt;/decoder&gt;</blockquote><blockquote>&lt;decoder name=”hillstone-custom1&quot;&gt;<br>&lt;parent&gt;hillstone-custom&lt;/parent&gt;<br>&lt;regex offset=”after_regex”&gt;zone \S+: (\S+ \S+ \S+)&lt;/regex&gt;<br>&lt;order&gt;AttackName&lt;/order&gt;<br>&lt;/decoder&gt;</blockquote><blockquote>&lt;decoder name=”hillstone-custom1&quot;&gt;<br>&lt;parent&gt;hillstone-custom&lt;/parent&gt;<br>&lt;regex offset=”after_regex”&gt;URL (\S+://\S+.\S+.\S+),&lt;/regex&gt;<br>&lt;order&gt;URL&lt;/order&gt;<br>&lt;/decoder&gt;</blockquote><blockquote>&lt;decoder name=”hillstone-custom1&quot;&gt;<br>&lt;parent&gt;hillstone-custom&lt;/parent&gt;<br>&lt;regex offset=”after_regex”&gt;category (\S+),&lt;/regex&gt;<br>&lt;order&gt;BlockCategory&lt;/order&gt;<br>&lt;/decoder&gt;</blockquote><blockquote>&lt;decoder name=”hillstone-custom1&quot;&gt;<br>&lt;parent&gt;hillstone-custom&lt;/parent&gt;<br>&lt;regex offset=”after_regex”&gt;, action (\S+)&lt;/regex&gt;<br>&lt;order&gt;Action&lt;/order&gt;<br>&lt;/decoder&gt;</blockquote><blockquote>&lt;decoder name=”hillstone-custom1&quot;&gt;<br>&lt;parent&gt;hillstone-custom&lt;/parent&gt;<br>&lt;regex offset=”after_regex”&gt;zone from (\S+ \S+ \S+)&lt;/regex&gt;<br>&lt;order&gt;ZoneFrom&lt;/order&gt;<br>&lt;/decoder&gt;</blockquote><p>Thank you for taking the time to read this blog post. Stay safe ….</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=67563dfe9aff" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Enabling MySQL Logs In The Linux Environment]]></title>
            <link>https://medium.com/@HirushanTech/enabling-mysql-logs-in-the-linux-environment-f45f30b4e67e?source=rss-e28f43841b7f------2</link>
            <guid isPermaLink="false">https://medium.com/p/f45f30b4e67e</guid>
            <category><![CDATA[sql]]></category>
            <category><![CDATA[sql-queries]]></category>
            <category><![CDATA[logs]]></category>
            <category><![CDATA[mysql]]></category>
            <category><![CDATA[database]]></category>
            <dc:creator><![CDATA[Hirushan Sajindra]]></dc:creator>
            <pubDate>Tue, 05 Apr 2022 06:04:11 GMT</pubDate>
            <atom:updated>2022-04-05T06:23:26.352Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/848/1*dYng3JWZeWTxkLE_68uT_g.jpeg" /></figure><p>The MySQL log file is a collection of records of actions taken. The MySQL server creates log files based on the activities that are taken. General query logs, error logs, ISAM logs, binary logs, update logs, and sluggish query logs are all examples of log files.</p><p>This blog post describes how to enable General logs, error logs, and Slow query logs in the Linux environment. I used CentOS 7 to do this task.</p><p>Ok…. Let’s Start</p><h3><strong>General Logs</strong></h3><p>The general query log is <strong>a general record of what MySQL</strong> <strong>Server is doing.</strong></p><p>It’s consists of :</p><ul><li>Query.</li><li>Field List.</li><li>The name of the database is currently in use.</li><li>Connect (eg:- root@localhost on using Socket / Access denied for user ‘root’@’localhost’).</li><li>Date and Time.</li></ul><h3><strong>How To Check General Logs Are Already Enabled or Disabled?</strong></h3><p>Here you can check the general logs are already enabled or disabled using the below query. After login into the MySQL server, you can execute this query.</p><p><strong><em>show variables like ‘%general%’;</em></strong></p><p>As the result of the above query, you can see, the <a href="https://www.computerhope.com/jargon/d/default.htm">default location</a> of storing general logs and already enabled or disabled the general logs as below figure.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/717/1*InJLxAoqk0uotEH970K9sA.png" /><figcaption>Default Location Of General Logs</figcaption></figure><h3>How To Enable General Log?</h3><p>First, stop the MySQL service using this command,</p><p><strong><em>systemctl stop mysqld</em></strong></p><p>Then create the log file in a particular location. eg:- /var/lib/mysql, (you can use any name and any location)</p><p><strong><em>touch linux2.log</em></strong></p><p>After that give the file permission to the above-created file using the below command.</p><p><strong><em>chmod 777 linux2.log</em></strong></p><p>Now you can get the created <strong><em>linux2.log </em></strong>file path using <em>pwd</em> command. Then copy the path of the created <strong><em>linux2.log </em></strong>file to the relevant place of<em> my.cnf</em> file.</p><p><strong><em>/var/lib/mysq/linux2.log</em></strong></p><p>Then go to this location (/etc/my.cnf) to access MySQL configuration file.</p><p>The<em> my.cnf</em> file content is like this,</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/547/1*RzoVNVs3-BwhLrx8eyU6Dw.png" /><figcaption>Content of <em>my.cnf</em></figcaption></figure><p>In this file, we should modify this area like this.</p><p><strong><em>[mysqld]</em></strong></p><p><strong><em>general_log =1</em></strong></p><p><strong><em>general_log_file = /var/lib/mysql/linux2.log</em></strong> (The location where the logs should be store)</p><p>In here, genera_log = 0 ⇒ disable , 1 ⇒ enable.</p><p>Then copy and paste the path of the created log file like this ⇒ <strong><em>general_log_file = /var/lib/mysql/linux2.log</em></strong></p><p>After these configurations, you should start the MySQL service.</p><p><strong><em>systemctl start mysqld</em></strong></p><p>Then go to the MySQL server using the below command.</p><p><strong><em>mysql -u root -p</em></strong></p><p>Now you should edit your database. After that look at the created log file (linux2.log) using the <strong><em>cat</em></strong> command. Now you can see the access logs, modification logs, queries, etc, related to server-side activities.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/914/1*a0p-XP7tXGsVpuFLybJ7Sg.png" /><figcaption>General Log</figcaption></figure><h3>Error Logs</h3><p>The error log contains a record of mysqld startup and shutdown times. It also contains diagnostic messages such as errors, warnings, and notes that occur during server startup and shutdown, and while the server is running.</p><h3><strong>How To Check Error Logs Are Already Enabled or Disabled?</strong></h3><p>Here you can check the details of the error logs using the below query. After login into the MySQL server, you can execute this query.</p><p><strong><em>show variables like ‘%error%’;</em></strong></p><p>As the result of the above query, you can see, the default location of storing Error logs and more.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/709/1*fLJUT-c7LqCBy8uVSIh50w.png" /><figcaption>Default Location Of Error Logs</figcaption></figure><h3>How To Enable Error Logs?</h3><p>First, stop the MySQL service using this command,</p><p><strong><em>systemctl stop mysqld</em></strong></p><p>Then create the log file in a particular location. eg:- /var/lib/mysql, (you can use any name and any location)</p><p><strong><em>touch errorlogsql.log</em></strong></p><p>After that give the file permission to the above-created file using the below command.</p><p><strong><em>chmod 777 errorlogsql.log</em></strong></p><p>Now you can get the created <strong><em>errorlogsql.log </em></strong>file path using <em>pwd</em> command. Then copy the path of the created <strong><em>errorlogsql.log </em></strong>file to the relevant place of<em> my.cnf</em> file.</p><p><strong><em>/var/lib/mysq/errorlogsql.log</em></strong></p><p>Then go to this location (/etc/my.cnf) to access MySQL configuration file and then add these configurations.</p><p><strong><em>[mysqld]</em></strong></p><p><strong><em>log_error =1</em></strong></p><p><strong><em>log-error= /var/lib/mysql/errorlogsql.log</em></strong></p><p>After these configurations, you should start the MySQL service.</p><p><strong><em>systemctl start mysqld</em></strong></p><p>Then go to the MySQL server.</p><p><strong><em>mysql -u root -p</em></strong></p><p>Now you should create an error related to your MySQL server. After that read the created error log file (errorlogsql.log) using the <strong><em>cat </em></strong>command. Now you can see the errors and Warnings related to server-side activities.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*f6ktanGtR643N2Pxd2hYSw.png" /><figcaption>Error Logs</figcaption></figure><p><a href="https://stackoverflow.com/questions/5441972/how-to-see-log-files-in-mysql">How to see log files in MySQL?</a></p><h3>Slow Query Logs?</h3><p>The MySQL slow query log is where the MySQL database server registers all queries that exceed a given threshold of execution time. This can often be a good starting place to see which queries are slowest and how often they are slow.</p><p>Slow queries might indicate that your database is doing more work than it needs to, which implies it is consuming more resources. Everything can start to slow down when restricted resources, such as CPU or I/O, run out. When you don’t utilize the resources you have, inefficient resource usage becomes an issue.</p><p><a href="https://orangematter.solarwinds.com/2018/01/17/slow-queries-move-fast-to-fix-them/">Slow Queries? Move Fast to Fix Them</a></p><h3>How To Check Slow Query Logs Are Already Enabled or Disable?</h3><p>Here you can check that the slow query logs are already enabled or disabled using the below query. After login into the MySQL server, you can execute this query.</p><p><strong><em>show variables like ‘%slow_query_log%’;</em></strong></p><p>As the result of the above query, you can see, the default location of storing slower query logs and already enabled or disabled the slower query logs as below figure.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/702/1*NS1MIiercsUPw3Ob-bbL5g.png" /><figcaption>Default Location Of S<em>low query logs</em></figcaption></figure><h4><strong>How To Enable Slower Query Logs?</strong></h4><p>First, stop the MySQL service using this command,</p><p><strong><em>systemctl stop mysqld</em></strong></p><p>Then create the log file in a particular location. eg:- /var/lib/mysql, (you can use any name and any location)</p><p><strong><em>touch slow-mysql-query.log</em></strong></p><p>After that give the file permission to the above-created file using the below command.</p><p><strong><em>chmod 777 slow-mysql-query.log</em></strong></p><p>Now you can get the created <strong><em>slow-mysql-query.log </em></strong>file path using <em>pwd</em> command. Then copy the path of the created <strong><em>slow-mysql-query.log </em></strong>file to the relevant place of<em> my.cnf</em> file.</p><p><strong><em>/var/lib/mysq/slow-mysql-query.log</em></strong></p><p>Then go to this location (/etc/my.cnf) to access MySQL configuration file.</p><p>Then go to this location (/etc/my.cnf) to access MySQL configuration file and then add these configurations.</p><p><strong><em>[mysqld]</em></strong></p><p><strong><em>slow_query_log = 1</em></strong></p><p><strong><em>slow_query_log_file = /var/lib/mysql/slow-mysql-query.log</em></strong></p><p><strong><em>long_query_time = 10</em></strong></p><p>In here (<em>long_query_time = 10</em>) the minimum value is 1 second and the default value of long_query_time is 10 seconds of execution time, this means, that if your query takes more than 10 seconds to execute, it should be written into this log file.</p><p>After these configurations, you should start the MySQL service.</p><p><strong><em>systemctl start mysqld</em></strong></p><p>Then go to the MySQL server.</p><p><strong>mysql -u root -p</strong></p><p>Now you should execute some slow-running queries on the MySQL server. After that look at the created slow-query.log file (slow-mysql-query.log) using the <strong><em>cat </em></strong>command. Now you can see the slow query logs related to server-side activities.</p><p>More resources :</p><p><a href="https://stackoverflow.com/questions/6479107/how-to-enable-mysql-query-log">How to enable MySQL Query Log?</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f45f30b4e67e" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[SpaceX CTF Walkthrough]]></title>
            <link>https://medium.com/@HirushanTech/spacex-ctf-walkthrough-3618498b11b0?source=rss-e28f43841b7f------2</link>
            <guid isPermaLink="false">https://medium.com/p/3618498b11b0</guid>
            <category><![CDATA[ctf]]></category>
            <category><![CDATA[cybersecurity]]></category>
            <category><![CDATA[cyberattack]]></category>
            <category><![CDATA[spacexctf]]></category>
            <category><![CDATA[ctf-writeup]]></category>
            <dc:creator><![CDATA[Hirushan Sajindra]]></dc:creator>
            <pubDate>Sat, 25 Sep 2021 15:37:45 GMT</pubDate>
            <atom:updated>2021-09-25T15:54:11.614Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*qvbUwNhyWhmTxn_sFUDPaQ.jpeg" /><figcaption><a href="https://www.hacking.reviews/2017/07/capture-flag-security-wargame.html?m=0">https://www.hacking.reviews/2017/07/capture-flag-security-wargame.html?m=0</a></figcaption></figure><h3><strong>Introduction</strong></h3><p>The aim of capture the flag (CTF), an outdoor game in which two or more teams each have a flag (or another marker), is to capture the other team’s flag, which is set at the team’s “base,” and return it safely to their own base.</p><p>This CTF box is aimed mostly at new banking employees who work in the cyber security section and are interested in information security. This is an excellent opportunity for them to put their pen-testing and cyber security abilities to the test. SpaceX will put your fundamental computer science, logical thinking, programming, and problem-solving abilities to the test.</p><p>Every participant in this CTF box must complete 20 levels. In order to progress in this challenge, you must discover and submit flags at each level. In order to make our CTF box more professional, we employed technologies such as cryptography, steganography, basic programming techniques, and certain web-based activities. We now have contemporary technology in addition to traditional approaches.</p><p>They may gain a clear understanding of what information security is, what the most significant vulnerabilities are, and how information security has progressed so far by taking on these CTF tasks.</p><h3><strong>Theme</strong></h3><p>We’re going to utilize Elon Musk’s life narrative as a theme, from the beginning through his major ambition of driving a vehicle on Mars. It will get increasingly fun as you progress through the levels.</p><p>Because of his environmentally conscious mindset, he developed a strong interest in eco-friendly technology throughout time. But he was unable to put such technologies to the test. As a result, he intended to establish his own business. He lacked the financial resources to establish a business. As a result, he decided to sell PayPal in order to launch his own business. Then he renamed himself Tesla and began working on it. He introduced an eco-friendly vehicle, which became the company’s most popular creation. His interest grew with the passage of time. He became interested in rocket science as a result of this. As a result of this, he founded SpaceX. He touted SpaceX’s re-usable rocket as a game-changing innovation. He then let a vehicle into the spot. Then he intends to walk on Mars, as well as transport cars and people to the Red Planet. In this endeavor, his ultimate objective is to drive his automobile on Mars. He then let a vehicle into the spot. Then he intends to walk on Mars, as well as transport cars and people to the Red Planet. In this endeavor, his ultimate objective is to drive his automobile on Mars.</p><h3><strong>SpaceX</strong></h3><p>Our CTF box is <strong>Spacex</strong> and it is based on the space journey to mars one of the biggest dreams that Elon Musk has. We are primarily focused on new commerce of banks and other financial organizations, as well as working employees, to develop and test their cyber security expertise. Aside from information security professionals, Web developers, security analysts, software developers, and pen-testers may all gain a comprehensive picture of current IT risks and vulnerabilities.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/544/1*_g3jk4r7txQigDwrgnwMMQ.png" /></figure><p>Under <strong>Story, </strong>we have explained Our attractive theme story and under the <strong>about</strong> section, we have explained our target audience and what are technologies we are planning to examine throughout this journey and also There are 20 levels in this CTF box 14 from the web-based section and 6 from shell-based levels by getting all the flags player can get full marks which are 2000.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*iXu05Nyf4ts-j55dB9vrqw.png" /><figcaption>SpaceXCTF Story</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*oJZYHO0-zjt1KCztBuHkpg.png" /><figcaption>SpaceXCTF About</figcaption></figure><p>After that player should come back to the home page and click the START button in order to start the CTF box.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*p0nMuj08hCLUhUP96eozWQ.png" /><figcaption>Start the game</figcaption></figure><p>After that player should register his or her name to get the logging credentials.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Jj4qceJWqManiiK4R_-jHA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/349/1*GAH6On8r2K0Ms7Eg1TYRdQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*XxOR4KR0F09cnnorsBdUTQ.png" /></figure><h3>Admin Page</h3><p>Our CTF box has an admin page. This privilege is given to the organization that is going to buy our product. He or she has full control over our CTF box In order to get those privileges officers have to log in to our CTF box.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/913/1*8LTqtgYVQjXvtNG-gEveyA.png" /><figcaption>Admin Login page</figcaption></figure><p><strong><em>Username :- spacex | Password :- rocket</em></strong></p><p>Under admin privileges, the admin can view our CTF levels and in the update facility, he or she can change the level and update with another one, and also if the admin wants they can remove CTF levels as well.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*L1hgoDVFm6JQoxx9VfWrww.png" /><figcaption>Admin Dashboard</figcaption></figure><h4><strong><em>Level 01</em></strong></h4><p>This is the first level of our SpaceX CTF box. The main focus of this first stage is to identify the player’s skills on identify the hints and act accordingly. As a cyber security vocationalist these kinds of primary skills are very essential.</p><p>This level has provided a 2D picture. It means this picture has length and width as the hint says the player has already identified these two dimensions, the third one is height.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/859/1*dor1g9vhHjFi4Sqp7n7YnA.png" /><figcaption>Hint Page (Level 01)</figcaption></figure><p>After getting the flag player should go back to the submission page and submit it. For this level, the player will get 10 marks.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/796/1*hUiTVU9bnixnxHWwPvhnGA.png" /><figcaption>Submission page of Level 01</figcaption></figure><p>The submission flag should be this,</p><p><strong><em>spacex{height_length_width}</em></strong></p><p>Entering these three dimensions according to this pattern is mandatory.</p><h4>Level 02</h4><p>ASCII is a kind of number that represents every text in computers. As cybersecurity-related people, they should have a proper image about these kinds of basics of computer science.</p><p>This level has provided a picture(.jpg) with numbers. The first player should understand what are those numbers?</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/889/1*cv2kodaliO13mzxEEIdNag.png" /><figcaption>Hint Page (Level 02)</figcaption></figure><p>Then the player should decode it and get the flag.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/861/1*AvbA12hlbre6dWj8Uciozw.png" /><figcaption><a href="https://www.duplichecker.com/ascii-to-text.php">https://www.duplichecker.com/ascii-to-text.php</a></figcaption></figure><p><a href="https://www.duplichecker.com/ascii-to-text.php">ASCII to Text | Convert you ASCII code into Text</a></p><p>After getting the flag player should go back to the submission page and submit it as shown in the hint. For this level, player will get 20 marks.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*r_6rjJdwtO631_yddg85-Q.png" /><figcaption>Submission page of Level 02</figcaption></figure><p>The submission flag should be this,</p><p><strong><em>spacex{Elon_Musk}</em></strong></p><h4>Level 03</h4><p>QR code (Quick Response code) is a type of matrix barcode which was introduced by a Japanese company called Denso wave in 1994. It is often used to store web URLs, tracking details, and such kinds of details. So that it is an old technique but these days it is very popular because of social media. As earlier stated this level examines the player’s knowledge about new technologies like QR code. So, in the hint, we have given a QR code. But there is a problem.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*we_PJE8Phb1XmKmY4S4uyQ.png" /><figcaption>Hint Page (Level 03)</figcaption></figure><p>The QR code has been corrupted. There are some blank spots in the QR code. Therefore player should download the QR code and then he or she should fill those blank/white spots.</p><p>QR code has black and white spaces. The player should identify the corrupted are as and fill them with black.</p><p>After getting the edited QR code player should decode it using an online tool</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1003/1*Kmc1oM7jcGOL3hfEGdJ3bw.png" /><figcaption><a href="https://webqr.com/">https://webqr.com</a></figcaption></figure><p>Then the player should go back to the level three submission page and submit the flag then the player will get 35 marks for completing this level.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/802/1*kyI90BE3fgvTbAZggeV3Jw.png" /><figcaption>Submission page of Level 03</figcaption></figure><p>The summation flag should be this,</p><p><strong><em>spacex{stanford}</em></strong></p><h4>Level 04</h4><p>Steganography is a technique that uses under cryptography to hide some information inside a picture or an audio file. It is a more secure method to store data because the attacker can’t imagine that data will be there. On the other hand, some attackers also use this technique to transmit malicious content through the network. In this method, the receiver has to enter the password in order to get the data from the steganography file.</p><p>To achieve the flag at this level the player should have a clear image of the technique called Steganography. The level has provided a picture (.jpg). If the player directly tries to decode it will fail. The Player has to take the password by inspecting the page.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/953/1*OV-ghIIlyFFAPogiscaRNg.png" /><figcaption>Hint Page (Level 04)</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*D2Nf6s7dZl3HWIr79xQI9Q.png" /></figure><p>The lowest size .jpg is the steno picture.</p><p>In all these methods the player should download the jpg file.</p><p>Using an online tool with the password and the jpg file and easily decode the file and get the flag.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/812/1*bjVwHT2vOChkjEFFN023Jg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/967/1*mQ-YVZxfgJlsCa1Kwjb-Fw.png" /></figure><p><a href="https://futureboy.us/stegano/decinput.html">Steganographic Decoder</a></p><p>Not only by online tool there is a Linux tool called <strong>Steghide</strong> to decode steganography. This is not a default tool so the player has to download and install it before using it. Use this code.</p><p><strong>steghide extract -sf ‘path/of/stegno/file’ -p password -xf ‘path/to/extracted/file’</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*8ZGLAnJ13oSUwSWoTyvbhg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Qzc9QLIIyvY9OSVSKiRCCw.png" /></figure><p>After getting the flag player should go back to the submission page and submit it as shown in the hint. For this level, the player will get 40 marks.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1022/1*HpL-65MnyXKtk8RJDcCbDQ.png" /><figcaption>Submission page of Level 04</figcaption></figure><p>The submission flag should be this,</p><p><strong><em>Spacex{@@ElonMusk_1971@@}</em></strong></p><h4>Level 05</h4><p>Audio listening is a completely rare thing when considering about cyber security employees. But it can be useful when detecting an attack because in a computer network every hardware has its own security system. So that they indicate if there is any weakness in their service. It will be a great help to stop it before happening something big. As cyber security employees, they should be much focused on even small changes of the system at this level we have provided an audio clip. The player should identify the sound (what generates that sound).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/885/1*3YUDewJfXcS-zQ_cHFpzVA.png" /><figcaption>Hint Page (Level 05)</figcaption></figure><p>After getting the flag player should go back to the submission page and submit it as shown in the hint. For this level, player will get 50 marks.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*A1dUqk1oNUWyyaOm-lcCRA.png" /><figcaption>Submission page of Level 05</figcaption></figure><p>The submission flag should be this,</p><p><strong><em>spacex{ROCKET}</em></strong></p><h4>Level 06</h4><p>Braille is a tactile writing device that is used for visually blind individuals. Embossed paper is used to write it historically. Braille owners can use refreshable braille monitors to read computer screens and other mobile devices. They can type braille on a braille writer, such as a portable braille notetaker or a printer that prints with a <a href="https://en.wikipedia.org/wiki/Braille_embosser">braille embosser</a> or write it with the original slate and stylus. Braille is named for its inventor, Louis Braille, a Frenchman who was blinded as an infant in an accident. In the year 1824. But now it has been used as a cryptographic encoding method. So as a new technology cyber security employees should be aware of new technologies.</p><p>In this level, players have given a poem. In that poem, some letters are replaced with some dot patterns. The first player should understand those dot patterns are related to the Braille alphabet.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*JEYk5rMZ4mgk_zEBObMrLg.png" /><figcaption>Hint Page (Level 06)</figcaption></figure><p>The player should decode every dot pattern using the Braille alphabet then the player can have the flag for level six.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/844/1*MxLTCmfRgLgmm6tVuP9zqA.png" /><figcaption>The Braille Alphabet</figcaption></figure><p><a href="https://www.pharmabraille.com/pharmaceutical-braille/the-braille-alphabet/">The Braille Alphabet</a></p><p>After getting the flag player should go back to the submission page and submit it as shown in the hint. For this level, player will get 70 marks.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/885/1*jA-aNxk_OsdD7NpTIdZUOw.png" /><figcaption>Submission page of Level 06</figcaption></figure><p>The submission flag should be this,</p><p><strong><em>spacex{fleetwooddragons}</em></strong></p><h4>Level 07</h4><p>As a worker of cyber security domain most of the time they have to work with web-based applications. In order to implement security mechanisms, have a good experience on code structures and how they work.</p><p>At this level, there is no direct hint. the player should find the hint and it will automatically send him or her to the flag. There is a blog page in this level and there are several blogs shown on this page. As earlier stated, the hint is also hidden. So that player has to first find the hint among the page source code using inspect element.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*kR7mMvnPVzgfPIAir1LVtg.png" /><figcaption>Source Code Of The Level 07 Submission Page</figcaption></figure><p>Then the player should find that sentence in every blog on that page. Finally, the player will find that sentence at “Synchronizer Token Pattern” last word of that phrase is the “flag”.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/848/1*TQNxyDHOw4ysZD1JUBctTQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/873/1*elvcFPJbkN07MntWGuQ4hw.png" /><figcaption>Blog Post</figcaption></figure><p><a href="https://medium.com/@Hirushan96/synchronizer-token-pattern-f5f4406e3dfd">Synchronizer Token Pattern</a></p><p>After getting the flag player should go back to the submission page and submit it as shown in the hint. For this level, player will get 70 marks.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*QfrpmH7nQwGrRU07sTzsKg.png" /><figcaption>Submission page of Level 07</figcaption></figure><p>The submission flag should be this,</p><p><strong><em>spacex{PHPSESSID}</em></strong></p><h4>Level 08</h4><p>In the cyber security field, cryptography has a significant part and under encoding base 64 is very popular and on the other hand, hash is also a very secured encoding system because the length of the ciphertext is not depending on plain text length it only depends on the algorithm that they use to hashing. because of that attacker can’t guess the content length. But there is a problem in hashing that normally it can’t crack but because of rainbow tables hash value can be cracked if it is not salted.</p><p>To achieve the flag in this level player should have that primary knowledge of these areas. So that this level has provided a string and there is a description about base 64 which was taken from <a href="https://en.wikipedia.org/wiki/Base64">Wikipedia</a>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*lNI521AyyY-TrSg4coObvw.png" /><figcaption><a href="https://en.wikipedia.org/wiki/Base64">https://en.wikipedia.org/wiki/Base64</a></figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*c0H_4UfgzBy6PLfvuvXnXg.png" /><figcaption>Hint Page (Level 08)</figcaption></figure><p>First, the player has to decode from base 64 because there is a “=” sign at the end of the string. This step can be done using the online tool as well as using Linux commands after saving the string inside a file.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/799/1*kAExsvgxjJREu9c2jJ6Nuw.png" /><figcaption>Decoding By Using The Kali Linux</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/718/1*uR1F8XJI3m9AcaUWKw-q-Q.png" /><figcaption>Decoding By Using The Online Tool</figcaption></figure><p><a href="https://www.base64decode.org/">Base64 Decode and Encode - Online</a></p><p>Then the player should crack the hash using an online tool. Then the player can get the flag.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*EW3DtxR98mi82M9X3qAf0Q.png" /><figcaption>Crackstation</figcaption></figure><p><a href="https://crackstation.net/">CrackStation - Online Password Hash Cracking - MD5, SHA1, Linux, Rainbow Tables, etc.</a></p><p>After getting the flag player should go back to the submission page and submit it as shown in the hint. For this level, the player will get 80 marks.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/932/1*vTtzIZ_d4lNKHHCSr8-WGA.png" /><figcaption>Submission page of Level 08</figcaption></figure><p>The submission flag should be this,</p><p><strong><em>spacex{SolarCity}</em></strong></p><h4>Level 09</h4><p>As a cyber-security employee players should have proper knowledge of ransomware, botnet kinds of attacks, and type of attackers because after having a clear idea of those areas they can clearly identify what kind of attacks will be there in his or her job section. Not only knowledge but also it will help them to act responsibly because of identifying the seriousness of their jobs This level has provided a video on common cyber attacks and attackers. So that player should watch that full video.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/900/1*KsD4fMXzwDt32J3FIIoBnA.png" /><figcaption>Hint Page (Level 09)</figcaption></figure><p>Then based on the video player should answer five MCQ-type questions. In order to get the flag answering all those five questions correctly is mandatory.</p><p>If you haven’t answered all questions correctly you can’t go to the next stage.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/783/1*q-0QLF575n_o4dMdW0DgBg.png" /><figcaption>MCQ Questions (i)</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/799/1*iNE03Mip8MypU1L1lK953w.png" /><figcaption>MCQ questions (ii)</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/768/1*q_12UKKaM5ACbYpGSSiloQ.png" /><figcaption>The Flag Isn’t Displayed</figcaption></figure><p>After answering the all questions correctly the player will get a string. Then the player should identify it is base 64 encoded and then he or she should decode it.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/706/1*dtFYAp1B9gzDQ_YLsISNGQ.png" /><figcaption>The Encoded Flag Is Displayed</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/804/1*7DO-rd6-N2VHVwTvjjiX9g.png" /><figcaption>Decoding By Using The Online Tool</figcaption></figure><p><a href="https://www.base64decode.org/">Base64 Decode and Encode - Online</a></p><p>After getting the flag player should go back to the submission page and submit it as shown in the hint (fig33). For this level, player will get 90 marks.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/971/1*Meb0J5ouTzsg6spVZzMtLg.png" /><figcaption>Submission page of Level 09</figcaption></figure><p>The submission flag should be this,</p><p><strong><em>spacex{Neuralink}</em></strong></p><h4>Level 10</h4><p>This level will evaluate the player’s social engineering skills. This skill is a little bit tricky because it is commonly used by attackers to get sensitive information from users to do some dirty works. But this skill is also important to cyber security employees to avoid these kinds of attacks and this can be used to get information from users and make the security system more convenient to use because the security is not important in the system not used by people.</p><p>This level has provided some massive information about some kind of invention, So the player has to find the flag by reading the content or by using the internet. The flag is the name of that invention. The name is not in this content.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/793/1*6kome5uSfDv_LraNLGuD4g.png" /><figcaption>Hint Page (Level 10) (i)</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/897/1*DkcAL4owKuOK_ZmQ7McR-A.png" /><figcaption>Hint Page (Level 10) (ii)</figcaption></figure><p>After getting the flag player should go back to the submission page and submit it as shown in the hint. For this level, player will get 95 marks.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/959/1*cohKzwb933xl2668RLrxSg.png" /><figcaption>Submission page of Level 10</figcaption></figure><p>The submission flag should be this,</p><p><strong><em>spacex{STARLINK}</em></strong></p><h4>Level 11</h4><p>The one-time pad (OTP) is an unbreakable encryption technique that uses a one-time pre-shared key that is the same size as, or longer than, the message being sent. A plaintext is combined with a random hidden key in this technique (also referred to as a one-time pad). The plaintext is then encrypted by combining each bit or character with the corresponding bit or character from the pad using the modular extension. It is an old technology but it is still unbreakable. The reason is to ignore it because it is not user-friendly. By learning these concepts as cyber security employees they can add these into new technologies. Therefore this is the right time to revise those memories.</p><p>This level has a server error page to fix this error the player has to go to the hint page to get some idea.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/828/1*G0JQ7DkRHh4x6Usjd6WP_A.png" /><figcaption>Error Page</figcaption></figure><p>On the hint page, there are two strings. The player has to identify both of the strings are encoded with base 64.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1003/1*2YcY44mgKIuux4yces-k9Q.png" /><figcaption>Hint Page (Level 11)</figcaption></figure><p>After decoding the strings there are two sentences with some capital letters by combining those letters player can get ciphertext and the key.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/870/1*YSOaX7uXV-lh_1XqwJUSQA.png" /></figure><p>Then the player has to go back to the error page and by inspecting the code he or she can see the level provided OTP.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/892/1*B8vkspfLSRFJ-1XHTsDEZQ.png" /><figcaption>One-Time Pad (OTP)</figcaption></figure><p>Using that OTP, and the key the player can decrypt the ciphertext. The decrypted output is the flag. After getting the flag player should go back to the submission page and submit it as shown in the hint. For this level, player will get 105 marks.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/910/1*k90mV4kzojLCoQGq8z9FhA.png" /><figcaption>Submission page of Level 11</figcaption></figure><p>The submission flag should be this,</p><p><strong><em>spacex{FANTASY}</em></strong></p><h4>Level 12</h4><p>Cross-Site Scripting (XSS) attacks are injection attacks in which malicious scripts are inserted into normally trustworthy and innocuous websites. XSS attacks occur when an attacker uses a web application to deliver malicious code to a particular end-user, usually in the form of a browser-side script. The flaws that cause these attacks to work are common and can be found anywhere a web application uses user input in its output without validating or encoding it. Therefore the objective of this level is to make a clear image of how the XSS works and how it can be stopped.</p><p>This level has provided a web page of Tesla car sales where the player can select any car he or she wants then the model name will be there on another page.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/785/1*3njuyy2K7SUka4_jqQLZMg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/772/1*ErRboW3RtRuTy7Co3OLcrg.png" /><figcaption>Tesla Showroom</figcaption></figure><p>You can see the below page, after click the submit button.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/879/1*Qj8pDiatP7xoi5DUo_I5GQ.png" /><figcaption>Hint Page (Level 12)</figcaption></figure><p>Then the player can be input letters whatever he or she likes (<strong>ex:-hi</strong>).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/922/1*kIYMCYOCMTNlTat4B3qMjQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/964/1*6rSi3pSMuZ9blS7t6GU76A.png" /></figure><p>Then the player should understand this is a vulnerable cite. Then player should enter a script and submit it, the script should be like this.</p><p><strong>&lt;script&gt;alert(document.cookie)&lt;/script&gt;</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/840/1*SYs9KsHqI7UWJXfY_v4m9g.png" /><figcaption><strong>&lt;script&gt;</strong></figcaption></figure><p>After that you will get an alert there is a string with the “#” mark.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/699/1*NHI4Kx_-GJEcLsIHkPezDQ.png" /><figcaption>Hashed Flag</figcaption></figure><p>Because of the hash mark player should understand the string is hashed one and it should be cracked using an online tool. That is the flag.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*XtCQTVwtoilnwAyGqztGNQ.png" /></figure><p>As well as that string which is in the alert can be taken from cookie details.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/874/1*n6KgmTSF1LQRFcd8i6iuaA.png" /><figcaption>Cookies</figcaption></figure><p>After getting the flag player should go back to the submission page and submit it as shown in the hint. For this level, player will get 120 marks.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/901/1*cH7hWarAAvhh98R63jHySA.png" /><figcaption>Submission page of Level 12</figcaption></figure><p>The submission flag should be this,</p><p><strong><em>spacex{NikolaTesla}</em></strong></p><h4>Level 13</h4><p>Colors have meaning, like that in HTML every color has a hexadecimal value to represent it, and also by converting this into ASCII it will represent a letter. So that this method is used as a steganography method to transmit some confidential messages as well this method is very unique and it is more secured because it’s not a common area to check. The objective of this level is to force them to pay much attention to these areas as an employee in cyber security unit.</p><p>This level has a moving color bar with multiple colors. From time to time the color is changing. The player can identify there are five colors in this bar.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/745/1*3gv5RFf2NhkHVNo2f51wxw.png" /><figcaption>Hint Page (Level 13)</figcaption></figure><p>On code, the inspection player can see hexadecimal values of all four colors. So that player should guess there is a connection between the flag and these values.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/773/1*UOBIyf9sFy5waMepgq39dg.png" /></figure><p>So, the player should convert all those hexadecimal values to ASCII. Why there is no letter in the fourth color.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/709/1*omTMVK2RXZ914M9t44E_1g.png" /><figcaption>Hex to ASCII Text Converter</figcaption></figure><p>Because 97 is not a hexadecimal value it is an ASCII value so it should be converting into text.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*r1HG4agdfTzqFIT40-I_1g.png" /><figcaption>ASCII To Text Converter</figcaption></figure><p><a href="https://www.duplichecker.com/ascii-to-text.php">ASCII to Text | Convert you ASCII code into Text</a></p><p>By combining all these letters player can get the flag. After getting the flag player should go back to the submission page and submit it as shown in the hint. For this level, the player will get 130 marks.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/895/1*xSfdB4pXt8lFj4W7HkhV9Q.png" /><figcaption>Submission page of Level 13</figcaption></figure><p>The submission flag should be this,</p><p><strong><em>spacex{Tosca}</em></strong></p><h4>Level 14</h4><p>This level is like a flashback level this level will examine the skills on conversions between binary, hexadecimal, and ASCII as well as you should have skills to crack the hashes and identify base 64 encoded content and decoding it as a day to day worker with computers player should have experienced these kinds of conversions. As well as employees in cybersecurity-related areas they should have the skills to identify them and a clear idea about what are the weaknesses among them.</p><p>This level has provided a <a href="https://discord.com/">discord </a>link and jpg file. In this level, the hint is also hidden. So that player should find the hint first. For that player should have a discord account. He or she can use it by discord software or online.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/884/1*93c19CKGYnGaSkR-qaXDIw.png" /><figcaption>Hint Page (Level 14)</figcaption></figure><p>There is a server in discord for this level and the invitation link for that level on the page.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/704/1*d14XiXRHfrdMf_7LLSQfYQ.png" /><figcaption>SpaceX Server</figcaption></figure><p>Then the player should download both the .jpg file and the text file in the discord server. It is useful for the jump to the next level.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/783/1*dr4uZzp-qdYWGDw9wHEJGw.png" /><figcaption>Inside the Server</figcaption></figure><p>Then the player should take the .jpg file and decode the steganography using an online tool or using Linux commands like earlier explained in level4. Use the password as <strong>teslaElon.</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/667/1*MqujuF0gn0grjCggRabamw.png" /></figure><p><a href="https://futureboy.us/stegano/decinput.html">Steganographic Decoder</a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/757/1*N_i7oKyuI7GXG2p93ANbjw.png" /></figure><p>In the hint, there are so many functions that are already done to the content of the text file so in order to find the fag player should follow the bottom to the top procedure.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/832/1*oMVUfGJXGGbLNIBpvbj3TA.png" /><figcaption>Content of the downloaded file</figcaption></figure><p>The first player should convert binary content into ASCII using an online tool.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/656/1*-1p6_mAl48PGPjY3gcyaew.png" /><figcaption>Converting binary values into ASCII</figcaption></figure><p>Then the ASCII content into text using an online tool.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/772/1*_2cH6IUCZXubjB0pGHwn1Q.png" /><figcaption>Converting ASCII into text</figcaption></figure><p>Then the player should understand the base 64 because there is a “=” sign at the end of the content. So player should decode using an online tool or Linux commands.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/785/1*F41Aif2Ql86nx7PmomoW0A.png" /><figcaption>Converting using online tool</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*SOyA4IiCjfkSRR1qY2_k3Q.png" /><figcaption>Converting using Kali Linux</figcaption></figure><p>After getting binary content convert it into hexadecimal by using an online tool.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/708/1*GarBJAMojap0soreQVpoeg.png" /><figcaption>Converting Binary values into Hexadecimal values</figcaption></figure><p>Then covert hexadecimal value to ASCII by using an online tool.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/821/1*J9mdseeg-b1Ud6vrXNb6kw.png" /><figcaption>Converting Hexadecimal values into ASCII</figcaption></figure><p>Then the player should understand again, the base 64 because there is a “=” sign at the end of the content. So player should decode using an online tool or Linux commands.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/709/1*rM5YN3_dESndrzT8_e-r7A.png" /><figcaption>Converting using the online tool</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*9tLkxTN2x8lN6-RYdNW2iQ.png" /><figcaption>Converting using Kali Linux</figcaption></figure><p>At the final stage, player has to crack the hash according to the hint by using an online tool. It is the flag for this level.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*fRSzcCboKlXQzBtPG65h1A.png" /></figure><p><a href="https://crackstation.net/">CrackStation - Online Password Hash Cracking - MD5, SHA1, Linux, Rainbow Tables, etc.</a></p><p>After getting the flag player should go back to the submission page and submit it as shown in the hint. For this level, player will get 145 marks.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/909/1*l3-f7h39KaZcaOkL3g2Ieg.png" /><figcaption>Submission page of Level 14</figcaption></figure><p>The submission flag should be this,</p><p><strong><em>spacex{Starship}</em></strong></p><p>*******************************************************************</p><p><strong><em>Now all the web-based levels are finished, lets’ move into our server levels.</em></strong></p><p><em>Fallow these guidelines.</em></p><p>• Here onwards you must store every flag you get.</p><p>• Previous flags will helpful when you are work with future levels.</p><p>• use a putty tool to connect with the server.</p><p>• ssh username@54.255.74.144 (username in simple letters).</p><p>• Use 7zip tool to unzip the files.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/828/1*K0Hy9rMdIIw5PWD4zaZEhQ.png" /><figcaption>Guidelines for next levels</figcaption></figure><h4>Level 15</h4><p>These all levels are implemented in a Linux environment. So that the best way to do this level is to by Linux environment. The main difficulty is in the Linux platform is there is no Graphical User Interface (GUI) therefore the player should use commands. As employees in the cyber security area, they should be much more familiar with this environment. Hidden folders are very common in Linux. Most of the time confidential data will be there. It is very important for security purposes. At this level, the player has to access into the Linux box and log into it using the username and password which are the CTF have earlier provided at the login.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/869/1*WjzSKcaTTuyBOejbQnhtXg.png" /><figcaption>Player_Name@IP address of the Linux Machine</figcaption></figure><ul><li>To connect with the server</li><li>Extract spacexH.zip</li></ul><p>In this level first, the player has to find the hint. So that he or she has to go to SpaceX and find the file as below.</p><p><strong>cd /home/mirror/SpaceX</strong> (Go to the directory)</p><p><strong>ls</strong> (See the content)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/792/1*PGAw0ly5Ux5FzbbDKKMw_Q.png" /><figcaption>Content of the inside SpaceX directory</figcaption></figure><p>Then the player should go into directory<strong> elon</strong> to get the <strong>hint</strong>.</p><p><strong>cd elon</strong></p><p><strong>ls</strong></p><p><strong>cat hint.txt </strong>(Read the text file)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/685/1*d2Hu6n7vsq5mmOTAV3UAiA.png" /><figcaption>Content of the text file</figcaption></figure><p>According to the hint, the player has to go back to the <strong>SpaceX </strong>directory to see the hidden content.</p><p><strong>cd .. </strong>(The directory one level up from the current directory)</p><p><strong>ls -a </strong>(See the whole content of the directory)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/614/1*5Nlho_tnPBn1tkEgzFrsNA.png" /></figure><p>There is a new directory named <strong>“.spacexH”</strong>. First, it was hidden, now go inside it and see the content.</p><p><strong>cd .spacexH </strong>(go hidden directory)</p><p><strong>ls</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/703/1*BegbSuesgQ_e6ZKTd6dHMw.png" /><figcaption>Content of the spacexH directory</figcaption></figure><p>Then read the <strong>TeslaH.txt</strong> and get the flag using <strong>cat</strong> command.</p><p><strong>cat TeslaH.txt</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/710/1*FXnTbiJll3VTg_oP3592yQ.png" /><figcaption>Content of the ‘TeslaH’ text file</figcaption></figure><p>After getting the flag, the player should go back to the submission page and submit it as shown like this spacex{}. For this level, the player will get 150 marks.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/861/1*q3CmTKN7gqAFcw61QVT7xw.png" /><figcaption>Submission page of Level 15</figcaption></figure><p>The submission flag should be this,</p><p><strong><em>spacex{Mars_planet}</em></strong></p><h4>Level 16</h4><p>As a cyber security employee, they should have a clear idea about file structure otherwise he or she will be get lost inside Linux environment in Linux files have named as directories. The objective of this level is to check how they are familiar with Linux commands without vesting time how they achieve their goal.</p><p>Then the player should see the hint page and download parth_to_mars zip file and use the previous level flag to unzip it (Mars_planet)</p><p>The player can use GUI and directly type the password and extract the file and after downloading the 7zip tool by using this command he/she can extract it using terminal only. For that method also password is needed.</p><p><strong>7z x filename</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/801/1*NNcTPHd5CiPw88inV9YQ6A.png" /><figcaption>Extraction Process</figcaption></figure><p>In that directory, the player can see many directories named by English letters and in the hint, there is a structure of a rocket is displayed.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/715/1*Cjf-2iHN9mMIZ_RPF9ylBQ.png" /><figcaption>Hint Page (Level 16)</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*He_ci_Gaq_K48qR7s1nLQQ.png" /><figcaption>Content of the level16 directory</figcaption></figure><p>If a player checks one directory in there are also many directories named by English letters. So there is a way to find the flag easily by using this command in the level16 directory.</p><ul><li><strong>cd R/O/C/K/E/T/</strong></li><li><strong>ls</strong></li><li><strong>cat Flag</strong></li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1019/1*OxJjkam37c4TAX1RQxAaVg.png" /><figcaption>Content of the ‘Flag’ text file.</figcaption></figure><p>Inside the flag, player can see the flag. After getting the flag player should go back to the submission page and submit it as shown in the hint (fig83). For this level, player will get 150 marks.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/777/1*eHwFK_dDz1N3SYllNQ5zqg.png" /><figcaption>Submission page of Level 16</figcaption></figure><p>The submission flag should be this,</p><p><strong><em>spacex{Mars_Oasis}</em></strong></p><h4>Level 17</h4><p>As a cyber security employee sometimes, they have to find something in a short time. If he or she faces a situation like that they have to find some easy way to achieve that goal. At this level also the player has to face a situation like that. There are many ways to do it but doing it in the easiest and fastest way and remember that is the objective of this level.</p><p>Then the player should see the hint page and download the Think_as_elon zip file and use the previous level flag to unzip it (Mars_Oasis) Player can use GUI and directly type the password and extract the file and after downloading the 7zip tool by using this command he/she can extract it using terminal only. For that method also password is needed.</p><p><strong>7z x filename</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/866/1*ukkAf-N_tm9MHlvScc7pqQ.png" /><figcaption>Extraction Process</figcaption></figure><p>Inside the Level 17 directory, there is a text file named “level17” when the player reads it he or she can see so many repeated lines.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/916/1*ptVvzqmn3LxqELoJpMbRPA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/868/1*FtvfRoigLT_zmWFnf24Urg.png" /></figure><p>According to the hint, player should find the unique line. In order to do that easy player has to run two commands at once.</p><p><strong>sort level17 | uniq -u</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/637/1*a-JXYCCiUQDkIQdvlv8wQw.png" /></figure><p>By this command, player can get the unique line from all those lines. That is the flag for this level. After getting the flag player should go back to the submission page and submit it as shown in spacex{} (fig88). For this level, player will get 160 marks.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/816/1*ZjPv_H3HullbKc-Gcn1qsw.png" /><figcaption>Submission page of Level 17</figcaption></figure><p>The submission flag should be this,</p><p><strong><em>spacex{Elonmusk28junenineteenseventyone}</em></strong></p><h4>Level 18</h4><p>In Linux most of the system files, password files are encoded on the other hand most of them are binary files it mans it cant be readable and for security reasons, cyber security employees should pay their attention to those unreadable files because it can be malicious in order to do that employees should separate readable and unreadable files</p><p>Then the player should see the hint page and download the reading_materials zip file and use the previous level flag to unzip it (Elonmusk28junenineteenseventyone)</p><ul><li>Player can download all the files from <a href="https://en.wikipedia.org/wiki/File_Transfer_Protocol">FTP</a> at once but to unzip those files they need the previous level flag</li></ul><p>The player can use GUI and directly type the password and extract the file and after downloading the 7zip tool by using this command he/she can extract it using terminal only. For that method also password is needed.</p><p><strong>7z x filename</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/935/1*xpbvbjfDFaLdxyVf_kMyhw.png" /><figcaption>Extraction Process</figcaption></figure><p>In the Level18 directory. There are ten text files all file names have started name “text”.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/997/1*FP0MGQ68v-lUCq9-_qQJBQ.png" /><figcaption>Ten text files</figcaption></figure><p>Most f the files have un-readable.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Ygkkoyv6i2KQBYMWYuW8NQ.png" /><figcaption>Un-readable file</figcaption></figure><p>According to the hint, flag is readable. Then the player should find the file type using this command.</p><p><strong>file text*</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/734/1*VljquHP1ZCCpo5cleDYXAQ.png" /></figure><p>“text*” part has been used because every file name starts with “text”. Only the “text06” file is ASCII type one so that it is readable, by using this command player can get the flag.</p><p><strong>cat text06</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/718/1*sIM-8PVbKV3xDEKwgbtIZQ.png" /></figure><p>After getting the flag player should go back to the submission page and submit it as shown in spacex{}. For this level, player will get 160 marks.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/899/1*zs__Wa1qxW_AGRUGvSKlBA.png" /><figcaption>Submission page of Level 18</figcaption></figure><p>The submission flag should be this,</p><p><strong><em>spacex{paypal}</em></strong></p><h4>Level 19</h4><p>When anyone works with Linux commands most of the time, they have to find some special words. That process can’t do manually because it has not any user support because it is a little bit confusing but when talking about cyber security employees these kinds of mistakes can be dangerous. The objective of this level is to teach or memorize an easy way to do it</p><p>Then the player should see the hint page and download SpaceX zip file and use the previous level flag to unzip it (Paypal)</p><ul><li>Player can download all the files from <a href="https://en.wikipedia.org/wiki/File_Transfer_Protocol">FTP</a> at once but to unzip those files they need the previous level flag</li></ul><p>The player can use GUI and directly type the password and extract the file and after downloading the 7zip tool by using this command he/she can extract it using terminal only. For that method also password is needed.</p><p><strong>7z x filename</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*iAGDJBovv3WDljoO7tcODg.png" /><figcaption>Extraction Process</figcaption></figure><p>Inside the Level19 directory, there is a level19 file in that file there are some words and strings.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/789/1*DxmlAgY0mfCEYplZMYiROg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/593/1*Yul128Cou-fgHUy8sCRasA.png" /><figcaption>words and strings</figcaption></figure><p>According to the hint, the player should find a word (Spacex) from the file, and then he or she will get the flag for that player should run two commands at once.</p><p><strong>cat level19 | grep Spacex</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/965/1*e6LBhNAkM2WlLcDEpxFO2g.png" /></figure><p>The player will get a log string with “Spacex” it is the flag for this level. After getting the flag player should go back to the submission page and submit it as shown in spacex{}. For this level, player will get 165 marks.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/898/1*SwLIZ_TStPJjjzShd-KCpw.png" /><figcaption>Submission page of Level 19</figcaption></figure><p>The submission flag should be this,</p><p><strong><em>spacex{firsthumanwilllandonmars2024as}</em></strong></p><h4>Level 20</h4><p>As cyber security employee sometimes, they get information on properties about some files at that time they have to find using those properties. An owner, size, readable or unreadable, and executable or not these are some properties files have. Using all or some properties employees can find the file. Use one by one is not possible.</p><p>Then the player should see the hint page and download the find_the_file_get_the_flag zip file and use the previous level flag to unzip it (firsthumanwilllandonmars2024as)</p><p>The player can use GUI and directly type the password and extract the file and after downloading the 7zip tool by using this command he/she can extract it using terminal only. For that method also password is needed.</p><p><strong>7z x filename</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*6suIiwTmRfaUONORsTZVuA.png" /><figcaption>Extraction Process</figcaption></figure><p>There are twenty files in the Level20 directory. Some files are readable, some are not, some are executable some are not likewise there is a wide variety of file properties.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*HpmRYXhzGAqmgIaFTJ1Riw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*RNFJNd3OiTnPkgyn2z2Hdw.png" /></figure><p>According to hint, the file size is 72 bytes and it is not an executable player should match these conditions first by this command.</p><p><strong>find -type f -size 72c ! -executable</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*E_hV7Y8On61ZFBJoc0fj1Q.png" /></figure><p>Type is file 72c means 72 bytes! shows not and then the player should find the readable one among check10 and check13. For that use the file command.</p><p><strong>file ./filename</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/971/1*-lwb9jbWwXm_hqfryyc1Gw.png" /></figure><p>Then the player will get ASCII for check10 Then the player should read the file and it is the flag.</p><p><strong>cat check10</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/932/1*62epgDJhhU6pbM88TRknlg.png" /></figure><p>After getting the flag player should go back to the submission page and submit it as shown in spacex{}. For this level, the player will get 170marks.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/898/1*tg2st1OXtMwkNfxpQC6uKA.png" /><figcaption>Submission page of Level 20</figcaption></figure><p>The submission flag should be this,</p><p><strong><em>spacex{Tesla_Roadster}</em></strong></p><p>This is the end of our CTF box and now the players has faced all twenty levels and the total</p><p>Now the player has completed all 20 levels and he or she achieved full mark of <strong>2000 </strong>and well done.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*wguhtWWtJkzxWQ2noYf62g.png" /><figcaption>Scoreboard</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*bBidjvEHUr4woDRl7adYtg.png" /><figcaption>All levels completed (won) page</figcaption></figure><p>Thank You !! :)</p><p>SpaceXCTF can be download via the below link ...</p><p><a href="https://mega.nz/folder/4NpWXZAD#Q88gLa2vZgxHwtR0chfZFw">1.66 GB folder on MEGA</a></p><p>Use the below link for the setup …</p><p><a href="https://github.com/HirushanGitHub/SpaceXCTF">GitHub - HirushanGitHub/SpaceXCTF</a></p><p><strong><em>Owned by:- Hirushan Sajindra and Ryan Dias</em></strong></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=3618498b11b0" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Static Analysis And Dynamic Analysis For Android Package Kit (APK)]]></title>
            <link>https://medium.com/@HirushanTech/static-analysis-and-dynamic-analysis-over-android-package-file-apk-6721830cb155?source=rss-e28f43841b7f------2</link>
            <guid isPermaLink="false">https://medium.com/p/6721830cb155</guid>
            <category><![CDATA[dynamic-analysis]]></category>
            <category><![CDATA[mobsf]]></category>
            <category><![CDATA[static-analysis]]></category>
            <category><![CDATA[genymotion]]></category>
            <category><![CDATA[apk]]></category>
            <dc:creator><![CDATA[Hirushan Sajindra]]></dc:creator>
            <pubDate>Tue, 27 Jul 2021 16:00:39 GMT</pubDate>
            <atom:updated>2021-08-16T07:38:18.377Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*sApOQfOlj2f1jgKJxzE5nA.jpeg" /></figure><h3><strong>What is an APK file?</strong></h3><p>An APK file is an app created for Android, Google’s mobile operating system. Some apps come pre-installed on Android devices, while other apps can be downloaded from Google Play. Apps downloaded from Google Play are automatically installed on your device, while those downloaded from other sources must be installed manually.</p><h3>What does an APK file contain?</h3><p>Android packages contain all the necessary files for a single Android program. Below is a list of the most prominent files and folders:</p><ul><li>META-INF/: Contains the manifest file, signature, and a list of resources in the archive</li><li>lib/: Native libraries that run on specific device architectures (armeabi-v7a, x86, etc.)</li><li>res/: Resources, such as images, that were not compiled into <strong>resources.arsc</strong></li><li>assets/: Raw resource files that developers bundle with the app</li><li><strong>AndroidManifest.xml</strong>: Describes the name, version, and contents of the APK file</li><li><strong>classes.dex</strong>: The compiled <a href="https://techterms.com/definition/java">Java</a> classes to be run on the device (<a href="https://fileinfo.com/extension/dex">.DEX</a> file)</li><li><strong>resources.arsc</strong>: The compiled resources, such as strings, used by the app (<a href="https://fileinfo.com/extension/arsc">.ARSC</a> file)</li></ul><h3>How do I view the contents of an APK file?</h3><p>APK files are saved in a compressed <a href="https://fileinfo.com/extension/zip">.ZIP</a> format and can be opened by any Zip decompression tool. Therefore, if you would like to explore the contents of an APK file, you can rename the file extension to “.zip” and open the file, or you can open the file directly through a Zip application’s open dialog box.</p><p><a href="https://fileinfo.com/extension/apk">APK File Extension - What is an .apk file and how do I open it?</a></p><h3>What is Static Analysis?</h3><p>Static analysis (also known as static code analysis or source code analysis) employs tools to examine program code in search of application coding vulnerabilities, back doors, or other malicious code that might provide hackers access to sensitive corporate data or consumer data. In some situations, the analysis is carried out on a certain version of the source code, while in others, it is carried out on a specific form of the object code. When static analysis scans source or object code, it evaluates the security and functionality of software when the program is not operating, which is often early in the development lifecycle. An automated tool is usually used to do static analysis.</p><p><a href="https://www.whitehatsec.com/glossary/content/static-analysis">Static Analysis</a></p><h3>What is Dynamic Analysis?</h3><p>Dynamic analysis, also known as dynamic program analysis, is the evaluation of a program or technology using real-time data. <br>This type of analysis can be performed on either a virtual or real CPU. Instead of putting code offline, vulnerabilities and program behavior may be monitored while it’s running, giving you insight into how it behaves in the real world.</p><h3>Static Vs Dynamic Analysis</h3><p>Static code analysis is done by examining the code without the need to execute the program. The process provides an understanding of the code structure and can help ensure that the code adheres to industry standards. All code is scanned to check for any vulnerabilities and ensure the code is validated.</p><p>Dynamic analysis adopts the opposite approach and is executed while a program is in operation. <a href="https://www.whitehatsec.com/wp-content/uploads/2016/01/TRC_Spotlight_Sentinel_Dynamic.pdf">Dynamic analysis</a> performs continuous and concurrent risk assessments, searching for vulnerabilities within web applications and speeding interventions.</p><p><a href="https://www.whitehatsec.com/glossary/content/dynamic-analysis">Dynamic Analysis</a></p><h3>How to do Static Analysis for an APK file ?</h3><p>First of all You should download any Android package file. You can download it using this link :-<a href="https://apkpure.com/"> https://apkpure.com/</a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/306/1*n1B1wum6Jxc4PFWRbHqJ9g.png" /></figure><p>Apk is a compressed (.zip) package that contains resources and Java assembly code. You can see files like classes.dex and resources.arsc after open.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/515/1*r3TKCWn1_Q925Lc7FCpb1g.png" /></figure><p>But above this contend cannot be read because it is not readable format. As well as you can see manifest xml file as bellow which cannot be read.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/624/1*oWAQ7MclmoDVt-6i37MK5w.png" /></figure><p>Then decode this file using apktool. The decode command is <strong>apktool d filename.apk</strong> . Then look at again AndroidManifest.xml. Now you can read it because after decoding the files convert to the human ridable format.</p><p>[As well as you can do this using <em>dex2jar tool. The dex2jar tool command is </em><strong><em>d2j-dex2jar filename.apk</em></strong><em>]</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/624/1*rlcucHMVcu_Vxza_kbk5Ew.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/624/1*1K3NxSzv03bWpsVFwmhL_A.png" /></figure><p>You can see generated files after decompilation are as follows. It has AndroidManifest.xml which I mentioned above. As well as res file and smali file.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/624/1*NQzS0JaVdQDWT4WcDjKiUQ.png" /></figure><p>Then I used <a href="https://www.virustotal.com/gui/"><strong>virustotal </strong></a>analysis tool to analyze the apk file. Then you can see 38 out of 65 files detected as malicious application.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/624/1*agktgswC7G8nxDZlw219SA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/624/1*Cgl6Rt5arWY2lQFQFhAD2w.png" /></figure><p>After downloading MobSF analysis tool you can run Docer image like this. Then open the web browser and type like this <a href="http://localhost:8000/">http://localhost:8000</a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/523/1*TqbD7ewTbdoCsk-fzT0EFQ.png" /></figure><p>After that you can see window like this. Then you should chose your apk file and upload it.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/624/1*2BBWThG_X4muPc16iKLRrA.png" /></figure><p>After that you can get analysis report like this.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/624/1*dG7NF2lZ23tN-evwQTFcXA.png" /></figure><p>This is application signer certificate. It has details about application signature. It display the certificate status and description. Determine whether or not an application originated from its original source.</p><p>Eg : Certificate Status : Good</p><p>Description : certificate looks good</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/624/1*hRtVyO09XYyU00558FyoUQ.png" /></figure><p>This importance information describe about AndroidManifest.xml. You can see red color tag and green color tag. These tags highlighted automatically.</p><p>Here analyzes the permissions and determines its critical status as well as the permissions description.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/624/1*zHYQBbpaG1c_KF52vvs34g.png" /></figure><p>Red color represent bad (not secure), green color represent secure and blue color represent normal.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/624/1*seGCoU_r1P1JycpYeSiyhg.png" /></figure><p>Basically describe the analysis of structure of the application as well as you can look at the android APIs used in the app, such as java reflection and location.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/624/1*ufLJ-QER6sbrvJ1OCCbxGw.png" /></figure><p>Reference:-</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2FaFrCjRi6T6M%3Fstart%3D177&amp;display_name=YouTube&amp;url=https%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3DaFrCjRi6T6M&amp;image=http%3A%2F%2Fi.ytimg.com%2Fvi%2FaFrCjRi6T6M%2Fhqdefault.jpg&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=youtube" width="854" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/276acd7df4c35d1fc29fc866498298c5/href">https://medium.com/media/276acd7df4c35d1fc29fc866498298c5/href</a></iframe><h3>How to do Dynamic Analysis for an APK file ?</h3><p>First of all you should download and install <a href="https://www.genymotion.com/download/"><strong>Genymotion</strong></a>. Then you should download any apk file to the Genymotion.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/371/1*StyopyxEsGRmD0unIk7HLg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/353/1*6ernQvGDx8XzbfRQRvXkxg.png" /></figure><p>After installation the apk file you can see like this.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/294/1*GEnYvpAkKiZzUXo8AyoF2w.png" /></figure><p>After that you should open BurpSuite tool. Then click the proxy and then click the option tab. After that add new proxy pressing add button.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/624/1*J_PtwPID3-2RfOstSsMYZg.png" /></figure><p>Then you can see a window as below. There are two input field. Among them one is specific address and other one is Bind to port.</p><p>Eg :- Bind to port : 8080</p><p>specific address : 198.168.56.1</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/624/1*HyxE1H7sgXVYLiVWmwsTgQ.png" /></figure><p>Then this created proxy is connect to the Google Nexus 4 of the Genymotion like this. This is done by manually. In here you also enter proxy host name and <a href="https://www.varonis.com/blog/what-is-a-proxy-server/">poxy</a> port as bellow.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/222/1*O49UDSm7tIRzDlzmC3v3RQ.png" /></figure><p>Now the Google Nexus 4 is connected with the new created proxy. Therefore, all request, response and all are transferred through the proxy. This is also can be conceded as a intermediate stage. The analysis is occurred due to the transition of data traffic through the intermediate stage.</p><p>Then you should try to register and log into this app. In that time request is occurred. This request is transferred through the intermediate stage (proxy).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/431/1*0Vv2m5HOBc81pqyag3pxYw.png" /></figure><p>Now you can see this traffic analysis related to request as bellow.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/625/1*0EMRumdpBIQc6Y2b7mJ_3w.png" /></figure><p>Now you can see the request method , host, user-agent, accept-encoding, accept-language etc related to request in this report.</p><p>Reference :-</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2FRPPEfy39aos%3Ffeature%3Doembed&amp;display_name=YouTube&amp;url=https%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3DRPPEfy39aos&amp;image=https%3A%2F%2Fi.ytimg.com%2Fvi%2FRPPEfy39aos%2Fhqdefault.jpg&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=youtube" width="640" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/3566ed62371d5284b01b9a0b167e4e38/href">https://medium.com/media/3566ed62371d5284b01b9a0b167e4e38/href</a></iframe><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=6721830cb155" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[What is the dark web and How to access it ?]]></title>
            <link>https://medium.com/@HirushanTech/what-is-the-dark-web-and-how-to-access-it-1cfa30c37a9e?source=rss-e28f43841b7f------2</link>
            <guid isPermaLink="false">https://medium.com/p/1cfa30c37a9e</guid>
            <category><![CDATA[tor]]></category>
            <category><![CDATA[sci-hub]]></category>
            <category><![CDATA[darkweb]]></category>
            <category><![CDATA[dark-web-link]]></category>
            <category><![CDATA[hiddenwiki]]></category>
            <dc:creator><![CDATA[Hirushan Sajindra]]></dc:creator>
            <pubDate>Thu, 23 Jul 2020 19:43:50 GMT</pubDate>
            <atom:updated>2023-07-16T19:01:01.084Z</atom:updated>
            <content:encoded><![CDATA[<h3>What is the Dark Web and How to Access it?</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*dXzC6MWmfg3plEPfyf-PVg.jpeg" /><figcaption>Dark Web</figcaption></figure><h3>What is the dark web?</h3><p>The dark web is a part of the internet that search engines do not index. I think You have probably heard talk of the “dark web” as a terrorist hotbed. Researchers Daniel Moore and Thomas Rid of London’s King’s College categorized the content of 2,723 live dark websites in 2015 over a five-week period and found that 57 percent hosted illegal information.</p><p>Research conducted by Dr. Michael McGuires at the University of Surrey in 2019, Through the Web of Benefits, shows things have got worse. Since 2016, the number of dark web listings that could damage a business has increased by 20 percent. Of all listings (except those that sell drugs), 60 percent could potentially hurt businesses.</p><p><strong>As illegal businesses of the dark web</strong>, You can buy credit card numbers, all sorts of drugs, weapons, counterfeit money, stolen credentials for subscriptions, hacked Netflix accounts, and software that lets you break into the computers of other people. As well as Hackers can be employed to target your computers.</p><p>But not everything is illegal, there’s a legitimate side to the dark web too. You may enter, for example, a chess club or Black Book, a social network described as “the Tor Facebook.”</p><p>You may know further information about the dark web by watching this video.</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2FmA8pNpPvrr0%3Ffeature%3Doembed&amp;display_name=YouTube&amp;url=https%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3DmA8pNpPvrr0&amp;image=https%3A%2F%2Fi.ytimg.com%2Fvi%2FmA8pNpPvrr0%2Fhqdefault.jpg&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=youtube" width="854" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/2ce6d7a8182194f43bc4f51c2475fcc1/href">https://medium.com/media/2ce6d7a8182194f43bc4f51c2475fcc1/href</a></iframe><h3>What is the difference between the Deep web and the dark web?</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*HfI3w5RKE_ZakLk_oCZ81g.png" /><figcaption><a href="https://medium.com/digital-marketing-lab/the-difference-between-the-deep-web-and-the-dark-web-ec5a94b3655f">https://medium.com/digital-marketing-lab/the-difference-between-the-deep-web-and-the-dark-web-ec5a94b3655f</a></figcaption></figure><p>Many times the two terms are used interchangeably as if they are more or less the same thing. This is very inaccurate, as the deep web just refers to non-indexed pages, while the dark web refers to pages that are both non-indexed and involved in illegal niches.</p><p>This image using an iceberg metaphor should clear it up in an easier to comprehend way. As you can notice, ironically, the dark web is actually deeper than the deep web.</p><p><strong>The bottom line is this</strong>: the deep web might be made of up of non-indexed pages simply because search engines fail to see them or because they’re not deemed relevant enough to be indexed. In contrast, the dark web wants to be hidden, since it’s a hub for shady business on purpose.</p><p>The deep web is ethically neutral, it can be used for good or for bad. The dark web is where the parts of a moral-lacking economy and society come together.</p><p>As far as the relationship between them goes, not all deep web is the dark web, but all dark web is the deep web.</p><p><a href="https://heimdalsecurity.com/">Heimdal Security - Proactive Cyber Security Software</a></p><h3>What is the Tor browser?</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/620/1*RE8xswQ8rFMdqy7cSO9Jaw.jpeg" /></figure><p>You can access the dark web using the Tor browser. More information about the Tor browser is below…</p><p>The Tor Browser is a web browser that anonymity your web traffic using the Tor network, making it easy to protect your identity online.</p><p>If you’re investigating a competitor, researching an opposing litigant in a legal dispute, or just think it’s creepy for your ISP or the government to know what websites you visit, then the Tor Browser might be the right solution for you.</p><p>A few caveats: Browsing the web over Tor is slower than the clarinet, and some major web services block Tor users. Tor Browser is also illegal in authoritarian regimes that want to prevent citizens from reading, publishing, and communicating anonymously. Journalists and dissidents around the world have embraced Tor as a cornerstone of democracy online today, and researchers are hard at work improving Tor’s anonymity properties.</p><p>You can download the Tor Browser from bellow link..</p><p><a href="https://www.torproject.org/">The Tor Project | Privacy &amp; Freedom Online</a></p><h3>What are the Most popular .onion websites on the dark web?</h3><h3>The .onion site of Facebook</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/670/1*7yeh_V0FDK2SBPEIH6vNiA.png" /><figcaption>Facebook page from Tor browser</figcaption></figure><p>Facebookcorewwwi.onion is a website that allows Facebook to be accessed via the Tor protocol, using its top-level domain. It had been used by more than 1 million people monthly in April 2016. Now you can understand this site is a very popular site on the dark web. <br>Neither Twitter nor Google runs sites via Tor, and Facebook has been praised for permitting such access, which allows it accessible in countries that are actively attempting to block Facebook.</p><p><a href="https://www.facebookcorewwwi.onion/"><strong>https://www.facebookcorewwwi.onion/</strong></a></p><p>You can get an idea, of how to browse Facebook over the Tor from this site…</p><p><a href="https://www.makeuseof.com/tag/can-officially-browse-facebook-tor/">How to Browse Facebook Over Tor in 5 Steps</a></p><h3>The actual CIA</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/725/1*iVdxFG4_0H8J1Us6q2L4wg.png" /><figcaption>The actual CIA</figcaption></figure><p>This website is an actual CIA site. You can access this site using the below link.</p><p><a href="http://ciadotgov4sjwlzihbbgxnqg3xiyrg7so2r2o3lt5wz5ypk4sxyjstad.onion/"><strong>ciadotgov4sjwlzihbbgxnqg3xiyrg7so2r2o3lt5wz5ypk4sxyjstad.onion</strong></a></p><p>Tor has a very unlikely past. It was built by the U.S. First Navy to help informants posted abroad re-transmit details securely. In that context, the CIA has launched an Onion platform to help secure access to its services by people around the world.</p><h3>The Hidden Wiki</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/1*jlHX9cNJgUj9PT1PyBuCVw.png" /><figcaption>Hidden Wiki</figcaption></figure><p>Wikipedia provides a lot of connections to a wide variety of services and sources running on the dark web. Many of those connections are dead, and many more are connected to scams or potentially illegal activities. Therefore you should Select anything carefully.</p><p><a href="http://zqktlwiuavvvqqt4ybvgvi7tyo4hjl5xgfuvpdf6otjiycgwqbym2qad.onion/wiki/index.php/Main_Page"><strong>http://zqktlwiuavvvqqt4ybvgvi7tyo4hjl5xgfuvpdf6otjiycgwqbym2qad.onion/wiki/index.php/Main_Page</strong></a></p><h3>Sci-Hub</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/640/1*0cWQdUY9RTPIlVh3Z0N4TQ.png" /></figure><p>Sci-Hub is the scientific knowledge platform of the world. It hosts over 50 million research papers and makes them available for free. As well as provides unparalleled access to the collective knowledge of the world to underfunded research institutions, as well as individuals, something likely to accelerate the quest for an end to diseases, droughts, and poverty for humanity. Therefore we can express that this site is not harmful. As well as this site is more useful for knowledge seekers.</p><p><a href="http://scihub22266oqcxt.onion/"><strong>http://scihub22266oqcxt.onion/</strong></a></p><p>More, popular websites of the dark web…</p><p>The BBC: <a href="https://www.bbcnewsv2vjtpsuy.onion/"><strong>https://www.bbcnewsv2vjtpsuy.onion/</strong></a><br>The New York Times: <a href="https://www.nytimes3xbfgragh.onion/"><strong>https://www.nytimes3xbfgragh.onion/</strong></a><br>The Pirate Bay: <a href="http://uj3wazyk5u4hnvtk.onion/"><strong>http://uj3wazyk5u4hnvtk.onion/</strong></a></p><p><strong><em>Source:-</em></strong></p><p><a href="https://www.expressvpn.com/blog/best-onion-sites-on-dark-web/">20 Best Onion Sites on the Dark Web (2022) | ExpressVPN Blog</a></p><p>You should Know this before accessing the dark web. :)</p><p>How to access the dark web safely:-</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2FVUIhQoHgyeU&amp;display_name=YouTube&amp;url=https%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3DVUIhQoHgyeU&amp;image=http%3A%2F%2Fi.ytimg.com%2Fvi%2FVUIhQoHgyeU%2Fhqdefault.jpg&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=youtube" width="854" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/3192177b3e6e27823f46290df179dd20/href">https://medium.com/media/3192177b3e6e27823f46290df179dd20/href</a></iframe><p>Thank you for taking the time to read this blog post. Stay safe …. :)</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=1cfa30c37a9e" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Exploiting Vulnerabilities (Windows 2000)]]></title>
            <link>https://medium.com/@HirushanTech/exploiting-vulnerabilities-windows-2000-1e27de00ab56?source=rss-e28f43841b7f------2</link>
            <guid isPermaLink="false">https://medium.com/p/1e27de00ab56</guid>
            <category><![CDATA[windows-2000]]></category>
            <category><![CDATA[nmap]]></category>
            <category><![CDATA[nessus]]></category>
            <category><![CDATA[msfconsole]]></category>
            <dc:creator><![CDATA[Hirushan Sajindra]]></dc:creator>
            <pubDate>Tue, 16 Jun 2020 16:16:57 GMT</pubDate>
            <atom:updated>2020-06-16T16:16:57.496Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*g1F32bKwsC3GeqC5e25hDg.png" /><figcaption>Windows 2000 Server</figcaption></figure><h3>About Windows 2000</h3><p><strong>Windows 2000</strong> (also known as <strong>Win2K</strong>, <strong>W2K</strong>, <strong>Win2000</strong> or <strong>Windows 2K</strong>) is an <a href="https://simple.wikipedia.org/wiki/Operating_system">operating system</a> that was designed to work with computers that have either single or multiple processors. It was designed for <a href="https://simple.wikipedia.org/wiki/32-bit">32-bit</a> <a href="https://simple.wikipedia.org/wiki/Intel">Intel</a> <a href="https://simple.wikipedia.org/wiki/X86">x86</a> computers. It is part of the Microsoft Windows NT line of operating systems and was released to manufacturing on December 15, 1999 and officially on February 17, 2000. Windows 2000 comes in four versions: Professional, Server, Advanced Server, and Datacenter Server. Additionally, Microsoft offers Windows 2000 Advanced Server — Limited Edition and Datacenter Server — Limited Edition, which were released in 2001 and runs on 64-bit Intel Itanium processors. Windows 2000 was designed for businesses, but it was also popular with home users. A Home Edition of Windows 2000, codenamed Neptune, was planned, but was never released.</p><p>Windows 2000 uses two ‘modes’ — a ‘User Mode’ and a ‘Kernel Mode’. The Kernel Mode is specially for hardware drivers (drivers tell the computer how to ‘speak’ to something) and allows drivers to ‘speak’ to things in the computer. The User Mode is for <a href="https://simple.wikipedia.org/wiki/Computer_programs">computer programs</a> to run in without fear of causing harm to the computer.</p><p>All versions of Windows 2000 have things in common, including many system utilities such as the Microsoft Management Console (MMC) and standard system management applications such as a disk defragmentation utility. There is lots of support for different languages and for people with disabilities. Windows 2000 supports the Windows NT <a href="https://simple.wikipedia.org/wiki/Filesystem">filesystem</a> <a href="https://simple.wikipedia.org/wiki/NTFS">NTFS</a> 5, the <a href="https://simple.wikipedia.org/w/index.php?title=Encrypted_File_System&amp;action=edit&amp;redlink=1">Encrypted File System</a> (EFS), as well as basic and dynamic disk storage. Dynamic disk storage allows different types of volumes to be used (a volume is an area of storage on a hard disk that has been <a href="https://simple.wikipedia.org/w/index.php?title=Formatted&amp;action=edit&amp;redlink=1">formatted</a> with its own file system structure). The Windows 2000 Server version has many more features, including the ability to provide <a href="https://simple.wikipedia.org/w/index.php?title=Active_Directory&amp;action=edit&amp;redlink=1">Active Directory</a> services (a way of organising resources such as printers, users and group), a distributed file system (a file system that supports sharing of files) and fault-redundant storage volumes.</p><p>Windows 2000 can be installed and deployed to an <a href="https://simple.wikipedia.org/w/index.php?title=Enterprise&amp;action=edit&amp;redlink=1">enterprise</a> through either an attended or unattended installation. Unattended installations rely on the use of answer files to fill in installation information, and can be performed through a bootable CD using Microsoft Systems Management Server (SMS), by the System Preparation Tool (Sysprep).</p><h4><em>reference :- </em><a href="http://www.wikipedia.org/"><em>WWW.wikipedia.org</em></a></h4><h3>How to Exploiting Vulnerabilities of Windows 2000</h3><p>First of all You should ensure that KALI machine and Windows 2000 machine are established on same network.It can be check as bellow…</p><p>Start kali linux 1.0.3 version. Then open terminal of kali linux os. After that type the ifconfig command in the terminal. Then you can see the IP address of kali linux.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/481/1*DOE6WOyHqZF_j27x7Q9rKg.png" /><figcaption>Checking IP address of KALI machine</figcaption></figure><p>Start the windows 2000 OS. Then open command prompt (cmd) of windows. Then type ipconfig in the cmd. Then you can see IP address of the machine which has windows 2000.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/481/1*QCI4fKISyu8pe8evcXufGg.png" /><figcaption>Checking IP address of Windows machine</figcaption></figure><p><strong>PING EACH MACHINE FROM THE KALI LINUX MACHINE TO ENSURE WE HAVE FULL CONNECTIVITY.</strong></p><p>Then apply the <strong>ping</strong> command with windows IP address on kali terminal and check whether it is connected or not with the windows machine.</p><p>Then apply the <strong>ping</strong> <strong>[IP address of windows machine]</strong> command and check whether it is connected or not with the windows machine.</p><p>Ping or Packet Internet Groper is a network administration utility used to check the connectivity status between a source and a destination computer/device over an IP network. It also helps you assess the time it takes to send and receive a response from the network.</p><p>We all have our favorite websites that we frequently visit; if any of these does not load, we really want to know why it happened. Is it because we don’t have an internet connection or is it the issues with our internet service provider preventing us from accessing the website. Another reason might be the unavailability of the website itself. No matter what the reason, the Linux Ping command can provide you with all the answers.</p><p>Ping uses the ICMP(Internet Control Message Protocol) to send and receive echo messages from and to the host and destination computers respectively to tell us about the performance of the network. An ICMP request message is sent to the destination computer; if the destination IP address is available, it sends an ICMP message response to the host computer. This tells us about the connectivity status of the network such as round-trip time-the time taken to send and receive a packet of information.</p><p><a href="https://vitux.com/linux-ping-command/">The Linux Ping Command</a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/481/1*o7EdMC5C4RxfXArdFhga-g.png" /><figcaption>Check the connection using ping command on KALI</figcaption></figure><p>Then apply the ping [IP address of kali machine] command and check whether it is connected or not with the kali machine.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/489/1*VL7uvRXqsGah8Vk4hAA93A.png" /><figcaption>Check the connection using ping command on Windows</figcaption></figure><p>Then type nmap –O [target IP address] on kali machine. This command is used for looking OS and open ports of the hacking machine.</p><h4>What is Nmap?</h4><p>Nmap, or Network Mapper, is an open source Linux command line tool for network exploration and security auditing. With Nmap, server administrators can quickly reveal hosts and services, search for security issues, and <a href="https://phoenixnap.com/kb/nmap-scan-open-ports">scan for open ports</a>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/505/1*jFEW6ybZaYjBA17wsMPDew.png" /><figcaption>Type nmap –O [target IP address (Windows IP address)]</figcaption></figure><p>You can see the output of the nmap as follows.</p><p><strong>NMAP — USING NMAP TO IDENTIFY OS VERSION AND SERVICES ON THE VULNERABLE MACHINES.</strong></p><p>When the scan finished we can see all available open ports in windows 2000 that we can attack.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/475/1*n8XY8zkO9Vb5c2y6rg5dfw.png" /><figcaption>Output of nmap command</figcaption></figure><p>Then type service nessusd start.</p><p>What is nessus ?</p><p>Nessus is an open-source network vulnerability scanner that uses the Common Vulnerabilities and Exposures architecture for easy cross-linking between compliant security tools. Nessus employs the Nessus Attack Scripting Language (NASL), a simple language that describes individual threats and potential attacks.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/487/1*lZJBMubhboa3tpa_uweCow.png" /><figcaption>Start nessus</figcaption></figure><p>Start nessusd using command and Open a browser and browse to</p><p><a href="https://127.0.0.1:8834/"><strong>https://127.0.0.1:8834</strong></a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/552/1*4pDCZKACWyWuinH66tBzSw.png" /><figcaption>Nessus</figcaption></figure><p>Then go to scan template and new scan. After that type new scan name and target IP address of hacking machine. Then find weakness witch are related to the hacking machine.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/565/1*mV1YqC2Mr7ruBUjnBLDCNQ.png" /><figcaption>Inside of nessus</figcaption></figure><p>You can see the output like this.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/531/1*C_UjDt_z5rP5BI-XzKuRpA.png" /><figcaption>Vulnerabilities of Windows 2000 machine</figcaption></figure><p>Then type service apache2 start and service <strong>postgreSQL</strong> start to start this services.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/501/1*CUqkyhJ6kz_NIxAajb83cg.png" /><figcaption>Start postgreSQL</figcaption></figure><p>Then type <strong>msfconsole</strong> for start that tool.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/483/1*5N9VZrXJ3EA0QrdTDZomtw.png" /><figcaption>Start msconsole</figcaption></figure><p>Then select one of vulnerabilities in nessus tool.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/466/1*q1VkMB9Cz-Xu3rzfnNQfEQ.png" /><figcaption>select one of vulnerability</figcaption></figure><p>After that search vulnerabilities. Then you can see output like this. After that type use command and copy link as the image. We can use exploit which is in the relevant link by using <strong>use</strong> command as this way. (step 01)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/466/1*1ubmUqXAo3tcgTXo2Q6sqg.png" /></figure><p>Then type show options in the terminal. Options which are related to the exploit can be seen from this. (step 02)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/451/1*X1hNM2K0hTxKvjxwjsJ4Dg.png" /></figure><p>v Then type <strong>set RHOST [target IP address]</strong>.Here IP address of the hacking machine is set by this set <strong>RHOST</strong> command. (step 03)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/453/1*XTDMjpFoZWZX7SDZgKZ28w.png" /></figure><p>Then type exploit key word in the command. Now the machine, Windows 2000 has been hacked (step 04)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/441/1*fw7k3meiJNWFwqPJztDhtg.png" /><figcaption>hacked windows 2000 mechine</figcaption></figure><p>Now you can get data of window 2000 machine from KALI machine.</p><p>You can watch this video for more…</p><p><strong><em>Referance :- </em></strong><a href="https://www.youtube.com/channel/UCnm4xnMsEb8p0J-kKZheuhQ"><strong>CyberLK Home</strong></a><strong> (YouTube)</strong></p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2FLPiLS0N48Pw%3Fstart%3D86%26feature%3Doembed%26start%3D86&amp;display_name=YouTube&amp;url=https%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3DLPiLS0N48Pw&amp;image=https%3A%2F%2Fi.ytimg.com%2Fvi%2FLPiLS0N48Pw%2Fhqdefault.jpg&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=youtube" width="854" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/4fd1d7319f2bdf99d055bd8e7df6f0dc/href">https://medium.com/media/4fd1d7319f2bdf99d055bd8e7df6f0dc/href</a></iframe><p>You can get, Exploiting Vulnerabilities (Windows 2000) PDF from my GitHub Account.</p><p><a href="https://github.com/HirushanGitHub/Exploiting-Vulnerabilities-Windows-2000-.git">HirushanGitHub/Exploiting-Vulnerabilities-Windows-2000-</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=1e27de00ab56" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Exploiting Vulnerabilities]]></title>
            <link>https://medium.com/@HirushanTech/exploiting-vulnerabilities-90c416047c35?source=rss-e28f43841b7f------2</link>
            <guid isPermaLink="false">https://medium.com/p/90c416047c35</guid>
            <category><![CDATA[metasploit-framework]]></category>
            <category><![CDATA[kali-linux]]></category>
            <category><![CDATA[nessus]]></category>
            <category><![CDATA[vulnerability]]></category>
            <category><![CDATA[msfconsole]]></category>
            <dc:creator><![CDATA[Hirushan Sajindra]]></dc:creator>
            <pubDate>Mon, 04 May 2020 18:26:31 GMT</pubDate>
            <atom:updated>2020-07-23T04:08:52.624Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/780/1*KWShj9y941Q-Tij2ulMJ-w.jpeg" /></figure><h3>What is Metasploit?</h3><p>The Metasploit Framework is a Ruby-based, modular penetration testing platform that enables you to write, test, and execute exploit code. The Metasploit Framework contains a suite of tools that you can use to test security vulnerabilities, enumerate networks, execute attacks, and evade detection. At its core, the Metasploit Framework is a collection of commonly used tools that provide a complete environment for penetration testing and exploit development.</p><p><a href="https://metasploit.help.rapid7.com/docs/msf-overview">Metasploit Framework</a></p><p>First of all open terminal of Kali linux os. Then type ifconfig command. The IP address can be seen by using this command.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/755/1*LrgkCGYyr1IIlOWjYq_OOg.png" /><figcaption>Check the IP address of the KALI Linux</figcaption></figure><p>Then open Metasploit machine and type “<strong>ifconfig”</strong> command for seeing IP address of the<strong> “Metasploit machine.”</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/722/1*kmgIcQqC_N1LOHJ86K1BNQ.png" /><figcaption>Check the IP address of the Metasploit Framework</figcaption></figure><p>PING EACH MACHINE FROM THE KALI LINUX MACHINE TO ENSURE WE HAVE FULL CONNECTIVITY.</p><p>Then apply the “<strong>ping”</strong> command with <strong>metasploitable IP address</strong> on kali terminal and check whether it is connected or not with the <strong>metasploitable machine.</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/731/1*A4J995UiqLhzPIHdGJVWLA.png" /><figcaption>Full connectivity is checked in the KALI</figcaption></figure><p>Then apply the<strong> “ping [IP address of kali machine]”</strong> command on metasploitable and check whether it is connected or not with the kali machine.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/722/1*wp9vTKWEOTXVFANibYg4JQ.png" /><figcaption>Full connectivity is checked in the Mata Framework</figcaption></figure><p>Then type<strong> “nmap –O [target IP address]”</strong> on kali terminal. This command is used for looking OS and open ports of the hacking machine.</p><p>You can see the output of the<strong> “nmap”</strong> as follows.</p><p>When the scan finished we can see all available open ports in metasploitable that we can attack.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/833/1*_ZciEujfI88_jjbVMiTkSw.png" /><figcaption>part of the available open ports of Mata Framework</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/832/1*35ZcDKkG-pp8yb_tmd5lZw.png" /><figcaption>remaining ports</figcaption></figure><p>Then type “<strong>service nessusd start”</strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/834/1*loaY9oK3sDr7Nl4dFO7Xtw.png" /><figcaption>starting Nessus</figcaption></figure><h3>What is Nessus ?</h3><p>Nessus is an open-source network vulnerability scanner that uses the Common Vulnerabilities and Exposures architecture for easy cross-linking between compliant security tools. Nessus employs the Nessus Attack Scripting Language (NASL), a simple language that describes individual threats and potential attacks.</p><p>Nessus has a modular architecture consisting of centralized servers that conduct scanning, and remote clients that allow for administrator interaction. Administrators can include NASL descriptions of all suspected vulnerabilities to develop customized scans. Significant capabilities of Nessus include:</p><ul><li>Compatibility with computers and servers of all sizes.</li><li>Detection of security holes in local or remote hosts.</li><li>Detection of missing security updates and patches.</li><li>Simulated attacks to pinpoint vulnerabilities.</li><li>Execution of security tests in a contained environment.</li><li>Scheduled security audits.</li></ul><p>The Nessus server is currently available for Unix, Linux and FreeBSD. The client is available for Unix- or Windows-based operating systems.</p><p><a href="https://searchnetworking.techtarget.com/definition/Nessus">What is Nessus? - Definition from WhatIs.com</a></p><p>Start nessusd using command and Open a browser and browse to <a href="https://127.0.0.1:8834/">https://127.0.0.1:8834</a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/897/1*XjTjVaXDnvRHM7KJlPTbGA.png" /><figcaption>Vulnerability scanner</figcaption></figure><p>Then go to scan template and new scan. After that type new scan name and target IP address of hacking machine. Then find weakness witch are related to the hacking machine.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*VFPQ_zurt4VFsjUb8n8QuA.png" /><figcaption>find weakness witch are related to the hacking machine</figcaption></figure><p>You can see the output like this.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/988/1*c-QAmXlYRz9aY9bwTE5nOg.png" /><figcaption>show weakness of Mata Framework</figcaption></figure><h3>Start apache and mysql at boot on Kali Linux</h3><p>Apache and mysql are installed by default in Kali Linux. They can be accessed through the Kali Linux menu in Applications. To start apache web server click the menu entry at “Applications &gt; Kali Linux &gt; System Services &gt; HTTP &gt; apache2 start”. Similary to start mysql click MySQL &gt; mysql start.</p><p>However starting services manually everytime is a waste of time and its better to get them to start automatically at boot.</p><p>To configure services like apache, mysql etc to start automatically at bootup just execute the following simple commands.</p><h3>Apache</h3><p>The following command will configure apache to start at bootup.</p><pre>root@kali:~# update-rc.d apache2 enable<br>update-rc.d: using dependency based boot sequencing</pre><h3>Mysql</h3><p>The following command will configure mysql to start at bootup.</p><pre>root@kali:~# update-rc.d mysql enable<br>update-rc.d: using dependency based boot sequencing</pre><h3>Postgresql</h3><p>Postgresql is used by metasploit for caching data. Therefore its better to get it started at bootup as well. Command is similar to the above ones.</p><pre>root@kali:~# update-rc.d postgresql enable<br>update-rc.d: using dependency based boot sequencing</pre><p><a href="https://www.binarytides.com/start-apache-and-mysql-at-boot-on-kali-linux/">Start apache and mysql at boot on Kali Linux</a></p><p>Then type “<strong>service apache2 start”</strong> and “<strong>service postgreSQL start”</strong> to start this services.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/836/1*Ni1rRiVNWF-UlJnp6MpWwA.png" /><figcaption>service start apache and postgresql</figcaption></figure><h3>Accessing MSFconsole</h3><p>MSFconsole provides a command line interface to access and work with the Metasploit Framework. The MSFconsole is the most commonly used interface to work with the Metasploit Framework. The console lets you do things like scan targets, exploit vulnerabilities, and collect data.</p><p>Type “<strong>msfconsole” </strong>for start that tool.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/840/1*B93RibSDZaFFTU5k0pT1zQ.png" /><figcaption>Starting of msfconsole tool</figcaption></figure><p>Then select one of vulnerabilities.</p><h4>Vulnerabilities (01)</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*imyRSFsFfRgcEPd0ZfDATw.png" /><figcaption>vsftpd smiley face backdoor</figcaption></figure><p>After that <strong>search</strong> vulnerabilities. Then you can see output like this (fig 14). After that type use command and copy link as the image. We can <strong>use</strong> exploit which is in the relevant link by using <strong>use </strong>command as this way (fig 15)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/839/1*IM068tUGM_0x6YbJUTzwtA.png" /><figcaption>fig 14</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/838/1*ZBwX-2JhUO6HOhHvJvDajQ.png" /><figcaption>fig 15</figcaption></figure><p>Then type <strong>“show options”</strong> in the terminal. Options which are related to the exploit can be seen from this.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/840/1*Edx1DSlEJBoS0kxy7F080g.png" /><figcaption>show options</figcaption></figure><p>Then type <strong>“set RHOST [target IP address]”</strong>.Here IP address of the hacking machine is set by this “<strong>set RHOST”</strong> command.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/834/1*_aTrpr3HvxiWWM_pIMiiBg.png" /><figcaption>set target IP address</figcaption></figure><p>Then type<strong> “exploit”</strong> key word in the command. Now the machine, metasploitable has been hacked.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/835/1*qlpedkMAkjmm2Hefsv9qNQ.png" /><figcaption>Now the meta framework is Hacked</figcaption></figure><p>Now check Currant IP address using “<strong>ifconfig”</strong> command.The IP address is hacking machine IP address.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/835/1*YY9dV188iVSwevvEZAXLnQ.png" /><figcaption>Currant IP address</figcaption></figure><p>Now we can type “<strong>reboot” </strong>command on kali terminal (fig 20). After that metasploitable machine is rebooting (fig 21).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/839/1*b96RCnU3JuCRA7h9m9C3qw.png" /><figcaption>Type reboot command (fig 20)</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/719/1*gVxocMkZpxRQFNAmCH6nlA.png" /><figcaption>Rebooting the Metasploit Framework(fig 21)</figcaption></figure><p>Using these base mechanism we can hack Webcam from Kali Linux. :)</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=90c416047c35" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Quick sort Algorithm]]></title>
            <link>https://medium.com/@HirushanTech/quick-sort-algorithm-8b465e05501a?source=rss-e28f43841b7f------2</link>
            <guid isPermaLink="false">https://medium.com/p/8b465e05501a</guid>
            <category><![CDATA[quick-sort-algorithm]]></category>
            <category><![CDATA[functional-programming]]></category>
            <category><![CDATA[algorithms]]></category>
            <category><![CDATA[for-loop]]></category>
            <category><![CDATA[data-type]]></category>
            <dc:creator><![CDATA[Hirushan Sajindra]]></dc:creator>
            <pubDate>Wed, 22 Apr 2020 16:39:25 GMT</pubDate>
            <atom:updated>2024-02-07T02:53:49.127Z</atom:updated>
            <content:encoded><![CDATA[<p>Here Quick sort algorithm is used for array sorted. Initially here, there are <strong>ten</strong> numbers are taken as user input to the array which has size 10 and known as “<strong>A</strong>”</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/503/1*CHMjWXBz2BkXjenGyxwOEw.png" /><figcaption>User Input values</figcaption></figure><p>Here ten numbers are entered to the system by the user. Then original order of the entered numbers, ascending order of the entered numbers and median of the created ascending order are received as the output.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/743/1*A2-LapPRm9RfUqe2REJLhQ.png" /><figcaption>Output</figcaption></figure><p><strong><em>Source code is executed as below…</em></strong></p><p>Normally the execution of source code is started from the main function. At first an integer type array called as “ A ” is created in the “ main function ”. It means that the data type of this array is integer type. It is an empty array which has size 10. After that a variable is created which is called as “ i ”(data type is integer) for running <strong>for loops</strong>. Median variable is also crated under the <strong>float</strong> data type. Here float data type is used because, decimal numbers are most tended to receive as values. Taking of user input (numbers) and storing of these numbers to the array “A” are done by the first <strong>for loop</strong>.</p><p>After that “ !!!!!!! original Array !!!!!!! “ is printed by the <strong>printf</strong>. After running of it, the user input numbers are printed according to the original order due to the running of <strong>next for loop</strong>. Here all the numbers which were input are printed. After that “ @@@@@ Sorted Array @@@@@ “ is printed by the <strong>printf. </strong>After printing that, a calling is occurred from this “qsort(A,0,9)” to the “ qsort “ function with three parameters. The parameters are the array called “ A ”, first index (0) of it and last index (9).In the <strong>qsort function</strong> a calling is occurred by the q = partition(A,p,r) to the function which is called “ partition ” for preparing the values which are input by the user according to the <strong>ascending order</strong>. <strong>qsort function </strong>is recursion function.</p><p><strong><em>What is the recursion function ..</em></strong></p><p><strong><em>A Recursive function is a function that calls itself during its execution. When calling, the parameters takes less values than the parameters which are at the beginning of the function</em></strong><em>.</em></p><p><strong>More datails….</strong></p><p><a href="https://techterms.com/definition/recursivefunction">Recursive Function</a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/562/1*NoFgJ4VGkE-8vZOu6Lfmnw.png" /><figcaption>qsort function</figcaption></figure><p>An integer called “ q “ has been created in the<strong> qsort function</strong>. After that “p” value (first index of the “A” array) is checked that whether it is less or not than “ r ” value (last index of the “ A ”array) by an if condition. If the condition is true, the line, q = partition(A,p,r) is executed. In <strong>qsort function</strong>, a calling occurred to <strong>partition function </strong>with three parameters by the executing of this line. When the running of this line for the first time, the parameter values are which were the values sent from the <strong>main function</strong> to the <strong>qsort function. </strong>They are the array called “ A ”, first index in the array and the last index of the array. Partition function is as below.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*4Bdke84VGq-eToFy3_c1dg.png" /><figcaption>partition function</figcaption></figure><p><strong>Partition function</strong> and remained two lines of the <strong>qsort function</strong> can be described using a diagram with the simple example as below. (This is not pseudocode and the array of the pseudocode is stared from 1 to n. Here the array is stared from 0 to n.)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/723/1*KU6uG39MePU0nzk6GOkSsA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/838/1*eAPxZh9Xmo3J7dng96sfLA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/848/1*0-5CXM3lz4g7h7fkBk2n4w.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/837/1*um8ED7YWmndrHqh-3BO3OQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/846/1*F2SoBTjKI8TOK6vQzRGPNA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/844/1*313M0CXjBvuxl74SI1nnBQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/844/1*km25q9tfT88JtwTYNBf66w.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/846/1*owGS3rnhd1v0jcoRDOJnbw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/846/1*F6XEMCOMdWcMVVmLJzb3PQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/844/1*21MsXTEUfUd2N9f1miyW8Q.png" /></figure><p>Here, call is occurred with the shown three parameters from the<strong> qsort function to qsort function </strong>(recursion function). <strong>qsort function </strong>runs from start again. A calling is occurred to the <strong>partition function</strong>, if the if condition is true. Here length of the array from 0 to 5 is sorted.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/992/1*SgvevCMC6i7pJql_XH-85A.png" /></figure><p>Here also, call is occurred with the shown three parameters from the<strong> qsort function to qsort function </strong>(recursion function). Here, calling is occurred to partition function again. Here length of the array from 7 to 9 is sorted.</p><p>As this way execution is occurred until if condition is false in the <strong>qsort function</strong>. After the sorting of array called “ A ” , this array is printed as one by one a for loop in the main function. As finally, to calculate median of sorted array, the values of 4th index (A[4]) and the 5th index (A[5]) are added together and the sum is divided by 2 and this value is printed.</p><p>Source code available in my GitHub account…</p><p><a href="https://github.com/HirushanGitHub/Quick-sort-Algorithm.git">HirushanGitHub/Quick-sort-Algorithm</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=8b465e05501a" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Synchronizer Token Pattern]]></title>
            <link>https://medium.com/@HirushanTech/synchronizer-token-pattern-f5f4406e3dfd?source=rss-e28f43841b7f------2</link>
            <guid isPermaLink="false">https://medium.com/p/f5f4406e3dfd</guid>
            <category><![CDATA[ajax-call]]></category>
            <category><![CDATA[stp]]></category>
            <category><![CDATA[cookies]]></category>
            <category><![CDATA[csrf]]></category>
            <category><![CDATA[csrf-token]]></category>
            <dc:creator><![CDATA[Hirushan Sajindra]]></dc:creator>
            <pubDate>Sat, 18 Apr 2020 03:25:08 GMT</pubDate>
            <atom:updated>2020-04-30T07:28:45.237Z</atom:updated>
            <content:encoded><![CDATA[<h3>CROSS SITE REQUEST FOGERY (CSRF)</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/900/1*Md5vYS94SYAZaJqf9_pR3Q.jpeg" /><figcaption>What is CSRF ?</figcaption></figure><p>Cross-site-request-forgery (CSRF) is an attack.Here unauthorized user perform unexpected task to a web site by trapping authorized user when login.CSRF is also known as XSRF,Sea Surf or Session Riding.</p><p>A successful CSRF attack can result in damaged client relationship,unauthorized fund transfers,Change password and data theft by stealing session cookies.CSRF are conducted using malicious social engineering such as email or link.Here the victim is tended to send a forged request to a server from this email or link.Because of sending the forged request by the authorized user at the time of the attack,the server can’t identify whether the request is legitimate request or forged request.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/1*o6UZHEYaeWMmowHEgZAj5w.png" /><figcaption><a href="https://www.imperva.com/learn/application-security/csrf-cross-site-request-forgery/">https://www.imperva.com/learn/application-security/csrf-cross-site-request-forgery/</a></figcaption></figure><p>Request agent is validated by using cookies because of the HTTP is a stateless protocol.It is not required to type user credential for each attempt, after login to a website once.Therefore the server side generates a session identifier to identify the user.This session identifier is sent to the client side as a set cookie header in the first response.Then the cookie sent by server side is saved in the client browser.Now with every request which are sent from client side to the server side include this cookie,where the domain and path are matched.Here the cookies of the sent request and session identifier of the server side are checked that whether they are matched or not by the server side.If they are matched ,it is identified as a logged user.Although the request is from unauthorized user,the server side check only whether the user is already authenticated or not using the cookie of the sent request.Therefore ,there is no identification whether the request is sent by authorized or unauthorized user.</p><p>As a example,when a person login to the banking site,he/she is considered as a legitimate user. Therefore the cookies have been sent form the server side to the client. Meanwhile an attacker creates a nice website and then it is sent to the logged person for performing the malicious task.There are some methods except to this method.It means that the malicious link can be sent through the social media or email can be sent with malicious link.Malicious link is run when the link is clicked.The requirement of this is transferring of some amount of money to the attacker’s bank account.This requirement is sent to the bank with session cookies in the browser of the logged person. This requirement is performed because it is sent from the logged user.This is occurred without any awareness of the user.As well as any attacker can access to the account of the user from a CSRF attack.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/600/1*Eo17YwRvwQ50v2NG59oO1g.png" /><figcaption><a href="https://dev.to/caffiendkitten/it-s-really-me-i-swear-an-intro-to-csrf-543p">https://dev.to/caffiendkitten/it-s-really-me-i-swear-an-intro-to-csrf-543p</a></figcaption></figure><p><strong>It can be describe as below<em> using reference website(the link of this website is mentioned after the description)</em></strong></p><p>For example, a typical GET request for a $100 bank transfer might look like:</p><pre>GET <a href="http://netbank.com/transfer.do?acct=PersonB&amp;amount=$100">http://netbank.com/transfer.do?acct=PersonB&amp;amount=$100</a> HTTP/1.1</pre><p>A hacker can modify this script so it results in a $100 transfer to their own account. Now the malicious request might look like:</p><pre>GET <a href="http://netbank.com/transfer.do?acct=AttackerA&amp;amount=$100">http://netbank.com/transfer.do?acct=AttackerA&amp;amount=$100</a> HTTP/1.1</pre><p>A bad actor can embed the request into an innocent looking hyperlink:</p><pre>&lt;a href=&quot;http://netbank.com/transfer.do?acct=AttackerA&amp;amount=$100&quot;&gt;Read more!&lt;/a&gt;</pre><p>Next, he can distribute the hyperlink via email to a large number of bank customers. Those who click on the link while logged into their bank account will unintentionally initiate the $100 transfer.</p><p>Note that if the bank’s website is only using POST requests, it’s impossible to frame malicious requests using a &lt;a&gt; href tag. However, the attack could be delivered in a &lt;form&gt; tag with automatic execution of the embedded JavaScript.</p><p>This is how such a form may look like:</p><pre>&lt;body onload=&quot;document.forms[0].submit()&quot;&gt;<br>   &lt;form action=&quot;http://netbank.com/transfer.do&quot; method=&quot;POST&quot;&gt;<br>     &lt;input type=&quot;hidden&quot; name=&quot;acct&quot; value=&quot;AttackerA&quot;/&gt;<br>     &lt;input type=&quot;hidden&quot; name=&quot;amount&quot; value=&quot;$100&quot;/&gt;<br>     &lt;input type=&quot;submit&quot; value=&quot;View my pictures!&quot;/&gt;<br>   &lt;/form&gt;<br> &lt;/body&gt;</pre><p><a href="https://www.imperva.com/learn/application-security/csrf-cross-site-request-forgery/">What is CSRF | Cross Site Request Forgery Example | Imperva</a></p><p>As this way to prevent vulnerabilities unique value is used for each client session which is generated randomly.This unique value is called as CSRF token.These token values are random cryptographic values and these are generated when a session is started for a user.All the forms in the website have token.These are in the message body and they are exist as a hidden field.Although an attacker sends a form to a legitimate user,token value will be haven’t or the token value which is sent from the form will be not matched because of this mechanism.This is occurred because CSRF token value is unique for each session.It means that the attacker does not know about the token value of the legitimate user.</p><h3>Synchronizer Token Pattern</h3><p>synchronization token pattern is a method which prevents the cross-site-request-forgery (CSRF).Here unique value is used for session identifier. This value is known as a CSRF token.It means that when a user log in to a website,a random value is generated for a particular session from server side.It is called as a token.This token is saved in the server side.As well as when this token is transferred from server side to client side it is saved in the browser of the client side.As well as the value of the session variable called as “PHPSESSID” the which is stored in the browser as cookies,can identify the session.All the requests are validated in the server side by comparing browser token and server server side token.This mechanism can be described as below.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/696/1*wmnna674hoEfUf7URZ965g.png" /></figure><p>I have created a log in page.It is called as “login.html”.User can enroll to the server by using this page.</p><p><strong><em>Username :- root</em></strong></p><p><strong><em>Password :- 1234</em></strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*MJ6BHUt5ann-066Bzojbcw.png" /><figcaption>login page</figcaption></figure><p>Html code of the “login.html” page is as below.This is a simple html code.Username and Password are sent under the POST method to the “log_control.php” when the login button is clicked,after the user credential is filled.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*8UvM0Ca_1a2yalBzS6qJ8g.png" /><figcaption>html code of the login page</figcaption></figure><p>Username and Password are hardcoded in the “log_control.php”.If user credentials which are entered to the login page are matched with hardcoded values,the user is redirected to the “contact.html” page.Meanwhile session identifier is created as well as session identifier is saved in the browser as cookie.The cookie is saved as this way when “session_start()” is activated at this time CSRF token is generated.Here the value which is generated randomly is a binary size 32 value.Here the generated value is converted to a hex value and it is assigned to the session variable.This session variable is called as token.</p><p>If an invalid user credentials are entered,it is returned to the “login.html” page.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1000/1*1M-yM2VxGcsl8Ovgm7f4ZQ.png" /><figcaption>log_control.php</figcaption></figure><p>You can check cookies following these guide lines.At first you must log to the “contact.html” page and then you should right click “inspect element”.After that you should click “Application” in the inspect element.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/872/1*lRwFaWXjUE13KVNXjlErFw.png" /><figcaption>browser cookie</figcaption></figure><p>Here server side program is call as “GetCSRF.php”. ”GetCSRF.php” will return the stored CSRF token for the particular session in the JSON encoded format.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*hsWYtWajFanVD7HvqEazRw.png" /><figcaption>GetCSRF.php</figcaption></figure><p>To take CSRF token value from the server side,a javascript code has been implemented in the “contact.html”.After the loading of “contact.html” page is completed,this javascript part will be run.Here “Ajax call” is written to take to token value from the “GetCSRF.php”. Ajax call processes the request in the background without refreshing the page and returns the expected value.This value is taken through jquery.The value which is taken,is converted to JSON by “json.parse” function.After that JSON value is assigned to the “obj” variable and the CSRF token will be extracted.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/888/1*JVswmyQksSjj1BEg6Viovg.png" /><figcaption>Ajax Call</figcaption></figure><p>Extracted CSRF token is set to the hidden field,it means to the DOM element.For that,hidden field’s id called as “domCSRF” in the form is used.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/725/1*Zb_jhM16cPHKxOp-f0sByQ.png" /><figcaption>hidden field</figcaption></figure><p>Complete “contact.html” is as below.All the data which are filled to the “contact.html” form are sent to the “contact_sub.php” along the POST method,when the “contact.html” form is filled and the submit button is clicked.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/968/1*Lka6UB-ADe8B_NyGZT1Yog.png" /><figcaption>html code of the contact page</figcaption></figure><p>“contact.html” page is as below.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*miTt14OngC7xwVnV2sB9lQ.png" /><figcaption>contact page</figcaption></figure><p>CSRF token which is stored in the hidden field is also sent to the “contact_sub.php” with the other data of the form.Here the first name which was taken is assigned as “”firstname” variable,the last name is assigned as “lastname” and the token value is assigned as “csrf_token” variable.“contact_sub.php” code is as below.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*qpEYNhpBiRaShlwrehH0cw.png" /><figcaption>Contact_submit.php</figcaption></figure><p>After the server got the request, the CSRF token received through the form data and the CSRF token stored in the particular session will be compared.If it is matched,the message will be display as below with the entered name to the contact form.(This message can be shown after the running of the code in the GitHub. The GitHub link is has been mentioned at the end of this blog post)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*XNMhhyXPUmeQE23WaR_Vmg.png" /><figcaption>Success message</figcaption></figure><p>If it is not matched the message will be displayed as bellow with the entered name to the contact form.As well as it is possible to display this message when the token is not exist.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ygww8SqsjKLkDN1IOxafAQ.png" /><figcaption>Error message</figcaption></figure><p>For this source code in my GitHub account…</p><p><a href="https://github.com/HirushanGitHub/Synchronizer-Token-Pattern.git">HirushanGitHub/Synchronizer-Token-Pattern</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f5f4406e3dfd" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>