Controlling who can run an executable

2005-10-03 Thread Cigar
I am developing a program for a client.  She runs a shop where her
clients bring in items for sale or short term buyback.  Development of
the program has been going great but she's mentioned that there is a
'feature' coming up in the next couple of weeks that she'd like me to
implement that has me a bit worried.

My client has told me a story of how she hired someone from a competing
store and that person had brought a copy of the program her competition
was using to track clients and transactions.  He couldn't demonstrate
the program for one reason or another because it was protected in a way
that neither could circumvent. (She didn't remember how it was
protected, she had hired this person a long time ago.)

Now that I'm three months into the development of this program, my
client tells me she would like to protect her investment by preventing
her employees from doing the same to her.  (Going to the competition
and using her program.)

What my client cannot prevent:
- access to the .exe

What my client is looking to prevent:
- running of the exe by un-authorized individuals.

Ideas I've had to prevent someone from running the app:
- ask for a password every time the program is run. (I wonder how
quickly they will complain about this, not very secure once everyone
eventually finds out what the password is)
- make a little hardware dongle and check to see if it's on the
parallel port. (old idea)
- check for an encrypted flash drive and try to read an encrypted file
from it. (new idea)
- buy the client a Microsoft Fingerprint Keyboard and figure out if it
will make the clients life easier (two minutes of research showed this
idea has multiple problems)

What I want:
- the simplest thing that could possibly work!

I guess my problem isn't really a python problem.  This is a scenario
that any developer in any language might face where an executable
should only be run by approved individuals.

c.l.p searches I've tried:
'protecting code' - details how to make python files 'unreadable'
'preventing execution' - best one here details encrypting a root
password

Thanks

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Controlling who can run an executable

2005-10-04 Thread Cigar
Mike Meyer wrote:
> First thing to know; you can't stop someone who's sufficiently
> determined to run the program.

I have explained to her that I can't prevent someone who REALLY wants
her program from tossing a rock through her front window and making off
with her PC.  They'd get the hardware and the executable along with the
client and transactions data.  She conceeded that that would be out of
my scope of being able to protect her program.

> > Ideas I've had to prevent someone from running the app:
> > - ask for a password every time the program is run. (I wonder how
> > quickly they will complain about this, not very secure once everyone
> > eventually finds out what the password is)
>
> If only authorized people have the password, then this works. The
> problem is that her employees are probably authorized, but she doesn't
> trust them to not take the program to her competition. Which brings
> up an alternative goal:

I may have to just put password protection in and if she hangs herself
by 'sharing' the password with underlings she trusts (at the
present)... again that's outside of my control of protecting her.

> > What I want:
> > - the simplest thing that could possibly work!
>
> Telling her "Don't let your employees near the computer with media, or
> when it's connect to a network."

Currently this app is running on a stand alone PC.  There was a big
concern about hackers getting at her program or data from over the
internet.  I complemented her on this level of security.  No floppy
drive either.

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Controlling who can run an executable

2005-10-04 Thread Cigar
Paul Rubin wrote:
> "Cigar" <[EMAIL PROTECTED]> writes:
> > Now that I'm three months into the development of this program, my
> > client tells me she would like to protect her investment by preventing
> > her employees from doing the same to her.  (Going to the competition
> > and using her program.)
>
> Exactly what is the threat here?

I think the BIGGEST threat here is a feeling of vulnerablity.  She now
realizes that she is in a position that her competition was many years
ago when she came into possesion of program the 'other side' was using
and that she is now vulnerable.  She wants to feel safe in the
knowledge that she didn't reach into her pocket and pay thousands of
dollars for a program that now could now be used by her competition.
Nobody wants to pay money to level the playing field for all in a
business environment.

> Misuse of confidential data, or

It's just a collection of names, addresses, phone numbers, birthdays
and drivers licences/health cards.  I can think of a few dishonest
things that could be done with this but her competition has the
basically the same clients.

> just the code itself?
> Does the code do anything that fantastic?

Not by my standards but it is slowly replacing a paper system.  (Police
officer shows up and says 'We've just arrested John Smith.  Has he sold
you anything in the last 90 days.  The client says 'Just a minute' and
reaches for a set of 4" d-ring binders and turns hundreds of pages
looking for a Smith name...)  My client is relived that this senario
will soon disappear.

> Did the employees sign NDA's?  Usually this kind of thing is taken care of by
> legal agreements.

Good question!  I'm pretty sure not but that's something I could
suggest to her.

> What is the competitor going to do with this code even if they get it?

Simplify their lives.  See above.

> It's just keeping track of transactions and stuff, right?

You are correct sir.

> It's being
> tailored to one person's specific preferences and requirements, and
> the competitor's needs will be different and they may as well just use
> something generic.

Not really.  The client just wants to track people and what they buy,
sell or put on buyback.  Their competitions needs are the same.

> Also, is there an office network?  Maybe you could run the program on
> a server that most employees wouldn't have access to.  They'd use it
> through some limited client program or through a web browser.

A network exists but the client insists on a standalone PC.

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Controlling who can run an executable

2005-10-04 Thread Cigar
Paul Rubin wrote:
> Suppose that competitor's program that her employee had illicitly
> brought her wasn't protected, so she was able to run it.  You might
> ask her whether, ethical issues aside, she would be willing to use it
> on a daily basis, given it sounds like people in her industry know
> each other enough that word would probably get back to the competitor,
> and any resulting lawsuit would leave her up a creek.  If she's not
> willing to use her competitor's program under those cirumstances,
> should she really be afraid of her competitor using hers?  Also, if
> all she got from the competitor was an .exe, she'd have no way to
> customize it, and vice versa.

Oh I agree.  (I just thought of something while writing a respond to
this)  What if she DID get the program running and only told me she
couldn't and came up against the same morale, legal and technical
issues that you're pointing out here and decided against using the
program.  I guess maybe part of her doubts that her competition would
look at her program and come to the same m,l,t, conclusions about not
using it if it fell into their hands.

(I'm only guessing at how my client arrived at the decision to protect
her program.  All indicators suggests she is a moral, ethical and kind
hearted person)

> > It's just a collection of names, addresses, phone numbers, birthdays
> > and drivers licences/health cards.  I can think of a few dishonest
> > things that could be done with this but her competition has the
> > basically the same clients.
>
> Well, that sounds pretty confidential to me, but I'll take your word
> for it that the competitors are more interested in the code than the
> data.  I do think she's overestimating the threat.

Again I agree... but I would like to assuage her concerns as much as I
can technically.  It will keep a roof over my head awhile longer.

> > Not by my standards but it is slowly replacing a paper system.  (Police
> > officer shows up and says 'We've just arrested John Smith.  Has he sold
> > you anything in the last 90 days.  The client says 'Just a minute' and
> > reaches for a set of 4" d-ring binders and turns hundreds of pages
> > looking for a Smith name...)  My client is relived that this senario
> > will soon disappear.
>
> Is there something there that you can't do with a few spreadsheet macros?

Are you trying to put me out of a job? :)

> > > What is the competitor going to do with this code even if they get it?
> > Simplify their lives.  See above.
>
> Lawsuits don't simplify anyone's life ;-).

Costly for all.  I do agree.

> > A network exists but the client insists on a standalone PC.
>
> How about two PC's connected by a piece of ethernet cable, but no
> outside network connection.  The server is a laptop or palmtop locked
> in a desk drawer.  A little hole is drilled in the back of the drawer
> for the power and network cables.  The network cable is connected to a
> PC on top of the desk that the employees actually use, running a web
> browser or the like.

That might fly.  I'll have to ask her about that.

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Controlling who can run an executable

2005-10-04 Thread Cigar

