<?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 Redouane OTMANI on Medium]]></title>
        <description><![CDATA[Stories by Redouane OTMANI on Medium]]></description>
        <link>https://medium.com/@reotmani?source=rss-ea29a6da8fd0------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*_3Up4mH1wEPtXOUWD42jjw.jpeg</url>
            <title>Stories by Redouane OTMANI on Medium</title>
            <link>https://medium.com/@reotmani?source=rss-ea29a6da8fd0------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 28 Nov 2026 03:08:04 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@reotmani/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[If you are interested in Ethereum Smart Contracts Bug Bounty, this open-source tool is for you.]]></title>
            <link>https://medium.com/coinmonks/if-you-are-interested-in-ethereum-smart-contracts-bug-bounty-this-open-source-tool-is-for-you-9faae49d734?source=rss-ea29a6da8fd0------2</link>
            <guid isPermaLink="false">https://medium.com/p/9faae49d734</guid>
            <category><![CDATA[vulnerability]]></category>
            <category><![CDATA[blockchain-security]]></category>
            <category><![CDATA[bug-bounty]]></category>
            <category><![CDATA[smart-contract-blockchain]]></category>
            <category><![CDATA[ethereum-blockchain]]></category>
            <dc:creator><![CDATA[Redouane OTMANI]]></dc:creator>
            <pubDate>Tue, 28 Mar 2023 09:00:51 GMT</pubDate>
            <atom:updated>2026-01-11T23:20:37.161Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*HpqRuQI_tyOyKRTz6pYQyg.jpeg" /></figure><p>In 2020, we’ve developed a tool named <a href="https://github.com/RedouaneOTMANI/Ethereum_SCVADetection">SCVADetection (Smart Contracts Vulnerability and Attack Detection)</a> which is available on GitHub.</p><p>The tool is written in Java and Python, and used via a GUI which is so simple.</p><p>The vulnerabilities and attacks detected by our tool are :</p><ul><li><strong>App1 </strong>: Based on a Machine Learning approach, it detects Reentrancy Attack, Integer Overflow and Underflow, Transaction order dependence, Timestamp dependence.</li><li><strong>App2 </strong>: Reentrancy Attack.</li><li><strong>App3 </strong>: Reentrancy Vulnerability.</li><li><strong>App4 </strong>: Incorrect Blockhash, Timestamp dependence, Blocknumber dependence, Pseudo-Random Number Generator (PRNG)</li></ul><p>Here is a simple demo using TheDAO contract</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1006/1*3zmbdOGUdhXmj16w3VxyiA.png" /></figure><p>By using the option “<em>Insert an address of a Smart Contract</em>”, I’ll be able to insert TheDAO address.</p><pre>0xbb9bc244d798123fde783fcc1c72d3bb8c189413</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/999/1*-AM_E-1sFpxc7FXsAI6nQA.png" /></figure><p>We know that TheDAO hack occurred at the block number : <strong>1718497</strong>which we’ll use in the next step, by selecting a range starting at <strong>1718497</strong>and ending at <strong>1718597</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/991/1*IzLRVl5LjQ_b8_tdUZSQxw.png" /></figure><p>In the next step will generate what we called Detection Aid Modules (DAM), at the same time, the tool will create a folder at your current work space</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/937/1*EiNEayAvwru9b4Yik5JCxg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/588/1*wf4EIFEakJi0q8_uh1IMAQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/787/1*XE7WnNWu1e_yDHIH2URPOQ.png" /></figure><p>The final step is to launch the applications to generate PDF reports</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/987/1*t2TlaVRYOtANGaXB9V4eGQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/428/1*X9SYekdX9xyi3KBAhrm49g.png" /></figure><h3><strong>General Report</strong></h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/848/1*BuRapIm8XtNRPLO6l4gwJQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/595/1*5tceV5T_Ja7HbzRyA42gJA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/577/1*k57TtVQiRXEBf5zj6fQRRw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/456/1*N_M5dyPAZ0kHpX1gwown5Q.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/549/1*mDjcdyEGM6lPFDTuWSOpJw.png" /></figure><h3>App1</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/642/1*viQjjkq6NKFgtzuWlKgTVA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/682/1*WL3je2ZOPSDpZ_anBj09bg.png" /></figure><h3><strong>App2</strong></h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/814/1*_jG0L2R-1eS_-cF3By9CCw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/838/1*JWSeRg0l54gEq5uxkDaz0Q.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/546/1*BZAdtkoWAYd8aTaK34VdVA.png" /></figure><h3>App3</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/748/1*67_s-rd-VkfUqoByyqBwCA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/992/1*8rDgm55JGIyeNvUBjPWf4w.png" /></figure><h3>App4</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/868/1*0WX-L8p_MRKx1jIVxfAlbw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/606/1*nMUISMP5fvfkKkK-GiIj6w.png" /></figure><p><strong>Important</strong>. In the source code of our tool, the original comments and variable names, also the GUI were written in French, so that I had to translate the whole source code so that it’ll be useful to all English speakers, I hope the tool is still working perfectly, if not, I’ll try to maintain it in my spare time.</p><p>If you appreciate, please leave a comment, and follow me to get notified whenever I write new articles, you can also follow me on <a href="https://twitter.com/reotmani">Twitter</a> :)</p><blockquote><em>New to trading? Try </em><a href="https://medium.com/coinmonks/crypto-trading-bot-c2ffce8acb2a"><em>crypto trading bots</em></a><em> or </em><a href="https://medium.com/coinmonks/top-10-crypto-copy-trading-platforms-for-beginners-d0c37c7d698c"><em>copy trading</em></a><em> on </em><a href="https://medium.com/coinmonks/crypto-exchange-dd2f9d6f3769"><em>best crypto exchanges</em></a></blockquote><blockquote>Join Coinmonks<a href="https://t.me/coincodecap"> Telegram Channel</a> and<a href="https://www.youtube.com/c/coinmonks/videos"> Youtube Channel</a> get daily <a href="http://coincodecap.com/">Crypto News</a></blockquote><h3>Also, Read</h3><ul><li><a href="https://medium.com/coinmonks/free-crypto-signals-48b25e61a8da">Free Crypto Signals</a> | <a href="https://medium.com/coinmonks/crypto-trading-bot-c2ffce8acb2a">Crypto Trading Bots</a></li><li>An ultimate guide to <a href="https://medium.com/coinmonks/leveraged-token-3f5257808b22">Leveraged Token</a></li><li><a href="https://medium.com/coinmonks/top-17-folding-electric-bikes-5e296f0918cb">16 Best Folding Electric Bikes</a></li><li><a href="https://medium.com/coinmonks/the-28-best-electric-bikes-review-and-buying-guide-in-2023-7bb3146cb403">28 Best Electric Bikes Review</a></li><li>Top 3 <a href="https://medium.com/coinmonks/top-3-binance-futures-trading-bots-e6031f84b3f9">Binance Futures Trading Bots</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=9faae49d734" width="1" height="1" alt=""><hr><p><a href="https://medium.com/coinmonks/if-you-are-interested-in-ethereum-smart-contracts-bug-bounty-this-open-source-tool-is-for-you-9faae49d734">If you are interested in Ethereum Smart Contracts Bug Bounty, this open-source tool is for you.</a> was originally published in <a href="https://medium.com/coinmonks">Coinmonks</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Windows Incident Response : Windows 11]]></title>
            <link>https://medium.com/@reotmani/windows-incident-response-windows-11-56129163b40d?source=rss-ea29a6da8fd0------2</link>
            <guid isPermaLink="false">https://medium.com/p/56129163b40d</guid>
            <category><![CDATA[forensics]]></category>
            <category><![CDATA[incident-response]]></category>
            <category><![CDATA[security]]></category>
            <category><![CDATA[windows]]></category>
            <category><![CDATA[cybersecurity]]></category>
            <dc:creator><![CDATA[Redouane OTMANI]]></dc:creator>
            <pubDate>Wed, 01 Mar 2023 11:50:21 GMT</pubDate>
            <atom:updated>2023-03-01T22:05:15.460Z</atom:updated>
            <content:encoded><![CDATA[<h3>Windows Incident Response : Windows 11</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*vHkuoZDybQbBjUuKlyZUkg.png" /></figure><p>Incident response is the process by which an organization identify an attack, minimize its effects, contain damage and remediate the cause by analyzing the symptoms and performing technical analyses on the OS.</p><p>Its fundamentals are :</p><ul><li>Being familiar with the directory (its structure and content) of the <strong>C:\ (C:\Windows, C:\Windows\System32, C:\Users, C:\Program Files, ..etc)</strong></li><li>Knowing Windows command line, help yourself and check this <a href="https://ss64.com/nt/">A-Z Index of Windows CMD commands</a>.</li><li>Understanding the structure of event logs, mainly in the “Application”, “Security” and “System” channels to detect possible suspicious activities or threats. <strong>Application log</strong> are events logged by applications. <strong>System log </strong>are events logged by the operation system. <strong>Security log</strong> are events related to security, including login attempts or file deletion.</li><li>Monitoring User &amp; Group management for any suspicious activity.</li><li>Monitoring activities of users who have access to files/folders containing sensitive information.</li><li>Monitoring User Access Control (UAC)</li><li>Being familiar with concepts of process, parent process, child process, and in general process tree. <a href="https://processhacker.sourceforge.io/">Process Hacker</a> could be used to visualize process tree, careful, this later is considered as malware by <a href="https://www.virustotal.com/gui/file/28042dd4a92a0033b8f1d419b9e989c5b8e32d1d2d881f5c8251d58ce35b9063">some security tools</a>.</li><li>Being familiar with most <a href="https://www.forensicfocus.com/articles/standard-processes-in-windows-10/">important processes</a> from a security perspective, you could check out this <a href="https://alparslanakyildiz.medium.com/fundamental-windows-processes-6341696cf4f0">article</a> (smss.exe,csrss.exe,winlogon.exe,wininit.exe,lsm.exe,services.exe,lsass.exe,svchost.exe,taskhost.exe,explorer.exe.)</li><li>Monitoring scheduled tasks to be able to detect possible suspicious scheduled tasks (<strong>taskschd.msc</strong> and <strong>schtasks </strong>command)</li><li>Monitoring changes in the registry (<strong>regedit </strong>and “<strong>reg</strong>” command)</li><li>Monitoring firewall rules to detect whether new (and suspicious) rules have been added (<strong>wf.msc</strong> and “<strong>netsh</strong>” command) and check if the firewall is not disabled.</li><li>Monitoring Windows Management Instrumentation WMI, which provides an operating system interface so that its components give us information and different types of notifications. This could be used as recognition tool or pivot between machines.</li><li>Last but not least, taking into consideration <a href="https://lolbas-project.github.io/">Living Off The Land Binaries And Scripts aka LOLBAS</a>, which is a type of activity that misuses tools and executables that are already there because they are part of the operation system.</li></ul><p>The following of this article is fully inspired from <a href="https://www.hackingarticles.in/incident-response-windows-cheatsheet/">Raj Chandel’s Blog</a> and adapted to Windows 11. By the way, the Windows 11 is fresh installed with no malicious activity, this means it could be a knowledge base for you to compare while doing investigation with yours.</p><p>The outline of this article (as it should be)</p><blockquote><strong>Users (Local users, net user, net localgroup)</strong></blockquote><blockquote><strong>Processes (Task Manager, task list, PowerShell)</strong></blockquote><blockquote><strong>Services (GUI, net start, sc query, Get-Service )</strong></blockquote><blockquote><strong>Task Scheduler (GUI, tasklist, schtasks )</strong></blockquote><blockquote><strong>Startup (GUI, PowerShell, )</strong></blockquote><blockquote><strong>Registry (GUI, PowerShell,)</strong></blockquote><blockquote><strong>Active TCP and UDP Port (Cmd with netstat, PowerShell)</strong></blockquote><blockquote><strong>File Sharing (cmd with net view, PowerShell with SMBShare)</strong></blockquote><blockquote><strong>Files (cmd with forfiles)</strong></blockquote><blockquote><strong>Firewall Settings</strong></blockquote><blockquote><strong>Sessions with other system</strong></blockquote><blockquote><strong>Log Entries (GUI, cmd, PowerShell)</strong></blockquote><h3>Users</h3><p>Investigating user activity can provide valuable information about the root cause and scope of a security incident, here are some reasons :</p><ul><li><strong>Identify the source of the incident </strong>: By examining user activity, you can determine whether the incident was caused by an external threat actor or an insider threat. You can can also identify the specific user account or device that was involved in the incident.</li><li><strong>Determine the scope of the incident </strong>: user activity logs can help you determine the extent of the incident by identifying which systems or accounts were accessed by the attacker or compromised user.</li><li><strong>Collect evidence for forensics analysis</strong> : User activity logs can provide valuable evidence for forensic analysis, which can help you understand the attack methodology and identify potential vulnerabilities in your environment.</li><li><strong>Meet compliance requirements</strong> : Investigating user activity is often required to meet regulatory compliance requirements, such as HIPAA or PCI-DSS.</li></ul><p>Overall, investigating user activity can help you understand the who, what, when and how of a security incident, and can provide valuable insights for incident response, remediation, and prevention efforts.</p><h4>Local users</h4><ul><li>To get the list of local user accounts, press the <strong>Windows + R </strong>then type “<strong>lusrmgr.msc</strong>” and click on <strong>OK</strong>, then you’ll be able to find the the user accounts, their full names and descriptions.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/399/1*QZxFuUWhs9qa8Sh_Mvw0tQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/931/1*XkfmaZaGVi9AvEXiNVV0KQ.png" /></figure><ul><li>We can get the same result in PowerShell, run the PowerShell as an administrator, and type the command “<strong>Get-LocalUser</strong>”.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/375/1*dq8UXE3nZVRvJUNPGMpyQg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/961/1*rvhMThqKgboZjevWnNDH_w.png" /></figure><h4>Net user</h4><p>“Net user” is a command-line tool in Windows that allows you to manage user accounts and groups on a local or remote computer. With “net user,” you can create new user accounts, modify existing accounts, and even delete accounts if necessary.</p><p>Open a command line as an admin, then type “<strong>net user</strong>” so we can see the user accounts with their types.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/633/1*bnH97R4G56Jv0awATFgYPQ.png" /></figure><h4>Net localgroup</h4><p>“Net localgroup” is another command-line tool in Windows that allows you to manage local groups on a computer. With “net localgroup” you can create new groups, modify existing groups, and add or remove users from a group.</p><p>Open command line as an admin then type “<strong>net localgroup</strong>” to get all the groups.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/349/1*qaa9jP4Z_LSj-Gbsza-Nkw.png" /></figure><p>The we choose to display users of the “<strong>Administrators</strong>” group. Type the command “<strong>net localgroup Administrators</strong>”</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/738/1*ovg-mrZWF6urK3rt_dUUEQ.png" /></figure><h3>Processes</h3><p>Investigating processes is important in Windows Incident Response because it allows you to identify malicious or suspicious activity on a system. By examining the running processes on a computer, you can determine what programs and services are currently executing, and whether any of them are related to an ongoing security incident.</p><h4>Task Manager</h4><ul><li>Press <strong>Windows + R </strong>then type “<strong>taskmgr.exe</strong>”<strong> (</strong>Or by pressing the shortcut <strong>CTRL + Shift + ESC</strong>)</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/389/1*fpUWdp3pi_q-pD4rXuD5Nw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/748/1*OXU83WpBgnMMKfPwObYTtg.png" /></figure><h4>Command Prompt: <strong>tasklist</strong></h4><ul><li>To view the processes in the command prompt, type in the command “<strong>tasklist</strong>” and hit enter. This will display a list of all the running processes on the system, along with their unique process ID (PID), the name of the session that the process is running in, and the amount of memory that the process is currently using.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/656/1*rvCY5fK8rfT_u_Y0oWPxkw.png" /></figure><h4>PowerShell</h4><ul><li><strong>get-process </strong>: Retrieves a list of all the currently running processes. When you run this command, it displays information about each process, including the process name, process ID (PID), CPU usage, and memory usage. It can be useful for investigating potential security incidents, diagnosing system performance issues, or monitoring resource usage. By reviewing the list of processes returned by “Get-Process,” you can identify any processes that may be consuming an excessive amount of resources or that may be associated with malicious activity.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/722/1*ananTBZ_N37MG_3GqC-2sw.png" /></figure><ul><li><strong>wmic process list full</strong> : WMIC for Windows Management Instrumentation Command, is a command that shows you a detailed list of all the processes currently running, including information about each process like description, executable path, and other memory information, but be aware that the output can be very long and requires further analysis to be useful.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/646/1*_t0KEdQfIexKYuxe5LwRSg.png" /></figure><p>As we can see more details about the process “<strong>AnyDesk.exe</strong>”</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/593/1*AM0pXVDY7gqCR2KxF00VmA.png" /></figure><ul><li><strong>wmic process get name,parentprocessid,processid </strong>: This commands means what it sounds, we use it to get more details about the process : Its name, its parent process ID, and its process ID.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/576/1*_MoUTF0Yj2cGLZ-z5XiA5A.png" /></figure><ul><li><strong>wmic process where ‘ProcessID=PID’ get CommandLine </strong>: To get the path of the command line that executed the process.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/630/1*bYKfEBETCWyEpFjreQNm_A.png" /></figure><h3><strong>Services</strong></h3><p>By regularly reviewing the list of running services, you can identify any abnormal or suspicious behavior and take appropriate action to investigate and mitigate any security or performance issues.</p><h4>GUI</h4><ul><li>Press <strong>Windows + R </strong>then type “<strong>services.msc</strong>”</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/395/1*xChAtD2SLXZy_uXmDztFNA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/792/1*5SGR0DzaZawH4L4mybutJw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/792/1*Kr_2HaIq_vF85xRsMX78ag.png" /></figure><h4>net start (CMD)</h4><ul><li>Open a command prompt then type “<strong>net start</strong>” to get a list of running network services.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/414/1*kuuzp9Ob4JDAg65_nU66Xw.png" /></figure><h4>sc query (CMD)</h4><ul><li>“<strong>sc query</strong>” command retrieves a list of all the services installed on your computer and display information about each service, such as its display name, service name, status and startup type. In the screenshot below, the “WIN32_OWN_PROCESS” means that the service is a standalone process and is not intended to be shared by other services or applications.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/683/1*_j84nplFxB6yJdTQRUR84A.png" /></figure><h4><strong>Get-Service (PowerShell)</strong></h4><ul><li>You can also use the “Get-Service” on a PowerShell to get a list of services registered on the local computer.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/559/1*RBC4ylYd1Mo3GDaygjgkLA.png" /></figure><h3><strong>Task Scheduler</strong></h3><ul><li>The Task Scheduler tool is a feature in Windows that allows users to schedule tasks to run automatically at specific times or under certain conditions. It’s a powerful utility that can automate many tasks, such as running backups, launching programs or sending emails.</li><li>Here are some key features of the Task Scheduler tool:</li></ul><ol><li><strong>Scheduling</strong>: You can create tasks that run on a specific date and time, or on a recurring schedule, such as every day, week, or month.</li><li><strong>Triggers</strong>: You can also set up triggers that start a task when specific events occur, such as when the computer starts up, when a user logs on, or when a specific system event occurs.</li><li><strong>Actions</strong>: You can define actions for a task, such as running a program, sending an email, or displaying a message.</li><li><strong>Conditions</strong>: You can set conditions for a task, such as running only when the computer is idle or only when a specific network connection is available.</li><li><strong>History and logging:</strong> Task Scheduler keeps a record of task history and allows you to view detailed logs of task activity.</li></ol><p>Monitoring the Task Scheduler on your computer can be useful for several reasons, including:</p><ol><li><strong>Troubleshooting</strong>: The Task Scheduler is responsible for scheduling and running various tasks and processes on your computer, such as <strong>system updates</strong>, <strong>backups</strong>, and <strong>maintenance tasks</strong>. If you notice any issues with the Task Scheduler, such as tasks failing to run or errors being logged, it can indicate a problem that needs to be resolved.</li><li><strong>Security</strong>: <strong>Malware </strong>and other <strong>malicious software </strong>can sometimes create <strong>scheduled tasks</strong> to run on your computer, which can be used to steal data or perform other harmful actions. Monitoring the Task Scheduler can help you <strong>detect any unauthorized or suspicious tasks</strong> that have been created, so you can take action to remove them and prevent further damage.</li><li><strong>Performance</strong>: The Task Scheduler can sometimes run tasks that consume a lot of system resources, which can impact the performance of your computer. By monitoring the Task Scheduler, you can identify any tasks that are causing performance issues and take action to optimize or reschedule them.</li></ol><p>Overall, monitoring the Task Scheduler can help you ensure that your computer is running smoothly, securely, and efficiently, and can help you quickly detect and resolve any issues that may arise.</p><h4><strong>tasklist</strong></h4><ul><li>“<strong>tasklist</strong>” command as discussed in the “Processes” section, displays a list of processes along with various details about each process, such as the process name, process ID (PID), memory usage, and status</li><li>“<strong>tasklist /svc</strong>” displays a list of processes along with the services that are running within each process.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/675/1*WM4Rq9D7AtOdFuA5nXGPZA.png" /></figure><h4>Schtasks</h4><ul><li>Using command prompt, type “<strong>schtasks | more</strong>” to display the scheduled tasks, then you need to identify tasks which are high privileges and look suspicious.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/664/1*dcbezeV3w72dPDHVX4q5xA.png" /></figure><h4><strong>GUI</strong></h4><ul><li>You can also run the <strong>Task Scheduler</strong> tool of windows by simply pressing the “Windows” button then searching for <strong>Task Scheduler (</strong>Or by going to the path<strong><em> </em></strong><em>C:\ProgramData\Microsoft\Windows\Start Menu\Programs\Administrative Tools)</em></li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/628/1*ZblwwJ9nGOU5MEQUYBxTZw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/946/1*l8MJH6GRYOIm9nUJBZ7zvw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*jMqyjihQlhrfYX9vwC5HXA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/933/1*wys0PVZ6-GrkVur8GieU0Q.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*10yVpG4B5ap1KVXMpDkJqA.png" /></figure><h3><strong>Startup</strong></h3><p>the Startup folder and Startup tab in Task Manager are related to the applications and processes that run automatically when the user logs on to the system. By managing the startup programs and processes, it can help improve system performance and reduce startup time.</p><h4>GUI</h4><p>Open the Task Manager then select the “Startup” section, from here you can enable or disable applications and processes from running at startup.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/749/1*MyPqo9l7XOGYrJ7Dofqplg.png" /></figure><p>You can access the same result by pressing Windows button then searching for “Startup”</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/632/1*ZKLyCf_OwS5yGJAZGcjAcw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/786/1*5tNR2kf0-yYgrydWPUOZjg.png" /></figure><h4>PowerShell</h4><ul><li>To view the Startup applications in the PowerShell, type the command : “<strong>wmic startup get caption, command</strong>” or any other variation, such as “<strong>wmic startup get caption</strong>”</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/467/1*a2Szwtk7fn5KZuZmB7FTMA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*3-HV98Buhb1GAtSBQvlfeQ.png" /></figure><ul><li><strong>Get-CimInstance Win32_StartupCommand</strong> <strong>| Select-Object Name, command, Location, User | Format-List </strong>retrieves information about the startup programs and processes.</li></ul><p>Let me explain this PowerShell command in detail</p><ol><li>“<strong>Get-CimInstance Win32_StartupCommand</strong>”: Retrieves the instances of the<strong> Win32_StartupCommand </strong>WMI class, which contains information about the startup programs and processes.</li><li>“<strong>Select-Object Name, command, Location, User</strong>”: Selects the properties that we want to display for each Win32_StartupCommand instance. Name (the name of the startup program or process), command (the command line used to start the program or process), Location (the registry location where the startup entry is stored), and User (the user account under which the program or process is run).</li><li>“<strong>Format-List</strong>”: Formats the output as a list, making it easier to read and analyze.</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/981/1*CbCpGIbVmvyq26JzEkAFeA.png" /></figure><h3><strong>Registry</strong></h3><p>The Windows Registry is a hierarchical database that stores configuration settings and options for the Windows operating system and its applications. It is used to store information such as hardware and software settings, user preferences, and system security policies.</p><p>The Registry is organized into a tree-like structure, with keys and subkeys that correspond to various system components and settings. Each key and subkey can contain values that specify settings for the associated system component or application.</p><p>It can be accessed and modified using the Windows <strong>Registry Editor</strong>, which allows users to view and edit the contents of the Registry. However, modifying the Registry incorrectly can cause serious problems with the system, so it is important to exercise caution when making changes to the Registry.</p><p>Analyzing the Registry can be an important part of identifying potential security incidents or system issues. By reviewing the Registry keys and values associated with a particular system component or application, you can identify potential security weaknesses, misconfigurations, or malicious activity.</p><p>There are several Registry keys that are commonly monitored in Windows IR, here is a (non exaustive) list if the key Registry location that analysts may want to monitor :</p><ol><li>“HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Run” Contains a list of programs and processes that are configured to <strong>run automatically when a user logs into Windows</strong>, so monitoring changes to this key can help identify potentially unwanted or malicious programs.</li><li>“HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\RunOnce” Contains a list of programs and processes that are configured to run <strong>only once the next time a user logs into Windows</strong>. Monitoring changes to this key can help identify one-time actions or persistence mechanisms.</li><li>“HKLM\SYSTEM\CurrentControlSet\Services” Contains a list of <strong>Windows services installed on the system</strong>. Monitoring changes to this key can help identify modifications to services that could indicate malicious activity.</li><li>“HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon” Contains <strong>settings related to user authentication and login behavior</strong>. Monitoring changes to this key can help identify modifications to user authentication behavior that could indicate a security incident.</li><li>“HKCU\Software\Microsoft\Windows\CurrentVersion\Run” Contains a list of programs and processes that are configured to run automatically when a user logs into Windows.</li><li>“HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Image File Execution Options” Contains <strong>configuration settings for Windows processes and applications</strong>. Attackers may use this key to hijack legitimate processes or applications to execute malicious code.</li><li>“HKLM\SOFTWARE\Policies\Microsoft\Windows Defender” Contains <strong>settings related to Windows Defender. </strong>Monitoring changes to this key can help identify attempts to disable or modify Windows Defender protection.</li><li>“HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System” Contains system policies that can be used to control various settings on the system, such as<strong> user account control (UAC) and password policies</strong>.</li><li>“HKLM\SYSTEM\CurrentControlSet\Control\Session Manager\Environment” Contains<strong> environment variables</strong> that are used by Windows and other applications. Monitoring changes to this key can help identify attempts to modify the system environment to execute malicious code.</li><li>“HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\ProfileList” Contains information about<strong> user profiles</strong> on the system. Monitoring changes to this key can help identify attempts to create new user accounts or modify existing ones.</li><li>“HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders” Contains information about the locations of <strong>various Windows folders</strong>, such as the desktop, documents, and downloads folders. Monitoring changes to this key can help identify attempts to modify these folders or move data to/from them.</li></ol><h4>GUI</h4><ul><li>Open Regedit : By pressing <strong>Windows </strong>+ <strong>R </strong>then type “<strong>regedit</strong>”</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/394/1*pWGmatXmTGSzU4FvlqspwA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/695/1*Dbr38NDmStqs1bCPmZgGgg.png" /></figure><h4>PowerShell</h4><ul><li>You can also get the same result using the PowerShell command <strong>reg query </strong>followed by the location of the Registry Key.</li></ul><p><strong>reg query “HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon”</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/843/1*8k2Hhh01a5WU5rmgONF05A.png" /></figure><p><strong>reg query “HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\RunOnce”</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/943/1*0zxPOnDdq_zeTqtrwm-PMA.png" /></figure><h3><strong>Active TCP and UDP Port</strong></h3><p>Monitoring active TCP/UDP ports can help :</p><ul><li><strong>Identify unauthorized network connections</strong> that may be used by an attacker to establish a command and control channel or exfiltrate data from the system.</li><li><strong>Detect malicious activity s</strong>uch as port scanning or malware communication.</li><li><strong>Investigate network activity </strong>related to a specific process or service running on the system. For example, you may be able to identify which processes are responsible for specific network connections and determine if they are legitimate or suspicious.</li></ul><h4><strong>netstat</strong></h4><ul><li>You can run the command <strong>netstat -ano</strong></li></ul><p>“<strong>-a</strong>” Displays<strong> all active connections</strong> and listening ports, including both TCP and UDP protocols.</p><p>“<strong>-n</strong>” Displays addresses and port numbers in numerical format instead of resolving hostnames.</p><p><strong>“-o</strong>” Displays the <strong>owning process ID</strong> associated with each connection or listening port. This can be useful for identifying which process is responsible for a specific network connection.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/697/1*C2zTQKsWbUMCGJzqLWBs9w.png" /></figure><h4><strong>PowerShell</strong></h4><ul><li>In PowerShell the equivalent of the <strong>netstat </strong>command <strong>is the “Get-NetTCPConnection”</strong>. It allows you to view active TCP connections on the system and provides you more detailed information that the “<strong>netstat</strong>” command.</li></ul><p><strong>Get-NetTCPConnection -State Established</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/929/1*yc3Yfngrowm7g5dP2wFRPQ.png" /></figure><p><strong>Get-NetTCPConnection -LocalAddress 192.168.205.133 | Sort-Object<br>LocalPort</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/940/1*X7LhL6EbbioHb34IjcDjLA.png" /></figure><ul><li>There is also the “<strong>Get-NetUDPEndpoint</strong>” command, which can be used to view active UDP connections.</li></ul><p><strong>Get-NetUDPEndpoint | Where-Object {$_.OwningProcess -ne 0} | Format-Table -AutoSize</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/865/1*Rq6SvTm3JJlUfOO48EITxg.png" /></figure><h3><strong>File Sharing</strong></h3><p>File sharing allows users to access files and folders on other computers over a network. this can be a potential security risk, as it can enable unauthorized users to gain access to sensitive information.</p><h4><strong>net view</strong></h4><ul><li>You can check file sharing with the command <strong>net view localhost</strong></li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/321/1*vgMPLBz5jWoO9DsCqwgBjg.png" /></figure><h4><strong>SMBShare</strong></h4><ul><li>SMB (Server Message Block) is a protocol used by Windows for sharing files and printers over a network.</li><li>SMBShare is cmdlet that enables you to manage file sharing on Windows using the SMB protocol.</li><li>Investigating SMBShare can help you identify any security issues or unauthorized access shared resources. It allows you view the current configuration of SMB files shares and see if any new shares have been created recently.</li></ul><p><strong>Get-SMBShare</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/749/1*DmjyEQI71lv0yBpDvn-SaA.png" /></figure><h3><strong>Files</strong></h3><p>Monitoring files on Windows helps you detect if someone has gained unauthorized access to sensitive files or has made changes to them, also, you can detect unusual file activity that could indicate the presence of malware, this later often modifies or creates files on a system to maintain persistence and evade detection.</p><h4><strong>GUI</strong></h4><ul><li>Open File Explorer and navigate to the folder where you want to search for files, the click on the search box located in the top-right corner of the window.</li></ul><ol><li>Type “<strong>size:</strong>” followed by the file size you want to search for. For example, “<strong>size:&gt;100MB</strong>” will search for all files that are larger than 100 megabytes.</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/935/1*LGAyJ1T8CgoPF3crrC6Y2Q.png" /></figure><p>2. To search for files based on a <strong>date range</strong>, type “<strong>date:</strong>” followed by the date range. For example, “<strong>date:last week</strong>” will search for all files that were modified within the last week. You can also use specific dates in the format “<strong>mm/dd/yyyy</strong>”.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/939/1*ny_YtK6vO7XcZqAR4gka-g.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/940/1*cmYC-mcKYBdaRRDUkHDUig.png" /></figure><p>The search box has many other possible search options such as :</p><p>3. <strong>Type </strong>: to search for a specific type of file such as document, image, audio, etc.</p><p>4. <strong>Name </strong>: to search for files with a specific name or part of the name.</p><p>5. <strong>Kind </strong>: to search for files with a specific kind or file extension, such as .docx, .pdf, .mp3, etc.</p><p>6. <strong>Tags </strong>: to search for files with a specific tag assigned to them.</p><p>7. <strong>Authors </strong>: to search for files created by a specific author.</p><p>8. <strong>Title </strong>: to search for files with a specific title.</p><p>9. <strong>Content </strong>: to search for files containing specific text or keywords.</p><p>10. <strong>Folder </strong>: to search for files in a specific folder or location.</p><h4><strong>Forfiles</strong></h4><ul><li><strong>Forefiles</strong> command is a built-in command in Windows, that allows you to perform batch processing on files, such as :</li></ul><ol><li>Searching files older than a certain date, deleting files, ..</li><li>Copy files to a certain location based on specific criteria.</li><li>Running a command on files that match a certain pattern.</li><li>..</li></ol><p>Here are some examples of how to use forfiles for investigating</p><ol><li><strong>Finding files modified in the last 24 hours:</strong></li></ol><p>This command will search for all files in the “target_directory” and its subdirectories that have been modified in the last 24 hours and print their paths to the command prompt. The <strong>/s</strong> option tells forfiles to look into subdirectories (recursively), and the<strong> /m</strong> option with *.* to look for all files with all possible extensions.</p><p>forfiles /p &quot;C:\target_directory&quot; /s /m *.* /d -1 /c &quot;cmd /c echo @path&quot;</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/789/1*FOfmtTdNN2TK8dsxf2e6RA.png" /></figure><p>2<strong>. Finding files larger than a specific size</strong>:</p><p>This command will search for all files in the “target_directory” and its subdirectories that are larger than 1MB (which is 1000000, yes unfortunately the forfiles command does not support unit suffices like MB or GB, so you need to write it in bytes) and print their paths to the command prompt.</p><p>forfiles /p &quot;C:\target_directory&quot; /s /m *.* /c &quot;cmd /c if @fsize gtr 1000000 echo @path&quot;</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/928/1*ycu0NKHo6rqcEPsy9XNv3Q.png" /></figure><p><strong>3. Finding files with a specific extension:</strong></p><p>This command will search for all files in the “target_directory” and its subdirectories that have a “.docx” extension and print their paths to the command prompt.</p><p>forfiles /p &quot;C:\target_directory&quot; /s /m *.docx /c &quot;cmd /c echo @path&quot;</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/849/1*p-WJ12jt5aunyUOdK8WoIA.png" /></figure><p><strong>4. Finding and deleting files older than a specific date:</strong></p><p>This command will search for all files in the “target_directory” and its subdirectories that are older than 30 days and delete them.</p><p>forfiles /p &quot;C:\target_directory&quot; /s /m *.* /d -30 /c &quot;cmd /c del @path&quot;</p><p><strong>IMPORTANT.</strong> As <strong>forfiles </strong>has the potential to delete or modify a large number of files if used improperly. Always test your commands on a small subset of files before using them on a larger scale.</p><h3><strong>Firewall Settings</strong></h3><p>By monitoring firewall settings, you can identify any unauthorized changes or configurations that could allow attackers to bypass the firewall and gain access to sensitive information or systems.</p><p>Here are some examples of commands that you can use to check the firewall settings</p><ol><li>Check if the Windows Firewall is enabled:</li></ol><p><strong>netsh advfirewall show allprofiles</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/867/1*lxs9vR-1f-hGjELgW5ixUQ.png" /></figure><p>2. Check the list of inbound rules:</p><p><strong>netsh advfirewall firewall show rule name=all dir=in</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/941/1*Vh-131Vi_U5i7dafxsnvRA.png" /></figure><p>3. Check the list of outbound rules:</p><p><strong>netsh advfirewall firewall show rule name=all dir=out</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/950/1*mJgJkMTwI74ApJuUH7_dXg.png" /></figure><p>4. Check the firewall log to see if any traffic is being blocked : (PowerShell)</p><p>Based on event <a href="https://learn.microsoft.com/en-us/windows/security/threat-protection/auditing/event-5152">ID 5152</a> which is logged in the security event log when the firewall drops a packet. Running this command will give you a list of all the dropped network packets recorded in the Security event log.</p><p><strong>Get-EventLog -LogName Security | Where-Object {$_.EventID -eq 5152}</strong></p><p>5. Check the firewall status and profile settings: (PowerShell)</p><p><strong>Get-NetFirewallProfile | Select-Object Name,Enabled,DefaultInboundAction,DefaultOutboundAction</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/932/1*fCmdFtHuqI5r3pYJ7LAr9w.png" /></figure><h3><strong>Sessions with other system</strong></h3><p>Checking open sessions with other system can help detect lateral movement by attackers, also, suspicious activities such as multiple failed login attempts.</p><p>You can use the command <strong>net sessions</strong> or <strong>net use</strong>, with admin privileges, to display information about the established sessions.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/400/1*AY4vnmnzyERGHtH0SDAKIg.png" /></figure><h3><strong>Log Entries</strong></h3><p>Analyzing log entries helps identify potential security incidents or events. Windows generates various types of logs, such as security logs, system logs, and application logs, you can then try to identify anomalies and patterns that indicate potential security breaches (Unauthorized access, data exfiltration, malware infections, ..)</p><h4>Event Viewer</h4><p>Press<strong> Windows + R </strong>then type “<strong>eventvwr.msc</strong>” or just look for it after pressing the Windows button.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/788/1*tHCuugzWvvD6Fm4uZhvPQw.png" /></figure><h4>Cmd</h4><p>To print logs of a particular event in command prompt, type “<strong>wevtutil qe &lt;log_type&gt;</strong>” for example : <strong>wevtutil qe system</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/940/1*zkwtvqr8uAlxnG1aRUtvPA.png" /></figure><h4>PowerShell</h4><ul><li><strong>Get-EventLog </strong>retrieves events from the Windows event logs. It allows you to retrieve a list of events from a specified event log, and filter the results based on specific criteria such as event ID, time range, source, and message content.</li></ul><p>Here is it’s basic syntax :</p><pre>Get-EventLog [-LogName] &lt;String[]&gt; [[-InstanceId] &lt;Int64[]&gt;] [-After &lt;DateTime&gt;] [-Before &lt;DateTime&gt;] [-UserName &lt;String[]&gt;] [-ComputerName &lt;String[]&gt;] [-EntryType &lt;String[]&gt;] [-Index &lt;Int32[]&gt;] [-Message &lt;String[]&gt;] [-Newest &lt;Int32&gt;] [-Source &lt;String[]&gt;] [-AsBaseObject] [-Force] [-WhatIf] [-Confirm] [&lt;CommonParameters&gt;]</pre><ul><li><strong>Get-EventLog -L </strong>retrieves a list of available event logs on a Windows System, it will print the names of the available logs their maximum size and the retention policy for each log.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/629/1*_uEPzP0CV1qGnQLmK1r2uQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/931/1*Bi0qlP5nskrZO0zY3wt44A.png" /></figure><ul><li><strong>Get-WinEvent </strong>retrieves events and event logs from local and remote computers running Windows. It is a more powerful and versatile alternative to Get-EventLog, which is an older cmdlet that only retrieves events from the classic Windows event logs.</li></ul><p>Here is an example to retrieve all events from the System log</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/927/1*kNt7wxVTYZH9bmFD9N8s-Q.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/923/1*3py-_3G98v_ia7jw28Nueg.png" /></figure><p>Here is the syntax for further use :</p><pre>Get-WinEvent [-LogName] &lt;string[]&gt; [-FilterHashtable &lt;hashtable&gt;] [-MaxEvents &lt;int&gt;] [-Oldest] [-Newest] [-ComputerName &lt;string[]&gt;] [-Credential &lt;pscredential&gt;] [-AsBaseObject] [-Force] [-EA &lt;erroraction&gt;] [-Verbose] [-Debug] [-WhatIf] [-Confirm] [&lt;CommonParameters&gt;]</pre><p>Thanks for reading :)</p><h3>Resources</h3><p>&lt;<a href="https://www.linkedin.com/posts/jforsain_soc-windows-activity-7029593799127388160-1348?originalSubdomain=fr">https://www.linkedin.com/posts/jforsain_soc-windows-activity-7029593799127388160-1348?originalSubdomain=fr</a>&gt;</p><p>&lt;<a href="https://www.hackingarticles.in/incident-response-windows-cheatsheet/">https://www.hackingarticles.in/incident-response-windows-cheatsheet/</a>&gt;</p><p>&lt;<a href="https://gist.github.com/RomelSan/9ebef17aa9aa061d6b32e2e250181942">https://gist.github.com/RomelSan/9ebef17aa9aa061d6b32e2e250181942</a>&gt;</p><p>Many thanks to ChatGPT.</p><p>If you appreciate, please leave a comment, follow me to get notified whenever I write new articles, you can also follow me on <a href="https://twitter.com/reotmani">Twitter</a> :)</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=56129163b40d" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[MITRE ATT&CK : DeTTECT]]></title>
            <link>https://medium.com/@reotmani/dettect-70db2d219bde?source=rss-ea29a6da8fd0------2</link>
            <guid isPermaLink="false">https://medium.com/p/70db2d219bde</guid>
            <category><![CDATA[mitre-attack]]></category>
            <category><![CDATA[threat-actor]]></category>
            <category><![CDATA[security-operation-center]]></category>
            <category><![CDATA[datasource]]></category>
            <category><![CDATA[blue-team]]></category>
            <dc:creator><![CDATA[Redouane OTMANI]]></dc:creator>
            <pubDate>Mon, 30 Jan 2023 19:00:10 GMT</pubDate>
            <atom:updated>2023-02-14T10:57:06.979Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*6TTURMxDhj8tGDUz" /></figure><p>DeTT&amp;CT for Detect Tactics, Techniques &amp; Combat threats, is a tool used to help Blue Team using the MITRE ATT&amp;CK framework to score and compare the quality of collected log sources, visibility coverage, detection coverage and Threat Actors behavior.</p><p>In other words, DeTT&amp;CT answers the question : When it comes to detection, which log sources are most important ? Thus, using this framework, Blue Team can quickly detect gaps in detection coverage or visibility and prioritize the ingestion of new log sources.</p><p>DeTT&amp;CT provides a framework that can map the available entity information in ATT&amp;CK and helps manage Blue Teams’ data, visibility and detection coverage.</p><p>It consists of :</p><ul><li>A python tool (DeTT&amp;CT CLI)</li><li>YAML administration files.</li><li>DeTT&amp;CT editor (to create and modify YAML administration files)</li><li>Notation tables for detection, data sources and visibility.</li></ul><p>DeTT&amp;CT CLI is a python script (dettect.py) that works with 06 different modes :</p><ul><li><strong>editor </strong>: Launching the DeTT&amp;CT editor web interface.</li><li><strong>datasources (ds)</strong> : Mapping and quality of data sources.</li><li><strong>visibility (v)</strong> : Visibility coverage mapping based on techniques and data sources.</li><li><strong>detection (d)</strong>: Mapping of detection coverage based on techniques.</li><li><strong>group (g)</strong>: Mapping of Threat Actor groups.</li><li><strong>generic (ge)</strong>: Includes statistics on ATT&amp;CK log sources and updates on techniques, groups and software.</li></ul><p>Outline of the article</p><ol><li>DeTT&amp;CT Install &amp; Config</li><li>DeTT&amp;CT Data sources</li><li>DeTT&amp;CT Visibility</li><li>DeTT&amp;CT Detection</li><li>Gap Analysis</li></ol><h3>1. DeTT&amp;CT Install &amp; Config</h3><p>On linux machine</p><pre>git clone https://github.com/rabobank-cdc/DeTTECT.git<br>cd DeTTECT<br>pip install -r requirements.txt</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/790/0*0udSpAc16R7JbPXX" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/656/0*6rd7ohEy6FnDFeaQ" /></figure><p>To start the DeTT&amp;CT editor :</p><pre>python3 dettect.py e</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/653/0*qNF9JahrgLbUBrgG" /></figure><p>Next, use a web browser to access <strong>&lt;Host IP address&gt;:8080</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*1NKNp_4vvpEMb994" /></figure><p>We can also use DeTT&amp;CT to get which data source covers most of the techniques in MITRE/ATT&amp;CK, to do so, we launch the python script with the following options.</p><pre>python dettect.py generic -ds </pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*hV4P1IQsMqLWL3Ix" /></figure><p>As we can see, the data source “Command Execution” covers 262 techniques based on MITRE/ATT&amp;CK.</p><h3>2. DeTT&amp;CT Data sources</h3><p>Lets start by using this feature</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*y5A2CtasKqCoqiDo" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/proxy/0*TPkw7gbvCJQX2P_t" /></figure><p>Then “<strong>Add data source</strong>”<strong> </strong>at this stage on the right we can choose our data sources</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*6q_XszRZamPX-F53" /></figure><p>For example, lets choose :</p><ul><li>Command execution, Process Creation, File Modification, OS API Execution, File Creation.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*u0TczHwDLPwMrYtF" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/741/0*eksjMK7kzwaytvP4" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/559/0*8e16mNpO4kGYKHN0" /></figure><p>Once the data sources added, we can save the file, by clicking on “Save YAML file”. (You can put the file in the same place as the “dettect.py” for the further experiments)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*5y1Cgkn4DVetoyec" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/551/0*ayw_pS3dqjANdynM" /></figure><h4>Use case 1:</h4><p>Date tracking can help us monitor the improvement of our data sources. To generate a graph based on the generated “data-sources.yaml” file, we can execute “dettect.py” script with the following options :</p><pre>python dettect.py ds -fd data-sources-endpoints.yaml -g</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*4rIJv0Gjc8102pJL" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/216/0*_6f8J466331nZep0" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*oqVdfSwtOQrEvT22" /></figure><h4>Use case 2:</h4><p>We can also use the generated file with MITRE/ATT&amp;CK Navigator</p><p>First, we convert the .yaml to .json file</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/442/0*D11R4LhIVjipooUH" /></figure><pre>python3 dettect.py ds -fd ../data-sources-new.yaml -l</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*_TPbRFcaM1kTRKl2" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/729/0*43xEDxK2Ps6-hRDj" /></figure><p>Next, we upload the “.json” file on <a href="https://mitre-attack.github.io/attack-navigator/">MITRE Navigator</a> by clicking on “OPen Existing Layer”</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*hzE7Dj9DsCB70aBf" /></figure><p>Thus, we can see the techniques covered by choosing the 05 data sources used above.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*3RG0DwI3c8KTu8dB" /></figure><p>The colors as shown in the legend represent the percentage of log sources for each technique.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/636/0*M_nbjb8GOjb7VGe3" /></figure><p>We notice that the “Web Portal Capture” technique is 100% covered since it requires the log source : “File Modification” which is available.</p><p>Lets take another example, for the technique “Domain Account”, we notice that it requires the following data sources : Command Execution, Process Creation, User Account Creation. This last was not included above, so the “Domain Account” technique is only covered at 66%.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/394/0*fxhRgll3gHGuWLTj" /></figure><p>To summarize, if we want to improve the coverage of a particular technique, we have MITRE ATTACK to see which data source(s) should we integrate for our detection.</p><p>In addition, you can used this data source layer with a MITRE ATT&amp;CK threat analysis layer and pinpoint gaps in your detection based on this analysis.</p><h3>3. DeTT&amp;CT Visibility</h3><p>In this section, we will use DeTT&amp;CT to see our level of visibility.</p><p>Lets start by generating a YAML technique administration file based on the data source administration file “data-sources-new.yaml” generated in the previous section.</p><p>By default, the “ — — yaml” argument includes only those techniques for which the visibility score is greater than 0.</p><pre>python3 dettect.py ds -fd data-sources-new.yaml --yaml</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*FcHX3jbtyWtugcMz" /></figure><p>If we want to include all ATT&amp;CK techniques that apply :</p><pre>python3 dettect.py ds -fd data-sources-new.yaml --yaml --yaml-all-techniques</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*AM3vaUQUaj0LUY9F" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/432/0*UxIA_n7cu1DhtTs6" /></figure><p>The two resulting files will give us an approximate visibility scores. To see the difference we can upload’em in DeTT&amp;CT Editor at the “<strong>TECHNIQUES</strong>” level.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*hm6SMzyQ4JSvq5v7" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*9m3GSWStLAGLA7q0" /></figure><p>We can see on the right that the score is 0 for the file generated by the <strong>— yam-all-techniques</strong> option.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/762/1*ozJ-jMVuHam81hyNcXKAKA.png" /></figure><p>Further, for this tutorial, I’ll keep using the file generated where I have included only the techniques for which the visibility score is higher that 0 “techniques-administration-example.yaml”</p><p>To view the visibility scores on MITRE ATT&amp;CK Navigator we convert the file to json.</p><pre>python3 dettect.py v -ft techniques-administration-example.yaml -l</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*uX6u8tb9fPEQRmIB" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/218/0*LRdNKtCQsx7djfGH" /></figure><p>Then, we upload it on <a href="https://mitre-attack.github.io/attack-navigator/">MITRE Navigator</a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*_rSfnPdGM0yg08eC" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/383/0*nPqByv4KrP9lzRRX" /></figure><p>We can see thus, the visibility score of 1 out of 4 of the techniques in relation to the data sources.</p><h3>4. DeTT&amp;CT Detection</h3><p>Once we have listed our data sources, with a good understanding of visibility, we can move on to detection.</p><p>Using the YAML techniques administration file generated in the previous section, we can administer our detection level with the following :</p><ul><li>The system(s) to which the detection applies (Windows terminals, Windows servers, Linux server)</li><li>A detection score, which is the date when the detection was implemented or improved.</li></ul><p>We upload the ile “techniques-administration-example.yaml” in the “TECHNIQUES” of DeTT&amp;CT</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*U2aJPcxOYBGhdR3w" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*qWEcTiaVFjclWUW7" /></figure><p>Then, we select one of the techniques :</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/766/0*nwLoOhZQWs1F_Er2" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/750/0*_cruC8lD1fyKJgg6" /></figure><p>We save the file</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/235/0*QjF1CiuC0wGfPDdp" /></figure><p>Next, to visualize the file on MITRE ATT&amp;CK (the -l option is for layer)</p><pre>python3 dettect.py d -ft techniques-administration-example.yaml -l</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*PDXvp7ZyqgALmqYQ" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*nELyqOns83Aht2mE" /></figure><p>As we can see, we had assigned a score to the “OS Credential Dumping” technique as a result, only the later will appear in our layer.</p><h3>5. Gap Analysis</h3><p>With DeTT&amp;CT we can compare our detection layer with a threat analysis layer, or any another layer generated specifically for an exercise by Red Teams to identify possible gaps in our detection.</p><p>Executing the “dettect.py” script with the following options would highlight the differences:</p><pre>python3 dettect.py g -g &lt;Threat Actor Group Layer&gt;.yaml -o &lt;Our Layer&gt;.yaml -t detection.</pre><p>Example :</p><pre>python3 dettect.py g -g sample-data/groups.yaml -o ../techniques-administration-example.yaml -t detection</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*-m0pN0f3erQhAbKQ" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*1Gloy00x2aSFAM_8" /></figure><p>We can also generate a layer that compares the visibility and detection</p><p>Using the detection mode</p><pre>python3 dettect.py d -ft techniques-administration-endpoints.yaml -o</pre><p>Or with the visibility mode, both commands return the same layer.</p><pre>python3 dettect.py v -ft  techniques-administration-endpoints.yaml -o</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*SYcpnJ1UZBrt4mRz" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*xbItffcJXMhjdurB" /></figure><p>If you appreciate, please leave a comment, follow me to get notified whenever I write new articles, you can also follow me on <a href="https://twitter.com/reotmani">Twitter</a> :)</p><h3>Resources</h3><ul><li><a href="https://blog.nviso.eu/2022/03/09/dettct-mapping-detection-to-mitre-attck/">DeTT&amp;CT : Mapping detection to MITRE ATT&amp;CK</a></li><li><a href="https://github.com/rabobank-cdc/DeTTECT">GitHub - rabobank-cdc/DeTTECT: Detect Tactics, Techniques &amp; Combat Threats</a></li><li><a href="https://www.mbsecure.nl/blog/2019/5/dettact-mapping-your-blue-team-to-mitre-attack">DeTT&amp;CT: Mapping your Blue Team to MITRE ATT&amp;CK™ - MB Secure</a></li></ul><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2FEXnutTLKS5o%3Ffeature%3Doembed&amp;display_name=YouTube&amp;url=https%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3DEXnutTLKS5o&amp;image=https%3A%2F%2Fi.ytimg.com%2Fvi%2FEXnutTLKS5o%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/efade4624300b8a21fa6ee82c2bee6fd/href">https://medium.com/media/efade4624300b8a21fa6ee82c2bee6fd/href</a></iframe><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=70db2d219bde" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Smart Contracts Vulnerabilities]]></title>
            <link>https://medium.com/coinmonks/smart-contracts-vulnerabilities-abbd6185252a?source=rss-ea29a6da8fd0------2</link>
            <guid isPermaLink="false">https://medium.com/p/abbd6185252a</guid>
            <category><![CDATA[ethereum-blockchain]]></category>
            <category><![CDATA[blockchain]]></category>
            <category><![CDATA[smart-contracts]]></category>
            <category><![CDATA[vulnerability]]></category>
            <category><![CDATA[ethereum]]></category>
            <dc:creator><![CDATA[Redouane OTMANI]]></dc:creator>
            <pubDate>Mon, 28 Nov 2022 10:01:28 GMT</pubDate>
            <atom:updated>2025-10-18T07:06:00.188Z</atom:updated>
            <content:encoded><![CDATA[<p>As we have introduced in previous article <a href="https://medium.com/coinmonks/ethereum-smart-contracts-1d92dd8e7f83">Ethereum Smart contract </a>and some of basic concepts of Ethereum Blockchain. It’s time for us to bring up the security aspect, since smart contracts process and transfer considerable amount of assets, so in addition to its proper execution, it is crucial that after being implemented still protected against attacks, lets not forget its immutable nature.</p><p><strong>In this article</strong>, I am going through a bunch of vulnerabilities in smart contracts. Then, <strong>in the next few articles</strong>, I’ll try going through series of some of famous attacks that exploited these vulnerabilities last years, allowing hackers to steal money or cause other damage, and we’ll see how to prevent and secure, using two attacks detection methods.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*wbqImpTvZ9QuazmyisikFg.png" /></figure><h3>Outline of the article</h3><blockquote><strong><em>1. Blockchain level</em></strong></blockquote><blockquote><strong><em>2. EVM level</em></strong></blockquote><blockquote><strong><em>3. Solidity level</em></strong></blockquote><p>There are multiple vulnerabilities in Ethereum smart contracts that could cause serious security problems, and may occur at different levels Blockchain level, Ethereum Virtual Machine (EVM) level or Solidity level.</p><pre><strong>Blockchain level<br>    </strong>Bad Randomness<br>    Timestamp Dependence<br>    Solidity incorrect blockhash<br>    Transaction-order Dependence<br>    Unencrypted private data On-chain</pre><pre><strong>EVM level<br>    </strong>Short address attack<br>    Immutable bugs<br>    Stack size limit</pre><pre><strong>Solidity level<br>    Call control<br>           </strong>- Reentrancy<br>           - Message call with hardcoded gas amount<br>           - <strong>Call to the Unknown<br>                - </strong>Delegatecall to Untrusted Callee<br>                - Solidity call without data<br>                - Solidity Unchecked external call</pre><pre><strong>    Access control<br>          - Protection Issues<br>                - </strong>Unprotected selfdestruct<br>                - Unprotected Ether Withdrawal, Leaking Ether to arbitrary address<br>                - Unexpected Ether<br>                - Authorization through tx.origin<br>                - Missing protection against Sig Replay Attack<br>                - Lack of Proper Signature Verification<br>                - Insufficient signature information (Signature Malleability) <br>                - Hash collisions with MVLA<br>          <strong>-</strong> <strong>Visibility Issues<br>                - </strong>Functions Default Visibility<br>                - State Variable Default Visibility</pre><pre><strong>    Data control<br>          - Arithmetic Issues<br>                - </strong>Integer overflow/underflow<br>                - Array overflow<br>          - Ether lost (Frozen Ether, locked money)</pre><pre><strong>    Resource control<br>          - DoS<br>                - </strong>DoS with Failed Call<br>                - DoS With Block Gas Limit<br>          - Code With No effects<br>          - Presence of unused variables<br>          - Insufficient Gas Greifing</pre><pre><strong>    Solidity Programming Issues<br>          - Tool control<br>                 - </strong>Outdated compiler version<br>                 - Floating or No Pragma<br>                 - Uninitialized Storage Pointer<br>                 - Use of Deprecated functions constructions<br>                 - Erroneous constructor name<br>          - Variable Shadowing<br>          - Write to Arbitrary Storage Location<br>          - Incorrect Inheritance Order<br>          - Typographical Errors<br>          - Forcing Ether to</pre><pre><strong>Exception Handling<br>          - </strong>Assert Violation<br>          - Requirement Violation</pre><p>Well, I’ve tried my best to draw it so you can see it more clearly.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*hwBi-SjNVskLE5LTfExmjQ.png" /><figcaption>Smart contracts Vulnerabilities</figcaption></figure><p>Lets go through some of these vulnerabilities, most famous to be more accurate.</p><h3>1. Blockchain level</h3><h4><strong>1. 1 Transaction-order Dependence</strong></h4><p>Each block contains a set of transactions, while the state of the blockchain is updated several times, the state of a smart contract is determined by the value of its fields and the current balance. Furthermore, the actual state of a smart contract is <strong>unpredictable </strong>for any user when it is being called via a transaction by a user. As a result, there is <strong>no guarantee </strong>that the transaction will be in the same state as the contract when it is initialized.</p><p>If a block includes two transactions that invoke the same contract at the same time, then users will not be able to know which state the contract is in at the time their individual transactions were/will be executed.</p><p>As shown above, if user 1 and user 2 send transaction <strong>Ti </strong>and <strong>Tj </strong>to a smart contract t the same time <strong>t</strong>, respectively, both users do not know at what state the contract is in when the first transaction is executed. In addition, the order of these transactions is determined by only the miners of th block. Even if user 1 sends transaction <strong>Ti </strong>before user 2 send <strong>Tj</strong>. There is absolutely no guarantee that <strong>Ti </strong>will be executd before <strong>Tj</strong>. If Ti is executed first, the state of the contract will change from state <strong>S </strong>to state <strong>Si</strong>; But, if <strong>Tj </strong>is executed first, the state of the contract will change from state <strong>S </strong>to state <strong>Sj</strong>. Therefore, the final state of a contract depends on the order of execution of the transactions, which is determined by the order of block mining.</p><p>Exploiting this vulnerability would be critical in real-world situtations where buyers and sellers use smart contracts for their financial transactions. This is because sellers often update the price of their items for sale, and buyers send their purchase requests with the prices they observed when sending the transaction. As a result, buyers may have to spend much more than expected in the case of an attack that exploits transaction order dependency.</p><p>How ever, this problem could be avoided by using a transaction counter to “lock in” the initial price agreed on.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ghhMgecgbgADoEaSgkeaww.png" /><figcaption><strong>Transaction-order Dependence</strong></figcaption></figure><h4>1. 2 <strong>Timestamp Dependence</strong></h4><p>To perform any operation on Ethereum Blockchain such as Ether transfer, a smart contract receives a timestamp that specifies the time when the block was generated. This timestamp is set by the miners according to the time of their local system. Therefore, it can be manipulated and modified by’em easily.</p><p>This vulnerability occurs when a smart contract uses the block timestamp as a part of the trigger condition for the execution of critical operation or as a source of random generator. A malicious miner could adjust the provided timestamp by a few seconds, thus changing the output of the contact to their own advantage.</p><p>The timestamp dependency is due to the fact that Ethereum only requires that a timestamp must be greater that that of its previous block and within 900 seconds of the current clock’s future. Thus, if a contract uses a timestamp-based condition to determine whether or not to transfer money, a malicious miner can slightly shift the timestamp to satisfy the condition for the attacker’s benefit. To avoid this vulnerability, the authors suggest using the block index instead, because it is incremental and is protected from manipulation.</p><h3>2. Ethereum Virtual Machine (EVM) level</h3><h4><strong>2.1 Immutable bugs</strong></h4><p>One of the characteristics of smart contracts is that they are immutable. They cannot be modified or deleted after being deployed in the blockchain. This also implies their behavior will be the one expected by the users, since it is guaranteed by the consensus protocol. However, if the contract contains a bug, there is no way to fix it, for this reason, it’s important to educate programmers and developers to design more secure contracts and provide ways to modify or terminate(or destroy -to be more accurate-) them during implementation.</p><h4>2.2 <strong>Stack size limit</strong></h4><p>Each time a contract invokes another contract or itself, the call stack associated with the transaction increases by one frame. Since the call stack is limited to <strong>1024 </strong>frames, a new invocation beyond this limit will cause an exception. This vulnerability was addressed by hard work on the Ethereum blockchain and resulted in a “fork” that redefined how call gas consumption is calculated. Thus, a caller can allocate at most <strong>63 </strong>units out of <strong>64 </strong>: Since, currently, the gas limit per block is <strong>4.7M</strong> units, this implies that the maximum reachable depth of the call stack is always less than <strong>1024</strong>.</p><h3>3. Solidity level</h3><h4><strong>3.1 Reentrancy</strong></h4><p>Reentrancy was first observed in 2016 during the attack on the DAO. It occurs when external contract calls are allowed to make new calls to the calling contract before the initial execution is complete.</p><p>When the contract does not update its state before sending funds, an attacker could recursively call the target’s fund withdrawal function. Therefore, this allows the attacker to bypass the validity check until the caller’s contract is drained of all its ether or the transaction runs out of gas.</p><p>This vulnerability is due to the structure of the fallback function allowing an attacker to repeatedly call the caller’s function also by the lack of a gas limit when transferring the control flow to another contract.</p><p>However, this can be avoided by ensuring that the state variables of the contract are updated before calling another contract. This is done by introducing a “mutex” lock on the state of the contract to ensure that only the owner of the lock can change the state and using the transfer method to send money to other contracts because this method only transmits 2300 gas to called contract.</p><p>Note that there are two main types of Reentrancy : Single function reentrancy and cross function reentrancy.</p><p><strong><em>Single-function</em></strong>. Is simpler and easier to prevent that cross-function reentrancy. It occurs when the vulnerable function is the only function the attacker is trying to call each time.</p><p><strong><em>Cross-function</em></strong>. Is more difficult to detect. It occurs when a vulnerable function shares a state with another function that has an advantageous effect for the attacker.</p><h4>3.2 <strong>Mishandled exceptions</strong></h4><p>In Ethereum, there are several ways for one contract to call another, for example, via sending an instruction or directly calling a function of the contract itself.</p><p>This vulnerability occurs when exceptions are not handled properly. Indeed, depending on how the call is made, the exception in the called contract may propagate to the caller. These inconsistencies in exception propagation open the door to new vulnerabilities that can be exploited by malicious users who invoke calling contracts by causing their sending functions fail. In addition, exceptions can be caused by many situations, such as running out of gas, exceeding the call stack limit, unexpected system error in the called node. Thus, one way to address this problem is to set an upper limit on the gas usage in a call.</p><h4>3.3 <strong>Gasless send</strong></h4><p>Sending without gas causes a transaction to fail if not enough gas is supplied for a specific call. Since the maximum gas limit on the network can vary over time based on transaction charges, it is important to provide an outage exception based on gas consumption. It is also important to develop functions that do not require too much gas.</p><h4>3.4 <strong>Unchecked external call</strong></h4><p>Some external calls in Solidity, such as “<strong>send</strong>()”, “<strong>call</strong>()”, “<strong>delegatecall</strong>()” and “<strong>staticcall()</strong>” never throw exceptions, they only return a Boolean “<strong>false</strong>”. As a result, the execution of the contract will continue even if the call encounters a problem, if it fails accidentally or if an attacker forces its failure.</p><p>In order to solve this problem, it is recommended that the return value must be check manually by the developer, he can also use the “<strong>transfer()</strong>” function.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/970/1*X4pijM6MRfPjdSUd7Cth3w.png" /><figcaption>Vulnerable and not vulnerable code to Unchecked external call</figcaption></figure><h4>3.5 <strong>Authorization through tx.origin</strong></h4><p><strong>tx.origin </strong>is a Solidity variable that returns the address of the account that sent the transaction. Using this variable for authorization could make a contract vulnerable if an authorized account calls a vulnerable contract. A call could be made to the vulnerable contract that passes the authorization check since <strong>tx.origin</strong> returns the original sender of the transaction which, in this case, is the authorized account. To avoid this problem, it is recommended to use “<strong>msg.sender</strong>” instead of “<strong>tx.origin</strong>” authorization.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/816/1*cZ0WDy7auQ-1ElS3RxbV7w.png" /><figcaption>Vulnerable code using “tx.origin”</figcaption></figure><h4>3.6 <strong>Unprotected selfdestruct</strong></h4><p>The “<strong>Selfdestruct</strong>” instruction destorys a contract on the blockchain and sends the contract balance to the specified address. It is so useful for destroying contract that are no longer in use or vulnerable contracts ( bugs, loopholes, ..). However, if it does not have proper access controls malicious parties could use it to <strong>self-destruct </strong>the contract.</p><h4>3.7 <strong>Functions and Variables Default Visibility</strong></h4><p>Functions that do not have a specific visibility type are considered “public” by default. This can lead to a vulnerability if a developer forgets to set a visibility then a malicious user manages to make unauthorized or unintended state changes. To avoid this issue, it is recommended that the appropriate visibility must be specified based on the function. Note that functions can be specified as : “<strong>external</strong>”, “<strong>public</strong>”, “<strong>internal</strong>” and “<strong>private</strong>”.</p><h4>3.8 <strong>Integer overflow and underflow</strong></h4><p>This occurs in transactions that accept unauthorized data or values (for examples, data that exceeds the 256-bit limit). This is because since Solidity can only handle numbers up to 256 bits, increasing (or decreasing) a number above (or below) the maximum (or minimum) value can result in <strong>overflows </strong>(or <strong>underflows</strong>). In addition, this vulnerability is due to the fact that the Solidity source code does not perform proper validation on numeric inputs, and neither the Solidity compiler, nor the EVM enforces integer underflow or overflow detection.</p><p>It’s therefore recommended to use the <a href="https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/utils/math/SafeMath.sol"><strong>OpenZepplin SafeMath</strong></a><strong> </strong>library to mitigate such attacks.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*gC-mZiN6nQ67s77G85lprw.png" /><figcaption>Vulnerable source code example : Integer overflow and underflow</figcaption></figure><h4>3.9 <strong>Ether lost (Frozen Ether, locked money)</strong></h4><p>Contracts programmed to receive ether must implement methods such as “<strong>transfer</strong>”, “<strong>send</strong>” or “<strong>call.value</strong>” in order to withdraw ether. Therefore, if the contract does not implement these methods, it will cause a money block!</p><p>The source code below shows an example of contract programmed to receive ether but not to withdraw it.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/502/1*rRlWq88sVQFxoRijzGf1kQ.png" /><figcaption>Vulnerable source code example : Ether lost (Frozen Ether, locked money)</figcaption></figure><h4>3.10 <strong>Denial of service (DoS)</strong></h4><p>An attack of this type makes the smart contract inaccessible to its users. It can be due to a costly loop, an infinite loop, underpriced operations, call failures or a gas limit.</p><h4>3.10.1 A costly loop</h4><p>These are loops containing costly operations that can drain a contract of all its gas.</p><h4>3.10.2 An infinite loop</h4><p>A bug or a programming error that can cause a possible infinite loop.</p><h4>3.10.3 Under-Priced Operations</h4><p>In general, the value of gas is proportional to the resources consumed by the operation. However, some operations known as “IO-heavy operations” underestimate this value, causing them to be executed in quantity in a single transaction. This way an attacker could launch a DOS attack on the contract or on the Ethreum blockchain. This problem has been solved by changing the values of the different operations.</p><h4>3.10.4 DoS with Failed Call</h4><p>External calls can fail accidentally or deliberately, which can result in a vulnerability that allows a DOS attack.</p><p>To minimize the damage caused by such failures, it is recommended to isolate each external call into its own transaction that can be initiated by the call recipient.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*W3I6SoKDdMxfLyPWXmVBwA.png" /><figcaption>Vulnerable source code example : DOS with failed call</figcaption></figure><h4>3.10.5 DoS With Block Gas Limit</h4><p>When smart contracts are deployed or their internal functions are called, the execution of these actions requires a certain amount of gas. Depending on the computation power required, Ethereum specifies a gas limit per block, and the sum of all transactions included in a block cannot exceed a certain threshold.</p><p>Programming patterns, which are harmless in centralized applications, can lead to denials of service in smart contracts when the cost of executing a function exceeds the gas limit per block. Moreover, the modification of an array that size increases with the time can lead to a denial of service.</p><p>It is recommended to take into consideration arrays that grow with time as well as to avoid actions that require a loop on the whole data structure.</p><h3>Resources</h3><p><a href="https://arxiv.org/abs/1908.04507">https://arxiv.org/abs/1908.04507</a></p><p><a href="https://medium.com/coinmonks/protect-your-solidity-smart-contracts-from-reentrancy-attacks-9972c3af7c21">https://medium.com/coinmonks/protect-your-solidity-smart-contracts-from-reentrancy-attacks-9972c3af7c21</a></p><p><a href="https://arxiv.org/abs/1908.08605">https://arxiv.org/abs/1908.08605</a></p><p><a href="https://eprint.iacr.org/2016/1007.pdf">https://eprint.iacr.org/2016/1007.pdf</a></p><p><a href="https://ntnuopen.ntnu.no/ntnu-xmlui/bitstream/handle/11250/2479191/18400_FULLTEXT.pdf">https://ntnuopen.ntnu.no/ntnu-xmlui/bitstream/handle/11250/2479191/18400_FULLTEXT.pdf</a></p><p><a href="https://swcregistry.io/">https://swcregistry.io/</a>\</p><blockquote>New to trading? Try <a href="https://medium.com/coinmonks/crypto-trading-bot-c2ffce8acb2a">crypto trading bots</a> or <a href="https://medium.com/coinmonks/top-10-crypto-copy-trading-platforms-for-beginners-d0c37c7d698c">copy trading</a></blockquote><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=abbd6185252a" width="1" height="1" alt=""><hr><p><a href="https://medium.com/coinmonks/smart-contracts-vulnerabilities-abbd6185252a">Smart Contracts Vulnerabilities</a> was originally published in <a href="https://medium.com/coinmonks">Coinmonks</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Port knocking]]></title>
            <link>https://medium.com/@reotmani/port-knocking-dbe6d8aaeb9?source=rss-ea29a6da8fd0------2</link>
            <guid isPermaLink="false">https://medium.com/p/dbe6d8aaeb9</guid>
            <category><![CDATA[firewall]]></category>
            <category><![CDATA[linux-tutorial]]></category>
            <category><![CDATA[kali-linux]]></category>
            <category><![CDATA[port-knocking]]></category>
            <category><![CDATA[ubuntu]]></category>
            <dc:creator><![CDATA[Redouane OTMANI]]></dc:creator>
            <pubDate>Mon, 03 Oct 2022 07:02:24 GMT</pubDate>
            <atom:updated>2023-01-22T10:40:28.451Z</atom:updated>
            <content:encoded><![CDATA[<p>Port knocking is a simple concept, it’s like you invite friends at home, you tell them, when you arrive, you ring twice <em>short</em>, then once <em>long</em> on the bell, so I that can recognize you then open the door, otherwise it’s a false alarm.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/626/1*G8glSHJmHhef5I20YUNlNA.png" /></figure><blockquote><strong># sudo apt-get update &amp;&amp; sudo apt-get upgrade</strong></blockquote><p>From this step, we have two methods, first one, passing by <strong>IPtables</strong>, second one using <strong>Knockd </strong>package(simple, which I recommend). I’ll go through both of’em.</p><p>We need to make sure that ssh server is installed</p><blockquote><strong># sudo apt-get install openssh-server</strong></blockquote><p>Then,</p><blockquote><strong># sudo service ssh status</strong></blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*acsA1i3ZvSHnPKrxcJ-iXw.png" /><figcaption><strong>Network Topology</strong></figcaption></figure><blockquote><strong>Plan</strong></blockquote><blockquote><strong>1. First method : Using Knockd</strong></blockquote><blockquote>​ ​ ​​​ ​ ​1.1​​ ​<strong>Install &amp; Configure Knockd</strong></blockquote><blockquote>​ ​ ​​​ ​ ​​​1.2 <strong>Closing the port</strong></blockquote><blockquote>​ ​ ​​​ ​ ​​​1.3 ​<strong>Configure the knock client</strong></blockquote><blockquote><strong>2. Second method : Manually using IPTables</strong></blockquote><h3><strong>1. First method : Using Knockd</strong></h3><h4>1.1​​ ​<strong>Install &amp; Configure Knockd</strong></h4><p>Lets start by installing the knockd</p><blockquote><strong># sudo apt install knockd</strong></blockquote><p>Then editing the file “knockd.conf”</p><blockquote><strong># sudo nano /etc/knockd.conf</strong></blockquote><p>As we can see the default configuration, by the way, it’s important to change theses default values, already known, it could be used to compromise the security of your system.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/792/1*bazJcVUMn1HMoX4j-mmjNw.png" /></figure><p>We modify then the sequence, you can use your preferred sequence. So here in our example, by “knocking” on the ports : 7777, 8888 then 9999 the port of SSH is gonna open. Same goes for closing it.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/766/1*sjZNUFxmw81XPhXqkVlKcA.png" /></figure><p>Next step, we edit the “<strong>/etc/default/knockd</strong>”</p><blockquote><strong># sudo nano /etc/default/knockd</strong></blockquote><p>Look for the line : “START_KNOCKD”, uncomment it, then set the value to <strong>1</strong></p><p>As for line “KNOCKD_OPTS” we set its value the active interface in our machine. We could use <strong>ifconfig</strong> or <strong>tcpdump -D</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/469/1*wCazM6IbReJB-ftw_RYDlg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/275/1*YJKjOjUKqiHcH2VYkIw0iw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/380/1*E8_w2DOmCKvkAGx4ZTyMvA.png" /></figure><p>In my case its the “ens33” interface.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/455/1*EaGmg8eRLXyfeSFp0JGckA.png" /></figure><p>Saves then quit the “knockd” file.</p><p>We can now, start, enable and check the status of <strong>knockd</strong></p><blockquote><strong># sudo systemctl start knockd</strong></blockquote><blockquote><strong># sudo systemctl enable knockd</strong></blockquote><blockquote><strong># sudo systemctl status knockd</strong></blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1018/1*MCX_ygovusGSH3xRGgwq8Q.png" /></figure><h4>1.2 <strong>Closing the port</strong></h4><p>We need to close ssh port, since the knockd service role is to open/close a port.</p><p>We need to active the ufw firewall, then check its status</p><blockquote><strong># sudo ufw enable</strong></blockquote><blockquote><strong># sudo ufw status numbered</strong></blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/443/1*c3To1IYHqWDMvmJf-NEUQw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/431/1*kIA8Mwhpv-fe2HQWFXFsig.png" /></figure><p>As we can see, clearly all ports are closed. I mean lets jump to our Kali machine to try to connect to the Ubuntu machine via SSH. We’ll get a connection timeout error!</p><blockquote><strong># ssh &lt;Username&gt;@&lt;Server IP Address&gt;</strong></blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/580/1*vjMB8QnVV6D_HNEK8uYJRw.png" /></figure><h4>1.3 ​<strong>Configure the knock client</strong></h4><blockquote><strong># sudo apt install knockd</strong></blockquote><blockquote><strong># knock -v &lt;Server IP Address&gt; &lt;Sequence&gt;</strong></blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/568/1*uA7BkUcZsoZUYtipI-bt4A.png" /></figure><p>In my case :</p><blockquote><strong># knock -v 192.168.205.129 7777 8888 9999</strong></blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/701/1*kHnTytLUsCylqyJUxXHlKw.png" /></figure><p>To close the port we send the closing knock sequence</p><blockquote><strong># knock -v 192.168.205.129 4444 5555 6666</strong></blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/553/1*YQ12Vpp0feisGmkKT9jMbQ.png" /></figure><h3><strong>2. Second method : Manually using IPTables</strong></h3><p>Well, first we need to make sure that ssh is running</p><blockquote><strong># service ssh status</strong></blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/594/1*-SBiniVXvBO42H6CKS91Dw.png" /></figure><p>Next, we need to create a bash script, that going to contains our commands to add new rules in Iptables</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/526/1*ZIG49pAnn9MwPxb2soek9A.png" /></figure><p>And put into it the following script</p><pre>#! /bin/bash</pre><pre>###-X, --delete-chain [chain].<br>###-F To delete all the rules</pre><pre>iptables -X<br>iptables -F</pre><pre>iptables -X INTO-P2<br>iptables -X INTO-P3<br>iptables -X INTO-P4</pre><pre>#To accept established connexions.</pre><pre>iptables -A INPUT -p tcp --dport 22 -m state --state ESTABLISHED -j ACCEPT<br>iptables -A INPUT -p tcp --dport 22 -m state --state RELATED -j ACCEPT</pre><pre>#Create new chains with their rules</pre><pre>iptables -N INTO-P2<br>iptables -A INTO-P2 -m recent --name P1 --remove<br>iptables -A INTO-P2 -m recent --name P2 --set<br>iptables -A INTO-P2 -j LOG --log-prefix &quot;INTO P2: &quot;<br> <br>iptables -N INTO-P3<br>iptables -A INTO-P3 -m recent --name P2 --remove<br>iptables -A INTO-P3 -m recent --name P3 --set<br>iptables -A INTO-P3 -j LOG --log-prefix &quot;INTO P3: &quot;<br> <br>iptables -N INTO-P4<br>iptables -A INTO-P4 -m recent --name P3 --remove<br>iptables -A INTO-P4 -m recent --name P4 --set<br>iptables -A INTO-P4 -j LOG --log-prefix &quot;INTO P4: &quot;<br> <br>iptables -A INPUT -m recent --update --name P1</pre><pre>#We need to define the sequence, for example 6666,7777, 8888, 9999,<br>#The more random the sequence is, the better it is.<br>iptables -A INPUT -p tcp --dport 6666 -m recent --name P1 --set</pre><pre>iptables -A INPUT -p tcp --dport 7777 -m recent --rcheck --seconds 10 --name P1 -j INTO-P2</pre><pre>iptables -A INPUT -p tcp --dport 8888 -m recent --rcheck --seconds 10 --name P2 -j INTO-P3</pre><pre>iptables -A INPUT -p tcp --dport 9999 -m recent --rcheck --seconds 10 --name P3 -j INTO-P4</pre><pre>#At this moment we open the ssh port (if the sequence is respected)<br>iptables -A INPUT -p tcp --dport 22 -m recent --rcheck --seconds 10 --name P4 -j ACCEPT</pre><pre>#A by default rule to keep ssh port closed (if the sequence is not respected)<br>iptables -A INPUT -p tcp --dport 22 -m state --state NEW -j DROP</pre><p>You should have something like this:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/776/1*TsvGIVlcQ62_5FbYNDHH9w.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/824/1*JJy5te5WU345h5TEWA3cNg.png" /></figure><p>Before executing the bash script, lets jump into our Kali machine to test a simple ssh connection.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/556/1*9RccCPMKgWfZ3aAQCapR6w.png" /></figure><p>Lets go back to Ubuntu to execute the bash script</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/949/1*DAMTlyYHHrMp1f-n119sEA.png" /></figure><p>[Kali]</p><p>We can see that connection is blocked.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/294/1*1FvwL9BfcRAaJtYEXIwNbA.png" /></figure><p>Now, lets knock the ports 6666, 7777, 8888 and 9999</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/583/1*Qbs6TTYbC_NOYFi7SOX11w.png" /></figure><p>And here you have it, thanks for reading :)</p><p>If you enjoy my stories, you can follow me on <a href="https://twitter.com/reotmani">Twitter</a></p><h3>Resources</h3><p><a href="https://www.researchgate.net/figure/Port-knocking-example-The-firewall-is-opened-in-response-to-a-specific-port-sequence_fig1_4207374">https://www.researchgate.net/figure/Port-knocking-example-The-firewall-is-opened-in-response-to-a-specific-port-sequence_fig1_4207374</a></p><p><a href="https://www.tecmint.com/port-knocking-to-secure-ssh/">https://www.tecmint.com/port-knocking-to-secure-ssh/</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=dbe6d8aaeb9" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[SOC Explained]]></title>
            <link>https://medium.com/@reotmani/soc-explained-8fd5cf6009ba?source=rss-ea29a6da8fd0------2</link>
            <guid isPermaLink="false">https://medium.com/p/8fd5cf6009ba</guid>
            <category><![CDATA[cybersecurity]]></category>
            <category><![CDATA[siem]]></category>
            <category><![CDATA[blue-team]]></category>
            <category><![CDATA[defensive-security]]></category>
            <category><![CDATA[security-operation-center]]></category>
            <dc:creator><![CDATA[Redouane OTMANI]]></dc:creator>
            <pubDate>Mon, 19 Sep 2022 11:08:36 GMT</pubDate>
            <atom:updated>2023-04-17T06:41:42.387Z</atom:updated>
            <content:encoded><![CDATA[<p>Cybersecurity nowdays is more sophisticated than what we think it is. Multiple jobs for different levels and various backgrounds. These positions include Offensive security, Defensive Security, etc.</p><p>In this article I am going through one of the defensive security positions : A SOC Analyst.</p><blockquote><strong>What is a SOC ?</strong></blockquote><blockquote><strong>Types of SOC Models</strong></blockquote><blockquote><strong>People, Process &amp; Technology</strong></blockquote><blockquote><strong>SOC positions</strong></blockquote><blockquote><strong>SOC Analyst missions</strong></blockquote><blockquote><strong>Technical skills</strong></blockquote><blockquote><strong>Soft skills</strong></blockquote><blockquote><strong>How to become an effective SOC analyst ?</strong></blockquote><h3><strong>What is a SOC ?</strong></h3><p>Security Operation Center is a centralized function, employing : People, Processes &amp; Technology to <strong>constantly</strong> monitor &amp; analyze the security of an organization. The main purpose is to prevent, detect, analyze &amp; respond to cyber security incidents.</p><h3><strong>Types of SOC Models</strong></h3><p>There are several types of SOC depending on needs, requirements &amp; budget.</p><blockquote>In-house SOC</blockquote><blockquote>Virtual SOC</blockquote><blockquote>Co-Managed SOC</blockquote><blockquote>Command SOC</blockquote><blockquote>Multifunction SOC/NOC</blockquote><h4>In-house, Dedicated or Internal SOC</h4><p>The company sets its own SOC team, SOC firms consider establishing an internal SOC should have a budget to get support continuity. Its size depends on the organization’s size, risk, security needs &amp; budget. A dedicated SOC is essential for global companies that have private data in various locations and must comply with regulation and security policies.</p><h4>Virtual SOC (VSOC)</h4><p>The security team does not have its own facility, nor does it have its own infrastructure. The VSOC is a web-based portal build on decentralized security technologies, which allows teams to monitor events remotely from different locations.</p><h4>Co-Managed SOC</h4><p>Resource constraints and budget limits are the main reasons to choose this model. It consists of an internal SOC personnel working with an external(outsourced) vendor : Managed Security Service Provider (MSSP). Note that coordination is really important. The effectiveness of this model depends on the right balance between the control you keep in-house vs what you outsource to your MSSP.</p><h4>Command SOC</h4><p>A high-level group that oversees (sometimes even controls) other SOCs and performs forensics &amp; other recovery processes in large region. Organizations that use this model are senior groups that include major telecom providers, defense agencies, <a href="https://www.forbes.com/lists/global2000/">Global 2000 companies</a>, etc.</p><h4>Multifunction SOC/NOC</h4><p>A combination of a Security Operation Center SOC with a Network Operation Center NOC. It has dedicated facility (Team &amp; infrastructure) to go beyond security functions and include IT operations.</p><h3><strong>People, Process &amp; Technology</strong></h3><p>Serious coordination is required to build a successful SOC. Which revolves around 03 primary components : People, Process and Technology.</p><h4>People</h4><p>The most important asset any organization has is its people. As attack types are constantly changing, highly trained personnel familiar with security alerts and attack scenarios are needed, so that they can easily adapt to new types of attack. Organizations would also benefit from focusing on a wider range of training for the junior staff members, enabling them to attain the holistic view of the security posture. With expanded knowledge, your staff will explore new areas within the SOC.</p><h4>Process</h4><p>The second critical piece to successful SOC operations is following established predefined processes (NIST, ITIL, TOGAF, PCI, HIPAA, etc). This brings your SOC structure to a good maturity, these processes require extreme standardization of actions to ensure nothing is skipped.</p><h4>Technology</h4><p>There are so many options in so many aspects of security, you need to follow the market and technology closely to find the best solution for you. This being said, sometime the best product on the market may not be the best for you, due to your low budget. Of course, there are some points to consider : Does it integrate with my other security products ? Is the staff trained ? What will it cost to transition ?</p><p>Understanding and taking an interest in your people, developing processes and leveraging technologies is what makes a successful SOC analyst.</p><h3><strong>SOC positions</strong></h3><blockquote>SOC Analyst</blockquote><blockquote>SOC Manager</blockquote><blockquote>Incident Responder</blockquote><blockquote>Threat Hunter</blockquote><blockquote>CERT (Computer Emergency Response Team) Manager</blockquote><h4>SOC Analyst</h4><p>The Soc analyst supervises the organization’s information system in order to detect suspicious or malicious activities. It can be divided into Levels : 1, 2 and 3 according to its structure (I’m gonna talk about this point in a dedicated article).</p><h4>SOC Manager</h4><p>Soc Manager takes on management responsibilities (Budgeting, strategizing, managing personnel &amp; coordinating operations). He plans and organizes the day-to-day operations of the SOC in order to assess the level of vulnerabilities, detect suspicious or malicious activities. He sets up the security incident detection service, validates the proper execution of the supervision and security event management processes and ensures complete and accurate reporting of key indicators, defines &amp; pilots the SOC service improvement plan. In a nutshell, he deals with operational rather than technical matters.</p><h4>Incident Responder</h4><p>Generally works within a Computer Emergency Response Team (CERT) or Computer Security Incident Response Team (CSIRT). In case of suspicion of malicious activities, he performs technical analysis, identifies the attacker’s modus operandi &amp; qualifies the extent of the compromise. He provides then, remediation to ensure hardening of systems under attack.</p><h4>Threat Hunter</h4><p>A member whose purpose is to find vulnerabilities before the hacker could exploit ’em. He studies the evolution of attacker’s motivation, modus operandi in order to adjust cybersecurity strategy. He provides CERT/CSIRT and SOC with reliable and contextualized information to allow’em adapt and improve their prevention, detection &amp; incident response capabilities.</p><h4>CERT (Computer Emergency Response Team) Manager</h4><p>CERT Manager ensures the proper execution of investigations and coordination during a security incident to ensure an effective response.</p><h3><strong>SOC Analyst missions</strong></h3><p>In 5 words : Detect, React, Implement, Monitor and Report.</p><h4>Detect</h4><ul><li>Identify security events in real time, to analyze and qualify it.</li><li>Evaluate the severity of security incidents.</li><li>Notify security incidents then escalate if necessary.</li></ul><h4>React</h4><ul><li>Transmit action plans to the entities in charges of processing and provide support regarding corrective measures to be implemented.</li><li>Make recommendations on immediate measures.</li><li>Accompany the investigations teams.</li></ul><h4>Implement</h4><ul><li>Implement and maintain the security infrastructure (SIEM solutions and SOC products, etc).</li><li>Contribute to the definition of the event log collection strategy.</li><li>Develop and maintain the event correlation rules.</li></ul><h4>Monitor</h4><ul><li>Improve continuously the procedures, and create new ones for new types of incidents.</li><li>Ensure permanent monitoring of threats, vulnerabilities and attack methods to enrich event correlation rules.</li></ul><h4>Report</h4><ul><li>Complete reporting dashboards.</li><li>Maintain documentation.</li></ul><h3><strong>Technical skills</strong></h3><h4>Technical Foundations</h4><ul><li>System administration skills (Linux, Windows)</li><li>Computer networking skills</li><li>Knowledge of common systems, common services</li><li>Knowledge of at least one scripting language (Bash, PowerShell, etc).</li></ul><h4>Technical Security Foundations</h4><ul><li>Network security knowledge</li><li>Practical and theoretical knowledge of event log correlation tools and security monitoring solutions : SIEM &amp; EDR</li><li>Practice of log analysis</li><li>Practice of network flux analysis</li><li>Malware analysis skills</li><li>Threat hunting skills</li><li>CTI Knowledge</li><li>OSINT skills</li><li>Practical and theoretical knowledge of Offensive Security, attack and intrusion techniques.</li><li>Practical and theoretical knowledge of digital forensics and incident response.</li></ul><h3><strong>Soft skills</strong></h3><ul><li>Ethical sense is necessary to work not only in a SOC but in Cybersecurity in general.</li><li>Good verbal and written communication skills, you should be able to write in executive English.</li><li>Personal workload management.</li><li>Critical thinking.</li><li>Being a good team player.</li></ul><h3><strong>How to become an effective SOC analyst ?</strong></h3><p>Well, becoming a SOC Analyst is common, becoming an effective SOC analyst is not..</p><p>A successful SOC analyst should have the basic knowledge I talked about above, to get these skills you can study Computer Science, but this is not the only way, as an autodidact you can learn from various resources on Internet. Bottom line, you cannot ensure security if you don’t know its foundations. As you learn Technical Security Foundations, you start to understand the parallels with Technical Foundations (which is the basic knowledge) to push the envelope, understanding GRC will help you contextualize your investigations : Where and when the attack happened? , Where, when and to whom I’ll explain my findings ? What’s the impact ? ..etc.</p><p>Being able to communicate is also important, to help inform decision makers also, other team members.</p><p>I’d like to thank you for reading, for sure I’ll continue improving this article in near future while gaining more &amp; more experience within a SOC.</p><p>If you enjoy my stories, you can follow me on <a href="https://twitter.com/reotmani">Twitter</a></p><h3>Resources</h3><p><a href="https://www.linkedin.com/posts/revanth-potluri-89349078_socanalyst-activity-6962657699394179072-Fsp9?utm_source=share&amp;utm_medium=member_desktop">https://www.linkedin.com/posts/revanth-potluri-89349078_socanalyst-activity-6962657699394179072-Fsp9?utm_source=share&amp;utm_medium=member_desktop</a></p><p><a href="https://www.linkedin.com/posts/biggingerhoneypot_effective-soc-analyst-activity-6971833195197538304-vVzi?utm_source=share&amp;utm_medium=member_desktop">https://www.linkedin.com/posts/biggingerhoneypot_effective-soc-analyst-activity-6971833195197538304-vVzi?utm_source=share&amp;utm_medium=member_desktop</a></p><p><a href="https://www.ssi.gouv.fr/uploads/2021/10/anssi-panorama_metiers_cybersecurite-2020.pdf">https://www.ssi.gouv.fr/uploads/2021/10/anssi-panorama_metiers_cybersecurite-2020.pdf</a></p><p><a href="https://www.varonis.com/blog/security-operations-center-soc">https://www.varonis.com/blog/security-operations-center-soc</a></p><p><a href="https://arcticwolf.com/resources/blog/five-types-of-security-operations-center-models/">https://arcticwolf.com/resources/blog/five-types-of-security-operations-center-models/</a></p><p><a href="https://letsdefend.io/blog/how-to-become-a-soc-analyst/">https://letsdefend.io/blog/how-to-become-a-soc-analyst/</a></p><p><a href="https://www.anomali.com/blog/level-up-your-soc-focus-on-people-process-and-technology">https://www.anomali.com/blog/level-up-your-soc-focus-on-people-process-and-technology</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=8fd5cf6009ba" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Untangle — IPSec]]></title>
            <link>https://medium.com/@reotmani/untangle-ipsec-4cd08f32b4a0?source=rss-ea29a6da8fd0------2</link>
            <guid isPermaLink="false">https://medium.com/p/4cd08f32b4a0</guid>
            <category><![CDATA[cybersecurity]]></category>
            <category><![CDATA[ngfw]]></category>
            <category><![CDATA[firewall]]></category>
            <category><![CDATA[ipsec-vpn]]></category>
            <category><![CDATA[ipsec]]></category>
            <dc:creator><![CDATA[Redouane OTMANI]]></dc:creator>
            <pubDate>Mon, 05 Sep 2022 07:02:06 GMT</pubDate>
            <atom:updated>2023-01-22T10:39:15.562Z</atom:updated>
            <content:encoded><![CDATA[<h3>Untangle — IPSec</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/702/1*3YWjeyw2pm80gE9314go-g.png" /><figcaption>Untangle</figcaption></figure><p>Untangle is Next Generation Firewall, mainly used in companies, it secures network and improves their performance. There are two solutions, the first one : “(NG) Firewall” which is intended for small companies (which I’ll go through in this tutorial). The second one is “Untangle Internet Content (IC)” which is intended for large companies.</p><p>Untangle integrates solutions such as: Firewall, router, connection filtering, ad blockers and my other tools.</p><p>Internet Protocol Security or IPSec, is a set of protocols of the 3rd layer in OSI model. Its main purpose is to transport data over an IP network. Initially, IPSec was intended for the IPv6 protocol, but given the slow deployment of IPv6 and the strong need of companies, it has been adapted to IPv4. It allows a secure connection via Internet, no need to set up a private network which saves money (and other resources). So a computer with IPSec tool can access remotely, and safely to the company’s network.</p><p>IPSec can be used in two modes :</p><p><strong>Tunnel mode : </strong>The entire packet is encrypted including the source and destination IP addresses.</p><p><strong>Transport mode : </strong>Only the data are encrypted.</p><p>IPSec ensures : Confidentiality, Data integrity, Authentication and prevents Replay attacks.</p><p>It works by Key exchange, using different protocols:</p><ul><li>ISAKMP protocol : Establishes, negotiates, modifies and removes security associations between two parties.</li><li>ESP (Encapsulating Security Payload, protocol n°50) or AH(Authentication Header, protocol n°51) : Ensures the transfer of data and provides integrity, authentication and confidentiality.</li><li>IKE (Internet Key Exchange) : Negotiates the connection and checks if an IPSec transmission is possible between the two ends of the tunnel.</li></ul><h3>Plan</h3><blockquote><strong>1. Download, installation and configuration</strong></blockquote><blockquote><strong>2. IPSec : Untangle to Untangle</strong></blockquote><blockquote><strong>2.1 </strong>Network topology</blockquote><blockquote><strong>2.2 </strong>Configuration</blockquote><blockquote><strong>2.3 </strong>Analyzing traffic with Wireshark</blockquote><blockquote><strong>3. IPSec : Untangle to StrongSwan</strong></blockquote><blockquote><strong>3.1</strong> Network topology</blockquote><blockquote><strong>3.2</strong> Installation &amp; configuration of StrongSwan</blockquote><blockquote><strong>3.3</strong> Configuration (Untangle side)</blockquote><blockquote><strong>3.4</strong> Analyzing traffic with Wireshark</blockquote><h3><strong>1. Download, installation and configuration</strong></h3><h3>Download</h3><p>The Untangle virtual machine is available via this <a href="https://wiki.untangle.com/index.php/NG_Firewall_Downloads">link</a>. For this tutorial I’ll use the free .ova version.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/995/1*KaEnBUjOSjN_pdXjAsm1GQ.png" /></figure><h3>Installation</h3><p>After downloading Untangle image, we’ll proceed via VirtualBox.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/550/1*z4CzICv86ib7cW-Zvm81Zw.png" /></figure><p>We import the .ova file</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/884/1*O0JKRhy5Fq6fIpACpVkyWA.png" /></figure><p>It’s ready to be launched.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/588/1*xIgrrM4UMilqqSrA_VyTiw.png" /></figure><h3>Configuration</h3><p>When we launch the VM, we’ll have this screen displayed, which is the setup tool. You must first choose the language of the setup:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1004/1*ri2oFZmFiBmpUeHGi7Jidg.png" /></figure><p>First, obviously, you <em>must </em>read and accept the terms of use of Untangle :D</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/986/1*jNKEuTEs8toBRNsyb8Nu4Q.png" /></figure><p>We have to configure the server. In our case, we have a trial version, so we can put any password and email address:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1006/1*HFgijVMZHMeQ4m0DjeM98Q.png" /></figure><p>By the way, did I forget to mention that Untangle is supposed to have two networks interfaces. We need to make sure that the network access modes of the machines in VirtualBox are “Bridged Adapter” and “Internal Network”</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/602/1*72bDzGQfUAFlxOZnFEgsGg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/586/1*WD_ycCK67yz6bUc-7rWfew.png" /></figure><p>the Internet connection must be configured. Lets renew the DHCP and test the connectivity :</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1010/1*LfTG06udhK289FSUnW-qEQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/802/1*KCdgjx4CmTutlBP4n_OYoQ.png" /></figure><p>We need, now, to configure the internal network interface. We have two choices :</p><ul><li>The “Router” mode : The DHCP server is activated and the machines that are internal will have as IP addresses 192.168.2.X in our case.</li><li>The “Transparent Bridge” mode : There is no DHCP server and a firewall is present.</li></ul><p>→ In our case we opt for the “Router” mode</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1003/1*cbHK_WYNwpEkKfYjArvGsA.png" /></figure><p>As a last step, we have the choice to enable automatic updates and to connect our machine to the Command Center Access. After that, the configuration of Untangle server is complete.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/561/1*tIFpyYm6_OqpkkAnZe6upw.png" /></figure><p>Now, lets move on to the next configuration part</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/790/1*j_Yo5WjKFHx4db1Xmuw88g.png" /></figure><p>All we have to do is to create or log in into you Untangle account. In this tutorial, we’ll create a new one.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/946/1*mR4rhU6KTzLI-26-AKpSxg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/942/1*IxGUBW9hcVLcljwA54CZEw.png" /></figure><p>Once the registration is done, we have the possibility to install the recommended applications. In our project we’ll accept because <strong>IPSec </strong>is what we are looking for, and installed with these recommended applications.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/475/1*tinunlCo2cq-UfrbZZgHnA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/424/1*6LC2HngmSUj5x_S6EIh7Dg.png" /></figure><p>As you can see, IPSec is installed</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1014/1*mpijNCd1xRI6TAHVAvuq7A.png" /></figure><h3><strong>2. IPSec : Untangle to Untangle</strong></h3><h4><strong>2.1 </strong>Network topology</h4><p>A first topology, that we propose in this tutorial is Untangle-based</p><p>In order to use IPSec between two machines, both of’em must support IPSec, hence, the installation of two Untangles machines on both sides.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*7dgPrktM8UyueAG6yaog0w.png" /></figure><h4><strong>2.2 </strong>Configuration</h4><p>Before installing IPSec tunnel, it’s obvious that no communication can take place between the two Ubuntu machines.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/538/1*Y1K3Sd54G1LyPlSa2WRMyw.png" /></figure><p>On the first Untangle machine, we create then, an IPSec tunnel by clicking on “Add” button.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*sNI6jg1iDKk-ujNqUBI9rg.png" /></figure><p>A form to fill in is displayed it is the tunnel configuration</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/951/1*WvaFbpFjPweoxRAxCj103w.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/888/1*KhRt_uSfVO6R1jKZedQtxA.png" /></figure><blockquote>Enabled <em>:</em> <em>Activate or deactivate the tunnel.</em></blockquote><blockquote>Connection Type <em>: </em><strong><em>Tunnel</em></strong><em>/</em><strong><em>Transport</em></strong><em>.</em></blockquote><blockquote><strong><em>In the tunnel mode</em></strong><em>, which is most used, you can specify whether it is a connection between two machines, between a machine and a subnet or between two subnets. </em><strong><em>The transport mode </em></strong><em>is for a connection between two machines only.</em></blockquote><blockquote>IKE Version <em>: The version of IKE protocol, which is responsible for authenticating both parties trying to connect to the secure network.</em></blockquote><blockquote>Connect Mode <em>: </em><strong><em>Always Connected, </em></strong><em>The connection is automatically initiated when IPSec restarts. </em><strong><em>On-demand</em></strong><em>, The tunnel remains in sleep mode waiting to respond to an incoming connection request.</em></blockquote><blockquote>Interface <em>: The interface in Untangle that will be associated with IPSec.</em></blockquote><blockquote>Any remote host <em>: A checkbox to allow all IPSec connections from any IP address. If this box is checked, it removes “Remote host” since it’s not necessary anymore.</em></blockquote><blockquote>Remote Host <em>: The IP address or domain name of the remote host with which this tunnel will be established.</em></blockquote><blockquote>Local Identifier <em>: By default it takes the value of the local IP address of the external interface.</em></blockquote><blockquote>Remote Identifier <em>: By default it takes the IP address of the remote host.</em></blockquote><blockquote>Local Network <em>: The local subnet (o a local machine), which will be accessible through IPSec by machines on the remote subnet (or a remote machine), (through the other side of the tunnel).</em></blockquote><blockquote>Remote Network <em>: The remote subnet (or a remote machine) that is in the other end of the tunnel.</em></blockquote><blockquote>Shared Secret <em>: A pre-shared key used to authenticate the connection, which must be the same on both sides. The use of a random key is strongly recommended.</em></blockquote><blockquote>Ping Address <em>: An address in the remote host to test the connection.</em></blockquote><blockquote>Authentication and SA/Key Exchange <em>: The two phases represent the security association. By checking the boxes, you can change the default settings, suc as the encryption algorithm, hash function, etc.</em></blockquote><p>We need to do the same configuration at the second Untangle machine (the other side of the tunnel).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/949/1*wRDZvuyt3zpdI9R86OzRsg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/947/1*q3Ds7JPeLfArbmUg3b0POQ.png" /></figure><p>Once the configuration is set up, we verify that the tunnel is active :</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/988/1*GEJ7G_3qaIjLMMVlLrqqTA.png" /></figure><p>Now, we have such network topology</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*91S78UMUILM4DRvMt63HuA.png" /></figure><p>The IPSec tunnel is now active, we can make a last check with a ping between two Ubuntu machines.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/572/1*pwlpG5F-fxbTnjJ8jU647g.png" /></figure><h4><strong>2.3 </strong>Analyzing traffic with Wireshark</h4><p>IPSec has a lot of options, one of these options is “Bypass all IPSec traffic”. It prevents IPSec traffic from being filtered by other applications or services.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/584/1*9Uln_O0rew-6ArLM0SVtsw.png" /></figure><p>The communication between our two machines has been established, but what guarantees that our packets are really passing through the tunnel ?</p><p>For this, we propose to place a third party machine(as a Man in the Middle) to sniff the network traffic :</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*VbW4A_ScLVu-TJtZKR9Ajw.png" /></figure><p>On the configuration of this machine, we put the interface in promiscuous mode which allows the network card to accept all the packets it receives, event if they are not addressed to it :</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/685/1*6smlyFgV_YwRwDGCqL3q9A.png" /></figure><p>We’ll use Wireshark to sniff the traffic, we know that IPSec uses protocols like ISAKMP and ESP to communicate between the two machines, so we’ll use theses as a search filter in Wireshark:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/723/1*pAx05m7jkpd_04wj4L6Hbw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/734/1*CUPf--BMAu9URuJNV5Qa8w.png" /></figure><p>Finally, we can see that none of the addresses of our two machines are visible. This is normal, since the IPSec tunnel mode also encrypts the source and destination IP addresses.</p><h3><strong>3. IPSec : Untangle to StrongSwan</strong></h3><p>In the first pat, we’ve used Untangle on both sides, with an IPSec Subnet-To-Subnet.</p><p>In this second part, we propose to keep Untangle on one side and put StrongSwan on the other, with a Subnet-To-Host topology.</p><h4><strong>3.1</strong> Network topology</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*-M7JGujSnZ7SqRSI0RA4tQ.png" /></figure><h4><strong>3.2</strong> Installation &amp; configuration of StrongSwan</h4><p>Before proceeding to the installation of StrongSwan, we must activate the Packet-Forwarding, by editing the file “sysctl.conf”</p><blockquote><strong># sudo nano /etc/sysctl.conf</strong></blockquote><p>In this file, we look for, then ucomment the following lines (or we could add’em directly the end of the file) :</p><blockquote>net.ipv4.ip_forward = 1</blockquote><blockquote>net.ipv6.conf.all.forwarding = 1</blockquote><blockquote>net.ipv4.conf.all.accept_redirects = 0</blockquote><blockquote>net.ipv4.conf.all.send_redirects = 0</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/730/1*DHIWYVLBkSWfe2FU65bnvA.png" /></figure><p>To check that we’ve entered theses parameters correctly we use the command :</p><blockquote><strong># sudo sysctl -p</strong></blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/359/1*Az03AXn7zCcXTQisM63gGQ.png" /></figure><p>Let’s go back to the installation &amp; configuration of StrongSwan</p><blockquote><strong># sudo apt update</strong></blockquote><blockquote><strong># sudo apt install strongswan</strong></blockquote><blockquote><strong># sudo systemctl status strongswan-starter</strong></blockquote><p>We verify that it’s activated</p><blockquote><strong># sudo systemctl is-enabled strongswan-starter</strong></blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/588/1*EoPJTwCTpkdgyHhBWVo8DQ.png" /></figure><p>Let’s move on to the tunnel configuration. First, we save the original IPSec configuration file in case, and we put our configuration on the copy of this file.</p><blockquote><strong># sudo cp /etc/ipsec.conf /etc/ipsec.conf.backup</strong></blockquote><blockquote><strong># sudo nano /etc/ipsec.conf</strong></blockquote><p>We’ll go ahead with the following configuration (NOTE. We must make sure that the parameters are the same on the other side of the tunnel, ie, Untangle side in this tutorial).</p><blockquote>config setup</blockquote><blockquote>​ ​ ​​​ ​ ​​​ ​ ​​​charondebug=”all”</blockquote><blockquote>​ ​ ​​​ ​ ​​​ ​ ​​​uniqueids=yes</blockquote><blockquote>conn strongswan-to-untangle</blockquote><blockquote>​ ​ ​​​ ​ ​​​ ​type=tunnel</blockquote><blockquote>​ ​ ​​​ ​ ​​​ ​ auto=start</blockquote><blockquote>​ ​ ​​​ ​ ​​​ ​keyexchange=ikev1</blockquote><blockquote>​ ​ ​​​ ​ ​​​ ​authby=secret</blockquote><blockquote>​ ​ ​​​ ​ ​​​ ​left=192.168.0.20</blockquote><blockquote>​ ​ ​​​ ​ ​​​ ​leftsubnet=192.168.0.20</blockquote><blockquote>​ ​ ​​​ ​ ​​​ ​right=192.168.0.21</blockquote><blockquote>​ ​ ​​​ ​ ​​​ ​rightsubnet=192.168.2.1/24</blockquote><blockquote>​ ​ ​​​ ​ ​​​ ​ike=aes256-sha1-modp1024!</blockquote><blockquote>​ ​ ​​​ ​ ​​​ ​esp=aes256-sha1-modp1024!</blockquote><blockquote>​ ​ ​​​ ​ ​​​ ​aggressive=no</blockquote><blockquote>​ ​ ​​​ ​ ​​​ ​keyingtries=%forever</blockquote><blockquote>​ ​ ​​​ ​ ​​​ ​ikelifetime=28800s</blockquote><blockquote>​ ​ ​​​ ​ ​​​ ​lifetime=3600s</blockquote><blockquote>​ ​ ​​​ ​ ​​​ ​dpddelay=30s</blockquote><blockquote>​ ​ ​​​ ​ ​​​ ​dpdtimeout=120s</blockquote><blockquote>​ ​ ​​​ ​ ​​​ ​dpdaction=restart</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/735/1*DUiQoTrBPT6hG3pxfcGtrw.png" /></figure><p>Lets explain some parameters</p><blockquote><strong>type </strong>: Tunnel or Transport.</blockquote><blockquote><strong>keyexchange </strong>: the version of the IKE.</blockquote><blockquote><strong>authby </strong>: Type of authentication, by password, we put “secret”.</blockquote><blockquote><strong>left </strong>: The local interface that will be external and compose the first end of the tunnel.</blockquote><blockquote><strong>leftsubnet </strong>: The local subnet.</blockquote><blockquote><strong>right </strong>: The remote interface that is on the other end of the tunnel.</blockquote><blockquote><strong>rightsubnet </strong>: The remote subnet.</blockquote><blockquote><strong>ike </strong>: The parameters of IKE, such as the encryption algorithm, hash function, etc.</blockquote><p>We can now save and quit the file “ipsec.conf”, and edit another file to put the addresses of the two interfaces of the two ends of the tunnel, as well as specify the password “azerty” (in this tutorial, but, USE STRONG PASSWORDS)</p><blockquote><strong># sudo nano /etc/ipsec.secrets</strong></blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/751/1*Y2wcLYdAvjaCggG-wx1ttA.png" /></figure><p>We can now restart IPSec, then check its status.</p><blockquote><strong># sudo ipsec restart</strong></blockquote><blockquote><strong># sudo ipsec status</strong></blockquote><p>If Untangle (Or IPSec) is not configured (or disabled) on the other end of the tunnel, the command returns :</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/399/1*Dn8I4rlllPvFamnmnEcZnw.png" /></figure><p>On the other hand, if IPSec on the other end is properly configured and enabled :</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1005/1*pIDXhpyLSA3Ai_jfNiMg4Q.png" /></figure><h4><strong>3.3</strong> Configuration (Untangle side)</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*xTHon1aZLnaNmo3vzkylQA.png" /></figure><p>At the security association (The two phases IKE and ESP), we must put exactly the same parameters of StrongSwan in IPSec of Untangle.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/892/1*1kk_MmXgy2LEwOdyGde8WQ.png" /></figure><p>After validation, we check the status of this tunnel</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/971/1*ZxmqZZk11WbgAP0KAviNYw.png" /></figure><p>At this point, everything is OK. Now we can proceed to the tests</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/577/1*6aeQrwX14KZBe3FFlR-I4Q.png" /></figure><h4><strong>3.4</strong> Analyzing traffic with Wireshark</h4><p>From the attacker (Man In The Middle) perspective with Wireshark</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/678/1*fJJVBZqyH9FuZt0o6luMTQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/742/1*qbvmVTgPU7tjMXjIVbX-dg.png" /></figure><p>We can see that, the ping does pass through the tunnel.</p><p>To conclude, I’d like first, to thank you reading, through this tutorial, we’ve seen that Untangle is an easy tool to deploy, it only requires some config to set up the tool.</p><p>Untangle brings advantages to the company that uses it, thanks to the applications it includes, such as IPSec. In fact, this one could save money because the implementation of a virtual tunnel generally costs less than a real one.</p><p>If you enjoy my stories, you can follow me on <a href="https://twitter.com/reotmani">Twitter</a></p><h3>Ressources</h3><p><a href="https://support.untangle.com/hc/en-us/articles/115015677787-Configuring-L2TP-Xauth-IKEv2-on-NG-Firewall">Configuring L2TP/Xauth/IKEv2 on NG Firewall</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=4cd08f32b4a0" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Kali Undercover Mode (Simple, but useful)(A very quick tutorial)]]></title>
            <link>https://medium.com/@reotmani/kali-undercover-mode-simple-but-useful-a-very-quick-tutorial-3286bf112a50?source=rss-ea29a6da8fd0------2</link>
            <guid isPermaLink="false">https://medium.com/p/3286bf112a50</guid>
            <category><![CDATA[kali-linux]]></category>
            <category><![CDATA[information-security]]></category>
            <category><![CDATA[hacking]]></category>
            <category><![CDATA[cybersecurity]]></category>
            <category><![CDATA[pentesting]]></category>
            <dc:creator><![CDATA[Redouane OTMANI]]></dc:creator>
            <pubDate>Fri, 12 Aug 2022 20:15:32 GMT</pubDate>
            <atom:updated>2023-01-22T10:36:55.834Z</atom:updated>
            <content:encoded><![CDATA[<p>Kali undercover mode, makes it look like Windows 10.</p><p>To switch to undercover mode</p><blockquote><strong># kali-undercover</strong></blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/377/1*2baZCxnvbFy5bnKvUc-usg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*vf7OeTl11bnwxA8t3GcFcw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/913/1*Sd2K0jM7e30odRGiCDdehA.png" /></figure><p>Then to go back to normal mode (The same command)</p><blockquote><strong># kali-undercover</strong></blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/353/1*kScILzU9fEA3VFLBCAcR2g.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/936/1*4NxpxKGA6YwcMgr_hP9HQw.png" /></figure><p>I’ll save you the trouble, but I guess you know when you could use it ;)</p><p>Note. It was released with <strong>Kali Linux 2019.4 </strong>so I’m not sure if you could try it on earlier releases.</p><p>Thanks :)</p><p>If you enjoy my stories, you can follow me on <a href="https://twitter.com/reotmani">Twitter</a></p><h3>Resources:</h3><p><a href="https://www.kali.org/docs/introduction/kali-undercover/">https://www.kali.org/docs/introduction/kali-undercover/</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=3286bf112a50" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Fail2ban]]></title>
            <link>https://medium.com/@reotmani/fail2ban-eb42bd5caccd?source=rss-ea29a6da8fd0------2</link>
            <guid isPermaLink="false">https://medium.com/p/eb42bd5caccd</guid>
            <category><![CDATA[ubuntu-server]]></category>
            <category><![CDATA[fail2ban]]></category>
            <category><![CDATA[security]]></category>
            <category><![CDATA[cybersecurity]]></category>
            <category><![CDATA[linux]]></category>
            <dc:creator><![CDATA[Redouane OTMANI]]></dc:creator>
            <pubDate>Sat, 06 Aug 2022 08:45:40 GMT</pubDate>
            <atom:updated>2023-01-22T10:35:40.872Z</atom:updated>
            <content:encoded><![CDATA[<p>Fail2ban is a framework to prevent against intrusions (written in Python by the way). It could be installed on Linux, to detect automatically any suspect behaviors, so that it blocks (or only) sends alerts.</p><p>For example, it could detect <strong>X authentication attempts</strong> on a service like (ssh) then it’ll block the IP address source of theses attempts, it could also detect abnormal queries (on Apache for ex), and so on!</p><p>In this tutorial, I’ll go through the installation and configuration of Fail2ban.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/611/1*pBF_oWVtfYUItgeaSWVP3Q.png" /></figure><p><strong>Plan</strong></p><ol><li><strong>Overall functioning</strong></li><li><strong>Installation</strong></li><li><strong>Configuration</strong></li><li><strong>Tests</strong></li><li><strong>Managing banned IP addresses</strong></li></ol><h4>1. Overall functioning</h4><p>Fail2ban works with “jails”. Globally a jail is one or more services/ports on which we’ll apply rules, in which we’ll place IP addresses that do not respect these <em>rules</em>. In fact, once a suspect IP address is detected, measures to treat it will be taken.</p><p>By default, we’ll block IP address using <strong>IPtables</strong> rules(Firewall on Linux) for 600 seconds (10 minutes). Example : Blocking IP address after 3 attempts with a wrong password.</p><h4>2. Installation</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*stplwOzgfdyZi5--2TMF6Q.png" /><figcaption>Network Topology</figcaption></figure><p>All of the phases of installation and configuration of Fail2ban are going to take place in Ubuntu. As for Kali, it we’ll help us during tests.</p><p>So lets start, and as always</p><blockquote><strong><em># </em>sudo apt update &amp;&amp; sudo apt upgrade</strong></blockquote><p>Then,</p><blockquote><strong># sudo apt-get install fail2ban</strong></blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/466/1*jrlvsfXwzvhwLBxEc3I2Nw.png" /></figure><p>Lets access then comment the content of the directory “<strong>/etc/fail2ban/</strong>”</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/975/1*49XINpBfANupzBTpTQ3Hmg.png" /><figcaption>“/etc/fail2ban” content</figcaption></figure><p>As we can see, we have the two configuration files : “<strong>fail2ban.conf</strong>” and “<strong>jail.conf</strong>”. Also, the two directories “<strong>action.d</strong>” and “<strong>filter.d</strong>”</p><ul><li><strong>fail2ban.conf. </strong>Contains configuration of some operational settings like the way the deamon logs info, and the socket and pid file it will use.</li><li><strong>jail.conf. </strong>Contains the parameters (like bantime)</li><li><strong>action.d : </strong>Contains actions to take in case o intrusion attempts.</li><li><strong>filter.d : </strong>Contains Regexp to parse logs.</li></ul><p>We’ll be more interested in “<strong>jail.conf</strong>” file, since it allows us to configure behaviors of jails. Note that it’s recommended to create a <em>copy </em>of this file, otherwise, we’ll lose its content after updates.</p><blockquote><strong>#sudo cp jail.conf jail.local</strong></blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*hUfzeI9LT28i2La8yZnOVg.png" /></figure><h4>3. Configuration</h4><p>Lets edit the new file “jail.local” (copy of “jail.conf”)</p><blockquote><strong># sudo nano -l /etc/fail2ban/jail.local</strong></blockquote><p>In this file we need to uncomment some options like : <strong>ignoreip</strong>, <strong>ignorecommand</strong>, <strong>bantime</strong>, <strong>findtime</strong>, <strong>maxretry</strong>, <strong>desemail</strong>, <strong>sender</strong>, <strong>mta</strong>, <strong>protocol</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/933/1*lt5GDiEV0D2CtaQWKTuIjA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/770/1*BexEgajtLC2WMstqBbt9Ug.png" /></figure><ul><li><strong>ignoreip </strong>useful to allow some specific IP addresses, as we’ve put above, 127.0.0.1/8 is our localhost machine, it make sense since that we don’t want to block our server. We could by the way, by the way, add more IP addresses, separated by spaces.</li><li><strong>destemail</strong> email to receive alerts.</li><li><strong>sender</strong> obviously the sender of the email.</li></ul><p>Notice that the file “jail.local” contains so many commands &amp; options, each one is preceded by a comment to explain how it works.</p><p>The directory “<strong>/etc/fail2ban/filter.d</strong>” contains the rules to be used by Fail2ban to parse log files</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ugNPoXooAcd6JG3v2vpM1Q.png" /></figure><p>Filter files must have “<strong>.conf</strong>” extension, and need to be identified by its name, so that we could activate/disactivate jails in the “<strong>jail.local</strong>” file.</p><p>Lets take <strong>ssh</strong> filter as example, we need to go back to the file “<strong>jail.local</strong>”<strong> </strong>to jails section</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/890/1*ePivrfJNoQi3fZDQAxuHhg.png" /></figure><ul><li><strong>[sshd] :</strong> is the filter name.</li><li><strong>enabled</strong> : to activate the jail.</li><li><strong>port</strong> : for service name.</li><li><strong>logpath</strong> : refers to the authentication file, to identify all ssh connection, as result we can read than extract connection failures.</li><li><strong>maxretry</strong> : Number of failures before a host get banned.</li></ul><p>We could add more options, otherwise, default options are going to be taken into account, like <strong>findtime</strong>, <strong>bantime</strong></p><ul><li><strong>bantime </strong>: Number of seconds a host is banned</li><li><strong>findtime </strong>: Number of maxretry during the last “findtime”</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/831/1*jyrKt5rJqPBHHr8Xrlgepg.png" /></figure><p>Finally, we need to run <strong>fail2ban </strong>server, then restart the <strong>fail2ban-client</strong> then check its status</p><blockquote><strong># sudo service fail2ban start</strong></blockquote><blockquote><strong># sudo fail2ban-client reload</strong></blockquote><blockquote><strong># sudo fail2ban-client status</strong></blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/690/1*13RP7dGaOBBAjUSg5vzZ9g.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/653/1*lxVvwM8wXiHr5ot2KOIvUg.png" /></figure><p>As we can see, the <strong>sshd </strong>jail is activated.</p><p>— — — —</p><p>The directory “<strong>action.d</strong>” contains actions to be taken in case of abnormal behavior, theses action files specify which commands are executed to ban or unban an IP address. If we desire local changes, we could create an <em>[actionname].local</em><strong><em> </em></strong>file in the “<strong>action.d</strong>” directory. Each action file contains two sections : <strong>Definition </strong>&amp; <strong>Init</strong>. For more details check this <a href="https://manpages.debian.org/experimental/fail2ban/jail.conf.5.en.html">link</a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*XPJ4ORywmjIucnt4AchqYQ.png" /></figure><h4>4. Tests</h4><p>From another machine, lets try to connect to <strong>SSH </strong>service with more than 3 attempts to activate fail2ban (and see if it works)</p><p>It is possible that <strong>ssh </strong>service is not installed</p><blockquote><strong># sudo apt install openssh-server</strong></blockquote><blockquote><strong># sudo systemctl status ssh</strong></blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/600/1*u8gMU34xRQw654MYx-qxqQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/756/1*Ts1lI6qDutBeptC_dG7oAw.png" /></figure><p>Our ssh server is running!</p><p>Lets jump to our Kali machine</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/859/1*AGqOmSR06cIq33nkZEVaDQ.png" /></figure><p>Then go back to our Ubuntu to see logs on <strong>sshd </strong>jail</p><p><strong># sudo fail2ban-client status sshd</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/468/1*-j44YyjMxsaXv759GyoIJQ.png" /></figure><p>As we can see, it’s our Kali’s IP address that is being blocked. We can no longer (at least for 10 minutes) try to connect to ssh.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/652/1*kwWts3vkcbnd-_EjTuURqw.png" /></figure><h4><strong>5. Managing banned IP addresses</strong></h4><p>As we’ve talked above, we can see the active <strong>jails</strong> with status, and know if a <strong>jail </strong>has banned IP addresses, using status followed by the jail name.</p><p>Now, if one of our IP addresses is blocked due to a repeated and manipulation or tests, we can remove it from the Fail2ban banned IP address with this command :</p><blockquote><strong># sudo fail2ban-client set sshd unbanip 192.168.205.128</strong></blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/681/1*cq8ohiBLQRZFwQpEljJgAA.png" /></figure><p>We could also ban manually an IP address :</p><blockquote><strong># sudo fail2ban-client set sshd banip 192.168.205.128</strong></blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/646/1*DTtZlNYdIBpOsU_Whkhk_Q.png" /></figure><p>To conclude, Fail2ban is great and simple tool to install then use. It provides large number of predefined rules, easy to implement.</p><p>If you enjoy my stories, you can follow me on <a href="https://twitter.com/reotmani">Twitter</a></p><h3>Resources</h3><p><a href="http://www.fail2ban.org/wiki/index.php/Main_Page">http://www.fail2ban.org/wiki/index.php/Main_Page</a></p><p><a href="https://www.it-connect.fr/premiers-pas-avec-fail2ban/#V_Test_du_filtre_SSH">https://www.it-connect.fr/premiers-pas-avec-fail2ban/#V_Test_du_filtre_SSH</a></p><p><em>[Credit to Yasmine]</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=eb42bd5caccd" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Ethereum Smart Contracts]]></title>
            <link>https://medium.com/coinmonks/ethereum-smart-contracts-1d92dd8e7f83?source=rss-ea29a6da8fd0------2</link>
            <guid isPermaLink="false">https://medium.com/p/1d92dd8e7f83</guid>
            <category><![CDATA[ethereum]]></category>
            <category><![CDATA[ethereum-blockchain]]></category>
            <category><![CDATA[smart-contract-blockchain]]></category>
            <category><![CDATA[smart-contracts]]></category>
            <category><![CDATA[smart-contract-security]]></category>
            <dc:creator><![CDATA[Redouane OTMANI]]></dc:creator>
            <pubDate>Fri, 15 Jul 2022 22:47:00 GMT</pubDate>
            <atom:updated>2025-10-18T07:06:51.982Z</atom:updated>
            <content:encoded><![CDATA[<p>Ethereum is a project created by <a href="https://fr.wikipedia.org/wiki/Vitalik_Buterin"><strong>Vitalik Buterin</strong></a><strong> </strong>in 2013. Basically, he wanted a scripting language, a way to create programs for Bitcoin, however, he didn’t have that approval from Bitcoin community to do so. So he went ahead and created his own project which later became a giant in its own.</p><p>The purpose of Bitcoin is simply to create a cryptocurrency. As for Ethereum, it is a platform for building programs, so a blockchain that allow not only to store data and transactions but also programs.</p><p>In this article, I will present the smart contracts, as well as basics of Ethereum.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*78PY52iKFQPtINiDBBnhHA.png" /></figure><h3><strong>Outline of the article</strong></h3><p><strong>I. What is a smart contract ?</strong></p><p><strong>II. The basics of Ethereum</strong></p><ol><li><strong>Token</strong></li><li><strong>Initial coin offering</strong></li><li><strong>Ether</strong></li><li><strong>Wallet</strong></li><li><strong>Gas</strong></li><li><strong>Ethereum Virtual Machine</strong></li><li><strong>Oracles</strong></li><li><strong>Decentralized Autonomous Organization</strong></li><li><strong>The fork</strong></li><li><strong>The attack against The DAO.</strong></li></ol><h3><strong>I. What is a smart contract ?</strong></h3><p>A smart contract is a computer program that runs automatically and autonomously on each node of the blockchain. It is constituted and governed by a set of rules and clauses concluded between the two parties involved in the transaction.</p><p>Based on the logic “If this, then that” allowing to exchange money, goods, shares or any other object of value in a transparent way and without trust intermediary.</p><p>It is a concept that was developed by cryptographer and computer scientist Nick Szabo in the mid- 1990s, long before the advent of Blockchain technology. The word “smart contract” defines a set of rules that automatically execute if conditions are met without the involvement of a trusted third party. But this idea could not be realized at the time because no technology supported the implementation of smart contracts… Until 2009, the application of blockchain technology emerged with Bitcoin, allowing the implementation of a draft of smart contracts, however, it was not until 2013, with the appearance of Ethereum, that the smart contracts were truly implemented and introduced.</p><p>Indeed, Bitcoin was not able to deploy smart contracts because the programming language associated with it, the “Bitcoin script” which, unlike Ethereum’s “Solidity” programming language, was not Turing complete. In other words, it was not possible to code any logic with the bitcoin script, moreover, the important element missing from Bitcoin script are <strong>loops</strong>. Besides, this is not accidental, they have it intentionally, because in general, programs run on each node of the Blockchain, so they can really slow down if someone intentionally (or not) creates a program that contains an infinite loop. Loops are indeed a dangerous tool if they are used in an incorrect way.</p><h3><strong>II. The basics of Ethereum</strong></h3><p>Ethereum is considered a decentralized network of computers that anyone can program and use. In particular, it allows transactions to be carried out and any type of data to be stored on its blockchain. It is characterized by a multitude of basic concepts : Token, ICO, Ether, Wallet, Gas, EVM, Oracles, Fork, DAO, etc.</p><h4><strong>1. Token</strong></h4><p>A token is a digital asset issued and exchangeable on a Blockchain, and having the characteristics of a crypto currency. It is transferable between two parties without a trusted third party.</p><p>Tokens have several functions and their possibilities of use are very numerous. Thus a token can represent a right, a means of payment or a unit of exchange value within a given application or ecosystem.</p><h4><strong>2. Initial coin offering</strong></h4><p>An ICO (Initial Coin Offering) is a fundraising mechanism that works by issuing tokens that can be exchanged for crypto currencies during the start-up phase of a project. The tokens exchanged do not represent shares in the company, they allow to prepay the product or service to be developed.</p><h4><strong>3. Ether</strong></h4><p>Ether is a decentralized, tradable digital cryptocurrency, which additionally powers the Ethereum network by paying for transaction fees and computing services.</p><h4><strong>4. Wallet</strong></h4><p>Wallets are applications that allow you to store funds (Ether), easily perform transactions and check the balance whenever the need arises. In addition, wallets have public addresses that allow them to uniquely identify themselves in the network. Therefore, if a person wants to send ether, they will send it to this public address. It should be noted that in addition to ether, wallets also store user’s private keys.</p><h4><strong>5. Gas</strong></h4><p>We talked about <strong>loops</strong> above and why Bitcoin script never included them because someone can maliciously or accidentally make an infinite loop or a very heavy load that will slow down the calculations on all nodes and therefore slow down the network. Ethereum on the other hand has solved this problem with the concept of gas, now loops are no longer a threat. To put it simply, we have a quantity of gas that we will use to pay for all the operations we need to perform. As the <a href="https://docs.google.com/spreadsheets/d/1m89CVujrQe5LAFJ8-YAUCcNK950dUzMQPMJBxRtGCqs/edit#gid=0">Excel </a>file shows how many units of gas it takes to perform an operation, each operation has its own cost (even for low-level operations). At this point, we can clearly see how this solves the problem, even if our program is computationally too heavy or if it contains an infinite loop, in which cas it will quickly run out of gas and stop working. This concept really encourages people to write good code, otherwise you don’t want your code to be inefficient even a little bit, because it will cost you.</p><p>So gas is the amount of computer time needed to perform an operation. Thus, an the complexity of an operation increases, the cost of the gas unit increases. Each unit of gas has a price denominated in Gwei (1 Gwei = 0.000000001 ETH), defined by the demand on the market.</p><p><strong>Why don’t we use Ether to pay instead of gas ?</strong></p><p>Well, the price of ether changes overnight, it changes all the time, every day, so it would be very unpredictable to try to figure out what it is going to cost you to do what you are doing.</p><p>The connection between <strong>gas </strong>and <strong>ether</strong>, helps us to see the difference between Bitcoin and Ethereum.</p><p>The predominant idea behind Bitcoin is to create a cryptocurrency for people to transact, exchange and pay for services, something that is transparent and borderless, with no restrictions and no permissions (You don’t have to ask permission to send money anywhere you want). This is the principle behind Bitcoin.</p><p>Whereas with Ethereum, and ether, even if people don’t use it to make transactions, they pay to run their programs.</p><h4><strong>6. Ethereum Virtual Machine</strong></h4><p>One of the security aspects dealt with in Ethereum answers the problem : If someone writes a virus like a smart contract and the deploys it on the blockchain, everyone will have a copy, and suddenly, that’s the end, all the nodes will be infected. This is where the EVM (Ethereum Virtual Machine) comes in, it runs on your computer, and therefore it completely encapsulates everything that passed through it. So, these programs run on the EVM and nothing can get out, since it is not in contact with the host machine, so it is isolated, so if something were to go wrong, this program will never have access to your files, it will never be able to see them.</p><h4><strong>7. Oracles</strong></h4><p>The Ethereum blockchain and blockchains in general cannot call on an external service. In other words, it is blind to the outside world, hence the need to use an oracle.</p><p>The oracle is a service in charge of manually entering an external data into the blockchain. Indeed, at the moment T, which will have been defined in advance, the oracle will retrieve the information that has been requested and will insert it into the Blockchain at the place that has been designated. When the smart contract that needs this data is executed, it will search for it in the Blockchain at the designated address and then execute according to this data.</p><h4><strong>8. Decentralized Autonomous Organization</strong></h4><p>What are organizations nowadays ? An organization is composed of a director, managers and employees, etc.</p><p>Well, these people follow certain procedures in order to make their company work. For the checks and everything, within that company, everything is done by humans most of the time, it’s just procedures that have to be followed by people, to make business decisions, every organization has work that has to be done.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*byKA09hPe_sp5bIO1vG4Uw.png" /><figcaption>Organization</figcaption></figure><p>So the idea is to assume that if we have an organization, where we don’t have to do it the traditional way, that is when it can be done automatically, that will bring the notion of smart contracts. If we code all this into smart contracts, all of a sudden you have an organization that works by itself, without human intervention, and that’s what DAO is all about. So a DAO (Decentralized Autonomous Organizations) is a fully decentralized and automated organization. It exists only on the Ethereum Blockchain and its participants interact with each other only on the Blockchain. As a result, the DAO is characterized by its transparency and continuous operation.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/948/1*YuDOtdrquiJK5TviDpOBTg.png" /><figcaption>DAO</figcaption></figure><h4><strong>9. The fork</strong></h4><p>A fork is a division into several branches. At the blockchain level, it can be a division of the blockchain caused by a conflict between blocks or a division caused by a change in the protocol governing the blockchain. There are two types of fork : The soft fort and the hard fork.</p><p><strong>The soft fork.</strong> Is a change in the rules known as backwards compatible, that is to say, it’s unnecessary to update all the nodes and miners for the blockchain to continue to function.</p><p><strong>The hard fork</strong>. Is a fork that modifies more deeply the rules governing the Blockchain. As a result, the blockchain becomes unusable for miners who do not update their system. At the end of this process, two cases are possible : Either all the nodes and miners accept the consensus and update their system, or some of the nodes and miners refuse to update their systems. In this case, two blockchains will be built in parallel.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*DE7UrWt75TyF7-iWqMGt5g.png" /><figcaption>Hard Fork</figcaption></figure><h4><strong>10. The attack against The DAO</strong></h4><p><strong>DAO </strong>was one of the first decentralized autonomous organizations created by Vitalik Buterin in <strong>2016 </strong>on Ethereum. The concept was to create an investor-led venture capital fund, where it helps develop decentralized applications to run on Ethereum, it’s like a noble cause to help others start their own decentralized projects on the blockchain. Note that the DAO organization does not belong to any country.</p><p>In <strong>May 2016</strong>, when it finally appeared, they raised one hundred and fifty million dollars <strong>$150,000,000 </strong>through Crowdfunding and it was the highest amount in the history of crowdfunding. People believed in this idea of decentralization.</p><p>However, unfortunately, there was a mistake in the DAO code, a vulnerability, I’d rather say.. In the way the DAO smart contracts were programmed, because as we said, these DAOs are entirely governed by smart contracts rather than people.</p><p>As a result, the DAO was attacked and hacked, in <strong>June 2016 </strong>for <strong>$50</strong> <strong>million</strong> (at the time), and what’s interesting here is that the attacker didn’t do anything “illegal”, he just found this loophole in the code, and he used it to transfer money from the DAO’s account to his own account…</p><p>Everyone saw what was going on, but they couldn’t do anything about it, because the DAO is autonomous, and you can’t just tell it what to do, it does things on its own, it’s governed by its own algorithms, and at the same time, there was this loophole in the contract that allows the attacker to steal ether. Not to mention the fact that the contract is immutable in nature, you can’t change it once it’s in the blockchain, you can’t just go and change things because that’s against the purpose of the blockchain, so that was a major problem.</p><p>However, the good news was and according to the design of the DAO, there was a fail-safe mechanism that meant that the funds could not be withdrawn in full, until about 30 days later.</p><p>At this point, the whole community had the opportunity and time to think and decide what to do, so there was a dilemma, which was “Code is Law ?“. One part of the community said <em>we’re not going to do anything, because the code is law, and we can’t just go and change thing that are supposed to be unchangeable and so we have to use it as it is.</em></p><p>The other part of the community said <em>this is way too much money, fifty million dollars, and it belongs to people, and we’re going to do hard fork by changing the rules, and that way, we’ll be able to change the contract and get money back then giving it to its owners.</em></p><p>Eventually, they ended up doing a hard fork and it was Vitalik’s initiative to do the fork, but because some people didn’t like the idea, not because they wanted to protect the attacker, but to preserve the integrity of this concept of blockchain, that is there is a smart contract, it is a contract for a reason.</p><p>As a result, Ethereum was divided into <strong>ETH (Ethereum)</strong> and <strong>ETC (Ethereum Classic)</strong>. In the ETH version, the pirated money as recovered and distributed to people, but in the ETC version, the money remained in the possession of the attacker.</p><p>It was, so to say, <strong>two parallel worlds</strong>, in one the money was recovered and in the other the money remained with the attacker, because the stolen money was doubled in both versions of Ethereum.</p><p>At the end the hacker, had left with<strong> 67 million</strong> dollars in the ETC version (67 because it was calculated later, exchange and all).</p><p>Note that the problem was in the DAO code and not in Ethereum, it was a problem in the way the smart contract was coded not the platform.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*j1N60m0oM6EFW37KXHDEPw.png" /><figcaption>Hard fork</figcaption></figure><h4><strong>Resources</strong></h4><p><a href="https://www.superdatascience.com/courses/blockchain-a-z">https://www.superdatascience.com/courses/blockchain-a-z</a></p><p><a href="https://repository.psau.edu.sa/jspui/retrieve/5965ad5a-ec46-44ca-9109-a6bc540991d4/IRJAES-V4N2P546Y19.pdf">https://repository.psau.edu.sa/jspui/retrieve/5965ad5a-ec46-44ca-9109-a6bc540991d4/IRJAES-V4N2P546Y19.pdf</a></p><p><a href="https://www.superdatascience.com/pages/blockchain">https://www.superdatascience.com/pages/blockchain</a></p><p><a href="https://membres-ljk.imag.fr/Jean-Guillaume.Dumas/Enseignements/ProjetsCrypto/Ethereum/ethereum-yellowpaper.pdf">https://membres-ljk.imag.fr/Jean-Guillaume.Dumas/Enseignements/ProjetsCrypto/Ethereum/ethereum-yellowpaper.pdf</a></p><p><a href="https://www.ethereum-france.com/quest-ce-que-lethereum/">https://www.ethereum-france.com/quest-ce-que-lethereum/</a></p><p><a href="https://ethereum.org/en/">https://ethereum.org/en/</a></p><p><a href="https://cryptoast.fr/gas/">https://cryptoast.fr/gas/</a></p><p><a href="https://cryptoast.fr/quest-ce-que-la-machine-virtuelle-ethereum/">https://cryptoast.fr/quest-ce-que-la-machine-virtuelle-ethereum/</a></p><blockquote>New to trading? Try <a href="https://medium.com/coinmonks/crypto-trading-bot-c2ffce8acb2a">crypto trading bots</a> or <a href="https://medium.com/coinmonks/top-10-crypto-copy-trading-platforms-for-beginners-d0c37c7d698c">copy trading</a></blockquote><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=1d92dd8e7f83" width="1" height="1" alt=""><hr><p><a href="https://medium.com/coinmonks/ethereum-smart-contracts-1d92dd8e7f83">Ethereum Smart Contracts</a> was originally published in <a href="https://medium.com/coinmonks">Coinmonks</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>