Python Forum
Machine Learning Antivirus [Urgent]
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Machine Learning Antivirus [Urgent]
#1
Bit of a long one, so apologies in advance. I'm at the last stage of my dissertation, and all that's left for me is to use a neural network I co-developed with my supervisor to scan PE files to check whether they are infected or not.

My current to-do list, (not including testing and report write-up):
1. Generate a list of known system calls from a .txt file
2. Scan a drive/directory for PE files
3. Use said scan results to extract system calls from those PE files that were detected.
4. Generate a list of system calls the file makes, removing those which are not on the master list
5. The two lists then need to be compared, with system calls that appear on both lists generating a '1', and system calls that are only on the master list to appear as a '0'.
6. The list then needs to run through the neural network, (currently an .rda file, still need to convert it to .pmml)
7. The end result is the file being flagged as a virus, or not.

I'm not really a Python programmer, (or a programmer as such), hence me asking. Where should I start with all this? Should I be using lists, or try to generate a dictionary; and which libraries should I use for these tasks? From my understanding, the code won't exactly be long, but I genuinely have no clue how to approach this, or even how to begin.

I was given a small section of code to use for extracting the system calls:

import pefile
import sys

value = sys.argv[1]

pe = pefile.PE(value)

for entry in pe.DIRECTORY_ENTRY_IMPORT:
    for imp in entry.imports:
        print(hex(imp.address), imp.name)
It's supposed to extract system calls from PE files, though I have no idea how to get it to work. As mentioned before, any advice/help would be greatly appreciated, as the deadline, (17th August), is closing in, and I would hate to lose months of work over a tiny bit of code.
Reply
#2
Just by looking at this, isn't imp.name already the name of the system call that's used in the PE file?  What output do you currently get?
Reply
#3
(Jul-27-2017, 07:08 PM)nilamo Wrote: Just by looking at this, isn't imp.name already the name of the system call that's used in the PE file?  What output do you currently get?

My current issue is that the code snippet doesn't give any output, it just gives the following error:

Error:
Traceback (most recent call last): File "C:/.../extract_syscalls.py", line 4, in <module> value = sys.argv[1] IndexError: list index out of range
I'm not entirely sure how to fix this issue. Should I not be using argv?
Reply
#4
This error means that you run the script without supplying any command line arguments. i.e. it expects you to supply command line argument when you run the script like this
c:/>python extract_syscalls.py <value>
of course you need to replace <value> with the actual one you want to use in your script (I don't know what it is)

Most probably you run the script from IDE. In more advanced IDEs you can setup CLI arguments for the run/test purposes
Reply
#5
It looks like with what you have so far, the argument your script is expecting is the name of a pe file.  So you'd call it like python extract_syscalls.py some_lib.dll, though it also looks like it'd need to be in the same folder as your script, unless you passed a fully qualified path.  Which is fine for testing, right?
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
Exclamation Python Homework (Urgent help needed!!) chickenseizuresalad 6 4,267 Oct-11-2021, 01:59 AM
Last Post: Underscore
Exclamation urgent , Python homework alm 2 2,290 May-09-2021, 11:19 AM
Last Post: Yoriz
  urgent I got a syntax errors alm 2 5,840 Feb-28-2021, 02:54 PM
Last Post: alm
Heart Urgent homework help needed Medou 4 2,709 Nov-24-2020, 09:28 AM
Last Post: buran
  Errors with Machine Learning trading bot-- not sure why MattKahn13 2 1,560 Aug-08-2020, 06:43 PM
Last Post: MattKahn13
  [Urgent] build code GodMaster 2 1,793 Mar-23-2020, 12:25 AM
Last Post: jefsummers
  Bifid Genkey (Urgent) Laura123 2 2,039 Mar-09-2020, 08:09 PM
Last Post: micseydel
  Python Homework Help *Urgent GS31 2 2,574 Nov-24-2019, 01:41 PM
Last Post: ichabod801
  Need help! Please! Urgent! foxylen 1 2,288 Feb-27-2019, 05:50 PM
Last Post: buran
  (Not urgent) IDLE issue with methods vinfer12 5 3,935 Mar-22-2018, 09:00 PM
Last Post: Gribouillis

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020