Skip to content

This Repository is a collection of different ethical hacking tools and malware's for penetration testing and research purpose written in python, ruby, rust, c++, go and c.

Add files via upload

Abdul Wahab Junaid37a38df5468f
diff --git a/Steganography/python.png b/Steganography/python.png
new file mode 100644
index 0000000..0ada078
Binary files /dev/null and b/Steganography/python.png differ
diff --git a/Steganography/python_secrets.png b/Steganography/python_secrets.png
new file mode 100644
index 0000000..9fa2ee7
Binary files /dev/null and b/Steganography/python_secrets.png differ
diff --git a/Steganography/steganography_LSB.py b/Steganography/steganography_LSB.py
new file mode 100644
index 0000000..c4c19f8
--- /dev/null
+++ b/Steganography/steganography_LSB.py
@@ -0,0 +1,82 @@
+#!/usr/bin/env python
+
+from PIL import Image
+
+def set_LSB(value, bit):
+ if bit == '0':
+ value = value & 254
+ else:
+ value = value | 1
+ return value
+
+def get_LSB(value):
+ if value & 1 == 0:
+ return '0'
+ else:
+ return '1'
+
+def get_pixel_pairs(iterable):
+ a = iter(iterable)
+ return zip(a, a)
+
+
+def extract_message(image):
+
+ c_image = Image.open(image)
+ pixel_list = list(c_image.getdata())
+ message = ""
+
+ for pix1, pix2 in get_pixel_pairs(pixel_list):
+ message_byte = "0b"
+ for p in pix1:
+ message_byte += get_LSB(p)
+
+ for p in pix2:
+ message_byte += get_LSB(p)
+
+ if message_byte == "0b00000000":
+ break
+
+ message += chr(int(message_byte,2))
+
+ return message
+
+def hide_message(image, message, outfile):
+
+ message += chr(0)
+ c_image = Image.open(image)
+ c_image = c_image.convert('RGBA')
+ out = Image.new(c_image.mode, c_image.size)
+ width, height = c_image.size
+ pixList = list(c_image.getdata())
+ newArray = []
+
+ for i in range(len(message)):
+ charInt = ord(message[i])
+ cb = str(bin(charInt))[2:].zfill(8)
+ pix1 = pixList[i*2]
+ pix2 = pixList[(i*2)+1]
+ newpix1 = []
+ newpix2 = []
+
+ for j in range(0,4):
+ newpix1.append(set_LSB(pix1[j], cb[j]))
+ newpix2.append(set_LSB(pix2[j], cb[j+4]))
+
+ newArray.append(tuple(newpix1))
+ newArray.append(tuple(newpix2))
+
+ newArray.extend(pixList[len(message)*2:])
+
+ out.putdata(newArray)
+ out.save(outfile)
+ return outfile
+
+
+if __name__ == "__main__":
+ print("Testing hide message in python_secrets.png with LSB ...")
+ print(hide_message('python.png', 'Hidden message', 'python_secrets.png'))
+ print("Hide test passed, testing message extraction ...")
+ print(extract_message('python_secrets.png'))
+
+
diff --git a/Steganography/stepic_hide_message.py b/Steganography/stepic_hide_message.py
new file mode 100644
index 0000000..47fb830
--- /dev/null
+++ b/Steganography/stepic_hide_message.py
@@ -0,0 +1,9 @@
+from PIL import Image
+import stepic
+
+image = Image.open("python.png")
+image2 = stepic.encode(image, 'This is the hidden text'.encode("utf8"))
+image2.save('python_secrets.png','PNG')
+image2 = Image.open('python_secrets.png')
+data = stepic.decode(image2)
+print("Decoded data: " + data)