Advertisement
JSchmoe

how not to use popen

Aug 3rd, 2016
492
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.39 KB | None | 0 0
  1. void ip_lookup(char* host, char* out, IRCSession* session) {
  2.     char sbuf[256];
  3.     sprintf(sbuf, "./geoip.rb %s", host);
  4.  
  5.     printf("[*] Running %s\n", sbuf);
  6.     FILE* fp = popen(sbuf, "r");
  7.  
  8.     while (fgets(sbuf, 256, fp) != NULL) {
  9.         if (sbuf[0] == 0x00) continue;
  10.  
  11.         write_to_socket(session, out, "\rPRIVMSG %s :%s", session->channel, sbuf);
  12.     }
  13.  
  14.     pclose(fp);
  15. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement