How to prevent exposing truecrypt arguments? - linux

I have a script that mounts a truecrypt volume and the password is given as an argument. Any user on the system may issue the command ps -aux | grep truecrypt which will reveal the password to the encrypted volume. Moreover, by traversing the proc directory, again the password can be revealed. I have root access to my machine, but I am sure that changing the permissions of the ps command and the proc directory will brake functionality in other parts of the system. On one hand I want to mount the volumes automatically without requiring user interaction, on the other hand, compromising the password of the truecrypt volume is out of the question. I might be able to find some acceptable solution using expect but before doing so I wanted to ask if anybody has a better idea?

I used pexpect to solve my problem in a python script, equivalent shell scripts should look similar conceptually
Instead of
mntMyDir = '/mnt/' + myDir
os.system('truecrypt ' + mntMyDir + '.tc ' + mntMyDir + ' --password=' + myPassword + ' --keyfiles= --protect-hidden=no')
os.chdir(mntMyDir + '/tree')
I used
mntMyDir = '/mnt/' + myDir
truecryptCmd = 'truecrypt ' + mntMyDir + '.tc ' + mntMyDir + ' --keyfiles= --protect-hidden=no'
child = pexpect.spawn(truecryptCmd)
child.expect('Enter password for ' + mntMyDir + '.tc: ')
child.sendline(myPassword)
child.wait()
os.chdir(mntMyDir + '/tree')

Related

FreeSwitch ESL: NodeJS/JS/Freeswitch Syntax Confliction

I'm building a Twillio-like Dialer API using Modesl in Node.JS to send commands and parameters to Freeswitch Console.
Edit: I've narrowed down the issue to a syntax issue, where the javascript I'm using to input my variables are conflicting with FreeSwitchs syntax.
uuid_send_dtmf needs to have a ' in front of it, whereas uuid is a NodeJS parameter that needs to be passed after one space, as is dmtf, and the api_on_answer requires a ' for closing after my parameters are passed.
Syntax has always been my weak point, any help would be greatly appreciated.
,api_on_answer='uuid_send_dtmf ' + uuid + ' ' + dmtf +' ' }
conn.api('originate {
origination_uuid=' + uuid
+ ',origination_caller_id_number=' + cid
+ ',api_on_answer=uuid_send_dtmf ' + uuid
+ ' ' + dmtf +' }
sofia/external/' + pnumber + '#provider', function(res) {
Currently the command is giving a very vague error of little help:
2019-03-17 08:53:22.755065 [DEBUG] switch_ivr_originate.c:2204 Parsing global variables
2019-03-17 08:53:22.755065 [ERR] switch_ivr_originate.c:2209 Parse Error!
2019-03-17 08:53:22.755065 [DEBUG] switch_ivr_originate.c:3941 Originate Resulted in Error Cause: 27 [DESTINATION_OUT_OF_ORDER]
What is the correct way to do what I need?
Fixed using '\' to input ' inline.
var onanswer = '\'' + uuid + ' ' + dmtf;
try this,
conn.api(`originate {origination_uuid=${uuid},origination_caller_id_number=${cid},api_on_answer='${uuid_send_dtmf} ${uuid} ${dtmf}'}sofia/external/${pnumber}#${provider}`, function(res) {
template literals or strings, enclosed by back-ticks, this would provide you the required format, cheers :)

not allowing me to copy file do to files permission

I have made a program that changes the background picture of my desktop every user defined seconds and there is no problems with that part. However I do have a problem with changing the picture of the log in screen I have set up my computer correctly (a windows 7 computer) to change the background picture (including editing the registry to be able to change the picture more then once).
I currently changing my login picture manually by moving the picture to a folder I created C:\windows\system32\oobe\info\backgrounds. I've chosen to make the task automated using python. I will delete the existing image, copy the new image to the folder and then rename the image to backgroundDefault.jpg and repeat every user defined seconds.
To copy, rename, and delete these files using the os module I've tested these steps in my cmd and it works.
Now what seems to be the problem?
Well I'm able to find the folder using os.path.exists however I'm unable to copy, delete or rename anything because the program doesn't have permission.
It is also worth noting that I have already tried to give my user permission to write in the folder and I already tried to give the python programme administrator access not only the python program but Py.exe and th pyw.exe that sit in the wondows folder
Is there a way to give the program permission or is there another way of changing the folder that I need to move the files to? Or even is there a different snipit of script I could use to achieve a login background change?
def path_writer_bg():
folders_path_bg = input("Please type the folders path of the login background here, then press enter"
"\n>")
if os.path.exists(folders_path_bg):
open("your_path_bg.txt", "w").write(folders_path_bg)
read_folder_path_bg = open("your_path_bg.txt", "r").read()
if os.path.exists("task_bg.txt"):
open("task_bg.txt", "w").write("dir " + read_folder_path_bg + " /s /b >listed_bg.txt")
file_read_task_bg = open("task_bg.txt", "r").readline()
else:
open("task_bg.txt", "w").write("dir " + read_folder_path_bg + " /s /b >listed_bg.txt")
file_read_task_bg = open("task_bg.txt", "r").readline()
os.popen(file_read_task_bg)
else:
input("invalid input. press enter to retry \n")
path_writer_bg()
if os.path.exists("your_path_bg.txt"):
read_folder_path_e_bg = open("your_path_bg.txt", "r").read()
open("task_bg.txt", "w").write("dir " + read_folder_path_e_bg + " /s /b >listed_bg.txt")
file_read_task_e_bg = open("task_bg.txt", "r").readline()
os.popen(file_read_task_e_bg)
else:
path_writer_bg()
def everything_bg():
with open("listed_bg.txt") as file_bg:
num_lines_bg = sum(1 for line_bg in open("listed_bg.txt"))
for num_bg, line_bg in enumerate(file_bg, 1):
rand_line_bg = random.randrange(num_lines_bg - 1)
lines_bg = open("listed_bg.txt", "r").readlines()
open('temp_bg.txt', 'w').writelines(lines_bg[rand_line_bg])
wallpaper_bg()
def wallpaper_bg():
path_bg = open("temp_bg.txt", "r").readline()
if os.path.exists("C:\\Windows\\System32\\oobe\\info\\backgrounds\\backgroundDefault.jpg"):
os.popen("del C:\\Windows\\System32\\oobe\\info\\backgrounds\\backgroundDefault.jpg")
else:
pass
if os.popen("copy /y" + path_bg + " C:\\Windows\\System32\\oobe\\info\\backgrounds"):
os.popen("dir C:\\Windows\\System32\\oobe\\info\\backgrounds /s /b >renamer.txt")
else:
pass
if os.path.exists("renamer.txt"):
rename = open("renamer.txt", "r").readline()
else:
pass
os.popen("rename " + rename + "backgroundDefault.jpg")
wallpaper_bg()
exit()
time.sleep(10)
everything()
Maybe it is because that specific file can't be changed with python due to Microsoft not allowing software to change any file in system32.

Want to run several db.query() method in parallel without getting any error

I am using Node JS . I am a beginner. I use OrientJS to connect orientdb from Node JS. I want to run several db.query() method in parallel. This queries are formed by reading a large text file using line-by-line module.
For example,
var queryForGeoUpdate = 'update (' +
'\nselect from (' +
"\n select expand(outE('GeoAgentSummary')) " +
'\n from Agent ' +
'\n where name = "' + name + '" and number = \'' + number + "' and type = '" + type + "'" +
"\n) where in.name = '" + Geo + "'" +
'\n) increment _' + FiscalYear + ' = ' + TMSSalesAllocatedBookingsNet + 'f, _' +
FiscalPeriodID + ' = ' + TMSSalesAllocatedBookingsNet +
'f, _' + FiscalQuarterID + ' = ' + TMSSalesAllocatedBookingsNet + 'f'
// console.log(queryForGeoUpdate)
db.query(queryForGeoUpdate) // query and db call for Country ends here
like db.query(queryForGeoUpdate) there are seven queries like db.query(queryForRegionUpdate) and so on...
if I run it asynchronously "process out of memory occurrs". If I run it synchronously it takes too much time. How can I solve it within very less time..
Any help is appreciated..
I am not familiar with the DB you are using. If you are sure the DB works "correctly" and the calls you make are correct (e.g. if there isn't a way to make you queries much smaller) you could try running with:
node --max_old_space_size="memmory in MB, try something large like 8192" app.js
It seems rather strange that a DB query would run out of memory thought... I always assumed queries are, generally speaking,a lot more CPU intensive and require relatively little memory.
For these sort of large queries you might also try spawning separate processes:
https://nodejs.org/api/child_process.html

Powerbuilder 11.5 Run command in Win7 64bit

I have been developing an application which uses thermal
printers to print receipts.
Until now the following code (PB 11.5) was working as a
charm:
Environment env
GetEnvironment(env)
ls_port= 'LPT1'
ls_command = 'COPY ' + ls_tempfile + ' ' + ls_port
Choose Case env.OSType
Case windows!
ls_command = 'command.com /c ' + ls_command
Case windowsnt!
ls_command = 'cmd.exe /c "' + ls_command + '"'
Case else
ls_command = 'cmd.exe /c "' + ls_command + '"'
End Choose
li_cmd = Run(ls_command,Minimized!)
I have just deployed my application to a big customer with
Win7 64bit PCs and the command does not fire! I cannot print
at all!
I am in an awkard (to say the least) situation.
Can you help me?
Well, the problem was not in the PB Run statement but in a Net Use that I had done. Net Use in LPTx, COMx in Win7 64bit has tons of issues concerning privileges, user rights etc. Even the Print Directly to Printer option inside Printer Properties causes rights issues!! Oh God...

How to put multiple documents into Berkeley-DB XML container?

I have a directory with a bunch of XML documents and want to put all of them into a container.
In other words, I need to do something like this:
dbxml> putDocument tests/*.xml
I have written a GUI program to do that but the host server does not have X-windows installed, so must be in command line.
I do a similar thing when reloading certain XML docs into my current application DB. It helps if all of the files sharing a common naming convention. In python you would could use the following script to add doc001.xml to doc009.xml:
from bsddb3.db import *
from dbxml import *
#Load source files 001 - 009
sourceDir = 'C:/directory-containing-xml-docs'
fileRange = range(1,10)
for x in fileRange:
mycontainer = mymgr.openContainer("myDB.dbxml")
xmlucontext = mymgr.createUpdateContext()
xmlinput = mymgr.createLocalFileInputStream(sourceDir + "doc00" + str(x) + ".xml")
mycontainer.putDocument("doc00" + str(x) + ".xml", xmlinput, xmlucontext)
print 'Added: ' + str(x)
del mycontainer
print '1 - 9 Added'
Hope that helps
You could have a shell script write the list of XML files to another file and then call dbxml_load_container with the -f option.
Ended up using a script that lists files and puts everything into the DB.

Resources