Myles Strous wrote:
> What's more, Tim Golden's wmi module (see
> http://tgolden.sc.sabren.com/python/wmi.html) makes getting at these
> numbers very easy:
>
> import wmi
> c = wmi.WMI ()
> for thingy in c.Win32_NetworkAdapter():
>   print "Network Adaptor", thingy.MACAddress
> for thingy in c.Win32_Processor():
> print "Processor", thingy.ProcessorId
> for thingy in c.Win32_BIOS():
> print "BIOS", thingy.SerialNumber
> for thingy in c.Win32_BaseBoard():
> print "BaseBoard", thingy.SerialNumber
> for thingy in c.Win32_SystemEnclosure():
> print "System Enclosure", thingy.SerialNumber
> for thingy in c.Win32_DiskDrive():
> print "Disk Drive", thingy.PNPDeviceID
> for thingy in c.Win32_PhysicalMedia():
> print "Physical Media", thingy.SerialNumber
>
> Regards, Myles.

Ah... thing of beauty.  One of these will probably make it into my
final solution.

Thanks millions!

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Controlling who can run an executable

2005-10-04 Thread Cigar

Istvan Albert wrote:
> >was using to track clients and transactions.  He couldn't demonstrate
> >the program for one reason or another because it was protected in a way
> >that neither could circumvent. (She didn't remember how it was
> >protected, she had hired this person a long time ago.)
>
> I'd venture to guess that neither of the people above knew much about
> programming. So do the same, create a security measure that protects
> against this level of 'threat'.

I could ask her, "If you can't break it is that good enough security?"

> As others have pointed out the simplest way would be to detect the
> presence of a hidden file, or some hardcoded system value, mac address
> etc. Obscure this step even more by encrypting some of the information
> so that one can't just simply view it in a hex editor.
> 
> Istvan.

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Controlling who can run an executable

2005-10-04 Thread Cigar

Istvan Albert wrote:
> > I could ask her, "If you can't break it is that good enough security?"
>
> Guess not. Most non-programmers think everyone else who knows some
> programming is a some sort of hacker genius.
>
> Instead come up with a simple solution then explain her how it will
> works. I think in the ensuing conversation you'll find out more on what
> approach would put her mind at ease.
>
> Istvan.

Sorry I forgot to put the happy face at the end of that last sentence.
Yes I'll be a good boy.  :)

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Controlling who can run an executable

2005-10-04 Thread Cigar

Tony Nelson wrote:
> In article <[EMAIL PROTECTED]>,
>  "Cigar" <[EMAIL PROTECTED]> wrote:
>
> > I am developing a program for a client.  She runs a shop where her
> > clients bring in items for sale or short term buyback.  Development of
> > the program has been going great but she's mentioned that there is a
> > 'feature' coming up in the next couple of weeks that she'd like me to
> > implement that has me a bit worried.
> >
> > My client has told me a story of how she hired someone from a competing
> > store and that person had brought a copy of the program her competition
> > was using to track clients and transactions.  He couldn't demonstrate
> > the program for one reason or another because it was protected in a way
> > that neither could circumvent. (She didn't remember how it was
> > protected, she had hired this person a long time ago.)
> >
> > Now that I'm three months into the development of this program, my
> > client tells me she would like to protect her investment by preventing
> > her employees from doing the same to her.  (Going to the competition
> > and using her program.)
>  ...
>
> Call the competition and ask them what they used.  Point out that it
> worked.  If they won't tell you, just look at their software until you
> find out.
> 
> TonyN.:'[EMAIL PROTECTED]
>   '  <http://www.georgeanelson.com/>

Sorry.  All I have is this wonderful story to tell everyone.  This
employee she hired no longer works for her and the 'disk' that nobody
to could get working is gone as well.

Sadly there's nothing left for me to forensically examine.

-- 
http://mail.python.org/mailman/listinfo/python-list


mod_python and Internal Server Error ...

2005-06-28 Thread Julien Cigar
Hello,

I'm using mod_python 3.1.3 with Apache 2.0.54 on a Debian box with the
publisher handler and the Clearsilver template engine, and from time to
time apache returns an 500 error code (Internal Server Error). 
Apache errog.log file looks like :

[Tue Jun 28 14:42:12 2005] [error] [client 164.x.x.x] PythonHandler
mod_python.publisher: Traceback (most recent call last):
[Tue Jun 28 14:42:12 2005] [error] [client 164.x.x.x] PythonHandler
mod_python.publisher:   File
"/usr/lib/python2.3/site-packages/mod_python/apache.py", line 299, in
HandlerDispatch\nresult = object(req)
[Tue Jun 28 14:42:12 2005] [error] [client 164.x.x.x] PythonHandler
mod_python.publisher:   File
"/usr/lib/python2.3/site-packages/mod_python/publisher.py", line 98, in
handler\npath=[path])
[Tue Jun 28 14:42:12 2005] [error] [client 164.x.x.x] PythonHandler
mod_python.publisher:   File
"/usr/lib/python2.3/site-packages/mod_python/apache.py", line 454, in
import_module\nf, p, d = imp.find_module(parts[i], path)
[Tue Jun 28 14:42:12 2005] [error] [client 164.x.x.x] PythonHandler
mod_python.publisher: ImportError: No module named taxal

