Last active
June 30, 2025 20:39
-
-
Save Lomasterrrr/133640cfce7bbb477cf2b9596e0d284d to your computer and use it in GitHub Desktop.
parser for paste.debian(lesbian).net - is master work in 16 tatktov
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #include <stdio.h> | |
| #include <curl/curl.h> | |
| #include <string.h> | |
| #include <stdlib.h> | |
| #include <limits.h> | |
| #include <sys/types.h> | |
| #include <sys/random.h> | |
| #include <sys/time.h> | |
| #include <time.h> | |
| #include <assert.h> | |
| static inline u_int urand(u_int min, u_int max) | |
| { | |
| u_int random, range; | |
| ssize_t ret; | |
| if (min>max) | |
| return 1; | |
| range=(max>=min)?(max-min+1): | |
| (UINT_MAX-min+1); | |
| return ((ret=getrandom(&random, sizeof(u_int),GRND_NONBLOCK | |
| |GRND_RANDOM))==-1||(ret!=sizeof(u_int))?0: | |
| ((min+(random%range)))); | |
| } | |
| typedef struct __mem { | |
| char *buf; /* master buffer */ | |
| size_t size,max; | |
| } mem_t; | |
| static inline size_t discard_output(void *ptr, size_t size, size_t nmemb, void *userdata) | |
| { | |
| mem_t *m=(mem_t*)userdata; | |
| size_t tot=size*nmemb; | |
| if (m->size+tot>=m->max) | |
| tot=m->max-m->size-1; | |
| if (tot>0) { | |
| memcpy(m->buf+m->size,ptr,tot); | |
| m->size+=tot; | |
| m->buf[m->size]=0; | |
| } | |
| return size*nmemb; | |
| } | |
| static inline long check(const char *txt, char *buffer, size_t buflen) | |
| { | |
| CURLcode res; | |
| CURL *curl; | |
| long code; | |
| mem_t m={.buf=buffer,.size=0,.max=buflen}; | |
| if (buffer&&buflen>0) | |
| buffer[0]='\0'; | |
| curl_global_init(CURL_GLOBAL_DEFAULT); | |
| curl=curl_easy_init(); | |
| code=0; | |
| if (curl) { | |
| curl_easy_setopt(curl,CURLOPT_URL,txt); | |
| curl_easy_setopt(curl,CURLOPT_WRITEFUNCTION,discard_output); | |
| curl_easy_setopt(curl,CURLOPT_WRITEDATA,&m); | |
| curl_easy_setopt(curl,CURLOPT_TIMEOUT,1L); | |
| curl_easy_setopt(curl,CURLOPT_CONNECTTIMEOUT,1L); | |
| res=curl_easy_perform(curl); | |
| if (res==CURLE_OK) | |
| curl_easy_getinfo(curl,CURLINFO_RESPONSE_CODE,&code); | |
| curl_easy_cleanup(curl); | |
| } | |
| curl_global_cleanup(); | |
| return code; | |
| } | |
| int main(int argc, char **argv) | |
| { | |
| char res[USHRT_MAX], | |
| buf[USHRT_MAX]; | |
| long code; | |
| u_int num; | |
| for (;;) { | |
| num=urand(1000000,1383630); /* combination master generate */ | |
| memset(res,0,sizeof(res)); | |
| snprintf(res,sizeof(res),"http://paste.debian.net/%u",num); | |
| code=check(res,buf,sizeof(buf)); /* ok, so, code is 200 is ok */ | |
| if (code==200) | |
| if (!strstr(buf,"Entry not found")) | |
| printf("OK\t%s\n",res); /* aee */ | |
| } | |
| return 0; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment