Skip to content

Commit

Permalink
Updated to follow pylint requirements
Browse files Browse the repository at this point in the history
  • Loading branch information
gracelombardi committed Sep 28, 2022
1 parent 2f26779 commit dada343
Show file tree
Hide file tree
Showing 17 changed files with 100 additions and 39 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# CSEC791 MS Project - Grace Lombardi
# CSEC 791 MS Project - Grace Lombardi

## Twitter

Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
27 changes: 18 additions & 9 deletions TwitterDecodeBinary.py → twitter_decode_binary.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
"""
CSEC 791 MS Project
Grace Lombardi
Twitter Covert Channel
Decode Binary
"""

import tweepy
import twitter_config

Expand All @@ -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:
Expand Down
22 changes: 19 additions & 3 deletions TwitterDecodePlaintext.py → twitter_decode_plaintext.py
Original file line number Diff line number Diff line change
@@ -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")
Expand Down Expand Up @@ -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',
Expand Down
31 changes: 26 additions & 5 deletions TwitterEncodeBinary.py → twitter_encode_binary.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
"""
CSEC 791 MS Project
Grace Lombardi
Twitter Covert Channel
Encode Binary
"""

import tweepy
import twitter_config

Expand All @@ -11,24 +18,38 @@


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)
return chars


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()
Expand All @@ -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")


Expand Down
57 changes: 36 additions & 21 deletions TwitterEncodePlaintext.py → twitter_encode_plaintext.py
Original file line number Diff line number Diff line change
@@ -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")
Expand Down Expand Up @@ -43,25 +53,30 @@ 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:
client.remove_bookmark(i.id)


def main():
"""
This is the main encoding function.
"""
token = authenticate()
client = tweepy.Client(token)
message = get_message_input()
Expand All @@ -78,35 +93,35 @@ 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:
tweet_id = tweet.id
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)
Expand Down

0 comments on commit dada343

Please sign in to comment.