...

What is strange is that when I reload the page, it's displayed fine, but
from time to time I get 500 error code ... which is quite annoying ...

As I'm using the publisher handler, my index.py looks like :

import sys
import os.path
import neo_cgi
import neo_util
import neo_cs

from mod_python import util, apache
from psycopg import QuotedString

config = apache.import_module('config', autoreload = 0, log = 0)
utils = apache.import_module('utils', autoreload = 0, log = 0)
specimen = apache.import_module('specimen', autoreload = 0, log = 0)
taxon = apache.import_module('taxon', autoreload = 0, log = 0)
fulltextsearch = apache.import_module('fulltextsearch', autoreload = 0,
log = 0)

template_directory  = config.getTemplateDirectory()
template_main   = config.getTemplateMain()
template_menu   = config.getTemplateMenu()

def index(req):
return home(req)

def home(req):
return _render(req, 'home')

def links(req):
return _render(req, 'links')

def contact(req):
return _render(req, 'contact')

def taxal(req):
sort= req.form.getfirst('sort')
order   = req.form.getfirst('order')

tl = taxon.taxon()
tl.getTaxaList(sort, order)
hdf = tl.getHDF()
return _render(req, 'taxalist', hdf)

(...)

So for the above example if I GET http://b.abc.be/birds/taxal it should
run the "def taxal(req)" function ... I don't understand why I get a
"mod_python.publisher: ImportError: No module named taxal" error message
in the apache logfile.

We have several virtualhosts : a.abc.be, b.abc.be, c.abc.be, ...
(fictive addresses). Our www directory is organized like this :
/var/www/vhosts/a.abc.be/ 
/var/www/vhosts/b.abc.be/
/var/www/vhosts/b.abc.be/enbi/
/var/www/vhosts/b.abc.be/enbi/projects/birds/
/var/www/vhosts/b.abc.be/enbi/projects/butterfly/
/var/www/vhosts/b.abc.be/enbi/projects/rubiaceae/
/var/www/vhosts/c.abc.be/blah/

I've tried with "PythonInterpPerDirectory on" in my .htaccess, but
without success ...

In advance thanks for your support


-- 
http://mail.python.org/mailman/listinfo/python-list


dbm

2006-12-27 Thread Julien Cigar
Hello list,

I have a dbm "database" which needs to be accessed/writed by multiple
processes. At the moment I do something like :

@with_lock
def _save(self):
f = shelve.open(self.session_file, 'c')

try:
f[self.sid] = self.data
finally:
f.close()

the with_lock() decorator create a .lock file which is deleted when the
function exit, so every operation did the following:
- acquire .lock file
- open the dbm file
- do the operation (save, load, ...)
- close the dbm file
- delete the .lock file

I made some tests and following my results the open() / close() add some
overhead (about 5 times slower). 

I read that the gdbm module should be safe against multiple processes (I
saw the "'u' -- Do not lock database." in the doc, so I presume it's
locked by default ?). Does it mean that two (or more) processes can open
the dbm file and write in the same time without
errors/corruptions/segfaults/... ?

Thanks,
Julien
-- 
http://mail.python.org/mailman/listinfo/python-list