Advertisement
snakerdlk

Linux - VBScript binary base64 decompress gen

Oct 22nd, 2012
59
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.00 KB | None | 0 0
  1. if [ $# -lt 2 ]; then
  2. echo "Uso: $0 <vbscript> <arquivo[:nome]> [arquivo2[:nome2]] [...]"
  3. exit 1
  4. fi
  5.  
  6. VBSCRIPT="$1"
  7. shift
  8.  
  9. cat > $VBSCRIPT <<EOF
  10. Option Explicit
  11. Dim outFile
  12. Dim base64Encoded
  13. EOF
  14.  
  15. for file in $@; do
  16. if [ "$( echo $file | grep -hoa :)" != "" ]; then
  17. fname=$(echo $file | cut -d: -f2)
  18. file=$(echo $file | cut -d: -f1)
  19. else
  20. fname=$(basename $file)
  21. fi
  22.  
  23. if ! test -f $file; then
  24. echo "ERROR - file missing: $file"
  25. continue
  26. fi
  27.  
  28. echo "Adicionando: $file > $fname"
  29.  
  30. cat >> $VBSCRIPT << EOF
  31. outFile = "$fname"
  32. base64Encoded="$(cat $file | base64 -w0)"
  33. decode base64Encoded, outFile
  34.  
  35. EOF
  36.  
  37. done
  38.  
  39. cat >> $VBSCRIPT << EOF
  40. private Sub decode(b64E, oF)
  41. dim b64D
  42. dim DM, EL
  43. dim bS
  44.  
  45. Set DM = CreateObject("Microsoft.XMLDOM")
  46. Set EL = DM.createElement("tmp")
  47. EL.DataType = "bin.base64"
  48. EL.Text = b64E
  49. b64D = EL.NodeTypedValue
  50.  
  51. Set bS = CreateObject("ADODB.Stream")
  52. bS.Type = 1
  53. bS.Open
  54. bS.Write b64D
  55. bS.SaveToFile oF, 2
  56. End Sub
  57. EOF
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement