How to Decrypt encrypted php code? - decode

How to decrypt the encrypted php code with following:
eval(key_variable(base64_decode('some text')));
this used a keywords instead of gzinflate.

Related

Encryption and file format in Kleopatra. Can't encrypt using Public Key

I created PGP key pair and I exported private and public key files. I know that files are fine because I was able to encrypt/decrypt files in GpgFrontend app using these keys. I was also able to do the same using Bouncy Castle library in C#.
Two questions:
1: In Kleopatra, I can't encrypt file with Public Key only. For some reason it doesn't work. Option is not available. To be able to encrypt/decrypt I have to load Private key. What is it that I am missing?
2: I am confused with encrypted data. When I open encrypted PGP file, data looks something like this:
…F†u—PEÛ Ù×´‡Ó"gÆx=ÑoãÝSŒ6M)!ÑÙ×g|;ä #+Pa,²TDV„ëùqá²*”—}×±dCÐÊsf^:Š†7¶LØnš{‹‰ždºV°G­(¸7Rd ôUµD#9ÖÕ÷ü Ý dëE¶-ýû¾/khØÇ~Zˆ0:±ðU5É¥žÇé¯7M Ôà}Ò:ÕÈàÒ€snœ­‘èÁq§ÀJ®zU’èDc%ߘ–yí|걫M„ð™=Üæ0ß| 5|¾ªô Åíú_lªkó‰Ùª>/–þ€ÈðkvÖwãz9Y±ŠÜW½ìFÍþ{ãF­ÔS fýâÚÐpá
8Z_.eÄŽÂU)õœ-•êSQÁ\¼—? ¥ã¢O¯J•ÔÖ D;<kÔPÚ.8ÀKƒNÒ€3túø°ÒºA¼ ‡KèÁ›X
but, when I use Notepad option in Kleopatra (or in GpgFrontend), and when I encrypt some text, encrypted data looks like this:
-----BEGIN PGP MESSAGE-----
hF4D1F0XuQWmdMYSAQdAJaVSF+2pME685EMW2M/xDKPKE6BxJiSYSgP06GGKUVgw
P+7Y91/iMOHz2dB4K2clkjgLbWXvy+DRlkBKXGzs7lSK6c3+HFv1L+EIj+mm+dni
1MAGAQkCEP6UbLZfq+aFWK3Fs4H7j05XYdovJvZv9GKEBQCbGT4PjB1ZrxkC+VfO
ybB5R6cWJMdo1mdUg05KAAfSinOM/19gXBrh2pwO/snX/bK7M1iA+qi0rYcGl7Lu
ijHm6PA1c8LBMKFz7Xc6lcA5CtsLTseHHHGEtQCt6Hd/z0EvQUA0FdiYKcieX/lA
W8y0V+Xjao86VmRNYVryx6pRmbq5+vN7H/9hnDNUxgzxVb/yQ90FePzDK73V/bsT
Im2MNTma9ruB
=j0ZY
-----END PGP MESSAGE-----
Why does encrypted data look different?
Thank you

Lumen Encrypted Key Decrypt in Node JS

I have a session cookie which is encrypted in Lumen Framework.
https://lumen.laravel.com/docs/8.x/encryption
I am trying to decrypt cookie in Node Js using crypto-js but I get an error message Error: Malformed UTF-8 data at Object.stringify
I have been stuck on this for a day not sure what I am doing wrong !!
Any Help would be appreciated.

Jenkins Decrypt API Token

