<?phpinclude"flag.php";
functionsleep_rand() { /* I wish php5 had random_int() */ $range =100000;
$bytes = (int) (log($range, 2) /8) +1;
do { /* Side effect: more random cpu cycles wasted ;) */ $rnd =hexdec(bin2hex(openssl_random_pseudo_bytes($bytes)));
} while ($rnd >= $range);
usleep($rnd);
}
?><!DOCTYPE html>
<html>
.......
<?php
if (isset ($_POST['flag'])):
sleep_rand(); /* This makes timing-attack impractical. */
?>
<br>
<div class="container">
<div class="row">
<?php
if (! strcasecmp ($_POST['flag'], $flag))
echo '<div class="alert alert-success">Here is your flag: <mark>' . $flag . '</mark>.</div>';
else
echo '<div class="alert alert-danger">Invalid flag, sorry.</div>';
?>
</div>
</div>
<?php endif ?>
........
</html>
After reading the code we can directly avoid a first part of php code because it’s impossible to break this function. But in second part the only things who can conduct to a vulnerability is strcasecmp, so this function check if the string given in field is same that a flag. Reading strcasecmp php documentation we can read that :
Now that we know what is source and sink analysis, we will learn how to automate code analysis (Know that automated the process can depends until your code base). We shall used two popular open source static code analysis tools CodeQL and Semgrep.
Abstract Syntax Trees
Modern static code analysis tools for better and deeply comprehension of code base need to understanding of multiple aspect of the code / programming language used like difference between function and a variable, usage of statement, class inheritance for object-oriented languages, the exact placement of parenthesis or semicolons and so on.
AST is a data-structure. It’s a tree that models the syntax of a programming language. AST serve to represent a syntactic structure of a proram, it’s used in a many anothers things, by example a compilers use AST like Clang for C/C++, Babel for Javascript, ast built-in module for Python.
In talking about ast module we can use it to watch what it seem like.
I’m Ted “Tedsig42” Regis Kouhouenou, a young Cybersecurity Enthusiast, CTF player, music lover, drawer. I spend any of my free time on Web Security Reseach . I also make any contributions on Open Source project like Exegol, The Hacker Recipes and Payload all the things. I play CTF and collaborate with @TheBugsReapersVulnerability Researcher / Bug Hunter team . I strive to provide as much information as i can about what i have learned on my blog tedsig42.re, which encompasses CTF writeups, research projects, and more.
Once we know where we are, then the world becomes as narrow as a map. When we don’t know, the world feels unlimited.
Liu Cixin, The Dark Forest
Introduction
Attack surface (the potential entry points to exploit a vulnerability) going often with the growing
of complexity of software. The vulnerabilities to be introduced, as developers’ capacity to properly secure these feature is
limited and mistakes are inevitable when dealing with millions of lines of code. Minor issues can be chained together into far more serious vulnerabilities.
Life is not like water. Things in life don’t necessarily flow over the shortest possible routeHaruki Murakami - 1Q84
Taint analysis (or source and sink analysis ) is the analysis of the flow of input through a program from sources to sinks .
It relies on a simple idea: a large number of vulnerabilities occur because attacker controlled input (the source) flows to a dangerous function (the sink).
If the input modifies other variables along the way, these
variables become “tainted” and are included in the analysis.
Hi everyone this is the first serie of my notes and my recap of the awesome/incredible book From Day Zerp to Zero Day
written by Eugene “Spaceraccoon” Lim a security researcher and white-hat hacker.
He learned rapidly because his first training was in how to learn. - Frank Herbert, Dune.
With the number of discovered and exploited zero days constantly growing, vulnerability research, or the process of analyzing systems
for new vulnerabilities, has zero to zero assumed a critical role in cybersecurity.