-
Notifications
You must be signed in to change notification settings - Fork 2
/
Ruby_Steganography_Malware.rb
30 lines (19 loc) · 1.36 KB
/
Ruby_Steganography_Malware.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# Created July 13, 2023 - By: Devon Griffith A.K.A. rootPHAGE / 我爱数据
# Run on Windows [ ruby <path to file>\Ruby_Steganography_Malware.rb ]
# A malware program written in Ruby that hides malware inside of an image using steganography
require 'chunky_png' # Ruby import statement for the library to load the image you need
image_path = 'path/to/your/image.png' # Path to the original image file
output_image_path = 'path/to/output/image.png' # Path to where you'll output the image file with the hidden malware
payload_file_path = 'path/to/payload/file.txt' # Path to the payload file
image = ChunkyPNG::Image.from_file(image_path) # Load the original image with ChunkyPNG
payload = File.read(payload_file_path) # Load the payload file
binary_payload = payload.unpack('B*')[0].split('') # Convert the malware payload into an array of binary strings
binary_payload.each_with_index do |bit, i| # Embed the payload into the image using Least Significant Bit (LSB) steganography (replace the least important bit of each pixel with ONE binary bit from the malware)
x = i % image.width
y = i / image.width
pixel = image[x, y]
new_pixel = pixel & 0xFE | bit.to_i
image[x, y] = new_pixel
end
image.save(output_image_path) # Save the image with the hidden malware stored inside the pixels
# DO NOT USE THIS SCRIPT MALICIOUSLY - PROVIDED FOR EDUCATIONAL PURPOSES ONLY