Rev-AmateursCTF2023-Volcano

  • DIE
    Image
1
透過_libc_start_main進入main function,根據題目,給他需要的bear以及volcano,最後再找出符合判斷式的結果。

Image

  • sub.c

    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
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    #include <stdio.h>
    #include <stdbool.h>

    int sub_1209(int x) {

    int v3;

    v3 = 0;

    while(x){
    ++v3;
    x /= 10;
    }

    return v3;
    }

    int sub_124D(int x) {

    int v3 = 0;

    while (x){
    v3 += x % 10;
    x /= 10;
    }
    return v3;
    }

    int sub_1430(int a, int b, int c) {

    int v5;
    int v6 = 1;
    v5 = a % c;

    while (b){
    if ((b&1)!=0)
    v6 = v5 * v6%c;
    b >>= 1;
    v5 = v5 * v5 % c;
    }
    return v6;
    }

    bool isbear(unsigned int bear){

    if ((bear & 1) != 0)
    return false;
    if ((bear % 3) !=2)
    return false;
    if ((bear % 5) != 1)
    return false;
    if ((bear % 7) == 3)
    return bear % 0x6D == 55;

    return false;

    }

    bool isvol(unsigned int v){


    unsigned int result;

    result = 0;

    while (v){
    result += v & 1;
    v >>= 1;
    }

    return result > 0x10 && result <= 0x1A;
    }

    int main() {

    int v9;
    int v10 = 4919;
    int volcano;
    int bear;
    printf("Finding numbers that satisfy the conditions...\n");


    for (unsigned int bear = 0; bear < 1000000; bear++) {
    if (isbear(bear)) {
    for (unsigned int volcano = 0; volcano < 1000000; volcano++) {
    if (isvol(volcano) &&
    sub_1209(volcano) == sub_1209(bear) &&
    sub_124D(volcano) == sub_124D(bear)) {
    for (v9 = 3; v9 < 1000000; v9 += 2) {
    if (v9 != 1 &&
    sub_1430(v10, volcano, v9) == sub_1430(v10, bear, v9)) {
    printf("Found a number that satisfies the conditions: %d\n", v9);
    printf("bear: %u, volcano: %u\n", bear, volcano);
    return 0;
    }
    }
    }
    }
    }
    }

    return 0;
    }

    Image

  • FLAG

    1
    amateursCTF{yep_th0se_l00k_th3_s4me_to_m3!_:clueless:}

Rev-AmateursCTF2023-Volcano
https://luoming1995125.github.io/2023/07/27/Rev-AmateursCTF2023-Volcano/
作者
Peter Luo
發布於
2023年7月27日
許可協議