Php -- loose comparison root me

Description

30 Points Link

Another PHP type juggling

Statement

Find a way to get the flag.

No bruteforce needed.

Challenge

In this challenge we are giving a web server with php in the backend and an nginx not vulnerable server with 2 input fields one with a seed and the other is a hash.

We are also giving the source code which is displayed below :

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61


 
        
            Unbreakable Random
            
            
            

         
        
        

source code

First thing i noticed was the loose comparison on line 46 and line 47.

1
2
    if[$s != false && $h != false] {
        if[$s.$r == $h] {

and as the challenge describe, this is our entry point.

Understanding the code

Let’s take a look at what this code does.

First let’s check the functions provided with the source code.

First Function

1
2
3
4
5
6
7
8
function gen_secured_random[] { // cause random is the way
    $a = rand[1337,2600]*42;
    $b = rand[1879,1955]*42;

    $a 

Chủ Đề