Advertisement
Guest User

Untitled

a guest
Sep 22nd, 2019
121
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 4.76 KB | None | 0 0
  1.  
  2. void * fetch(undefined4 *param_1)
  3.  
  4. {
  5.   uint16_t uVar1;
  6.   int iVar2;
  7.   ulong uVar3;
  8.   char *__s;
  9.   hostent *phVar4;
  10.   hostent *phVar5;
  11.   undefined8 uVar6;
  12.   int *piVar7;
  13.   void *__dest;
  14.   long lVar8;
  15.   undefined8 *puVar9;
  16.   long in_FS_OFFSET;
  17.   byte bVar10;
  18.   uint16_t local_11c;
  19.   char *local_118;
  20.   char *local_110;
  21.   char *local_108;
  22.   undefined4 local_b8;
  23.   undefined local_b4;
  24.   char *local_b0;
  25.   size_t local_a8;
  26.   undefined8 local_a0;
  27.   sa_family_t local_98;
  28.   uint16_t uStack150;
  29.   undefined4 uStack148;
  30.   undefined8 uStack144;
  31.   undefined8 uStack136;
  32.   long local_10;
  33.  
  34.   bVar10 = 0;
  35.   local_10 = *(long *)(in_FS_OFFSET + 0x28);
  36.   local_b8 = *param_1;
  37.   local_b4 = 1;
  38.   local_b0 = (char *)0x0;
  39.   local_a8 = 0;
  40.   local_a0 = 0;
  41.   local_118 = (char *)0x0;
  42.   uVar3 = min((uint)*(undefined8 *)(param_1 + 4),7);
  43.   iVar2 = strncmp("http://",*(char **)(param_1 + 2),(long)(int)uVar3);
  44.   if (iVar2 == 0) {
  45.     __s = (char *)(*(long *)(param_1 + 2) + 7);
  46.     local_108 = strchrnul(__s,0x2f);
  47.     if ((long)(local_108 + -(long)__s) < 0x101) {
  48.       local_110 = strchr(__s,0x3a);
  49.       if (local_108 <= local_110) {
  50.         local_110 = (char *)0x0;
  51.       }
  52.       if (local_110 == (char *)0x0) {
  53.         local_11c = 0x50;
  54.         local_118 = strndup(__s,(size_t)(local_108 + -(long)__s));
  55.       }
  56.       else {
  57.         local_118 = strndup(__s,(size_t)(local_110 + -(long)__s));
  58.         __s = strndup(local_110 + 1,(size_t)(local_108 + -(long)(local_110 + 1)));
  59.         if (__s == (char *)0x0) {
  60.                     /* WARNING: Subroutine does not return */
  61.           __assert_fail("atstr","task/main.c",0x7f,"fetch");
  62.         }
  63.         iVar2 = atoi(__s);
  64.         local_11c = (uint16_t)iVar2;
  65.         if ((iVar2 < 0) || (0x10000 < iVar2)) {
  66.           puts("invalid port");
  67.                     /* WARNING: Subroutine does not return */
  68.           abort();
  69.         }
  70.         free(__s);
  71.       }
  72.       if (local_118 == (char *)0x0) {
  73.                     /* WARNING: Subroutine does not return */
  74.         __assert_fail("domain","task/main.c",0x87,"fetch");
  75.       }
  76.       if (*local_108 == '\0') {
  77.         local_108 = "/";
  78.       }
  79.       if (*local_108 != '/') {
  80.                     /* WARNING: Subroutine does not return */
  81.         __assert_fail("path[0] == \'/\'","task/main.c",0x8d,"fetch");
  82.       }
  83.       uVar1 = htons(local_11c);
  84.       phVar4 = gethostbyname2(local_118,10);
  85.       lVar8 = 0x10;
  86.       puVar9 = (undefined8 *)&local_98;
  87.       while (lVar8 != 0) {
  88.         lVar8 = lVar8 + -1;
  89.         *puVar9 = 0;
  90.         puVar9 = puVar9 + (ulong)bVar10 * 0x1ffffffffffffffe + 1;
  91.       }
  92.       if (phVar4 != (hostent *)0x0) {
  93.         if (phVar4->h_addrtype != 10) {
  94.                     /* WARNING: Subroutine does not return */
  95.           __assert_fail("hent6->h_addrtype == AF_INET6","task/main.c",0x95,"fetch");
  96.         }
  97.         local_98 = 10;
  98.         uStack136 = *(undefined8 *)(*phVar4->h_addr_list + 1);
  99.         uStack144 = *(undefined8 *)*phVar4->h_addr_list;
  100.         uStack150 = uVar1;
  101.         iVar2 = memcmp(&local_98 + 8,in6addr_loopback,0x10);
  102.         if ((iVar2 == 0) || ((char)uStack144 == '\0')) {
  103.           local_b0 = "localhost not allowed";
  104.           goto LAB_00101de7;
  105.         }
  106.       }
  107.       phVar5 = gethostbyname2(local_118,2);
  108.       if (phVar5 != (hostent *)0x0) {
  109.         if (phVar5->h_addrtype != 2) {
  110.                     /* WARNING: Subroutine does not return */
  111.           __assert_fail("hent4->h_addrtype == AF_INET","task/main.c",0xa0,"fetch");
  112.         }
  113.         if ((**phVar5->h_addr_list == '\x7f') || (**phVar5->h_addr_list == '\0')) {
  114.           local_b0 = "localhost not allowed";
  115.           goto LAB_00101de7;
  116.         }
  117.       }
  118.       if ((phVar4 != (hostent *)0x0) &&
  119.          (uVar6 = make_request((sockaddr *)&local_98,0x80,local_118,local_108,&local_b0,
  120.                                (long *)&local_a8), (char)uVar6 != '\0')) goto LAB_00101e07;
  121.       if (phVar5 == (hostent *)0x0) {
  122.         piVar7 = __h_errno_location();
  123.         local_b0 = hstrerror(*piVar7);
  124.       }
  125.       else {
  126.         local_98 = 2;
  127.         uStack148 = *(undefined4 *)*phVar5->h_addr_list;
  128.         uStack150 = uVar1;
  129.         uVar6 = make_request((sockaddr *)&local_98,0x80,local_118,local_108,&local_b0,
  130.                              (long *)&local_a8);
  131.         if ((char)uVar6 != '\0') goto LAB_00101e07;
  132.       }
  133.     }
  134.     else {
  135.       local_b0 = "host too long";
  136.     }
  137.   }
  138.   else {
  139.     local_b0 = "not http";
  140.   }
  141. LAB_00101de7:
  142.   local_b4 = 0;
  143.   local_a8 = strlen(local_b0);
  144. LAB_00101e07:
  145.   free(local_118);
  146.   __dest = calloc(1,0x20);
  147.   memcpy(__dest,&local_b8,0x20);
  148.   if (local_10 == *(long *)(in_FS_OFFSET + 0x28)) {
  149.     return __dest;
  150.   }
  151.                     /* WARNING: Subroutine does not return */
  152.   __stack_chk_fail();
  153. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement