This forum is in archive mode. You will not be able to post new content.

Author Topic: [py] Simple file pumper  (Read 1418 times)

0 Members and 3 Guests are viewing this topic.

Offline dense

  • Serf
  • *
  • Posts: 23
  • Cookies: 4
    • View Profile
[py] Simple file pumper
« on: June 17, 2013, 05:55:01 PM »
Code: (Python) [Select]
import sys

if len(sys.argv) < 4:
    sys.exit('[-] Missing argument!')

fp = sys.argv[1]
size = int(sys.argv[2])
tp = sys.argv[3]

f = open(fp, 'ab')
if tp == '-kb':
    b_size = size * 1024
elif tp == '-mb':
    b_size = size * 1048576
else:
    sys.exit('[-] Use -mb or -kb!')

bufferSize = 256
for i in range(b_size/bufferSize):
    f.write(str('\0' * bufferSize))

f.close()

print '[+] Finished pumping', fp, 'with', size, tp

Usage:
Code: [Select]
python fpump.py [file] [size] [-mb/-kb]
« Last Edit: June 21, 2013, 10:45:59 AM by RedBullAddicted »

Offline Fur

  • Knight
  • **
  • Posts: 216
  • Cookies: 34
    • View Profile
Re: [py] Simple file pumper
« Reply #1 on: June 17, 2013, 06:13:10 PM »
Won't this throw an OutOfMemoryException (MemoryError?) if b_size is larger than the available RAM?

If so, you could do something like this:

Code: (Python) [Select]
const int BUFFER_SIZE = 256;

int bytesToPump = 1024;

while (bytesToPump > 0) {
   // Write(data, offset, count)
   junkFile.Write(new byte[BUFFER_SIZE], 0, Math.Min(bytesToPump, BUFFER_SIZE));
        bytesToPump -= BUFFER_SIZE;
}
I didn't bother looking for things that could go wrong in the above snippet.

Also, there seems to be a better way of achieving this here.

Oh, and there's no need to put a space before an exclamation mark.
« Last Edit: June 21, 2013, 10:46:13 AM by RedBullAddicted »

Offline dense

  • Serf
  • *
  • Posts: 23
  • Cookies: 4
    • View Profile
Re: [py] Simple file pumper
« Reply #2 on: June 17, 2013, 06:54:55 PM »
Yep, you're right.  Edited the main post.

The stackoverflow solution is faster and cleaner but it's seems it's platform specific. Would the pumped file if transfered from a ntfs system to a fat system be the same (pumped) ?  :)
« Last Edit: June 17, 2013, 06:55:29 PM by dense »

Offline Fur

  • Knight
  • **
  • Posts: 216
  • Cookies: 34
    • View Profile
Re: [py] Simple file pumper
« Reply #3 on: June 17, 2013, 08:43:22 PM »
Would the pumped file if transfered from a ntfs system to a fat system be the same (pumped) ?  :)
I don't think so, but I'm not a computer scientist.

Quote from: Shamanu4
Seek and truncate both create sparse files on my system

Quote from: mldonkey.sourceforge.net/Sparse_files
Because of the File Allocation Table format, sparse files cannot be supported on those filesystems. When data is written at an offset higher than file size, all disk space for lower offsets is allocated, then file size is adjusted.

So truncate and seek create sparse files, but FAT doesn't support sparse files.
« Last Edit: June 17, 2013, 08:44:01 PM by Fur »

Offline techb

  • Soy Sauce Feeler
  • Global Moderator
  • King
  • *
  • Posts: 2350
  • Cookies: 345
  • Aliens do in fact wear hats.
    • View Profile
    • github
Re: [py] Simple file pumper
« Reply #4 on: June 18, 2013, 04:17:56 AM »
File pumper? I tried googling it but all the links go to shit like hackforums and other skid crap.

I don't really see a reason to get something like a one line txt to be the size of 500Mb unless you hide code in it, not random bits.

What's the reason?
>>>import this
-----------------------------

Offline Fur

  • Knight
  • **
  • Posts: 216
  • Cookies: 34
    • View Profile
Re: [py] Simple file pumper
« Reply #5 on: June 18, 2013, 11:42:11 AM »
What's the reason?
Usually to make a file look more legitimate.
Nobody's doing to run avatar.movie.mp4.exe if it's 400 kilobytes.

Offline googlebot

  • NULL
  • Posts: 3
  • Cookies: 0
    • View Profile
Re: [py] Simple file pumper
« Reply #6 on: June 21, 2013, 10:41:00 AM »
:) the one not running the avatar.mp4.exe of small size is smarter than the one running avatar.mp4.exe which is 700 mb :)

 



Want to be here? Contact Ande, Factionwars or Kulverstukas on the forum or at IRC.