• We are currently performing site maintenance, parts of civfanatics are currently offline, but will come back online in the coming days. For more updates please see here.

Virus on a *.py or *.xml file?

stgelven

Prince
Joined
Apr 22, 2003
Messages
398
Location
pays de loire - france
hi! those last 2 days i had terrible trouble with some virus and spy. now everything is ok, but that problem give me this idea: is it not possible to make a virus with python? and i know YES!
It is certainely possible that some line of code in a mode run a virus or a trojan in our machines!

WHAT CAN WE DO TO PROTECT OURSELVES?
 
stgelven said:
hi! those last 2 days i had terrible trouble with some virus and spy. now everything is ok, but that problem give me this idea: is it not possible to make a virus with python? and i know YES!
It is certainely possible that some line of code in a mode run a virus or a trojan in our machines!

WHAT CAN WE DO TO PROTECT OURSELVES?

Just like everything on the internet, only download from sources you trust.
 
stgelven said:
you did ot understood. i mean it is possible to dowload a virus or whatever because its tne internet, ok, but for that there are antispy ware, antivirus program.

if a guy want to include in a mod somes instructions that gone to format your hard drive, there is no protection for that!

I understand. Spyware only catches known virus's. I could write and executable right now that no anti-virus software would catch. Its the same with mods, anti-virus won't catch them because they haven't been reported as virus's.

So it's no different. Dont download executables from the internet unless you trust the source, the same goes for mods.
 
Just learn the commands that do that kind of stuff and do a Find on the files that are changed.

The hard part will be to stop this once the SDK comes out...
 
stgelven said:
do you really think that it's usefull to answer like you did?

SORRY!:blush: i missunderstood your answer, i thought it was offenssive! so sorry !:blush:

yes, i agree but that is not a solution for every one!, i think that there is a problem of security for 90% of the civmen and as you sayed, with the SDK it might be worth!

(excuse me for my mistake, english is not my first language, as yoiu imagine!)
 
I really don't think open-source code would be most virus-writer's first choice of a platform. However, when the SDK comes out and people start making DLLs then anything goes. I think the community will make a big push to continue the open source format and demand that source code be included with all DLLs that get produced. After all, reading the code is really the only way to be sure.

Roger Bacon
 
vbraun said:
Also people could wait for other people to download it, and see the results.
Ah, the old "wait and see" approach. Takes a while, but it is the safest.
 
AngryPants said:
Ah, the old "wait and see" approach. Takes a while, but it is the safest.


yes, but that mean that some people should have trouble and it's not certain that you think of your civ mod if you are infected.


why not create a label "virus free"? some volonteer control the files and get the stamp ? may be ask to civfanatic's to create a stamp "virus free" for the controled thread?
 
Few points:
1) Internet is NOT as anonymous as it looks like. So it would not be so hard to track someone who would release malicious mod. (Et least if he does not do extra measures aginst it) It can be hard to arrest him, becose he can be in some country where it is not crime (etc..).
2) Some anti virus systems scan executables for suspicious actions, so even unknow virus can be stopped (sometimes) by them.

Btw. i dont fear as much malicious modders as modders who dont know that their computer was infected (speaking about time when SDK will be released).
 
Truth be told, gonna' be tough to stop people with python files if they really are that intent on evilness. However, if you're really paranoid about one, there are some quick checks you can do:

Since the easiest way to screw up a computer is to delete files or run programs, one of the easiest way to accomplish this through python is through system commands. In python, watch out for any script that imports sys and uses the command...

sys.command()

The argument for this function is a string that represents a command that you might see typed in a ms-dos window, so if you see:

sys.command("format c:")

You should probably put it down. Using a utility like grep will allow you to search for stuff like this easier. Searching for "command" might yeild many results, so you'll probably want to search for sys and see if it's ever imported in any mod files. Remember that a coder could say:

Code:
from sys import *

...

command("aReallyDevastatingCommand")

So looking for sys.command won't do it alone. Besides, there might be other commands in the sys module that can be used for bad purposes. It's probably better off that you ask the modder what they use the sys module for, even going so far as to ask them to implicitly declare what functions from sys they're using.

Code:
from sys import getwindowsversion

And while I'm thinking of it, I don't think there's much reason to use a lot of the stuff out the the sys module anyway, so be cautious with those anyway. That's not to say that anyone that imports the sys module into one of their python files are up to nasty things. An example is perhaps they wish to use sys.getwindowsversion() to put what version of windows you have in a log file incase an exception is raised (perhaps the problem is something that is Windows 98 specific, let's say).

The same goes with the os module. In my GEMP project (an mp3 player), I use this module to find and load mp3 files using the os.join and os.walk functions, but watch out if you see someone using calls like os.remove(), os.removedirs() or os.rmdir(). Most modders probably won't need this, since all of the data files to be loaded will be loaded by civ by adding entries in XML files about what files to add (such as their own interface files, music, etc).

Edit: Another function that you should look out for is eval(). This basically takes a string and evaluates it as if a python command. So eval("print 5") is the same as typing "print 5" at a python shell and hitting enter. This should almost never be needed, so watch out if any mod uses it.

So, you can use grep to search for imports inside of python files. If you are ever suspicous, ask the mod creator in their mod's thread what the code in question is for. If you're still suspicious, ask a trusted python coder or just live life without that mod.


Edit:
One more thought: Anyone worth their dime trying to ruin your computer with a python mod is probably got a very crafty way of making their code look so strange that a first glance at the code is not enough to see what it does. An example might be breaking up the string "format c:" into multiple innocent-looking strings and then taking bits and pieces to create their string, which makes grep tough to use to find them. Really, you're only defense, short of not running it, is looking through all the code.

As for when the .dll's from SDK mods start coming out, checking the code that comes with the dll's does nothing if you use the dll supplied, since it's tough to check if the dll supplied is actually a result of compiling the code supplied. If you really want to be safe, not only will you have to check the code, but you'll have to be able to compile it yourself.
 
Not much you can do to protect yourself really. But if 2000 people have downloaded something, and none come back and say "hey, you wiped my hard drive", then you could assume it's not infected.

There is nothing special about .py possibly being infected. .bat's and .exes and .zips could be infected too, and if they were custom made, (like the .pys would need to be, because viruses would not spread well through python, since it is not widely distributed enough) you AV may not detect them either.
 
It would be kind of fun to make a mod where all of the cities are directory names from your computer, and all the units are files in those directories. Then whenever you kill a unit the file gets deleted. Ironman Civ4.
 
Kael said:
It would be kind of fun to make a mod where all of the cities are directory names from your computer, and all the units are files in those directories. Then whenever you kill a unit the file gets deleted. Ironman Civ4.


lol...it could be like a multiplayer version of Uplink, with modded units as "viruses" and roads as "networks" and spies as "rootkits". That would be an intersting mod in reality (you know, without all the deleting of files, unless the files were actually part of the mod and not actual user files.).
 
Kael said:
It would be kind of fun to make a mod where all of the cities are directory names from your computer, and all the units are files in those directories. Then whenever you kill a unit the file gets deleted. Ironman Civ4.


yes, that coud be very funny! but we play on your computer for that, ok?
 
stgelven said:
yes, that coud be very funny! but we play on your computer for that, ok?

It should be multiplayer which each player represented by files on his local computer.
 
Back
Top Bottom