LinuxQuestions.org
Visit Jeremy's Blog.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Security
User Name
Password
Linux - Security This forum is for all security related questions.
Questions, tips, system compromises, firewalls, etc. are all included here.

Notices

Reply
 
Search this Thread
Old 03-18-2011, 11:23 AM   #1
prushik
Member
 
Registered: Mar 2009
Location: South Korea
Distribution: Lubuntu, BetterLinux
Posts: 364

Rep: Reputation: 28
reversing openssl commands


I am really bad with this stuff... This is probably a dumb question, but openssl just drives me crazy.
I have 2 images, I know the commands to decrypt them, I can do that, its easy. However, I want to also be able to re-encrypt after some modifications, and I just can't figure it out.
Again, I am really bad with this kind of thing. It looks to me like there is 4 separate security keys... Here are the commands I use to decrypt these image files, can somebody explain to me how to reverse these commands to re-encrypt the files?


cat install.tgz.p7m | openssl smime -verify -inform DER -signer ./signer_cert.txt -CApath /home/prushik/Public/keys/ca/ > ./install.bin
openssl enc -d -aes-256-cbc -pass file:/home/prushik/Public/keys/key < ./install.bin > install.tgz
tar xf install.tgz

cat image.ext2.bin | openssl smime -verify -binary -content /dev/stdin -noverify -inform PEM -in image.p7s | openssl enc -d -aes-256-cbc -salt -pass file:image.pwd | > image.ext2


The first block of commands is for the first file, the second file needs some kind of key from the first file to get decrypted.
 
Old 03-19-2011, 08:35 AM   #2
anomie
Senior Member
 
Registered: Nov 2004
Location: Texas
Distribution: RHEL, Scientific Linux, Debian, Fedora, Lubuntu, FreeBSD
Posts: 3,930
Blog Entries: 5

Rep: Reputation: Disabled
Here's your first decrypt statement:

Quote:
Originally Posted by prushik
Code:
openssl enc -d -aes-256-cbc -pass file:/home/prushik/Public/keys/key < ./install.bin > install.tgz
Here's how to re-encrypt that one:

Code:
openssl enc -aes-256-cbc -in install.tgz -out install.tgz.enc -pass file:/home/prushik/Public/keys/key -salt -e
Please read the enc(1) and smime(1) manpages. It might be easier to understand if you clean up your pipelines and document (for yourself) what is happening.

Last edited by anomie; 03-19-2011 at 08:38 AM. Reason: clarified.
 
Old 03-19-2011, 09:20 PM   #3
prushik
Member
 
Registered: Mar 2009
Location: South Korea
Distribution: Lubuntu, BetterLinux
Posts: 364

Original Poster
Rep: Reputation: 28
Quote:
Originally Posted by anomie View Post
Here's your first decrypt statement:



Here's how to re-encrypt that one:

Code:
openssl enc -aes-256-cbc -in install.tgz -out install.tgz.enc -pass file:/home/prushik/Public/keys/key -salt -e
Please read the enc(1) and smime(1) manpages. It might be easier to understand if you clean up your pipelines and document (for yourself) what is happening.
Great! thanks, just that first command might be enough, I should be able to modify a script in that first image so that the second image does not need to be encrypted at all.

In the command I posted to decrypt the second image, I think I added an extra pipe near the end accidentally, right before the redirect. Oops, sorry. For the most part I am pretty good at understanding pipes and redirects and such, but openssl and encryption stuff is just so complicated...
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Reversing Multilib mlangdn Slackware 3 02-05-2010 12:00 PM
Reversing a string using only commands from the SUS (Single UNIX Specification) Willard Programming 6 11-17-2009 11:30 AM
oops openssl-0.9.8e over openssl-0.9.8d bad install now 2 copies? rcorkum Slackware 4 06-29-2007 01:58 AM
reversing a macro Deepak Inbasekaran Programming 6 07-21-2006 12:41 AM
reversing videocard lackluster Linux - Hardware 1 11-16-2002 02:58 PM


All times are GMT -5. The time now is 10:08 AM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration