Is it possible to decrypt .seb file having password? - encryption

My school started to use Safe Exam Browser as platform for online tests and i wanted to know more about it. I was trying to understand how its configuration file are made and what they actually contain, so i started to read the documentation from here in order to decrypt one of that, but i didn't manage to do it. Could you please give me an idea of the procedure to follow to dercypt a .seb file, assuming that it is possible?

SEB configuration file is generated by opening SEB client, adjusting the settings to one's liking and entering the password (or digital certificate), which encrypts the config file. When you open .seb file with SEB and enter the password (which must be provided by your school), the .seb file is "decrypted" and the SEB client is configured accordingly. Without the password, it is generally impossible to break the encryption (for more details see Advanced Encryption Standard Security).
Although the .seb information can be extracted from SEB GUI settings plane, I am adding a Python script based on this thread. The complete encryption/decryption algorithm is described here.
import gzip
import zlib
import rncryptor # https://github.com/RNCryptor/RNCryptor
# Modify the rncryptor post_decrypt_data class to fit the algorithm
class RNCryptor_modified(rncryptor.RNCryptor):
def post_decrypt_data(self, data):
data = data[:-(data[-1])]
return data
def decrypt_SEB(password):
cryptor = RNCryptor_modified()
with gzip.open('encrypted.seb', 'rb') as f:
file_content = f.read()
decrypted_data = cryptor.decrypt(file_content[4:], password)
decompressed_data = zlib.decompress(decrypted_data,15 + 32)
with open("decrypted.seb", "wb") as f:
f.write(decompressed_data)
decrypt_SEB("enter_password_here")
This reads the decrypted .seb file ("encrypted.seb") and outputs the decrypted XML ("decrypted.seb").

Related

Chilkat - Encode into PKCS7 the following elements : XML Signed Document + Signature certificate itself encoded X509

We are trying to automate certain processes with Chilkat.
In particular we are trying to generate a PKCS7 document that contains the following features:
A signed xml document. This signing is done via smartcard and the
output must include the signature. For this point, we are using the
crypt2 object with :
EncodingMode, HashAlgorithm and charset attributes
SetSigningCert, OpaqueSignStringENC methods
We need also to include the signer's digital signature certificate in X.509 ASN encoding.
This second point is where we are having some problems.
We have obtained a valid signed document according to the 2 points through the createp7m method for manual testing but the point of our program is to automate the process in memory. Therefore, we are trying to use the OpaqueSignStringENC("original xml to sign") but we believe the point (2) is not being taken into account.
I don't know if anyone has encountered a similar problem. I just recently started working with encryption, certificates...sorry if I am explaining myself incorrectly.
Thanks everyone for your help and time

Ioncube: encryption for non-php file

I would like to ask a question about ioncube encryption. I have successfully encrypted a *.conf file.
When I run it, it doesn't seems to be running properly.
How can I encrypt a non-php file? Can you give a step by step process?
All steps taken from the latest ionCube Encoder User Guide for Version 9 and the GUI documentation.
Encrypt files
In the command line encoder, you can create encrypted files with the command
--encrypt "fileselector"
You can chain these together to select multiple files, and use Wilcards as selectors. For example:
ioncube_encoder --encrypt "*.conf" --encrypt "*.xml"
In the GUI you can enter these selectors in the 'Source Tab' in your Project settings, under the 'Non-PHP encryption extensions' label:
Loading encrypted files
Once the files are encrypted, you can read their content by calling the function:
mixed ioncube_read_file(string path [,bool &was_encrypted [,string passphrase] ] ] )
For example, if you encrypted the file foo.conf without passphrase, you can get the content back by calling:
$file_content = ioncube_read_file("foo.conf");
Note: This only works from already encoded files, otherwise the encryption would be useless. Furthermore, encrypted files can only be decrypted by files encoded with the same ionCube Encoder, i.e. if you encrypt your files on Machine 1 and try to decrypt them with files encoded on Machine 2, you won't be able to decrypt the file.

decrypting file from eToken

I am new to cryptography, hence I want to ask about my company's requirements.
We are using eToken with RSA support.
I have developed a code that encrypt file with public key and stored it in another file.
Now I want to pass the encrypted file to eToken, and here is my issue.
How can I access the eToken from a Java applet?
Is it right that I have to pass encrypted file to eToken and it will decrypt file for me?
How can I do this?

Check encrypted file for empty content

I'm using gpg to decrypt files sent to me by a vendor. Everything works fine accept for when the content of the encrypted file is empty (the vendor has told me that there is no content in the files in question).
If I try and decrypt one of these files I get:
gpg: can't handle this ambiguous
signature data
Is there any way to check that the file has no content accept for the header, so that I can set it up to fail more elegantly?
According to this mailing-list post, the official PGP tool has a bug that sometimes causes it to produce malformed messages. You can verify whether this is the case for your particular file by running gpg --list-packets path/to/encrypted/file.pgp and looking at the output. If you see a :onepass_sig packet: followed immediately by a :signature packet: then that's probably what's going on.
In my (limited) experience, this occurs if the sender has tried to encrypt an empty file. Unfortunately, since encryption is designed to make it difficult to see what's inside, it's hard to tell if that's actually the case before you try to decrypt it. gpg's --list-packets output will give you some information, but I've noticed that the :literal data packet: output will usually say "raw data: 0 bytes" even if the message contains a non-empty file.
You can make gpg ignore all signature data in the encrypted file with the --skip-verify option, but then of course you can't tell whether the file you're decrypting comes from a trusted source.
Assuming you are using a unix shell script, you could first do a '[ -s /the/file ]' before attempting the GPG decrypt.

Extend file upload class to use encryption

Is there an easy/straightforward way to extend the file upload class to encrypt files that are being uploaded? Not just encrypting the filename, but rather the data in the file itself.
I'm using mcrypt for db encryption, and would prefer to use the same for file encryption.
Looking through the Upload.php library, I don't see an obvious place where the uploaded file is read which is where I assume I'd shim in the encryption.
Any help/advice would be appreciated.
edit:
What I'm thinking is that somewhere in do_upload() (I'm thinking file_temp) the file gets encrypted before being moved (not copied!) into its final destination. However, I don't see anywhere in Upload.php where the code is working with any of the files' data outside of filename, size, type, etc. Does this approach make sense?
Rather than encrypting just the upload, use HTTPS/SSL to encrypt the entire connection between the client and server.
I decided to forgo modifying the upload class. What I did was after the file was uploaded, open the file, encrypt it, and write it out again.
$f=file_get_contents(BASE_PATH.$fileFullPath) or die ('<script>window.parent.transUpdateFail(\'no gfc'.$fileFullPath.'\');</script>');
$encf=$this->encrypt->encode($f,$this->e_key) or die ('<script>window.parent.transUpdateFail(\'no encrypt\');</script>');
$nf=fopen(BASE_PATH.$fileFullPath,"r+") or die ('<script>window.parent.transUpdateFail(\'no open '.$fileFullPath.'\');</script>');
$fw=fwrite($nf,$encf) or die ('<script>window.parent.transUpdateFail(\'no fwrite\');</script>');
fclose($nf);

Resources