Simple file pumper by den5e

ljuskaArchive
//archivePosts: 37Member, Moderator in C / C# / C++
/* Simple File Pumper                            */
/* by: den5e @ <den5e.blogspot.com>              */
/* Greetz to dk21, c0ax, baltazar, MikiSoft itd. */

const char NULLBYTE = '0';
const char* TP_MB = "-mb";
const char* TP_KB = "-kb";
const long MB = 1048576;
const int KB = 1024;

#include <iostream>
#include <fstream>
#include <string>
#include <cstring>
#include <stdlib.h>

bool pumpThatBitch(char *filename, int size, char *type);
void helpThatBitch();

int main(int argc, char *args[]){
    if(argc == 2){
        if(strcmp(args[1],"-help")){
            helpThatBitch();
            return 0;
        }
        else{
            std::cout << "[-] Unknown argument: " << args[1] << "\n";
            return 1;
        }
    }
    else if(argc == 4){
        char *filename = args[1];
        int size = atoi(args[2]);
        char *type = args[3];
        if(strcmp(type, TP_MB) == 0 || strcmp(type, TP_KB) == 0){
            pumpThatBitch(filename, size, type);
        }
        else{
            std::cout << "Unknown type: " << type << "\n";
            helpThatBitch();
            return 1;
        }
    }

    return 0;
}

bool pumpThatBitch(char *filename, int size, char *type){
    std::cout << "[+] Pumping " << filename << "\n";

    std::ofstream file(filename, std::ios::out | std::ios::binary | std::ios::ate | std::ios::app);

    int tp_size;

    if(strcmp(type, TP_KB) == 0) tp_size = KB;
    else tp_size = MB;

    if(file.is_open()){
        for(int i = 0; i < size; i++){
            for(int x = 0; x < tp_size; x++){
                file << NULLBYTE;
            }
        }

        std::cout << "[+] Success!\n";
    }else{
        file.close();
        std::cout << "[-] Fuck, failed to open file.\n";
        return false;
    }

    file.close();

    return true;
}

void helpThatBitch(){
    std::cout << "Usage: \n"
              << "[filename]\n"
              << "[size]\n"
              << "[-mb/-kb]\n";
}

Koriscenje:

fpump [filename] [size] [-kb/-mb]

pastebin:
http://pastebin.com/5ypu5yMd

Sign In or Register to comment.

Welcome

It looks like you're new here. If you want to get involved, click one of these buttons!

Discussions