diff --git a/README.md b/README.md index b7c6851..8fda65e 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# CSEC791 MS Project - Grace Lombardi +# CSEC 791 MS Project - Grace Lombardi ## Twitter diff --git a/DiscordDecodeBinary.py b/discord_decode_binary.py similarity index 100% rename from DiscordDecodeBinary.py rename to discord_decode_binary.py diff --git a/DiscordDecodePlaintext.py b/discord_decode_plaintext.py similarity index 100% rename from DiscordDecodePlaintext.py rename to discord_decode_plaintext.py diff --git a/DiscordEncodeBinary.py b/discord_encode_binary.py similarity index 100% rename from DiscordEncodeBinary.py rename to discord_encode_binary.py diff --git a/DiscordEncodePlaintext.py b/discord_encode_plaintext.py similarity index 100% rename from DiscordEncodePlaintext.py rename to discord_encode_plaintext.py diff --git a/FacebookDecodeBinary.py b/facebook_decode_binary.py similarity index 100% rename from FacebookDecodeBinary.py rename to facebook_decode_binary.py diff --git a/FacebookDecodePlaintext.py b/facebook_decode_plaintext.py similarity index 100% rename from FacebookDecodePlaintext.py rename to facebook_decode_plaintext.py diff --git a/FacebookEncodeBinary.py b/facebook_encode_binary.py similarity index 100% rename from FacebookEncodeBinary.py rename to facebook_encode_binary.py diff --git a/FacebookEncodePlaintext.py b/facebook_encode_plaintext.py similarity index 100% rename from FacebookEncodePlaintext.py rename to facebook_encode_plaintext.py diff --git a/RedditDecodeBinary.py b/reddit_decode_binary.py similarity index 100% rename from RedditDecodeBinary.py rename to reddit_decode_binary.py diff --git a/RedditDecodePlaintext.py b/reddit_decode_plaintext.py similarity index 100% rename from RedditDecodePlaintext.py rename to reddit_decode_plaintext.py diff --git a/RedditEncodeBinary.py b/reddit_encode_binary.py similarity index 100% rename from RedditEncodeBinary.py rename to reddit_encode_binary.py diff --git a/RedditEncodePlaintext.py b/reddit_encode_plaintext.py similarity index 100% rename from RedditEncodePlaintext.py rename to reddit_encode_plaintext.py diff --git a/TwitterDecodeBinary.py b/twitter_decode_binary.py similarity index 70% rename from TwitterDecodeBinary.py rename to twitter_decode_binary.py index 5176511..004e2f8 100644 --- a/TwitterDecodeBinary.py +++ b/twitter_decode_binary.py @@ -1,3 +1,10 @@ +""" +CSEC 791 MS Project +Grace Lombardi +Twitter Covert Channel +Decode Binary +""" + import tweepy import twitter_config @@ -11,26 +18,28 @@ def get_user_id(): + """ + This function prompts the user for a username and then returns the user id associated with that + username. + """ username = input("Enter the username of the profile to retrieve message from: ") response = client.get_user(username=username) return response.data.id -def convert_to_binary(chars): - binary = ''.join(format(ord(char), '08b') for char in chars) - return binary - - def main(): + """ + This is the main decoding function. + """ user_id = get_user_id() response = client.get_users_tweets(id=user_id) binary = [] list_ids = [] for tweets in response.data: - id = tweets.id - list_ids.append(id) - for id in list_ids: - likes = client.get_liking_users(id=id) + tweet_id = tweets.id + list_ids.append(tweet_id) + for tweet_id in list_ids: + likes = client.get_liking_users(id=tweet_id) if likes.data is None: binary.append('0') else: diff --git a/TwitterDecodePlaintext.py b/twitter_decode_plaintext.py similarity index 89% rename from TwitterDecodePlaintext.py rename to twitter_decode_plaintext.py index 92ae908..2474b63 100644 --- a/TwitterDecodePlaintext.py +++ b/twitter_decode_plaintext.py @@ -1,14 +1,24 @@ -import tweepy -from requests.auth import HTTPBasicAuth -import twitter_config +""" +CSEC 791 MS Project +Grace Lombardi +Twitter Covert Channel +Decode Plaintext +""" + import base64 import hashlib import os import re +import tweepy +from requests.auth import HTTPBasicAuth from requests_oauthlib import OAuth2Session +import twitter_config def authenticate(): + """ + This function authenticates with OAuth2 and returns the access_token. + """ redirect_uri = "https://ngrok.com" scopes = ["bookmark.read", "tweet.read", "users.read", "offline.access"] code_verifier = base64.urlsafe_b64encode(os.urandom(30)).decode("utf-8") @@ -43,11 +53,17 @@ def authenticate(): def get_name_input(): + """ + This function prompts the user to enter a name for the Twitter list. + """ message = input("Enter a name for the list: ") return message def main(): + """ + This is the main decoding function. + """ token = authenticate() client = tweepy.Client(token) mil_alphabet = {'a': 'alpha', 'b': 'bravo', 'c': 'charlie', 'd': 'delta', 'e': 'echo', diff --git a/TwitterEncodeBinary.py b/twitter_encode_binary.py similarity index 65% rename from TwitterEncodeBinary.py rename to twitter_encode_binary.py index 25ed616..9672bf6 100644 --- a/TwitterEncodeBinary.py +++ b/twitter_encode_binary.py @@ -1,3 +1,10 @@ +""" +CSEC 791 MS Project +Grace Lombardi +Twitter Covert Channel +Encode Binary +""" + import tweepy import twitter_config @@ -11,12 +18,20 @@ def get_user_id(): + """ + This function prompts the user for a username and then returns the user id associated with that + username. + """ username = input("Enter the username of the profile to place your message on: ") response = client.get_user(username=username) return response.data.id def get_message_input(): + """ + This function prompts the user for a message to encode and then returns a list of all characters + in the message. + """ message = input("Enter the message to encode: ") message = message.replace(" ", "") chars = list(message) @@ -24,11 +39,17 @@ def get_message_input(): def convert_to_binary(chars): + """ + This function coverts every character in the list to their binary equivalent. + """ binary = ''.join(format(ord(char), '08b') for char in chars) return binary def main(): + """ + This is the main encoding function. + """ user_id = get_user_id() response = client.get_users_tweets(id=user_id) message = get_message_input() @@ -39,13 +60,13 @@ def main(): "different user account.") else: for tweets in response.data: - id = tweets.id - list_ids.append(id) - for num, id in zip(binary, list_ids): + tweet_id = tweets.id + list_ids.append(tweet_id) + for num, tweet_id in zip(binary, list_ids): if num == '0': - client.unlike(id) + client.unlike(tweet_id) elif num == '1': - client.like(id) + client.like(tweet_id) print("Finished Liking/Unliking Tweets to Hide Message") diff --git a/TwitterEncodePlaintext.py b/twitter_encode_plaintext.py similarity index 76% rename from TwitterEncodePlaintext.py rename to twitter_encode_plaintext.py index 06bd448..4ac3d87 100644 --- a/TwitterEncodePlaintext.py +++ b/twitter_encode_plaintext.py @@ -1,14 +1,24 @@ -import tweepy -from requests.auth import HTTPBasicAuth -import twitter_config +""" +CSEC 791 MS Project +Grace Lombardi +Twitter Covert Channel +Encode Plaintext +""" + import base64 import hashlib import os import re +import tweepy +from requests.auth import HTTPBasicAuth from requests_oauthlib import OAuth2Session +import twitter_config def authenticate(): + """ + This function authenticates with OAuth2 and returns the access_token. + """ redirect_uri = "https://ngrok.com" scopes = ["bookmark.read", "bookmark.write", "tweet.read", "users.read", "offline.access"] code_verifier = base64.urlsafe_b64encode(os.urandom(30)).decode("utf-8") @@ -43,18 +53,20 @@ def authenticate(): def get_message_input(): + """ + This function prompts the user for a message to encode and then returns a list of all characters + in the message. + """ message = input("Enter the message to encode: ") message = message.replace(" ", "") chars = list(message.lower()) return chars -def get_name_input(): - message = input("Enter a name for the list: ") - return message - - def clear_bookmarks(client): + """ + This function removes all bookmarks. + """ bookmarks = client.get_bookmarks() if bookmarks.data is not None: for i in bookmarks.data: @@ -62,6 +74,9 @@ def clear_bookmarks(client): def main(): + """ + This is the main encoding function. + """ token = authenticate() client = tweepy.Client(token) message = get_message_input() @@ -78,25 +93,25 @@ def main(): for i in message: tweet_id = '' done = False - list = client.search_recent_tweets(query=mil_alphabet.get(str(i)) + ' -is:retweet ' - '-is:reply ' - '-is:quote', - max_results=10) + tweet_list = client.search_recent_tweets(query=mil_alphabet.get(str(i)) + ' -is:retweet ' + '-is:reply ' + '-is:quote', + max_results=100) word = mil_alphabet.get(str(i)) - token = list.meta['next_token'] - for tweet in list.data: + token = tweet_list.meta['next_token'] + for tweet in tweet_list.data: if tweet is not None: word_list = str(tweet).split() if word_list[0] == word: tweet_id = tweet.id done = True while done is False: - list = client.search_recent_tweets(query=mil_alphabet.get(str(i)) + ' -is:retweet ' - '-is:reply ' - '-is:quote', - max_results=10, next_token=token) + tweet_list = client.search_recent_tweets(query=mil_alphabet.get(str(i)) + ' -is:retweet' + ' -is:reply ' + '-is:quote', + max_results=100, next_token=token) word = mil_alphabet.get(str(i)) - for tweet in list.data: + for tweet in tweet_list.data: if tweet is not None: word_list = str(tweet).split() if word_list[0] == word: @@ -104,9 +119,9 @@ def main(): if tweet_id not in tweet_ids_list: done = True else: - token = list.meta['next_token'] + token = tweet_list.meta['next_token'] else: - token = list.meta['next_token'] + token = tweet_list.meta['next_token'] print(tweet_id) tweet_ids_list.append(tweet_id) client.bookmark(tweet_id=tweet_id)