I'm using Jenkins with DC/OS (Mesos) and the service doesn't have a standard login but instead uses Mesos/Zookeeper for authentication. I'm can access JENKINS_HOME and have the config files for each user. I see the config.xml and also see the secret.key. I found this code:
https://github.com/abrindeyev/jenkins-helpers/blob/master/bin/get_api_token.rb
whose purpose is to decode the Jenkins API Token from the config. However, when I run this I get the following error:
/root/decrypt_api.rb:28:in `final': wrong final block length (OpenSSL::Cipher::CipherError)
from /root/decrypt_api.rb:28:in `decrypt'
from /root/decrypt_api.rb:35:in `<main>'
Here's an example Token and Key (from a Docker Jenkins test container):
Cipher in config.xml:
<jenkins.security.ApiTokenProperty>
<apiToken>{AQAAABAAAAAwrkIhJkGOx+QkqgJ/Ep8NhecxeWcqAs78RI9v5kr8y1FSCJBA4YFHrneQGxmetsj3/xSywFRXItIbtuCufWR6ng==}</apiToken>
</jenkins.security.ApiTokenProperty>
Secret Key:
bdafc86eae946c35ca57d3af02a82b733741d59e1eca44e0a3f7ef0b8f25f8e6
How can I decode the Token with the cipher and the key?
You can decode Jenkins token by going to Script Console in your master node (or go to /script), then run the following command:
println(hudson.util.Secret.decrypt("{XXX=}"))
Note: Replace {XXX=} with your token string.
To decrypt it without using Jenkins, checkout these scripts:
tweksteen/jenkins-decrypt, menski/jenkins-decrypt.py.
Related:
Extract passphrase from Jenkins' credentials.xml
What password encryption Jenkins is using?
How to decrypt Jenkins passwords from credentials.xml?
go to
http://jenkins-host/script
hashed_pw='your-sercret-hash-S0SKVKUuFfUfrY3UhhUC3J'
passwd = hudson.util.Secret.decrypt(hashed_pw)
println(passwd)
it should decrypt your token

getting exception after encrypting password of conf/axis2/axsi2.xml

getting exception after encrypting password of conf/axis2/axsi2.xml , i have used ciphertool.sh to encrypt the password.
i was able to encrypt the other files of /repository/conf dir .
Did anyone faced same issue.
Thanks you.
we have seen problem to Encrypt axis2.xml .But after using below aliases and x-path we were able to encrypt passwords for axis2.xml:
Axis2.Https.Listener.TrustStore.Password=repository/conf/axis2/axis2.xml//axisconfig/transportReceiver[#name='https']/parameter[#name='truststore']/TrustStore/Password,false
Axis2.Https.Listener.KeyStore.Password=repository/conf/axis2/axis2.xml//axisconfig/transportReceiver[#name='https']/parameter[#name='keystore']/KeyStore/Password,false
Axis2.Https.Listener.KeyStore.KeyPassword=repository/conf/axis2/axis2.xml//axisconfig/transportReceiver[#name='https']/parameter[#name='keystore']/KeyStore/KeyPassword,false
Axis2.Https.Sender.TrustStore.Password=repository/conf/axis2/axis2.xml//axisconfig/transportSender[#name='https']/parameter[#name='truststore']/TrustStore/Password,false
Axis2.Https.Sender.KeyStore.Password=repository/conf/axis2/axis2.xml//axisconfig/transportSender[#name='https']/parameter[#name='keystore']/KeyStore/Password,false
Axis2.Https.Sender.KeyStore.KeyPassword=repository/conf/axis2/axis2.xml//axisconfig/transportSender[#name='https']/parameter[#name='keystore']/KeyStore/KeyPassword,false

Reading in from file

I am working on making a basic password keeper in Golang and want to be able to store the passwords encrypted using RSA. My encryption function and decryption functions both work and will encrypt and decrypt correctly. However after storing the password in a file and then reading the password back from the file the decryption function fails. I have checked to make sure that the reading in of the RSA key is correct and that is not my problem as reading in the RSA key works correctly.
Here is how I am writing my encrypted password to the file
ioutil.WriteFile(filename, encPassword, 0644)
and here is how I am reading back the password
encrypted, err = ioutil.ReadFile(encryptedFileName)
When I run my program I am currently receiving this error code
failed in decrypt_oaep: crypto/rsa: decryption error
exit status 1
My belief is that Read or Write file is adding something to the contents of the file because if I try and decrypt the password before the encrypted password is written or read from a file it will work fine. Any help would be appreciated.
If you need more code I can post more of it later.
Edit: here is a link to codeshare with my entire code: https://codeshare.io/PtMxk
In line 167 you are calling your encrypt function with label = []byte(product).
In line 120 you are calling your decrypt function with a label variable that has been defined but not initialized (i.e. you are sending an empty byte array)
decrypted = decrypt_oaep(private_key, encrypted, label)
Because of that, your decryption won't work. From the docs:
The label parameter must match the value given when encrypting
- https://golang.org/pkg/crypto/rsa/#DecryptOAEP
Solution:
In the decryption call (line 120) send []byte(product) as the label parameter.

Resources