Advertisement
Guest User

File Pumper Cpp

a guest
Apr 27th, 2012
118
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.71 KB | None | 0 0
  1. /* Simple File Pumper                            */
  2. /* by: den5e @ <den5e.blogspot.com>              */
  3. /* Greetz to dk21, c0ax, baltazar, MikiSoft itd. */
  4.  
  5. const char NULLBYTE = '0';
  6. const char* TP_MB = "-mb";
  7. const char* TP_KB = "-kb";
  8. const long MB = 1048576;
  9. const int KB = 1024;
  10.  
  11. #include <iostream>
  12. #include <fstream>
  13. #include <string>
  14. #include <cstring>
  15. #include <stdlib.h>
  16.  
  17. bool pumpThatBitch(char *filename, int size, char *type);
  18. void helpThatBitch();
  19.  
  20. int main(int argc, char *args[]){
  21.     if(argc == 2){
  22.         if(strcmp(args[1],"-help")){
  23.             helpThatBitch();
  24.             return 0;
  25.         }
  26.         else{
  27.             std::cout << "[-] Unknown argument: " << args[1] << "\n";
  28.             return 1;
  29.         }
  30.     }
  31.     else if(argc == 4){
  32.         char *filename = args[1];
  33.         int size = atoi(args[2]);
  34.         char *type = args[3];
  35.         if(strcmp(type, TP_MB) == 0 || strcmp(type, TP_KB) == 0){
  36.             pumpThatBitch(filename, size, type);
  37.         }
  38.         else{
  39.             std::cout << "Unknown type: " << type << "\n";
  40.             helpThatBitch();
  41.             return 1;
  42.         }
  43.     }
  44.  
  45.     return 0;
  46. }
  47.  
  48. bool pumpThatBitch(char *filename, int size, char *type){
  49.     std::cout << "[+] Pumping " << filename << "\n";
  50.  
  51.     std::ofstream file(filename, std::ios::out | std::ios::binary | std::ios::ate | std::ios::app);
  52.  
  53.     int tp_size;
  54.  
  55.     if(strcmp(type, TP_KB) == 0) tp_size = KB;
  56.     else tp_size = MB;
  57.  
  58.     if(file.is_open()){
  59.         for(int i = 0; i < size; i++){
  60.             for(int x = 0; x < tp_size; x++){
  61.                 file << NULLBYTE;
  62.             }
  63.         }
  64.  
  65.         std::cout << "[+] Success!\n";
  66.     }else{
  67.         file.close();
  68.         std::cout << "[-] Fuck, failed to open file.\n";
  69.         return false;
  70.     }
  71.  
  72.     file.close();
  73.  
  74.     return true;
  75. }
  76.  
  77. void helpThatBitch(){
  78.     std::cout << "Usage: \n"
  79.               << "[filename]\n"
  80.               << "[size]\n"
  81.               << "[-mb/-kb]\n";
  82. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement