<?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 Viraj Vaishnav on Medium]]></title>
        <description><![CDATA[Stories by Viraj Vaishnav on Medium]]></description>
        <link>https://medium.com/@hackpeas?source=rss-52db9eca77ea------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*L80y2WYeOaqMQDXdVVhwcQ.jpeg</url>
            <title>Stories by Viraj Vaishnav on Medium</title>
            <link>https://medium.com/@hackpeas?source=rss-52db9eca77ea------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 05 Dec 2026 17:36:32 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@hackpeas/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[two-sum picoCTF Writeup]]></title>
            <link>https://hackpeas.medium.com/two-sum-picoctf-writeup-4e82893cabda?source=rss-52db9eca77ea------2</link>
            <guid isPermaLink="false">https://medium.com/p/4e82893cabda</guid>
            <category><![CDATA[viraj-vaishnav]]></category>
            <category><![CDATA[picoctf]]></category>
            <category><![CDATA[integer-overflow]]></category>
            <category><![CDATA[ctf-writeup]]></category>
            <category><![CDATA[hackpeas]]></category>
            <dc:creator><![CDATA[Viraj Vaishnav]]></dc:creator>
            <pubDate>Thu, 31 Jul 2025 15:51:51 GMT</pubDate>
            <atom:updated>2025-07-31T15:51:51.296Z</atom:updated>
            <content:encoded><![CDATA[<h4>Description</h4><p>Can you solve this?What two positive numbers can make this possible: n1 &gt; n1 + n2 OR n2 &gt; n1 + n2Enter them here nc saturn.picoctf.net 65506. <a href="https://artifacts.picoctf.net/c/455/flag.c">Source</a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/964/1*5cfHe4FDlJUhJN5nBpbffg.png" /></figure><p>The Source file contains below code:</p><p>#include &lt;stdio.h&gt;<br>#include &lt;stdlib.h&gt;</p><p>static int addIntOvf(int result, int a, int b) {<br> result = a + b;<br> if(a &gt; 0 &amp;&amp; b &gt; 0 &amp;&amp; result &lt; 0)<br> return -1;<br> if(a &lt; 0 &amp;&amp; b &lt; 0 &amp;&amp; result &gt; 0)<br> return -1;<br> return 0;<br>}</p><p>int main() {<br> int num1, num2, sum;<br> FILE *flag;<br> char c;</p><p>printf(“n1 &gt; n1 + n2 OR n2 &gt; n1 + n2 \n”);<br> fflush(stdout);<br> printf(“What two positive numbers can make this possible: \n”);<br> fflush(stdout);<br> <br> if (scanf(“%d”, &amp;num1) &amp;&amp; scanf(“%d”, &amp;num2)) {<br> printf(“You entered %d and %d\n”, num1, num2);<br> fflush(stdout);<br> sum = num1 + num2;<br> if (addIntOvf(sum, num1, num2) == 0) {<br> printf(“No overflow\n”);<br> fflush(stdout);<br> exit(0);<br> } else if (addIntOvf(sum, num1, num2) == -1) {<br> printf(“You have an integer overflow\n”);<br> fflush(stdout);<br> }</p><p>if (num1 &gt; 0 || num2 &gt; 0) {<br> flag = fopen(“flag.txt”,”r”);<br> if(flag == NULL){<br> printf(“flag not found: please run this on the server\n”);<br> fflush(stdout);<br> exit(0);<br> }<br> char buf[60];<br> fgets(buf, 59, flag);<br> printf(“YOUR FLAG IS: %s\n”, buf);<br> fflush(stdout);<br> exit(0);<br> }<br> }<br> return 0;<br>}</p><p>it takes two input , integer values. add them and pass the result and the numbers to a function <strong>addIntOvf</strong>.</p><p>There are two in condition in main function. first condition check whether the result of addIntOvf is 0 or not, and if it is zero function will exit, but if the condition fail, then second if condition just check whether the input are positive or not, if numbers are positive then flag will be printed.</p><p>so plan -&gt; make the first if condition to get failed, and second should made.</p><p>static int addIntOvf(int result, int a, int b) {<br> result = a + b;<br> <strong>if(a &gt; 0 &amp;&amp; b &gt; 0 &amp;&amp; result &lt; 0)<br> return -1;</strong><br> if(a &lt; 0 &amp;&amp; b &lt; 0 &amp;&amp; result &gt; 0)<br> return -1;<br> return 0;<br>}</p><p>if we make “a” and “b” negative then second condition for will never met and flag will not be printed.</p><p>so we need to make</p><p><strong>if(a &gt; 0 &amp;&amp; b &gt; 0 &amp;&amp; result &lt; 0)<br> return -1;</strong></p><p>this condition satisfied.</p><p>In C , maximum int value possible is “2147483647” so if we insert 1 and 2147483647 , the sum will become -2147483648 . in this case “a” &amp; “b” are positive and result is negative.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/970/1*zEuG8_-LCZyw-ZKaBELQpg.png" /></figure><p>ByeBye…………</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=4e82893cabda" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[babygame01 picoCTF writeup]]></title>
            <link>https://hackpeas.medium.com/babygame01-picoctf-writeup-a356973261b9?source=rss-52db9eca77ea------2</link>
            <guid isPermaLink="false">https://medium.com/p/a356973261b9</guid>
            <category><![CDATA[ctf]]></category>
            <category><![CDATA[hackpeas]]></category>
            <category><![CDATA[ctf-writeup]]></category>
            <category><![CDATA[viraj-vaishnav]]></category>
            <category><![CDATA[picoctf]]></category>
            <dc:creator><![CDATA[Viraj Vaishnav]]></dc:creator>
            <pubDate>Wed, 30 Jul 2025 14:50:01 GMT</pubDate>
            <atom:updated>2025-07-30T14:50:01.652Z</atom:updated>
            <content:encoded><![CDATA[<h4>Description</h4><p>Get the flag and reach the exit.</p><p>Additional details will be available after launching your challenge instance.</p><p>Hints:</p><ol><li>Use ‘w’,’a’,’s’,’d’ to move around.</li><li>There may be secret commands to make your life easy.</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/966/1*eTc7x1uGhYrfXLsDWhfelg.png" /></figure><p>On launching the instance, it provide a binary named “game” ,</p><p>$ chmod +x game</p><p>$ ./game</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/898/1*SMB3_pKV9skvQSrMTUu33w.png" /></figure><p>Here I understand that, “@” is the position of player, and from hints we can move player position in top, bottom, left and right directions.</p><p>There is “X” at right bottom of map, if we drag player to that position, the program say “You Win!” and then exit , but no flag.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/858/1*9-AtbkTgmW60dcnUbj9JcA.png" /></figure><p>Lets open the binary in ghidra.</p><p>{<br> int iVar1;<br> undefined4 uVar2;<br> int in_GS_OFFSET;<br> int local_aac;<br> int local_aa8;<br> char local_aa4;<br> undefined local_aa0 [2700];<br> int local_14;<br> undefined *local_10;<br> <br> local_10 = &amp;param_1;<br> local_14 = *(int *)(in_GS_OFFSET + 0x14);<br> init_player(&amp;local_aac);<br> init_map((int)local_aa0,&amp;local_aac);<br> print_map((int)local_aa0,(int)&amp;local_aac);<br> signal(2,sigint_handler);<br> do {<br> do {<br> iVar1 = getchar();<br> move_player(&amp;local_aac,(char)iVar1,(int)local_aa0);<br> print_map((int)local_aa0,(int)&amp;local_aac);<br> } while (local_aac != 0x1d);<br> } while (local_aa8 != 0x59);<br> puts(“You win!”);<br> if (local_aa4 != ‘\0’) {<br> puts(“flage”);<br> win();<br> fflush(_stdout);<br> }<br> uVar2 = 0;<br> if (local_14 != *(int *)(in_GS_OFFSET + 0x14)) {<br> uVar2 = __stack_chk_fail_local();<br> }<br> return uVar2;<br>}</p><p>Here we can see the “You Win!” print and also there is win() function which will be called when local_aa4 will not be zero.</p><p>I changed variable names for better understanding.</p><p>{<br> int input_key;<br> undefined4 uVar1;<br> int in_GS_OFFSET;<br> int X_CORD;<br> int Y_CORD;<br> char WIN_VARIABLE;<br> undefined map [2700];<br> int local_14;<br> undefined *local_10;<br> <br> local_10 = &amp;param_1;<br> local_14 = *(int *)(in_GS_OFFSET + 0x14);<br> init_player(&amp;X_CORD);<br> init_map((int)map,&amp;X_CORD);<br> print_map((int)map,(int)&amp;X_CORD);<br> signal(2,sigint_handler);<br> do {<br> do {<br> input_key = getchar();<br> move_player(&amp;X_CORD,(char)input_key,(int)map);<br> print_map((int)map,(int)&amp;X_CORD);<br> } while (X_CORD != 29);<br> } while (Y_CORD != 89);<br> puts(“You win!”);<br> if (WIN_VARIABLE != ‘\0’) {<br> puts(“flage”);<br> win();<br> fflush(_stdout);<br> }<br> uVar1 = 0;<br> if (local_14 != *(int *)(in_GS_OFFSET + 0x14)) {<br> uVar1 = __stack_chk_fail_local();<br> }<br> return uVar1;<br>}</p><p>Now in above code, we can see WIN_VARIABLE is initialzed after MAP, so if can move our position to before the begining ( top and left and press, aaaaaaaa, wwwwww, ) , then it will possibly write some bytes to WIN_VARIABLE.</p><p>First move player to top left.</p><p>when I move position to 4 time left of top left, by typing aaaa and enter , Player has flag changed.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/898/1*UKquedHQ62YttXNfiZLYCw.png" /></figure><p>typing one more “a” lead to segmentation fault. but that doesn’t we need.</p><p>since player got flag after 4 left movement from top left WIN_VARIABLE got some bytes value and it became non zero, now we just need to visit position of “X” that is bottom right. then all condition will be made and win function will be called.</p><p>Luckily, I don’t have to drag my player position by typing too many ddddddd…………… and sssssssssssssssssssss………. .</p><p>in ghidra, I found a function called for moving player move_player</p><p>void move_player(int *param_1,char param_2,int param_3)</p><p>{<br> int iVar1;<br> <br> if (param_2 == ‘l’) {<br> iVar1 = getchar();<br> player_tile = (undefined)iVar1;<br> }<br> if (param_2 == ‘p’) {<br> solve_round(param_3,param_1);<br> }<br> *(undefined *)(*param_1 * 0x5a + param_3 + param_1[1]) = 0x2e;<br> if (param_2 == ‘w’) {<br> *param_1 = *param_1 + -1;<br> }<br> else if (param_2 == ‘s’) {<br> *param_1 = *param_1 + 1;<br> }<br> else if (param_2 == ‘a’) {<br> param_1[1] = param_1[1] + -1;<br> }<br> else if (param_2 == ‘d’) {<br> param_1[1] = param_1[1] + 1;<br> }<br> *(undefined *)(*param_1 * 0x5a + param_3 + param_1[1]) = player_tile;<br> return;<br>}</p><p>This function, param_2 is our input, and if it is ‘p’ , it will call another function solve_round which basically move player postion to bottom right directly. so</p><p>I open netcat session ,</p><ol><li>reach top left.</li><li>type “aaaa” and enter</li><li>Player has flag: 64</li><li>then “p” and enter to trigger solve_round function.</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/909/1*wFQWYy2pe8P6XowA_wD5Uw.png" /></figure><p>Easy Peasy….</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a356973261b9" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[VNE PicoCTF Writeup]]></title>
            <link>https://hackpeas.medium.com/vne-picoctf-writeup-6ca71d22c1bc?source=rss-52db9eca77ea------2</link>
            <guid isPermaLink="false">https://medium.com/p/6ca71d22c1bc</guid>
            <category><![CDATA[hackpeas]]></category>
            <category><![CDATA[viraj-vaishnav]]></category>
            <category><![CDATA[picoctf]]></category>
            <category><![CDATA[linux]]></category>
            <dc:creator><![CDATA[Viraj Vaishnav]]></dc:creator>
            <pubDate>Sun, 20 Jul 2025 12:06:21 GMT</pubDate>
            <atom:updated>2025-07-20T12:06:21.067Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/952/1*Z994LCKufn5a9I6nDx34DA.png" /></figure><p>After SSH to the challange -&gt;</p><p>got binary bin in ctf-player directory</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/559/1*0gmCETD6c_3oamZuOqZIew.png" /></figure><p>it ask to set env SECRET_DIR</p><p>after setting path to SECRET_DIR to /root</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/559/1*IDqgvXBTmFIHs-3BzLpROg.png" /></figure><p>this SECRET_DIR is exploitable, the bin binary is probably using ls command to lis the directory</p><p>lets exploit SECRET_DIR -&gt;</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/738/1*Ch7uUkEoxGQG3D_U2m8LEQ.png" /></figure><p>Thank You…</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=6ca71d22c1bc" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Commitment Issues picoCTF Writeup]]></title>
            <link>https://hackpeas.medium.com/commitment-issues-picoctf-writeup-ef4fa6f4cfae?source=rss-52db9eca77ea------2</link>
            <guid isPermaLink="false">https://medium.com/p/ef4fa6f4cfae</guid>
            <category><![CDATA[hackpeas]]></category>
            <category><![CDATA[picoctf]]></category>
            <category><![CDATA[ctf]]></category>
            <category><![CDATA[viraj-vaishnav]]></category>
            <dc:creator><![CDATA[Viraj Vaishnav]]></dc:creator>
            <pubDate>Fri, 18 Jul 2025 15:51:37 GMT</pubDate>
            <atom:updated>2025-07-18T15:51:37.800Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/954/1*7mQ5n2z6xMB_vTFKIkOjAw.png" /></figure><p>After downloading and extracting the zip:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/758/1*JHCWFU_ow5Uu7xSkMaEF7w.png" /></figure><p>there is a hidden git folder, so git commands</p><p>$ git status</p><p>$ git log</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/777/1*7droWdhIIId01ZAp3P35cQ.png" /></figure><p>git log shows a commit with create flag</p><p>$ git show ea859bf3b5d94ee74ce5ee1afa3edd7d4d6b35f0</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/594/1*6VWj0Zwjt9IkwJwX7fi9DQ.png" /></figure><p>So here is our flag. thank you ….</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ef4fa6f4cfae" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[credstuff picoCTF Writeup]]></title>
            <link>https://hackpeas.medium.com/credstuff-picoctf-writeup-9ee6dbae72fa?source=rss-52db9eca77ea------2</link>
            <guid isPermaLink="false">https://medium.com/p/9ee6dbae72fa</guid>
            <category><![CDATA[hackpeas]]></category>
            <category><![CDATA[cryptography]]></category>
            <category><![CDATA[viraj-vaishnav]]></category>
            <category><![CDATA[picoctf]]></category>
            <category><![CDATA[writeup]]></category>
            <dc:creator><![CDATA[Viraj Vaishnav]]></dc:creator>
            <pubDate>Fri, 11 Jul 2025 16:29:24 GMT</pubDate>
            <atom:updated>2025-07-11T16:29:24.493Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/957/1*kMka_73ZZtw-Smw7n27pgQ.png" /></figure><p>as the challange describe we need to find the password for cultiris , and it is mentioned position of username in usernames.txt ( line number) is the same position of its password in passwords.txt</p><p>so user cultiris prsent on line 378</p><p>greping its password</p><p>$ sed -n ‘378p’ passwords.txt [21:54:07]<br>cvpbPGS{P7e1S_54I35_71Z3}</p><p>its look like rot13 cipher from initial characters “cvpb”</p><p>$ echo “cvpbPGS{P7e1S_54I35_71Z3}” | rot13 [21:54:11]<br>picoCTF{C7r1F_54V35_71M3}</p><p>Thank You..</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=9ee6dbae72fa" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Disk, disk, sleuth! II picoCTF Wrietup]]></title>
            <link>https://hackpeas.medium.com/disk-disk-sleuth-ii-picoctf-wrietup-7d844944e7a5?source=rss-52db9eca77ea------2</link>
            <guid isPermaLink="false">https://medium.com/p/7d844944e7a5</guid>
            <category><![CDATA[ctf-writeup]]></category>
            <category><![CDATA[linux]]></category>
            <category><![CDATA[sleuth]]></category>
            <category><![CDATA[forensics]]></category>
            <dc:creator><![CDATA[Viraj Vaishnav]]></dc:creator>
            <pubDate>Mon, 07 Jul 2025 15:26:41 GMT</pubDate>
            <atom:updated>2025-07-07T15:26:41.408Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/960/1*cN8UJNfUuWE2AEFiLVqWqA.png" /></figure><p>Hints : <br>1. The sleuthkit has some great tools for this challenge as well.<br>2. Sleuthkit docs here are so helpful: <a href="http://wiki.sleuthkit.org/index.php?title=TSK_Tool_Overview">TSK Tool Overview</a><br>3. This disk can also be booted with qemu!</p><p>I need to have a word with the man who put 3rd hint in this challenge, when I read I thought I just have to boot this fucking image , you know how, with this fucking tool [ <a href="https://www.qemu.org/">https://www.qemu.org/</a> ] qemu</p><p>And I did,</p><p>First I installed the tool:</p><p>sudo apt install qemu-system-x86 qemu-utils</p><p>then I open the image with qemu-&gt;</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ZnkIpTcT7Mj7snBIhDXvKw.png" /></figure><p>and wasted my 30 minutes , to just login, then I read hints again. which talk about sleuth tool kit, and as the name of challenge suggest, why on earth I am wasting my time on this qemu tool.</p><p>So I switch to sleuth tool kit.</p><p>I run some image info commands.</p><p>$ mmls dds2-alpine.flag.img</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/964/1*K0vRmKdP5IZH3z5gPOeNoQ.png" /></figure><p>so there is a linux partition -&gt;</p><p>$ fls -o 2048 dds2-alpine.flag.img</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/731/1*FnBsm0SwJlfwDRpeM2OWeA.png" /></figure><p>lets list root directory:</p><p>$ fls -o 2048 dds2-alpine.flag.img 18290</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/834/1*JLDlsNuHV0E3IC4K8Zsoxw.png" /></figure><p>and now we have flag</p><p>$ icat -i raw -f ext4 -o 2048 dds2-alpine.flag.img 18291</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/912/1*wTlPyWcCzfZKxuEp4I_r_Q.png" /></figure><p>Tata, bye bye…</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=7d844944e7a5" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Disk, disk, sleuth! PicoCTF wrietup]]></title>
            <link>https://hackpeas.medium.com/disk-disk-sleuth-picoctf-wrietup-9098e5805d1a?source=rss-52db9eca77ea------2</link>
            <guid isPermaLink="false">https://medium.com/p/9098e5805d1a</guid>
            <category><![CDATA[grep]]></category>
            <category><![CDATA[linux]]></category>
            <category><![CDATA[ctf-writeup]]></category>
            <category><![CDATA[ctf]]></category>
            <category><![CDATA[picoctf]]></category>
            <dc:creator><![CDATA[Viraj Vaishnav]]></dc:creator>
            <pubDate>Mon, 07 Jul 2025 14:55:35 GMT</pubDate>
            <atom:updated>2025-07-07T14:55:35.435Z</atom:updated>
            <content:encoded><![CDATA[<p>Challenge is easy one, all you have to do is fucking grep =&gt;</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/960/1*9Lss42FSH9GMJZ4Is4_wbQ.png" /></figure><p>Still don’t understand, don’t know why the hell there is 4 hints, they never post hints in the challenge where I need it, but they give 4 fucking hints for this stupid challenge, open your eyes and zoom in below SS if you still don’t got the flag=&gt;</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/580/1*D_uKr-JDVYAI_9t7KTFY2w.png" /></figure><p>Tata, Bye,Bye..</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=9098e5805d1a" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[cut command | output management | Linux basic ( part 3 )]]></title>
            <link>https://hackpeas.medium.com/cut-command-output-management-linux-basic-part-3-22cedcd8ef3a?source=rss-52db9eca77ea------2</link>
            <guid isPermaLink="false">https://medium.com/p/22cedcd8ef3a</guid>
            <category><![CDATA[cut]]></category>
            <category><![CDATA[hackpeas]]></category>
            <dc:creator><![CDATA[Viraj Vaishnav]]></dc:creator>
            <pubDate>Fri, 22 Jul 2022 08:32:12 GMT</pubDate>
            <atom:updated>2022-07-22T08:32:12.618Z</atom:updated>
            <content:encoded><![CDATA[<p>This blog is about the cut command, which can be used to cut the strings/lines/columns/rows from the output, files, input, etc</p><p>say you have a string <a href="/service/mailto:bob@gmail.com">bob@gmail.com</a>;<a href="/service/mailto:rahul@gmail.com">rahul@gmail.com</a>;<a href="/service/mailto:krishna@gmail.com">krishna@gmail.com</a> and you want to separate all the emails then you can use the “cut -d” command to do so</p><pre>$ echo “<a href="/service/mailto:bob@gmail.com">bob@gmail.com</a>;<a href="/service/mailto:rahul@gmail.com">rahul@gmail.com</a>;<a href="/service/mailto:krishna@gmail.com">krishna@gmail.com</a>” | cut -d “;” 1 </pre><p>OUTPUT: <a href="/service/mailto:bob@gmail.com">bob@gmail.com</a></p><pre>$ echo “<a href="/service/mailto:bob@gmail.com">bob@gmail.com</a>;<a href="/service/mailto:rahul@gmail.com">rahul@gmail.com</a>;<a href="/service/mailto:krishna@gmail.com">krishna@gmail.com</a>” | cut -d “;” 2 </pre><p>OUTPUT: <a href="/service/mailto:rahul@gmail.com">rahul@gmail.com</a></p><pre>$ echo “<a href="/service/mailto:bob@gmail.com">bob@gmail.com</a>;<a href="/service/mailto:rahul@gmail.com">rahul@gmail.com</a>;<a href="/service/mailto:krishna@gmail.com">krishna@gmail.com</a>” | cut -d “;” 3 </pre><p>OUTPUT: <a href="/service/mailto:krishna@gmail.com">krishna@gmail.com</a></p><p>say you want to print only the first n character of each line from the output on the Linux terminal then =&gt; add this at the end of the command =&gt; | cut -c-n</p><pre>$ ls -lah | cut -c-10</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/949/1*QV5z8JHx_g6EB_zNbRGO5A.png" /></figure><p>say you want to print from character position from c1 to c2 of each line from the output on Linux terminal then =&gt; add this at the end of the command =&gt; | cut -c c1-c2</p><pre>$ ls -lah | cut -c 14-22</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/919/1*5HpAY2MaGCrtCRFhmOSOIQ.png" /></figure><p>If you like the blog, please give me a clap and follow me for more content.</p><p>For more CTFs and bug bounty writeup, or content related to ethical hacking, android penetration testing. follow me on:</p><p>Medium: <a href="https://hackpeas.medium.com/">https://hackpeas.medium.com</a></p><p>Youtube: <a href="https://www.youtube.com/channel/UC17W_Ircv7EmIIdbJeOQ_BQ">https://www.youtube.com/channel/UC17W_Ircv7EmIIdbJeOQ_BQ</a><br>Instagram: <a href="https://www.instagram.com/hackpeas/">https://www.instagram.com/hackpeas/</a><br>Linkedin: <a href="https://www.linkedin.com/in/viraj-vaishnav-19b0a61aa/">https://www.linkedin.com/in/viraj-vaishnav-19b0a61aa/</a><br>Twitter: <a href="https://twitter.com/VirajVaishnav16">https://twitter.com/VirajVaishnav16</a></p><p>Thank You..</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=22cedcd8ef3a" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[DevOps(3): Git/Github [ Advance ]]]></title>
            <link>https://hackpeas.medium.com/devops-3-git-github-advance-9f8d5b1bdf77?source=rss-52db9eca77ea------2</link>
            <guid isPermaLink="false">https://medium.com/p/9f8d5b1bdf77</guid>
            <category><![CDATA[hackpeas]]></category>
            <category><![CDATA[hacker]]></category>
            <category><![CDATA[devsecops]]></category>
            <category><![CDATA[viraj-vaishnav]]></category>
            <category><![CDATA[devops]]></category>
            <dc:creator><![CDATA[Viraj Vaishnav]]></dc:creator>
            <pubDate>Tue, 12 Jul 2022 00:46:22 GMT</pubDate>
            <atom:updated>2022-07-12T00:52:18.087Z</atom:updated>
            <content:encoded><![CDATA[<p>This blog consists of different terms used in Git/GitHub/version-control and some important differences.</p><p>The credit for this blog =&gt; goes to those who uploaded amazing graphical images explaining the workflow of git.</p><p><strong>Git vs Github =&gt;</strong></p><p>Git is a CLI-based tool that is used for version control and source code management while Github is a cloud-based platform that is based on git and used for managing Git repositories.</p><p><strong>Git commit</strong> =&gt; create a snapshot of the staged changes along a timeline of a Git project&#39;s history.</p><p><strong>HEAD</strong> =&gt; this is a pointer that points to the commit ID or the current commit</p><p><strong>Branch</strong> =&gt; A branch is a chain of commits that are on a separate timeline from the master, therefore, they do not have conflicting timelines.</p><p><strong>Downloading zip vs cloning of Github repository </strong>=&gt; when we download the zip of a repository, git files won’t come ( .git, .gitignore, .gitattribute, etc won’t come ), but in case of cloning all the files, including git files will be cloned to local disk.</p><p><strong>Git version control</strong> =&gt;<br>Git is a source control software allowing you to take snapshots and distribute your creations &amp; modifications over time.<br>GitHub is an application allowing you to store and interact with your repository on a remote server, as well as adding more features (eg. Publicity, licensing, collaborators)<br>Git is the bones and flesh of source control, while GitHub gives you the platform to work with your repository easier.</p><p><strong>Basic commands</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/630/0*HUNkaU83o__NtAs4.png" /></figure><pre>$ git init   ## this command initiate the git repository</pre><pre>$ git add &lt;folder1&gt; &lt;folder2&gt; &lt;etc.&gt; ## adding files/folders to git staging area</pre><pre>$ git commit -m “Your message about the commit” ## commiting files present in staging area</pre><pre>$ git remote add origin <a href="https://github.com/yourUsername/yourRepository.git">https://github.com/yourUsername/yourRepository.git</a></pre><pre>$ git push -u origin master ## pusing to branch master</pre><p><strong>Workflow</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/576/0*a9q-9-F7NvwhvWam.png" /></figure><p><strong>Staging area</strong> =&gt; The staging area can be described as <strong>a preview of your next commit</strong>. When you create a git commit, Git takes changes that are in the staging area and makes them a new commit</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ow2koYWDP1Ef5F4LENTqUQ.png" /></figure><h3>ADVANCED GIT COMMANDS</h3><p><strong>Checking status</strong> =&gt;</p><pre>$ git status</pre><p><strong>Adding and removing files =&gt;</strong></p><pre>$ git add PATH_OF_THE_FILE</pre><pre>## to add all the files present in the current directory<br>$ git add . </pre><pre>## removing the particular file from the commit</pre><pre>$ git rm PATH_OF_FILE </pre><pre>## removing the file from git commit forcefully [ Note: this command will remove the file and also delete the file ]</pre><pre>$ git rm -f PATH_OF_FILE</pre><pre>## this command will just make the file untracked locally, so it won’t go in git-commit [ recommended ]</pre><pre>$ git rm --cached PATH_OF_FILE </pre><p><strong>Git commit</strong> =&gt;</p><pre>## open a new file commit message file to put the comment in a very beautiful way<br>$ git commit</pre><pre>## when you want to give a one-liner commit</pre><pre>$ git commit -m “commit message”</pre><pre>## to view all the commits which we have done</pre><pre>$ git log </pre><h3>GOING BACK IN TIME</h3><p><strong>Git checkout</strong> =&gt; it simply means to switch the head pointer from the current branch to any other commit_id or any other branch. it just does switching and changes the working directory accordingly, it won’t change delete anything, or not make any changes until the user does.</p><p>Key points:</p><ul><li>&gt; Head will change</li><li>&gt; Working directory will change accordingly</li><li>&gt; No deletion of commit/files will happen. ( checkout do switching only )</li></ul><p>checkout command is used to switch between commits, branches, etc say we want to go back to some commit which we made earlier -&gt; first use git log to check the commit id for that commit, also remember where the HEAD is pointing ( on which branch )</p><pre>$ git checkout COMMIT_ID         </pre><pre><br>----&gt;&gt;&gt;&gt; now this will make the local repository to that commit, everything will be revert to that commit, files created after that commit will be invisible [ not permanently they will be secure in the .git folder, just for a better view, they will not visible ], and files will hided after that commit will be restored</pre><pre>## say we have visited some commit_id using checkout, and we want to restore the present time state then this command is used</pre><pre>$ git checkout BRANCH_NAME  <br>---&gt;&gt;&gt; this same command can also be used to switching head between branches</pre><p>we can also git checkout to create a new branch and switch to it</p><pre>$ git checkout -b NEW_BRANCH_NAME<br>---&gt;&gt;&gt; this will create a branch with name NEW_BRANCH_NAME and swith head to that branch</pre><p><strong>Git Revert</strong> =&gt; git revert current to move the head pointer to the targeted commit_id and make its current state, which means the entire commit history created after that commit_id will be removed( deleted ).</p><p>Key points:</p><ul><li>&gt; head will change</li><li>&gt; working directory will change accordingly</li><li>&gt; deletion of commits and data is there ( but not permanent, can be reverted )</li></ul><pre>$ git revert COMMIT_ID <br>------&gt;&gt;&gt;&gt;&gt;&gt;&gt; ## this command will revert and delete all the changes which are made between this commit_ID and its previous commit id</pre><p><strong>Reverting the git revert</strong></p><pre>## if we want to revert the actions done by the revert command accidentally, then revert also done in form of commit, we can revert the revert commit by using revert commit id only</pre><pre>$ git revert REVERT_COMMIT_ID</pre><p><strong>Git reset</strong> =&gt;</p><p>This wants to create a new commit like git revert or it is not just visiting the past like git checkout, it is a one-way path, if you reset to a commit, then your current stage becomes that commit, and all the commit is done after that commit will be deleted, no way to go back</p><p><strong>Note</strong>: git reset is very dangerous, use it with care</p><p>There are three kinds of git reset</p><ul><li><strong>soft</strong>: only changes HEAD, but doesn’t change staged files in index or working files.</li><li><strong>mixed</strong>: moves HEAD and updates the index with the contents of the revision to which HEAD now points.</li><li><strong>hard</strong>: moves HEAD and updates the index and working directory — this is the only version of reset that can cause data loss.</li></ul><pre>$ git reset --hard commit_id<br>---&gt;&gt;&gt; this is for hard reset, similar commands are their for mixed and soft</pre><p><strong><em>Difference: git reset vs git revert =&gt; actions done in git revert can be undone, but action done in reset can not be reversed.</em></strong></p><p><strong>.gitignore =&gt;</strong></p><p>This file contains the path of the files/folder which should not include in any git commit.</p><p>create a file with the name .gitignore <br>and add the path of files or directory you want to ignore, and don’t want to include in any commit <br>Note: do not add the completed os path, just add the path from the current directory</p><p>example of .gitignore file =&gt;<br># you can add a comment in .gitignore files with # in the beginning<br>log.txt<br>test/testing/<br>test/testing2/viraj.txt</p><p><strong>Removing cached files from the git</strong> =&gt;</p><p>If any file is being tracked even after putting it into .gitignore, then may there is some cached left of it, to remove the cache give below command</p><pre>$ git rm -r --cached . <br>$ git add -A</pre><p>Note: if you are adding a file in .gitignore, which is already committed once, then it will be kept tracked by git, since its cache is present there, for this you must remove the cached and after that</p><pre>$ git add . </pre><p>So that the file will be checked freshly from the .gitignore file and will be ignored</p><p><strong>working with branches</strong></p><p><strong>creating a new branch</strong> =&gt;</p><pre>$ git branch dev</pre><p>creating a new branch and switching to it</p><pre>## say we are currently in the master branch, then after executing this command, we will move to bugs and bugs will have all the commits done in master</pre><pre>$ git checkout -b bugs</pre><p><strong>listing all available branches</strong> =&gt;</p><pre>$ git branch -a ## the star one is the current one</pre><p><strong>Deleting a branch</strong> =&gt;</p><pre>$ git branch -d branch_name ## this will delete the branch locally only</pre><pre>$ git push origin --delete BRANCH_NAME ## this will create a commit which will delete the BRANCH_NAME</pre><p><strong>Note</strong>: commit of one branch will be different in all the branches, say we created a file, then that file will reflect in all the branches which present currently, but after we add this file in any of the branches&#39; commits, it will be shown in that branch only, it won’t reflect in other branches.</p><p><strong>Merging two branches</strong> =&gt;</p><p>Initial stage =&gt;</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/500/0*E7Z-pnYUQHD7r6pp.png" /></figure><p>After merging =&gt;</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/500/0*oAgDUyHBCaQuOIzv.png" /></figure><p>Say we merge the dev branch to the master branch then <br> -&gt; all commits of the dev branch will be merged to the master branch too.<br> -&gt; if in the master branch some extra commits are present, which are done on files from dev or the files having the same name as dev, then there will be a conflict, all if the files if branches have different changes, then they will be merged with the comments left for you to check, commit will be failed, and the respective merge will be put in the unstaged area so after you can check the comments and balance the code from both the branches and then you can add the files to the staged area and commit them.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*SH_KeXvbtmUpj-ujsCWiZQ.png" /></figure><p>In the above screenshot, you can see the master branch has some commits of the dev branch with the same commit_id, that’s how merging works. here I merged the dev branch into the master.<br><strong> Note</strong>: If one single file has a different commit in both the branches then while merging, commits from both the branches will be present in the file with a proper comment, only the commit will fail on purpose, and the purpose is that you cross-check the merged happened in the file which has committed in both the branches and do the final commit after the confirmation.</p><pre>## below command will merge the dev branch to the current branch</pre><pre><br>$ git remote dev </pre><pre>---&gt;&gt;&gt; say we are currently in master branch, and we want to merge the dev branch to master , then use above command to do so,<br>Git automatically tries to merge the separate histories when creating a merge commit. In case it comes across data that is altered in both histories, user intervention is required.</pre><p><strong>WORKING ON REMOTE REPOSITORY</strong></p><p><strong>Adding remote repository</strong> =&gt;</p><p>This means we are specifying the remote repository, where we want to put our data</p><pre>$ git remote add origin “URL_WITH_GIT”</pre><pre>$ git remote -v ## list all added origin</pre><p><strong>Git pull</strong> =&gt;</p><pre>$ git pull ## to pull the current branch</pre><pre>$ git pull origin master ## to pull the master branch</pre><p><strong>Git push</strong> =&gt;</p><p>pushing a recent commit to the GitHub</p><pre>$ git push -u origin branch_name</pre><p><strong>Rebasing two branches =&gt;</strong></p><p>In case of rebasing, the commits of the source branch are freshly committed to the head of the destination branch.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/588/1*4mjGzWKP64Id0sWoc_MUJA.png" /></figure><p>$ git rebase branch_name_the_source_one</p><p><strong><em>Diff: git rebase vs git merge</em></strong> =&gt; In merging commits on the source branch will be merged to the destination branch, with the same hash id, and the time of commit will be the same on both the branches while in the case of rebasing commits of source branch will be freshly committed to destination branch, means hash id will be different with different commit time.</p><p>For more CTFs and bug bounty writeup, or content related to ethical hacking, android penetration testing. follow me on:</p><p>Medium: <a href="https://hackpeas.medium.com/">https://hackpeas.medium.com</a></p><p>Youtube: <a href="https://www.youtube.com/channel/UC17W_Ircv7EmIIdbJeOQ_BQ">https://www.youtube.com/channel/UC17W_Ircv7EmIIdbJeOQ_BQ</a><br>Instagram: <a href="https://www.instagram.com/hackpeas/">https://www.instagram.com/hackpeas/</a><br>Linkedin: <a href="https://www.linkedin.com/in/viraj-vaishnav-19b0a61aa/">https://www.linkedin.com/in/viraj-vaishnav-19b0a61aa/</a><br>Twitter: <a href="https://twitter.com/VirajVaishnav16">https://twitter.com/VirajVaishnav16</a></p><p>Thank You..</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=9f8d5b1bdf77" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Input/Output and error redirection in Linux: Linux basic (part 2)]]></title>
            <link>https://hackpeas.medium.com/output-and-error-redirection-in-linux-linux-basic-part-2-5d81a5fe98a4?source=rss-52db9eca77ea------2</link>
            <guid isPermaLink="false">https://medium.com/p/5d81a5fe98a4</guid>
            <category><![CDATA[veer1024]]></category>
            <category><![CDATA[viraj-vaishnav]]></category>
            <category><![CDATA[hackpeas]]></category>
            <category><![CDATA[linux]]></category>
            <category><![CDATA[commands]]></category>
            <dc:creator><![CDATA[Viraj Vaishnav]]></dc:creator>
            <pubDate>Sun, 03 Jul 2022 10:46:52 GMT</pubDate>
            <atom:updated>2022-07-03T10:49:35.362Z</atom:updated>
            <content:encoded><![CDATA[<p><strong>Redirection in Linux:</strong></p><p>In Linux, there is a feature of redirection, by which we can change the input/output device or destination while executing the shell command.</p><p>In Linux, there are two kinds of output streams standard output ( symbolize as “1” in commands ) and standard error ( symbolize as “2” in commands )</p><h3><strong>Redirection of output:</strong></h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/806/1*_x02FfoDA5G7xDAD7yvlow.png" /></figure><p>so currently we have a directory with files regex.txt , test2.txt and test.txt</p><pre>$ ls # this command will give the list of files/directory in current folder</pre><p>so we are going to redirect the output of “ls” command to a new file called output.txt</p><pre>$ ls 1&gt;output.txt</pre><p>here 1 symbolizes the output of the given command and &gt; means redirecting the output of this command to “output.txt”</p><p><strong>Note: in Linux 1 means output, also known as standard output</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/826/1*IM_4bQdapum-T2bbShUHAg.png" /></figure><p>as you can see, a new file is created with the name “output.txt”, which contains all the file names, including its own name too.</p><h3>Redirection of error</h3><p>while executing a shell command, sometimes it gives an error, for example below command</p><pre>$ ls does_not_exsist.txt</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/818/1*bKPykvL4ShMg5n74cJcvjA.png" /></figure><p>it gives an error “No such file or directory”</p><p>if try to redirect the output to a file named “file.txt”, it redirects nothing,</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/839/1*uT7a4igoHU1BCe9sF7PZ0w.png" /></figure><p>file.txt is empty, because, there is no output generated from this command, only the error. but if we look for the below command</p><pre>$ cat *</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/808/1*xKICNttX1E8RU_x2gM7V1Q.png" /></figure><p>only_root.txt file can be read by root only user, so it is giving error, while file.txt is readable so it content is printed on screen,</p><p>lets redirect output to file.txt and error to error.txt</p><pre>$ cat * 1&gt;ouput.txt 2&gt;error.txt</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/737/1*YkCmlcktumguXeUgPS-Kkg.png" /></figure><p>1&gt; is redirecting input , while 2&gt; redirecting error</p><h3>Use of &amp;</h3><p>say we want to redirect output of 1 and 2 at the same destination</p><p>so we need to write command in this way</p><pre>$ command 1&gt;output.txt 2&gt;&amp;1</pre><p>the above commands mean, redirect 2 to the same destination where 1 is redirected.</p><p>If you like the blog, please give me a clap and follow me for more content.</p><p>For more CTFs and bug bounty writeup, or content related to ethical hacking, android penetration testing. follow me on:</p><p>Medium: <a href="https://hackpeas.medium.com/">https://hackpeas.medium.com</a></p><p>Youtube: <a href="https://www.youtube.com/channel/UC17W_Ircv7EmIIdbJeOQ_BQ">https://www.youtube.com/channel/UC17W_Ircv7EmIIdbJeOQ_BQ</a><br>Instagram: <a href="https://www.instagram.com/hackpeas/">https://www.instagram.com/hackpeas/</a><br>Linkedin: <a href="https://www.linkedin.com/in/viraj-vaishnav-19b0a61aa/">https://www.linkedin.com/in/viraj-vaishnav-19b0a61aa/</a><br>Twitter: <a href="https://twitter.com/VirajVaishnav16">https://twitter.com/VirajVaishnav16</a></p><p>Thank You..</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=5d81a5fe98a4" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>