This article mainly introduces examples of batch sandbox submission in python, and provides targeted analysis and example explanations for problems in batch sandbox submission, which has good reference value, for more information about how to submit a sandbox in python batch, see the example in this article. The specific method is as follows:
The following problems occur:
1. Use of Popen. in linux, parameters are passed through the list. do not use strings. Otherwise, the error "OSErrorror: [Errno 2] No such file or directory" may occur.
2. if the list needs to be copied and used in the shutil module, otherwise it will consecutively append... after the first sample is submitted, the subsequent submission parameters will be wrong.
The code is as follows:
import os from subprocess import Popen class SubmitCuckoo: """""" def __init__(self, dirctory): """Constructor""" self._dirctory = dirctory self._pargs = ["/usr/bin/python", "/home/xxx/xxx/submit.py"] def _file_callback(self, file_path): args = ["/usr/bin/python", "/home/xx/xxx/submit.py"] args.append(file_path) print "args:",args Popen(args) def submit_cuckoo(self, file_callback=_file_callback): """ """ dir = self._dirctory for root, dirs, files in os.walk(dir): for f in files: file_path = os.path.join(root, f) if file_callback: file_callback(self, file_path) if __name__ == "__main__": submit_cuckoo = SubmitCuckoo(r"/home/xxx/xxx/samples") submit_cuckoo.submit_cuckoo()
I hope this article will help you with Python programming.