Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- #include <string.h>
- #include <time.h>
- #include <math.h>
- #include <curl/curl.h>
- #define WIN32_LEAN_AND_MEAN
- #include <windows.h>
- #include <process.h>
- #define URL_BASE "http://twitter.com/statuses/update.xml"
- #define TWITLINE_VERSION "1.0"
- int fileLineCount(FILE*);
- void fillStrings(FILE*,char**,int);
- void cleanStrings(char**,int);
- void curl_thread(void * _options);
- typedef struct {
- char * postField;
- char * userPwd;
- char * proxy;
- long proxyType;
- long padding;
- } CURLOPTIONS;
- int success = 0;
- int threadEnd = 0;
- int main(int argc, char *argv[])
- {
- char *appname = argv[0];
- FILE * accounts = 0;
- FILE * comments = 0;
- FILE * s4proxys = 0;
- FILE * s5proxys = 0;
- bool _s4proxys = false;
- bool _s5proxys = false;
- int accountsCount = 0;
- int commentsCount = 0;
- int s4proxysCount = 0;
- int s5proxysCount = 0;
- int s4proxysCurrent = 0;
- int s5proxysCurrent = 0;
- char ** accountsStrings = 0;
- char ** commentsStrings = 0;
- char ** s4proxysStrings = 0;
- char ** s5proxysStrings = 0;
- if (argc > 1) {
- /* parse input parameters */
- for (argc--, argv++; *argv; argc--, argv++) {
- if (strncmp(*argv, "-", 1) == 0) {
- if (strncmp(*argv, "-H", 2) == 0) {
- fprintf(stderr,
- "\rUsage: %s [-a=accounts.txt] [-c=comments.txt] [-s4=socks4.txt] [-s5=socks5.txt]\n",
- appname);
- exit(1);
- } else if (strncmp(*argv, "-V", 2) == 0) {
- fprintf(stderr, "\r%s %s - %s\n",
- appname, TWITLINE_VERSION, curl_version());
- exit(1);
- } else if (strncmp(*argv, "-a=", 3) == 0) {
- int len = strlen(*argv) - 3;
- char * fileName = (char*)malloc(len+1);
- strncpy(fileName,*argv+3,len);
- fileName[len] = '\0';
- accounts = fopen(fileName,"r");
- free(fileName);
- if (accounts == NULL) {
- fprintf(stderr,"\r%s: invalid accounts file\n",appname);
- exit(1);
- }
- } else if (strncmp(*argv, "-c=", 3) == 0) {
- int len = strlen(*argv) - 3;
- char * fileName = (char*)malloc(len+1);
- strncpy(fileName,*argv+3,len);
- fileName[len] = '\0';
- comments = fopen(fileName,"r");
- free(fileName);
- if (comments == NULL) {
- fprintf(stderr,"\r%s: invalid comments file\n",appname);
- exit(1);
- }
- } else if (strncmp(*argv, "-s4=", 4) == 0) {
- int len = strlen(*argv) - 4;
- char * fileName = (char*)malloc(len+1);
- strncpy(fileName,*argv+4,len);
- fileName[len] = '\0';
- s4proxys = fopen(fileName,"r");
- free(fileName);
- if (s4proxys == NULL) {
- fprintf(stderr,"\r%s: invalid socks4 file\n",appname);
- exit(1);
- }
- } else if (strncmp(*argv, "-s5=", 4) == 0) {
- int len = strlen(*argv) - 4;
- char * fileName = (char*)malloc(len+1);
- strncpy(fileName,*argv+4,len);
- fileName[len] = '\0';
- s5proxys = fopen(fileName,"r");
- free(fileName);
- if (s5proxys == NULL) {
- fprintf(stderr,"\r%s: invalid socks5 file\n",appname);
- exit(1);
- }
- } else {
- fprintf(stderr, "\r%s: invalid or unknown option %s\n",appname, *argv);
- exit(1);
- }
- }
- }
- }
- if (accounts == NULL) {
- fprintf(stderr,"\r%s: invalid accounts file\n",appname);
- exit(1);
- }
- if (comments == NULL) {
- fprintf(stderr,"\r%s: invalid comments file\n",appname);
- exit(1);
- }
- // if (s4proxys == NULL && s5proxys == NULL) {
- // fprintf(stderr,"\r%s: no proxy list specified\n",appname);
- // exit(1);
- //}
- accountsCount = fileLineCount(accounts);
- commentsCount = fileLineCount(comments);
- if (s4proxys != NULL) s4proxysCount = fileLineCount(s4proxys);
- if (s5proxys != NULL) s5proxysCount = fileLineCount(s5proxys);
- accountsStrings = (char**)malloc(sizeof(char*) * accountsCount);
- fillStrings(accounts,accountsStrings,accountsCount);
- commentsStrings = (char**)malloc(sizeof(char*) * commentsCount);
- fillStrings(comments,commentsStrings,commentsCount);
- if (s4proxys != NULL) {
- s4proxysStrings = (char**)malloc(sizeof(char*) * s4proxysCount);
- fillStrings(s4proxys,s4proxysStrings,s4proxysCount);
- }
- if (s5proxys != NULL) {
- s5proxysStrings = (char**)malloc(sizeof(char*) * s5proxysCount);
- fillStrings(s5proxys,s5proxysStrings,s5proxysCount);
- }
- /* print separator line */
- printf("-----------------------------------------------------------\n");
- int totalProxys = s4proxysCount + s5proxysCount;
- //int accountsPerProxy = fabs((float)(accountsCount / totalProxys));
- int accountsPerProxy = 0;
- char * proxy = 0;
- bool isSocks4 = true;
- curl_global_init(CURL_GLOBAL_ALL);
- for (int i = 0; i < accountsCount; ++i) {
- char * randomComment = commentsStrings[rand() % commentsCount];
- char * postField = (char*)malloc(strlen(randomComment) + 8);
- wsprintf(postField,"status=%s",randomComment);
- /*if (i % accountsPerProxy == 0) {
- if (s4proxysCurrent < s4proxysCount) {
- isSocks4 = true;
- proxy = s4proxysStrings[s4proxysCurrent++];
- }
- else {
- if (s5proxysCurrent < s5proxysCount) {
- isSocks4 = false;
- proxy = s5proxysStrings[s5proxysCurrent++];
- }
- }
- }*/
- CURLOPTIONS * options = (CURLOPTIONS*)malloc(sizeof(CURLOPTIONS));
- options->postField = postField;
- options->userPwd = accountsStrings[i];
- options->proxy = proxy;
- options->proxyType = (isSocks4 ? CURLPROXY_SOCKS4 : CURLPROXY_SOCKS5);
- _beginthread(curl_thread,0,(void*)options);
- }
- while(threadEnd < accountsCount) { Sleep(10); }
- printf("%s: Total Accounts: %d, Total Proxys: %d\n",appname,accountsCount,totalProxys);
- printf("%s: Accounts per proxy: %d, Successful Logins: %d\n",appname,accountsPerProxy,success);
- printf("-----------------------------------------------------------\n");
- return 0;
- }
- void curl_thread(void * _options) {
- CURLOPTIONS * options = (CURLOPTIONS*)_options;
- CURL * curl_handle = curl_easy_init();
- curl_easy_setopt(curl_handle, CURLOPT_URL, URL_BASE);
- curl_easy_setopt(curl_handle, CURLOPT_CONNECTTIMEOUT, 6);
- curl_easy_setopt(curl_handle, CURLOPT_POST, 1);
- curl_easy_setopt(curl_handle, CURLOPT_POSTFIELDS, options->postField);
- curl_easy_setopt(curl_handle, CURLOPT_USERPWD, options->userPwd);
- //curl_easy_setopt(curl_handle, CURLOPT_PROXY,options->proxy);
- //curl_easy_setopt(curl_handle, CURLOPT_PROXYTYPE, options->proxyType);
- long res = curl_easy_perform(curl_handle);
- curl_easy_cleanup(curl_handle);
- free(options);
- if (res == 0) ++success;
- threadEnd++;
- }
- void cleanStrings(char ** strings, int count) {
- for (int i = 0; i < count; ++i) {
- free(strings[i]);
- }
- free(strings);
- }
- void fillStrings(FILE * file, char ** strings, int count) {
- int x = 0;
- for (; x < count;) {
- int j = 0;
- char c = 0;
- char str[256];
- do {
- c = fgetc(file);
- if (c != '\n') {
- str[j++] = c;
- }
- } while (c != '\n');
- if (j > 0) {
- char * _str = (char*)malloc(j+1);
- strncpy(_str,str,j);
- _str[j] = '\0';
- strings[x++] = _str;
- }
- }
- rewind(file);
- }
- int fileLineCount(FILE * f) {
- int c = 0,n = 0,j = 0;
- do {
- c = fgetc(f);
- if (c == '\n') {
- if (j > 0) ++n;
- j = 0;
- }
- else {
- ++j;
- }
- } while (c != EOF);
- rewind(f);
- return n;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement