• Hi guest! As you can see, the new Wizard Forums has been revived, and we are glad to have you visiting our site! However, it would be really helpful, both to you and us, if you registered on our website! Registering allows you to see all posts, and make posts yourself, which would be great if you could share your knowledge and opinions with us! You could also make posts to ask questions!

File manipulation in python

Joined
Sep 9, 2021
Messages
9,680
Reaction score
5,213
Awards
32
From what I understand, it is very close to C syntax or functions.
Since Im somewhat familiar with C, and bash, that's how I look at python code.
Essentially what I am attempting to write is a real-time security monitor, that simply bans attackers upon log entry, that runs every ten seconds or by log tripwire. Normal security method is by whitelist/allowed IP addresses only. Some other security tools may exist.

So, lets say we have a big ol file of ip addresses hidden in strings, whether sudo drops, or possible attack, or real system entry.
There are also spamhaus lists that it will match against as a side function of determining who the attacker is, and goes a step further in trying to backtrack the intruder.

But lets start with basics.
fPtr = open("/root/secmon/IPDenyFile.txt","r+")
while(line<>EOF) do
fPtr.read ()
if isIPAddr(line) then print "Bad IP found: line.IPAddr\n" + fPtr.read()
fPtr.close()

So that's what I can think of off what Ive read, and what Im trying to understand. Any insight appreciated.
This is actually being done for free for a friend due to hackers targeting him.
 
Last edited:
Joined
Sep 9, 2021
Messages
9,680
Reaction score
5,213
Awards
32
To be clear, what was above is pseudocode for what Im trying to understand my tour of Python.
I think the backtracking is best handled by a list structure, or a collection of sets.
One such component would be both source and destination address, verified by external calls to OS networking utilities with info suitable for handing over to prosecutors or police.
 
Top