• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Jeanne Boyarsky
  • Devaka Cooray
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Knute Snortum
  • Bear Bibeault
Saloon Keepers:
  • Ron McLeod
  • Tim Moores
  • Stephan van Hulst
  • Piet Souris
  • Ganesh Patekar
Bartenders:
  • Frits Walraven
  • Carey Brown
  • Tim Holloway

Universal security testing tool development

 
Marshal
Posts: 6851
470
Mac OS X VI Editor BSD Linux
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Jim ken wrote:Ok, then can some admin please delete my all posts regarding this query from this forum.


No. We usually don't delete the posts. If we'd do that, we'd be an empty site. Which is kind of an opposite idea of what the forum is about.

If you'd try to explain more clearly what is the task about, somebody maybe would be able to help.

As an example why is it so... Initially we were talking about the "security testing tool", but the code you posted contains only the GUI programming elements. So if the question would have been: "how to create a GUI", probably somebody would be able to help. However, if the task is really the one you described initially, then why do you post GUI at all? What it has to do with security testing?

In my opinion you have failed to explain the task clearly, so nobody knows how to help and with what in particular. Don't think the outcome would be significantly different on different forum.
 
Ranch Hand
Posts: 45
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How to show a found keyword in a particular path in a drive (which should search all files ,folders,subfolders in it)
and it's found line numbers( for that particular set of keywords which are listed in a excel file) in a set form
like [{keyword1, found at this file name 1 (line no1, line no2,...line no. n), found at this file name2 (in line1,line 2...line no. n),
found at this file name3 (in line no1,line2...line no. n),found at this file name n ( in line no1,line no2,line no. n),
(it's Total found count), similarly for all the keywords it should write desired results in a excel file from which it's starting to read
all these keywords which are listed in a particular column.
and then need to write it this data in a excel file with the column headings like keywords total found count, found in these files
(with their found line nos as well in these files along with the file name and line nos where it was exactly found)
 
Jim ken
Ranch Hand
Posts: 45
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
tried below code but it's not writing in desired format for excel:-
yourpath = 'D:\\Tool devlopment\\tool\\Folder
import glob
from collections
import Counter
import re
import errno
import os
import time
from datetime
import datetime
import datetime
import warnings
warnings.filterwarnings("ignore")
timestr = time.strftime("%Y%m%d-%H%M%S")

file2 = open("D:\\Tool devlopment\\tool\\Module\\excel.txt", 'r')
text_string1 = file2.read().lower()
word2 = text_string1.split()
sast_txt = "D:\\Tool devlopment\\tool\\Module\\SAST_ScanReport" + timestr + ".txt"
FO = open(sast_txt, 'w')
cnt = Counter()
for root, dirs, files in os.walk(yourpath, topdown = False):
   for name in files:
   path = os.path.join(root, name)
files = glob.glob(path)
for name in files:
   try:
   with open(name, encoding = "utf8", errors = 'ignore') as f:
   text_string1 = f.read().lower()
word1 = re.split("[^a-zA-Z]*", text_string1)
for i in range(0, len(word2)):
   if (word2[i] in set(word1)):
       cnt[word2[i]] += 1
str2 = "Vuernabilitiy found at line: " + str(i + 1) + ' in file ' + os.path.join(root, name) + "\n"
FO.write(str2)
str2 = ''


except IOError as exc:
   if exc.errno != errno.EISDIR:
   raise
for m in cnt:
   str3 = ''
str3 = str(m) + ' ' + str(cnt[m]) + ' ' + 'time' + '\n'
FO.write(str3)
FR = open(sast_txt, 'r')
sast_file = "D:\\Tool devlopment\\tool\\Module\\SAST_ScanReport" + timestr + ".html"
with open(sast_file, "w") as e:
   for lines in FR.readlines():
   e.write("<pre>" + lines + "</pre> <br>\n")

FO.close()
 
Jim ken
Ranch Hand
Posts: 45
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
also tried this one but this also did not work as expected :-
import os
import glob

def search_words(keyword,target_dir):
   files = glob.glob(target_dir+'/**', recursive=True)
   python_files = []
   results = []
   line_no = []
   #Isolate target files from folders and everything else
   for f in files:
       if f.endswith('.py'):
           python_files.append(f)

   for pyf in python_files:
       with open(pyf,'rb') as f:
           lines = f.readlines()
       for i,line in enumerate(lines):
           line = str(line)
           if line.find(keyword) > -1:
               line_no.append(i)

       results.append({'keyword':keyword,'lines':line_no,'target_file':pyf,'total_found':len(line_no)})
   return results
 
Jim ken
Ranch Hand
Posts: 45
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Any updates by experts on the same please?
 
Saloon Keeper
Posts: 5586
144
Android Mac OS X Firefox Browser VI Editor Tomcat Server Safari
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You may get better responses if you follow some common rules when posting, like ItDoesntWorkIsUseless and UseCodeTags. Although probably not in this topic, which is all over the place and thus hard to follow.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!