diff options
author | Kali Kaneko (leap communications) <kali@leap.se> | 2016-05-02 20:13:19 -0400 |
---|---|---|
committer | Kali Kaneko (leap communications) <kali@leap.se> | 2016-05-02 20:13:19 -0400 |
commit | 01e2a72ce30f0fbb4a027d3246a8ba16e00ae197 (patch) | |
tree | 22fc0d2b7016d34d48fad45c88349b0103cd8308 /scripts/create_payload.py | |
parent | 71a21f8fa46e8ea834fe3381abdadde59788d37b (diff) | |
parent | f72a3bf28f4bf001106ad4d42ae7eb4f61b77828 (diff) |
Merge remote-tracking branch 'kali-github/pr/2'
Diffstat (limited to 'scripts/create_payload.py')
-rwxr-xr-x | scripts/create_payload.py | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/scripts/create_payload.py b/scripts/create_payload.py new file mode 100755 index 0000000..d051661 --- /dev/null +++ b/scripts/create_payload.py @@ -0,0 +1,29 @@ +#!/usr/bin/env python + +""" +Create a payload file in disk to use during tests. Reads the name of the file +and the intended size of the payload from the "defaults.conf" file: + + PAYLOAD = /path/to/payload/file + PAYLOAD_SIZE = 500 # in Kb +""" + +import os +from ConfigParser import ConfigParser + +parser = ConfigParser() +parser.read('defaults.conf') + +PAYLOAD = parser.get('sync', 'payload') +PAYLOAD_SIZE = int(parser.get('sync', 'payload_size')) * 1024 + +if os.path.isfile(PAYLOAD): + os.unlink(PAYLOAD) + +content = 'a' * 1024 + +with open(PAYLOAD, 'w') as f: + length = 0 + while length < PAYLOAD_SIZE: + f.write(content) + length += len(content) |