Posts

4-1 Working with For-Loop (syntex)

python Looping through an entire List when you want to do the same action with every item in a list, you can use Python’s for loop. Let’s say we have a list of magician’s names and we want to print out each name in the list. This loop system approach could cause several problems for one, it would be repetitive to do this with a long list of names. Also we’d have to change our code each time the list’s length changed. A for loop avoids both of these issues by letting Python manage these issues internally. Let’s use a for loop to print out each name in a list of magicians : magicians = [ 'alice' , 'david' , 'carolina' ] for magician in magicians : print ( magician ) The output is a simple printout of each name in the list : alice david carolina A closer look at looping One of the most common ways to automates repetitive tasks. For example : for magician in magicians : This line tells Python to retrieve the first valu

PicoCTF crypto challenge - Mind your Ps and Qs

Image
Welcome file Description In RSA, a small e value can be problematic, but what about N? Can you decrypt this? values format : C = ciphertext p and q = prime numbers n = p * q phi = (p-1) * (q-1) e = some number that 1 < e < phi and gcd(e,phi) == 1 d = e^(-1) mod phi #! /usr/bin/env python3 from factordb . factordb import FactorDB import gmpy2 c = 240986837130071017759137533082982207147971245672412893755780400885108149006 n = 83141682808041786634050496818899003281031619353365351602217578439972014107627 e = 65537 f = FactorDB ( n ) f . connect ( ) p , q = f . get_factor_list ( ) ph = ( p -1 ) * ( q -1 ) d = gmpy2 . invert ( e , ph ) plaintext = pow ( c , d , n ) print ( "Flag: {}" . format ( bytearray . fromhex ( format ( plaintext , 'x' ) ) . decode ( ) ) )

PicoCTF web challenge - get_ahead

Image
Picoctf Two options When you look in to HTML file you can see two different option the ‘GET’ / ‘POST’ ┌─ [ visith@parrot ] ─ [ ~/Desktop/CTF/picoctf/get_ahead ] └──╼ $curl -I http://mercury.picoctf.net:47967/ 'GET' HTTP/1.1 200 OK flag: picoCTF { r3j3ct_th3_du4l1ty_cca66bd3 } Content-type: text/html ; charset = UTF-8 curl: ( 6 ) Could not resolve host: GET ┌─ [ ✗ ] ─ [ visith@parrot ] ─ [ ~/Desktop/CTF/picoctf/get_ahead ] └──╼ $curl -I http://mercury.picoctf.net:47967/ 'POST' HTTP/1.1 200 OK flag: picoCTF { r3j3ct_th3_du4l1ty_cca66bd3 } Content-type: text/html ; charset = UTF-8 curl: ( 6 ) Could not resolve host: POST

PicoCTF - forensics (information)

Image
Welcome file Information When you download that j-peg file u can see nice little cat. But in the hints they look into the picture details. So u need to install tool called exif and look into that. I found a suspsious thing in license tag looks like base64. visith@ubuntu:~/Desktop/ctf/picoctf/forensics/information$ exiftool cat.jpg ExifTool Version Number : 11.88 File Name : cat.jpg License : cGljb0NURnt0aGVfbTN0YWRhdGFfMXNfbW9kaWZpZWR9 visith@ubuntu:~/Desktop/ctf/picoctf/forensics/information$ echo cGljb0NURnt0aGVfbTN0YWRhdGFfMXNfbW9kaWZpZWR9 | base64 -d picoCTF { the_m3tadata_1s_modified } visith@ubuntu:~/Desktop/ctf/picoctf/forensics/information$

PicoCTF - binary exploitation (stonks)

Image
picoctf stonks First look at that file ‘vuln.c’. vuln.c file : # include <stdlib.h> # include <stdio.h> # include <string.h> # include <time.h> # define FLAG_BUFFER 128 # define MAX_SYM_LEN 4 typedef struct Stonks { int shares ; char symbol [ MAX_SYM_LEN + 1 ] ; struct Stonks * next ; } Stonk ; typedef struct Portfolios { int money ; Stonk * head ; } Portfolio ; int view_portfolio ( Portfolio * p ) { if ( ! p ) { return 1 ; } printf ( "\nPortfolio as of " ) ; fflush ( stdout ) ; system ( "date" ) ; // TODO: implement this in C fflush ( stdout ) ; printf ( "\n\n" ) ; Stonk * head = p -> head ; if ( ! head ) { printf ( "You don't own any stonks!\n" ) ; } while ( head ) { printf ( "%d shares of %s\n" , head -> shares , head -> symbol ) ; head = head -> next ; } retu

PicoCTF - Reverse engineering (transformation)

Image
Welcome file transformation Here u can use two methods recover this flag. you can simply use cyberchef online decoder or You can make a decode python script decode = '灩捯䍔䙻ㄶ形楴獟楮獴㌴摟潦弸彥ㄴㅡて㝽' print ( decode . encode ( 'utf-16-be' ) )

PicoCTF - general skills (wave the flag)

Image
Welcome file wave the flag isith@ubuntu:~/Desktop/ctf/picoctf/general/wave the flag$ chmod +x warm visith@ubuntu:~/Desktop/ctf/picoctf/general/wave the flag$ ./warm Hello user ! Pass me a -h to learn what I can do ! visith@ubuntu:~/Desktop/ctf/picoctf/general/wave the flag$ ./warm -h Oh, help? I actually don't do much, but I do have this flag here: picoCTF { b1scu1ts_4nd_gr4vy_18788aaa }