本文整理汇总了Python中pyflag.pyflagsh.environment函数的典型用法代码示例。如果您正苦于以下问题:Python environment函数的具体用法?Python environment怎么用?Python environment使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了environment函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test03cpTests
def test03cpTests(self):
""" Test the cp (copy) command """
self.env = pyflagsh.environment(case=self.test_case)
pyflagsh.shell_execv(env=self.env, command="load",
argv=[self.test_case,])
## Make a directory for the files:
tmpname = os.tmpnam()
os.mkdir(tmpname)
pyflagsh.shell_execv(env=self.env, command="cp",
argv=["/dscf108*", tmpname])
## Now verify the copy worked:
fd = open(tmpname+"/dscf1080.jpg",'r')
data = fd.read()
md5sum = md5.new()
md5sum.update(data)
self.assertEqual(md5sum.hexdigest(),'9e03e022404a945575b813ffb56fd841')
## Clean up:
for file in os.listdir(tmpname):
os.unlink(tmpname+'/'+file)
os.rmdir(tmpname)
示例2: test01ls
def test01ls(self):
""" Test the ls command """
self.env = pyflagsh.environment(case=self.test_case)
pyflagsh.shell_execv(env=self.env, command="load",
argv=[self.test_case,])
## Check we can list default directory
lines = [ l for l in pyflagsh.shell_execv_iter(env=self.env, command="ls",
argv=[])]
self.assertEqual(len(lines),18)
## Check we can list directories
lines = [ l for l in pyflagsh.shell_execv_iter(env=self.env, command="ls",
argv=["docs"])]
self.assert_(len(lines)>=3)
## Check that we can glob files:
lines = [ l for l in pyflagsh.shell_execv_iter(env=self.env, command="ls",
argv=["*.jpg"])]
self.assertEqual(len(lines),5)
## Check that we can glob directories:
lines = [ l for l in pyflagsh.shell_execv_iter(env=self.env, command="ls",
argv=["do*"])]
self.assert_(len(lines)>3)
示例3: test01RunScanners
def test01RunScanners(self):
""" Running Logical Index Scanner """
## Make sure the word secret is in there.
pdbh = DB.DBO()
pdbh.execute("select * from dictionary where word='secret' limit 1")
row = pdbh.fetch()
if not row:
pdbh.insert('dictionary', **{'word':'secret', 'class':'English', 'type':'word'})
env = pyflagsh.environment(case=self.test_case)
pyflagsh.shell_execv(env=env, command="scan",
argv=["*",'IndexScan'])
dbh = DB.DBO(self.test_case)
dbh2 = DB.DBO(self.test_case)
fsfd = DBFS(self.test_case)
dbh.execute("select inode_id, word,offset,length from LogicalIndexOffsets join %s.dictionary on LogicalIndexOffsets.word_id=%s.dictionary.id where word='secret'", (config.FLAGDB,config.FLAGDB))
count = 0
for row in dbh:
count += 1
path, inode, inode_id = fsfd.lookup(inode_id = row['inode_id'])
fd = fsfd.open(inode=inode)
fd.overread = True
fd.slack = True
fd.seek(row['offset'])
data = fd.read(row['length'])
print "Looking for %s: Found in %s at offset %s length %s %r" % (
row['word'], inode, row['offset'], row['length'],data)
self.assertEqual(data.lower(), row['word'].lower())
## Did we find all the secrets?
self.assertEqual(count,2)
示例4: test01RunScanner
def test01RunScanner(self):
""" Test cache scanner """
env = pyflagsh.environment(case=self.test_case)
pyflagsh.shell_execv(env=env, command="scan",
argv=["*",'ZipScan'])
pyflagsh.shell_execv(env=env, command="scan",
argv=["*",'MozCacheScan','GoogleImageScanner'])
示例5: test02catTests
def test02catTests(self):
""" Test the cat command """
self.env = pyflagsh.environment(case=self.test_case)
pyflagsh.shell_execv(env=self.env, command="load",
argv=[self.test_case,])
self.fsfd = FileSystem.DBFS(self.test_case)
fd = self.fsfd.open("/dscf1080.jpg")
data1=fd.read()
fd = self.fsfd.open("/dscf1081.jpg")
data2=fd.read()
fd = self.fsfd.open("/dscf1082.jpg")
data3=fd.read()
result = ''
for l in pyflagsh.shell_execv_iter(env=self.env, command="cat",
argv=["/dscf1081.jpg"]):
result+=l
self.assertEqual(result,data2)
result = ''
for l in pyflagsh.shell_execv_iter(env=self.env, command="cat",
argv=["/dscf108*"]):
result+=l
self.assertEqual(len(result),len(data1)+len(data2)+len(data3))
self.assert_(result==data1+data2+data3)
示例6: test01SMTPScanner
def test01SMTPScanner(self):
""" Test SMTP Scanner """
env = pyflagsh.environment(case=self.test_case)
pyflagsh.shell_execv(env=env,
command="scan",
argv=["*", ## Inodes (All)
"SMTPScanner", "RFC2822", "TypeScan"
]) ## List of Scanners
示例7: test01GmailScanner
def test01GmailScanner(self):
""" Test Google Image Scanner """
env = pyflagsh.environment(case=self.test_case)
pyflagsh.shell_execv(env=env,
command="scan",
argv=["*", ## Inodes (All)
"GoogleImageScanner",
]) ## List of Scanners
示例8: test01YahooMailScanner
def test01YahooMailScanner(self):
""" Test Scanner """
env = pyflagsh.environment(case=self.test_case)
pyflagsh.shell_execv(env=env,
command="scan",
argv=["*", ## Inodes (All)
"YahooMail20Scan",
]) ## List of Scanners
示例9: test01
def test01(self):
""" Test Reassebler """
env = pyflagsh.environment(case=self.test_case)
pyflagsh.shell_execv(env=env,
command="scan",
argv=["*", ## Inodes (All)
"NetworkScanners",
]) ## List of Scanners
示例10: test01RunScanner
def test01RunScanner(self):
""" Running scanners """
env = pyflagsh.environment(case=self.test_case)
pyflagsh.shell_execv(env=env, command="scan",
argv=["*",'ZipScan', 'TarScan', 'GZScan'])
pyflagsh.shell_execv(env=env, command="scan",
argv=["*",'JPEGCarver', 'ZipScan', 'TarScan', 'GZScan', 'TypeScan', 'IndexScan'])
示例11: test01GmailScanner
def test01GmailScanner(self):
""" Test Gmail Scanner """
env = pyflagsh.environment(case=self.test_case)
pyflagsh.shell_execv(env=env,
command="scan",
argv=["*", ## Inodes (All)
"GmailScanner", "YahooMailScan",
"SquirrelMailScan", "HotmailScanner"
]) ## List of Scanners
示例12: test02Hash
def test02Hash(self):
""" Test the hashes of loaded files """
env = pyflagsh.environment(case=self.test_case)
pyflagsh.shell_execv(env=env, command="scan",
argv=["*",'MD5Scan'])
dbh = DB.DBO(self.test_case)
dbh.execute("select binary_md5 from hash where binary_md5=%b",
"04D68B7C8993A3A485A5780EC1A8D62D".decode("hex"))
self.assert_(dbh.fetch(), "Expected hash not found")
示例13: test01CarveImage
def test01CarveImage(self):
""" Carving from Image """
env = pyflagsh.environment(case=self.test_case)
pyflagsh.shell_execv(env=env, command="scan",
argv=["*",'ScriptCarver'])
dbh = DB.DBO(self.test_case)
dbh.execute("select count(*) as c from type where type like %r", "%script")
row = dbh.fetch()
self.assert_(row != None)
self.assert_(row['c']>=3)
示例14: test01RunScanner
def test01RunScanner(self):
""" Test IE History scanner """
env = pyflagsh.environment(case=self.test_case)
pyflagsh.shell_execv(env=env, command="scan",
argv=["*",'IECarver'])
dbh = DB.DBO(self.test_case)
dbh.execute("select count(*) as c from ie_history")
row = dbh.fetch()['c']
print "Got %s rows" % row
self.assert_(row >= 20)
示例15: test01TypeScan
def test01TypeScan(self):
""" Check the type scanner works """
env = pyflagsh.environment(case=self.test_case)
pyflagsh.shell_execv(env=env, command="scan",
argv=["*",'TypeScan'])
## Make sure the extra magic is being used properly.
dbh = DB.DBO(self.test_case)
dbh.execute('select count(*) as count from type where type like "%%Outlook%%"')
count = dbh.fetch()['count']
self.failIf(count==0, "Unable to locate an Outlook PST file - maybe we are not using our custom magic file?")