OpenSSL scripts

Decrypt encrypted ts file

# index.m3u8
#EXTM3U
#EXT-X-VERSION:3
#EXT-X-TARGETDURATION:7
#EXT-X-MEDIA-SEQUENCE:0
#EXT-X-KEY:METHOD=AES-128,URI="https://localhost/ts.key",IV=0x00000000000000000000000000000000
#EXTINF:4.000000,
index0.ts
#EXTINF:4.000000,
index1.ts
#EXTINF:4.000000,
index2.ts
#EXTINF:4.000000,
index3.ts
#EXTINF:4.000000,
index4.ts
#EXTINF:4.000000,
index5.ts
#EXT-X-ENDLIST
curl "https://localhost/ts.key" -o ts.key
$KEY=`xxd -ps ts.key`
$IV="00000000000000000000000000000000"

FFMPEG_CONCAT_FILENAME="f.txt"
MP4_FILENAME="index.mp4"
ECRYPTED_FOLDER="encrypted"
DECRYPTED_FOLDER="decrypted"
mkdir $DECRYPTED_FOLDER

for i in {0..5}
do

TS_FILENAME=index$i.ts
ENC_TS_FILE=$ECRYPTED_FOLDER/$TS_FILENAME
curl "https://localhost/$TS_FILENAME" -o $ENC_TS_FILE

DEC_TS_FILE=$DECRYPTED_FOLDER/$TS_FILENAME
openssl aes-128-cbc -d -in $ENC_TS_FILE -out $DEC_TS_FILE -nosalt -K $KEY -iv $IV

echo "file $DEC_TS_FILE" >> $FFMPEG_CONCAT_FILENAME
done

ffmpeg -f concat -i $FFMPEG_CONCAT_FILENAME -codec copy $MP4_FILENAME

How To Generate a /etc/passwd password hash via the Command Line on Linux

If you're looking to generate the /etc/shadow hash for a password for a Linux user (for instance: to use in a Puppet manifest), you can easily generate one at the command line.

$ openssl passwd -1
Password:
Verifying - Password:
$1$3JUKmV3R$vZVeb51f1t6QZUecwuRHX0

If you want to pass along a salt to your password;

$ openssl passwd -1 -salt yoursalt
Password:
$1$yoursalt$5WA5NN0quMJ62v5LCu8kj1

The above examples all prompt your password, so it won't be visible in the history of the server or in the process listing. If you want to directly pass the password as a parameter, use one of these examples.

$ openssl passwd -1
Password:
Verifying - Password:
$1$rr7ygbpo$v.zYy4J3/B73NF/qsrDZJ0

$ echo 'joske' | openssl passwd -1 -stdin
$1$8HOL7Lpu$wYO7x5kUDw39GfQaVqelP/

By default, this will use an md5 algoritme for your password hash. The openssl tool only allows for those md5 hashes, so if you're looking for a more secure sha256 hash you can use this python script as shared by Red Hat.

$ python -c "import crypt; print crypt.crypt('joske')"
$6$0LNgXS95nJv2B6hm$BRNf00hyT5xGNRnsLSSn3xDPXIs6l34g2kpex4mh0w/fvGz4MYs02qWjVU5NrbVktoNVNRsHU6MUTUua4J5nO0

There you go!

你可能感兴趣的:(openssl,bash,m3u8,linux,ffmpeg)