-
Notifications
You must be signed in to change notification settings - Fork 0
/
twitter_decode_binary.py
61 lines (53 loc) · 1.54 KB
/
twitter_decode_binary.py
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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
"""
CSEC 791 MS Project
Grace Lombardi
Twitter Covert Channel
Decode Binary
"""
import re
import tweepy
import twitter_config
client = tweepy.Client(
bearer_token=twitter_config.bearer_token,
consumer_key=twitter_config.api_key,
consumer_secret=twitter_config.api_secret,
access_token=twitter_config.access_token,
access_token_secret=twitter_config.access_secret
)
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 main():
"""
This is the main decoding function.
"""
user_id = get_user_id()
response = client.get_users_tweets(id=user_id, max_results=100)
binary = []
list_ids = []
for tweets in response.data:
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:
for i in likes.data:
if str(i) == "lombardi_grace":
binary.append('1')
mes = []
binary = ''.join(binary)
print(binary)
history = re.findall('........', binary)
for i in history:
mes.append(chr(int(i, 2)))
decoded_message = ''.join(mes)
print("Message Successfully Decoded: ", decoded_message)
if __name__ == '__main__':
main()