├── output
└── dont_delete_this_folder.txt
├── config
└── credentials.ini
├── .img
└── carbon.png
├── .gitignore
├── docker_reqs.txt
├── requirements.txt
├── .dockerignore
├── docker-compose.yml
├── src
├── artwork.py
├── printcolors.py
├── config.py
└── Osintgram.py
├── .github
├── dependabot.yml
├── workflows
│ ├── lint_python.yml
│ └── close_inactive_issues.yml
└── FUNDING.yml
├── Dockerfile
├── Makefile
├── main.py
├── README.md
└── LICENSE
/output/dont_delete_this_folder.txt:
--------------------------------------------------------------------------------
1 | Please don't delete this folder.
--------------------------------------------------------------------------------
/config/credentials.ini:
--------------------------------------------------------------------------------
1 | [Credentials]
2 | username = USERNAME
3 | password = PASSWORD
--------------------------------------------------------------------------------
/.img/carbon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/thedev132/Osintgram/HEAD/.img/carbon.png
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | config/
2 | __pycache__/
3 | output/
4 | *.pyc
5 | *.json
6 | venv/
7 | credentials.ini
--------------------------------------------------------------------------------
/docker_reqs.txt:
--------------------------------------------------------------------------------
1 | requests==2.31.0
2 | requests-toolbelt==1.0.0
3 | geopy>=2.0.0
4 | prettytable==3.9.0
5 | instagrapi
6 | instaloader==4.10.3
--------------------------------------------------------------------------------
/requirements.txt:
--------------------------------------------------------------------------------
1 | requests==2.31.0
2 | requests-toolbelt==1.0.0
3 | geopy>=2.0.0
4 | prettytable==3.9.0
5 | instagrapi==2.0.3
6 | instaloader==4.10.3
7 | Pillow==10.2.0
--------------------------------------------------------------------------------
/.dockerignore:
--------------------------------------------------------------------------------
1 | .github
2 | .img
3 | doc
4 | output
5 | .dockerignore
6 | .gitignore
7 | Docker-compose.yml
8 | Dockerfile
9 | LICENSE
10 | Makefile
11 | README.md
--------------------------------------------------------------------------------
/docker-compose.yml:
--------------------------------------------------------------------------------
1 | version: '3.7'
2 |
3 | services:
4 | osintgram:
5 | container_name: osintgram
6 | build: .
7 | volumes:
8 | - ./output:/home/osintgram/output
--------------------------------------------------------------------------------
/src/artwork.py:
--------------------------------------------------------------------------------
1 | ascii_art = r"""
2 | ██████╗ ███████╗██╗███╗ ██╗████████╗ ██████╗ ██████╗ █████╗ ███╗ ███╗
3 | ██╔═══██╗██╔════╝██║████╗ ██║╚══██╔══╝██╔════╝ ██╔══██╗██╔══██╗████╗ ████║
4 | ██║ ██║███████╗██║██╔██╗ ██║ ██║ ██║ ███╗██████╔╝███████║██╔████╔██║
5 | ██║ ██║╚════██║██║██║╚██╗██║ ██║ ██║ ██║██╔══██╗██╔══██║██║╚██╔╝██║
6 | ╚██████╔╝███████║██║██║ ╚████║ ██║ ╚██████╔╝██║ ██║██║ ██║██║ ╚═╝ ██║
7 | ╚═════╝ ╚══════╝╚═╝╚═╝ ╚═══╝ ╚═╝ ╚═════╝ ╚═╝ ╚═╝╚═╝ ╚═╝╚═╝ ╚═╝
8 | """
9 |
--------------------------------------------------------------------------------
/.github/dependabot.yml:
--------------------------------------------------------------------------------
1 | # To get started with Dependabot version updates, you'll need to specify which
2 | # package ecosystems to update and where the package manifests are located.
3 | # Please see the documentation for all configuration options:
4 | # https://docs.github.com/github/administering-a-repository/configuration-options-for-dependency-updates
5 |
6 | version: 2
7 | updates:
8 | - package-ecosystem: "pip" # See documentation for possible values
9 | directory: "/" # Location of package manifests
10 | schedule:
11 | interval: "weekly"
12 |
--------------------------------------------------------------------------------
/src/printcolors.py:
--------------------------------------------------------------------------------
1 | import sys
2 |
3 | BLACK, RED, GREEN, YELLOW, BLUE, MAGENTA, CYAN, WHITE = range(8)
4 |
5 |
6 | def has_colours(stream):
7 | if not (hasattr(stream, "isatty") and stream.isatty):
8 | return False
9 | try:
10 | import curses
11 | curses.setupterm()
12 | return curses.tigetnum("colors") > 2
13 | except:
14 | return False
15 |
16 |
17 | has_colours = has_colours(sys.stdout)
18 |
19 |
20 | def printout(text, colour=WHITE):
21 | if has_colours:
22 | seq = "\x1b[1;%dm" % (30 + colour) + text + "\x1b[0m"
23 | sys.stdout.write(seq)
24 | else:
25 | sys.stdout.write(text)
26 |
--------------------------------------------------------------------------------
/.github/workflows/lint_python.yml:
--------------------------------------------------------------------------------
1 | name: lint_python
2 | on: [pull_request, push]
3 | jobs:
4 | lint_python:
5 | runs-on: ubuntu-latest
6 | steps:
7 | - uses: actions/checkout@v2
8 | - uses: actions/setup-python@v2
9 | - run: pip install bandit black codespell isort pytest pyupgrade safety
10 | - run: bandit -r . || true
11 | - run: black --check . || true
12 | - run: codespell --ignore-words-list="followings, medias" --quiet-level=2
13 | - run: isort --check-only --profile black . || true
14 | - run: pip install -r requirements.txt
15 | - run: pytest . || true
16 | - run: pytest --doctest-modules . || true
17 | - run: shopt -s globstar && pyupgrade --py36-plus **/*.py || true
18 |
--------------------------------------------------------------------------------
/.github/FUNDING.yml:
--------------------------------------------------------------------------------
1 | # These are supported funding model platforms
2 |
3 | github: thedev132
4 | # patreon: # Replace with a single Patreon username
5 | # open_collective: # Replace with a single Open Collective username
6 | # ko_fi: # Replace with a single Ko-fi username
7 | # tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel
8 | # community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry
9 | # liberapay: # Replace with a single Liberapay username
10 | # issuehunt: # Replace with a single IssueHunt username
11 | # otechie: # Replace with a single Otechie username
12 | # lfx_crowdfunding: # Replace with a single LFX Crowdfunding project-name e.g., cloud-foundry
13 | # custom: # Replace with up to 4 custom sponsorship URLs e.g., ['link1', 'link2']
14 |
--------------------------------------------------------------------------------
/.github/workflows/close_inactive_issues.yml:
--------------------------------------------------------------------------------
1 | name: Close inactive issues
2 | on:
3 | schedule:
4 | - cron: "30 1 * * *"
5 |
6 | jobs:
7 | close-issues:
8 | runs-on: ubuntu-latest
9 | permissions:
10 | issues: write
11 | pull-requests: write
12 | steps:
13 | - uses: actions/stale@v5
14 | with:
15 | days-before-issue-stale: 30
16 | days-before-issue-close: 14
17 | stale-issue-label: "stale"
18 | stale-issue-message: "This issue is stale because it has been open for 30 days with no activity."
19 | close-issue-message: "This issue was closed because it has been inactive for 14 days since being marked as stale."
20 | days-before-pr-stale: -1
21 | days-before-pr-close: -1
22 | repo-token: ${{ secrets.GITHUB_TOKEN }}
23 |
--------------------------------------------------------------------------------
/Dockerfile:
--------------------------------------------------------------------------------
1 | FROM python:3.9.2-alpine3.13 as build
2 | WORKDIR /wheels
3 | RUN apk add --no-cache \
4 | ncurses-dev \
5 | build-base
6 | COPY docker_reqs.txt /opt/osintgram/requirements.txt
7 | RUN pip3 wheel -r /opt/osintgram/requirements.txt
8 |
9 |
10 | FROM python:3.9.2-alpine3.13
11 | WORKDIR /home/osintgram
12 | RUN adduser -D osintgram
13 |
14 | COPY --from=build /wheels /wheels
15 | COPY --chown=osintgram:osintgram requirements.txt /home/osintgram/
16 | RUN pip3 install -r requirements.txt -f /wheels \
17 | && rm -rf /wheels \
18 | && rm -rf /root/.cache/pip/* \
19 | && rm requirements.txt
20 |
21 | COPY --chown=osintgram:osintgram src/ /home/osintgram/src
22 | COPY --chown=osintgram:osintgram main.py /home/osintgram/
23 | COPY --chown=osintgram:osintgram config/ /home/osintgram/config
24 | USER osintgram
25 |
26 | ENTRYPOINT ["python", "main.py"]
27 |
--------------------------------------------------------------------------------
/src/config.py:
--------------------------------------------------------------------------------
1 | import configparser
2 | import sys
3 |
4 | from src import printcolors as pc
5 |
6 | try:
7 | config = configparser.ConfigParser(interpolation=None)
8 | config.read("config/credentials.ini")
9 | except FileNotFoundError:
10 | pc.printout('Error: file "config/credentials.ini" not found!\n', pc.RED)
11 | sys.exit(0)
12 | except Exception as e:
13 | pc.printout("Error: {}\n".format(e), pc.RED)
14 | sys.exit(0)
15 |
16 | def getUsername():
17 | try:
18 |
19 | username = config["Credentials"]["username"]
20 |
21 | if username == '':
22 | pc.printout('Error: "username" field cannot be blank in "config/credentials.ini"\n', pc.RED)
23 | sys.exit(0)
24 |
25 | return username
26 | except KeyError:
27 | pc.printout('Error: missing "username" field in "config/credentials.ini"\n', pc.RED)
28 | sys.exit(0)
29 |
30 | def getPassword():
31 | try:
32 |
33 | password = config["Credentials"]["password"]
34 |
35 | if password == '':
36 | pc.printout('Error: "password" field cannot be blank in "config/credentials.ini"\n', pc.RED)
37 | sys.exit(0)
38 |
39 | return password
40 | except KeyError:
41 | pc.printout('Error: missing "password" field in "config/credentials.ini"\n', pc.RED)
42 | sys.exit(0)
43 |
--------------------------------------------------------------------------------
/Makefile:
--------------------------------------------------------------------------------
1 | SHELL := /bin/bash
2 |
3 | setup:
4 |
5 | @echo -e "\e[34m####### Setup for Osintgram #######\e[0m"
6 | @[ -d config ] || mkdir config || exit 1
7 | @echo -n "{}" > config/settings.json
8 | @read -p "Instagram Username: " uservar; \
9 | read -sp "Instagram Password: " passvar; \
10 | echo -en "[Credentials]\nusername = $$uservar\npassword = $$passvar" > config/credentials.ini || exit 1
11 | @echo ""
12 | @echo -e "\e[32mSetup Successful - config/credentials.ini created\e[0m"
13 |
14 | run:
15 |
16 | @echo -e "\e[34m######## Building and Running Osintgram with Docker-compose ########\e[0m"
17 | @[ -d config ] || { echo -e "\e[31mConfig folder not found! Please run 'make setup' before running this command.\e[0m"; exit 1; }
18 | @echo -e "\e[34m[#] Killing old docker processes\e[0m"
19 | @docker-compose rm -fs || exit 1
20 | @echo -e "\e[34m[#] Building docker container\e[0m"
21 | @docker-compose build || exit 1
22 | @read -p "Target Username: " username; \
23 | docker-compose run --rm osintgram $$username
24 |
25 | build-run-testing:
26 |
27 | @echo -e "\e[34m######## Building and Running Osintgram with Docker-compose for Testing/Debugging ########\e[0m"
28 | @[ -d config ] || { echo -e "\e[31mConfig folder not found! Please run 'make setup' before running this command.\e[0m"; exit 1; }
29 | @echo -e "\e[34m[#] Killing old docker processes\e[0m"
30 | @docker-compose rm -fs || exit 1
31 | @echo -e "\e[34m[#] Building docker container\e[0m"
32 | @docker-compose build || exit 1
33 | @echo -e "\e[34m[#] Running docker container in detached mode\e[0m"
34 | @docker-compose run --name osintgram-testing -d --rm --entrypoint "sleep infinity" osintgram || exit 1
35 | @echo -e "\e[32m[#] osintgram-test container is now Running!\e[0m"
36 |
37 | cleanup-testing:
38 | @echo -e "\e[34m######## Cleanup Build-run-testing Container ########\e[0m"
39 | @docker-compose down
40 | @echo -e "\e[32m[#] osintgram-test container has been removed\e[0m"
--------------------------------------------------------------------------------
/main.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env python3
2 |
3 | from src.Osintgram import Osintgram
4 | import argparse
5 | from src import printcolors as pc
6 | from src import artwork
7 | import sys
8 | import signal
9 |
10 |
11 | def printlogo():
12 | pc.printout(artwork.ascii_art, pc.RED)
13 | pc.printout("\nVersion 1.0 - Developed by Mohamad Mortada and Giuseppe Criscione\n\n", pc.YELLOW)
14 | pc.printout("Type 'list' to show all allowed commands\n")
15 |
16 | def cmdlist():
17 | pc.printout("NOT ALL COMMANDS ARE SUPPORTED YET CHECK README FOR A LIST OF SUPPORTED COMMANDS\n", pc.RED)
18 | pc.printout("captions\t")
19 | print("Get target's photos captions")
20 | pc.printout("commentdata\t")
21 | print("Get a list of all the comments on the target's posts")
22 | pc.printout("comments\t")
23 | print("Get total comments of target's posts")
24 | pc.printout("followers\t")
25 | print("Get target followers")
26 | pc.printout("followings\t")
27 | print("Get users followed by target")
28 | pc.printout("fwersemail\t")
29 | print("Get email of target followers")
30 | pc.printout("fwingsemail\t")
31 | print("Get email of users followed by target")
32 | pc.printout("fwersnumber\t")
33 | print("Get phone number of target followers")
34 | pc.printout("fwingsnumber\t")
35 | print("Get phone number of users followed by target")
36 | pc.printout("hashtags\t")
37 | print("Get hashtags used by target")
38 | pc.printout("info\t\t")
39 | print("Get target info")
40 | pc.printout("likes\t\t")
41 | print("Get total likes of target's posts")
42 | pc.printout("mediatype\t")
43 | print("Get target's posts type (photo or video)")
44 | pc.printout("photodes\t")
45 | print("Get description of target's photos")
46 | pc.printout("photos\t\t")
47 | print("Download target's photos in output folder")
48 | pc.printout("propic\t\t")
49 | print("Download target's profile picture")
50 | pc.printout("stories\t\t")
51 | print("Download target's stories")
52 | pc.printout("highlights\t")
53 | print("Download target's highlights")
54 | pc.printout("tagged\t\t")
55 | print("Get list of users tagged by target")
56 | pc.printout("target\t\t")
57 | print("Set new target")
58 | pc.printout("wcommented\t")
59 | print("Get a list of user who commented target's photos")
60 | pc.printout("wtagged\t\t")
61 | print("Get a list of user who tagged target")
62 |
63 |
64 | def signal_handler(sig, frame):
65 | pc.printout("\nGoodbye!\n", pc.RED)
66 | sys.exit(0)
67 |
68 |
69 | def completer(text, state):
70 | options = [i for i in commands if i.startswith(text)]
71 | if state < len(options):
72 | return options[state]
73 | else:
74 | return None
75 |
76 | def _quit():
77 | pc.printout("Goodbye!\n", pc.RED)
78 | sys.exit(0)
79 |
80 |
81 | signal.signal(signal.SIGINT, signal_handler)
82 |
83 | parser = argparse.ArgumentParser(description='Osintgram is a OSINT tool on Instagram. It offers an interactive shell '
84 | 'to perform analysis on Instagram account of any users by its nickname ')
85 | parser.add_argument('id', type=str, # var = id
86 | help='username')
87 | parser.add_argument('-C','--cookies', help='clear\'s previous cookies', action="store_true")
88 | parser.add_argument('-j', '--json', help='save commands output as JSON file', action='store_true')
89 | parser.add_argument('-f', '--file', help='save output in a file', action='store_true')
90 | parser.add_argument('-c', '--command', help='run in single command mode & execute provided command', action='store')
91 | parser.add_argument('-o', '--output', help='where to store photos', action='store')
92 |
93 | args = parser.parse_args()
94 |
95 |
96 | api = Osintgram(args.id, args.command)
97 |
98 |
99 |
100 | commands = {
101 | 'list': cmdlist,
102 | 'help': cmdlist,
103 | 'quit': _quit,
104 | 'exit': _quit,
105 | "commentdata": api.get_comment_data,
106 | 'comments': api.get_total_comments,
107 | 'followers': api.get_followers,
108 | 'followings': api.get_followings,
109 | 'fwersemail': api.get_fwersemail,
110 | 'fwingsemail': api.get_fwingsemail,
111 | 'fwersnumber': api.get_fwersnumber,
112 | 'fwingsnumber': api.get_fwingsnumber,
113 | 'hashtags': api.get_hashtags,
114 | 'info': api.get_user_info,
115 | 'likes': api.get_total_likes,
116 | 'mediatype': api.get_media_type,
117 | 'photodes': api.get_photo_description,
118 | 'photos': api.get_user_photo,
119 | 'propic': api.get_user_propic,
120 | 'stories': api.get_user_stories,
121 | 'tagged': api.get_people_tagged_by_user,
122 | 'highlights': api.get_user_highlights,
123 | 'target': api.change_target,
124 | 'wcommented': api.get_people_who_commented,
125 | 'wtagged': api.get_people_who_tagged
126 | }
127 |
128 |
129 | signal.signal(signal.SIGINT, signal_handler)
130 |
131 | if not args.command:
132 | printlogo()
133 |
134 |
135 | while True:
136 | if args.command:
137 | cmd = args.command
138 | _cmd = commands.get(args.command)
139 | else:
140 | signal.signal(signal.SIGINT, signal_handler)
141 | pc.printout("Run a command: ", pc.YELLOW)
142 | cmd = input()
143 |
144 | _cmd = commands.get(cmd)
145 |
146 | if _cmd:
147 | _cmd()
148 | elif cmd == "FILE=y":
149 | api.set_write_file(True)
150 | elif cmd == "FILE=n":
151 | api.set_write_file(False)
152 | elif cmd == "JSON=y":
153 | api.set_json_dump(True)
154 | elif cmd == "JSON=n":
155 | api.set_json_dump(False)
156 | elif cmd == "":
157 | print("")
158 | else:
159 | pc.printout("Unknown command\n", pc.RED)
160 |
161 | if args.command:
162 | break
163 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # Osintgram 🔎📸
2 |
3 | [](https://github.com/Datalux/Osintgram/releases/tag/1.3)
4 | [](https://img.shields.io/badge/license-GPLv3-blue)
5 | [](https://img.shields.io/badge/language-Python3-red)
6 | [](https://img.shields.io/badge/Docker-Supported-blue)
7 |
8 | Osintgram is a **OSINT** tool on Instagram to collect, analyze, and run reconnaissance.
9 | This tool is a rewrite of Datalux's Osintgram
10 |
11 |
12 |
13 |
14 |
15 | Disclaimer: **FOR EDUCATIONAL PURPOSE ONLY! The contributors do not assume any responsibility for the use of this tool.**
16 |
17 | Warning: It is advisable to **not** use your own/primary account when using this tool.
18 |
19 | ## Tools and Commands 🧰
20 |
21 | Osintgram offers an interactive shell to perform analysis on Instagram account of any users by its nickname. You can get:
22 |
23 | ```text
24 | Supported:
25 | ❌ - addrs Get all registered addressed by target photos
26 | ❌ - captions Get user's photos captions
27 | ❌ - comments Get total comments of target's posts
28 | ✅ - followers Get target followers
29 | ✅ - followings Get users followed by target
30 | ❌ - fwersemail Get email of target followers
31 | ❌ - fwingsemail Get email of users followed by target
32 | ❌ - fwersnumber Get phone number of target followers
33 | ❌ - fwingsnumber Get phone number of users followed by target
34 | ✅ - hashtags Get hashtags used by target
35 | ✅ - info Get target info
36 | ✅ - likes Get total likes of target's posts
37 | ❌ - mediatype Get user's posts type (photo or video)
38 | ❌ - photodes Get description of target's photos
39 | ✅ - photos Download user's photos in user output folder
40 | ✅ - propic Download user's profile picture in user output folder
41 | ✅ - stories Download user's stories in user output folder
42 | ✅ - highlights Download user's highlights in user output folder
43 | ✅ - tagged Get list of users tagged by target
44 | ❌ - wcommented Get a list of user who commented target's photos
45 | ❌ - wtagged Get a list of user who tagged target
46 | ```
47 |
48 | You can find detailed commands usage [here](doc/COMMANDS.md).
49 |
50 | [**Latest version**](https://github.com/Datalux/Osintgram/releases/tag/1.3) |
51 | [Commands](doc/COMMANDS.md) |
52 | [CHANGELOG](doc/CHANGELOG.md)
53 |
54 | ## FAQ
55 | 1. **Can I access the contents of a private profile?** No, you cannot get information on private profiles. You can only get information from a public profile or a profile you follow. The tools that claim to be successful are scams!
56 | 2. **What is and how I can bypass the `challenge_required` error?** The `challenge_required` error means that Instagram notice a suspicious behavior on your profile, so needs to check if you are a real person or a bot. To avoid this you should follow the suggested link and complete the required operation (insert a code, confirm email, etc)
57 |
58 |
59 | ## Installation ⚙️
60 |
61 | 1. Fork/Clone/Download this repo
62 |
63 | `git clone https://github.com/thedev132/Osintgram.git`
64 |
65 | 2. Navigate to the directory
66 |
67 | `cd Osintgram`
68 |
69 | 3. Create a virtual environment for this project
70 |
71 | `python3 -m venv venv`
72 |
73 | 4. Load the virtual environment
74 | - On Windows Powershell: `.\venv\Scripts\activate.ps1`
75 | - On Linux and Git Bash: `source venv/bin/activate`
76 |
77 | 5. Run `pip install -r requirements.txt`
78 |
79 | 6. Open the `credentials.ini` file in the `config` folder and write your Instagram account username and password in the corresponding fields
80 |
81 | Alternatively, you can run the `make setup` command to populate this file for you.
82 |
83 | 7. Run the main.py script in one of two ways
84 |
85 | * As an interactive prompt `python3 main.py `
86 | * Or execute your command straight away `python3 main.py --command `
87 |
88 | ## Docker Quick Start 🐳
89 |
90 | This section will explain how you can quickly use this image with `Docker` or `Docker-compose`.
91 |
92 | ### Prerequisites
93 |
94 | Before you can use either `Docker` or `Docker-compose`, please ensure you do have the following prerequisites met.
95 |
96 | 1. **Docker** installed - [link](https://docs.docker.com/get-docker/)
97 | 2. **Docker-composed** installed (if using Docker-compose) - [link](https://docs.docker.com/compose/install/)
98 | 3. **Credentials** configured - This can be done manually or by running the `make setup` command from the root of this repo
99 |
100 | **Important**: Your container will fail if you do not do step #3 and configure your credentials
101 |
102 | ### Docker
103 |
104 | If docker is installed you can build an image and run this as a container.
105 |
106 | Build:
107 |
108 | ```bash
109 | docker build -t osintgram .
110 | ```
111 |
112 | Run:
113 |
114 | ```bash
115 | docker run --rm -it -v "$PWD/output:/home/osintgram/output" osintgram
116 | ```
117 |
118 | - The `` is the Instagram account you wish to use as your target for recon.
119 | - The required `-i` flag enables an interactive terminal to use commands within the container. [docs](https://docs.docker.com/engine/reference/commandline/run/#assign-name-and-allocate-pseudo-tty---name--it)
120 | - The required `-v` flag mounts a volume between your local filesystem and the container to save to the `./output/` folder. [docs](https://docs.docker.com/engine/reference/commandline/run/#mount-volume--v---read-only)
121 | - The optional `--rm` flag removes the container filesystem on completion to prevent cruft build-up. [docs](https://docs.docker.com/engine/reference/run/#clean-up---rm)
122 | - The optional `-t` flag allocates a pseudo-TTY which allows colored output. [docs](https://docs.docker.com/engine/reference/run/#foreground)
123 |
124 | ### Using `docker-compose`
125 |
126 | You can use the `docker-compose.yml` file this single command:
127 |
128 | ```bash
129 | docker-compose run osintgram
130 | ```
131 |
132 | Where `target` is the Instagram target for recon.
133 |
134 | Alternatively you may run `docker-compose` with the `Makefile`:
135 |
136 | `make run` - Builds and Runs with compose. Prompts for a `target` before running.
137 |
138 | ### Makefile (easy mode)
139 |
140 | For ease of use with Docker-compose, a `Makefile` has been provided.
141 |
142 | Here is a sample work flow to spin up a container and run `osintgram` with just two commands!
143 |
144 | 1. `make setup` - Sets up your Instagram credentials
145 | 2. `make run` - Builds and Runs a osintgram container and prompts for a target
146 |
147 | Sample workflow for development:
148 |
149 | 1. `make setup` - Sets up your Instagram credentials
150 | 2. `make build-run-testing` - Builds an Runs a container without invoking the `main.py` script. Useful for an `it` Docker session for development
151 | 3. `make cleanup-testing` - Cleans up the testing container created from `build-run-testing`
152 |
153 | ## Development version 💻
154 |
155 | To use the development version with the latest feature and fixes just switch to `development` branch using Git:
156 |
157 | `git checkout development`
158 |
159 | and update to last version using:
160 |
161 | `git pull origin development`
162 |
163 |
164 | ## Updating ⬇️
165 |
166 | To update Osintgram with the stable release just pull the latest commit using Git.
167 |
168 | 1. Make sure you are in the master branch running: `git checkout master`
169 | 2. Download the latest version: `git pull origin master`
170 |
171 |
172 | ## Contributing 💡
173 |
174 | You can propose a feature request opening an issue or a pull request.
175 |
176 | Here is a list of Osintgram's contributors:
177 |
178 |
179 |
180 |
181 |
182 | ## External library 🔗
183 |
184 | [Instagram API](https://github.com/ping/instagram_private_api)
185 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | GNU GENERAL PUBLIC LICENSE
2 | Version 3, 29 June 2007
3 |
4 | Copyright (C) 2007 Free Software Foundation, Inc.
5 | Everyone is permitted to copy and distribute verbatim copies
6 | of this license document, but changing it is not allowed.
7 |
8 | Preamble
9 |
10 | The GNU General Public License is a free, copyleft license for
11 | software and other kinds of works.
12 |
13 | The licenses for most software and other practical works are designed
14 | to take away your freedom to share and change the works. By contrast,
15 | the GNU General Public License is intended to guarantee your freedom to
16 | share and change all versions of a program--to make sure it remains free
17 | software for all its users. We, the Free Software Foundation, use the
18 | GNU General Public License for most of our software; it applies also to
19 | any other work released this way by its authors. You can apply it to
20 | your programs, too.
21 |
22 | When we speak of free software, we are referring to freedom, not
23 | price. Our General Public Licenses are designed to make sure that you
24 | have the freedom to distribute copies of free software (and charge for
25 | them if you wish), that you receive source code or can get it if you
26 | want it, that you can change the software or use pieces of it in new
27 | free programs, and that you know you can do these things.
28 |
29 | To protect your rights, we need to prevent others from denying you
30 | these rights or asking you to surrender the rights. Therefore, you have
31 | certain responsibilities if you distribute copies of the software, or if
32 | you modify it: responsibilities to respect the freedom of others.
33 |
34 | For example, if you distribute copies of such a program, whether
35 | gratis or for a fee, you must pass on to the recipients the same
36 | freedoms that you received. You must make sure that they, too, receive
37 | or can get the source code. And you must show them these terms so they
38 | know their rights.
39 |
40 | Developers that use the GNU GPL protect your rights with two steps:
41 | (1) assert copyright on the software, and (2) offer you this License
42 | giving you legal permission to copy, distribute and/or modify it.
43 |
44 | For the developers' and authors' protection, the GPL clearly explains
45 | that there is no warranty for this free software. For both users' and
46 | authors' sake, the GPL requires that modified versions be marked as
47 | changed, so that their problems will not be attributed erroneously to
48 | authors of previous versions.
49 |
50 | Some devices are designed to deny users access to install or run
51 | modified versions of the software inside them, although the manufacturer
52 | can do so. This is fundamentally incompatible with the aim of
53 | protecting users' freedom to change the software. The systematic
54 | pattern of such abuse occurs in the area of products for individuals to
55 | use, which is precisely where it is most unacceptable. Therefore, we
56 | have designed this version of the GPL to prohibit the practice for those
57 | products. If such problems arise substantially in other domains, we
58 | stand ready to extend this provision to those domains in future versions
59 | of the GPL, as needed to protect the freedom of users.
60 |
61 | Finally, every program is threatened constantly by software patents.
62 | States should not allow patents to restrict development and use of
63 | software on general-purpose computers, but in those that do, we wish to
64 | avoid the special danger that patents applied to a free program could
65 | make it effectively proprietary. To prevent this, the GPL assures that
66 | patents cannot be used to render the program non-free.
67 |
68 | The precise terms and conditions for copying, distribution and
69 | modification follow.
70 |
71 | TERMS AND CONDITIONS
72 |
73 | 0. Definitions.
74 |
75 | "This License" refers to version 3 of the GNU General Public License.
76 |
77 | "Copyright" also means copyright-like laws that apply to other kinds of
78 | works, such as semiconductor masks.
79 |
80 | "The Program" refers to any copyrightable work licensed under this
81 | License. Each licensee is addressed as "you". "Licensees" and
82 | "recipients" may be individuals or organizations.
83 |
84 | To "modify" a work means to copy from or adapt all or part of the work
85 | in a fashion requiring copyright permission, other than the making of an
86 | exact copy. The resulting work is called a "modified version" of the
87 | earlier work or a work "based on" the earlier work.
88 |
89 | A "covered work" means either the unmodified Program or a work based
90 | on the Program.
91 |
92 | To "propagate" a work means to do anything with it that, without
93 | permission, would make you directly or secondarily liable for
94 | infringement under applicable copyright law, except executing it on a
95 | computer or modifying a private copy. Propagation includes copying,
96 | distribution (with or without modification), making available to the
97 | public, and in some countries other activities as well.
98 |
99 | To "convey" a work means any kind of propagation that enables other
100 | parties to make or receive copies. Mere interaction with a user through
101 | a computer network, with no transfer of a copy, is not conveying.
102 |
103 | An interactive user interface displays "Appropriate Legal Notices"
104 | to the extent that it includes a convenient and prominently visible
105 | feature that (1) displays an appropriate copyright notice, and (2)
106 | tells the user that there is no warranty for the work (except to the
107 | extent that warranties are provided), that licensees may convey the
108 | work under this License, and how to view a copy of this License. If
109 | the interface presents a list of user commands or options, such as a
110 | menu, a prominent item in the list meets this criterion.
111 |
112 | 1. Source Code.
113 |
114 | The "source code" for a work means the preferred form of the work
115 | for making modifications to it. "Object code" means any non-source
116 | form of a work.
117 |
118 | A "Standard Interface" means an interface that either is an official
119 | standard defined by a recognized standards body, or, in the case of
120 | interfaces specified for a particular programming language, one that
121 | is widely used among developers working in that language.
122 |
123 | The "System Libraries" of an executable work include anything, other
124 | than the work as a whole, that (a) is included in the normal form of
125 | packaging a Major Component, but which is not part of that Major
126 | Component, and (b) serves only to enable use of the work with that
127 | Major Component, or to implement a Standard Interface for which an
128 | implementation is available to the public in source code form. A
129 | "Major Component", in this context, means a major essential component
130 | (kernel, window system, and so on) of the specific operating system
131 | (if any) on which the executable work runs, or a compiler used to
132 | produce the work, or an object code interpreter used to run it.
133 |
134 | The "Corresponding Source" for a work in object code form means all
135 | the source code needed to generate, install, and (for an executable
136 | work) run the object code and to modify the work, including scripts to
137 | control those activities. However, it does not include the work's
138 | System Libraries, or general-purpose tools or generally available free
139 | programs which are used unmodified in performing those activities but
140 | which are not part of the work. For example, Corresponding Source
141 | includes interface definition files associated with source files for
142 | the work, and the source code for shared libraries and dynamically
143 | linked subprograms that the work is specifically designed to require,
144 | such as by intimate data communication or control flow between those
145 | subprograms and other parts of the work.
146 |
147 | The Corresponding Source need not include anything that users
148 | can regenerate automatically from other parts of the Corresponding
149 | Source.
150 |
151 | The Corresponding Source for a work in source code form is that
152 | same work.
153 |
154 | 2. Basic Permissions.
155 |
156 | All rights granted under this License are granted for the term of
157 | copyright on the Program, and are irrevocable provided the stated
158 | conditions are met. This License explicitly affirms your unlimited
159 | permission to run the unmodified Program. The output from running a
160 | covered work is covered by this License only if the output, given its
161 | content, constitutes a covered work. This License acknowledges your
162 | rights of fair use or other equivalent, as provided by copyright law.
163 |
164 | You may make, run and propagate covered works that you do not
165 | convey, without conditions so long as your license otherwise remains
166 | in force. You may convey covered works to others for the sole purpose
167 | of having them make modifications exclusively for you, or provide you
168 | with facilities for running those works, provided that you comply with
169 | the terms of this License in conveying all material for which you do
170 | not control copyright. Those thus making or running the covered works
171 | for you must do so exclusively on your behalf, under your direction
172 | and control, on terms that prohibit them from making any copies of
173 | your copyrighted material outside their relationship with you.
174 |
175 | Conveying under any other circumstances is permitted solely under
176 | the conditions stated below. Sublicensing is not allowed; section 10
177 | makes it unnecessary.
178 |
179 | 3. Protecting Users' Legal Rights From Anti-Circumvention Law.
180 |
181 | No covered work shall be deemed part of an effective technological
182 | measure under any applicable law fulfilling obligations under article
183 | 11 of the WIPO copyright treaty adopted on 20 December 1996, or
184 | similar laws prohibiting or restricting circumvention of such
185 | measures.
186 |
187 | When you convey a covered work, you waive any legal power to forbid
188 | circumvention of technological measures to the extent such circumvention
189 | is effected by exercising rights under this License with respect to
190 | the covered work, and you disclaim any intention to limit operation or
191 | modification of the work as a means of enforcing, against the work's
192 | users, your or third parties' legal rights to forbid circumvention of
193 | technological measures.
194 |
195 | 4. Conveying Verbatim Copies.
196 |
197 | You may convey verbatim copies of the Program's source code as you
198 | receive it, in any medium, provided that you conspicuously and
199 | appropriately publish on each copy an appropriate copyright notice;
200 | keep intact all notices stating that this License and any
201 | non-permissive terms added in accord with section 7 apply to the code;
202 | keep intact all notices of the absence of any warranty; and give all
203 | recipients a copy of this License along with the Program.
204 |
205 | You may charge any price or no price for each copy that you convey,
206 | and you may offer support or warranty protection for a fee.
207 |
208 | 5. Conveying Modified Source Versions.
209 |
210 | You may convey a work based on the Program, or the modifications to
211 | produce it from the Program, in the form of source code under the
212 | terms of section 4, provided that you also meet all of these conditions:
213 |
214 | a) The work must carry prominent notices stating that you modified
215 | it, and giving a relevant date.
216 |
217 | b) The work must carry prominent notices stating that it is
218 | released under this License and any conditions added under section
219 | 7. This requirement modifies the requirement in section 4 to
220 | "keep intact all notices".
221 |
222 | c) You must license the entire work, as a whole, under this
223 | License to anyone who comes into possession of a copy. This
224 | License will therefore apply, along with any applicable section 7
225 | additional terms, to the whole of the work, and all its parts,
226 | regardless of how they are packaged. This License gives no
227 | permission to license the work in any other way, but it does not
228 | invalidate such permission if you have separately received it.
229 |
230 | d) If the work has interactive user interfaces, each must display
231 | Appropriate Legal Notices; however, if the Program has interactive
232 | interfaces that do not display Appropriate Legal Notices, your
233 | work need not make them do so.
234 |
235 | A compilation of a covered work with other separate and independent
236 | works, which are not by their nature extensions of the covered work,
237 | and which are not combined with it such as to form a larger program,
238 | in or on a volume of a storage or distribution medium, is called an
239 | "aggregate" if the compilation and its resulting copyright are not
240 | used to limit the access or legal rights of the compilation's users
241 | beyond what the individual works permit. Inclusion of a covered work
242 | in an aggregate does not cause this License to apply to the other
243 | parts of the aggregate.
244 |
245 | 6. Conveying Non-Source Forms.
246 |
247 | You may convey a covered work in object code form under the terms
248 | of sections 4 and 5, provided that you also convey the
249 | machine-readable Corresponding Source under the terms of this License,
250 | in one of these ways:
251 |
252 | a) Convey the object code in, or embodied in, a physical product
253 | (including a physical distribution medium), accompanied by the
254 | Corresponding Source fixed on a durable physical medium
255 | customarily used for software interchange.
256 |
257 | b) Convey the object code in, or embodied in, a physical product
258 | (including a physical distribution medium), accompanied by a
259 | written offer, valid for at least three years and valid for as
260 | long as you offer spare parts or customer support for that product
261 | model, to give anyone who possesses the object code either (1) a
262 | copy of the Corresponding Source for all the software in the
263 | product that is covered by this License, on a durable physical
264 | medium customarily used for software interchange, for a price no
265 | more than your reasonable cost of physically performing this
266 | conveying of source, or (2) access to copy the
267 | Corresponding Source from a network server at no charge.
268 |
269 | c) Convey individual copies of the object code with a copy of the
270 | written offer to provide the Corresponding Source. This
271 | alternative is allowed only occasionally and noncommercially, and
272 | only if you received the object code with such an offer, in accord
273 | with subsection 6b.
274 |
275 | d) Convey the object code by offering access from a designated
276 | place (gratis or for a charge), and offer equivalent access to the
277 | Corresponding Source in the same way through the same place at no
278 | further charge. You need not require recipients to copy the
279 | Corresponding Source along with the object code. If the place to
280 | copy the object code is a network server, the Corresponding Source
281 | may be on a different server (operated by you or a third party)
282 | that supports equivalent copying facilities, provided you maintain
283 | clear directions next to the object code saying where to find the
284 | Corresponding Source. Regardless of what server hosts the
285 | Corresponding Source, you remain obligated to ensure that it is
286 | available for as long as needed to satisfy these requirements.
287 |
288 | e) Convey the object code using peer-to-peer transmission, provided
289 | you inform other peers where the object code and Corresponding
290 | Source of the work are being offered to the general public at no
291 | charge under subsection 6d.
292 |
293 | A separable portion of the object code, whose source code is excluded
294 | from the Corresponding Source as a System Library, need not be
295 | included in conveying the object code work.
296 |
297 | A "User Product" is either (1) a "consumer product", which means any
298 | tangible personal property which is normally used for personal, family,
299 | or household purposes, or (2) anything designed or sold for incorporation
300 | into a dwelling. In determining whether a product is a consumer product,
301 | doubtful cases shall be resolved in favor of coverage. For a particular
302 | product received by a particular user, "normally used" refers to a
303 | typical or common use of that class of product, regardless of the status
304 | of the particular user or of the way in which the particular user
305 | actually uses, or expects or is expected to use, the product. A product
306 | is a consumer product regardless of whether the product has substantial
307 | commercial, industrial or non-consumer uses, unless such uses represent
308 | the only significant mode of use of the product.
309 |
310 | "Installation Information" for a User Product means any methods,
311 | procedures, authorization keys, or other information required to install
312 | and execute modified versions of a covered work in that User Product from
313 | a modified version of its Corresponding Source. The information must
314 | suffice to ensure that the continued functioning of the modified object
315 | code is in no case prevented or interfered with solely because
316 | modification has been made.
317 |
318 | If you convey an object code work under this section in, or with, or
319 | specifically for use in, a User Product, and the conveying occurs as
320 | part of a transaction in which the right of possession and use of the
321 | User Product is transferred to the recipient in perpetuity or for a
322 | fixed term (regardless of how the transaction is characterized), the
323 | Corresponding Source conveyed under this section must be accompanied
324 | by the Installation Information. But this requirement does not apply
325 | if neither you nor any third party retains the ability to install
326 | modified object code on the User Product (for example, the work has
327 | been installed in ROM).
328 |
329 | The requirement to provide Installation Information does not include a
330 | requirement to continue to provide support service, warranty, or updates
331 | for a work that has been modified or installed by the recipient, or for
332 | the User Product in which it has been modified or installed. Access to a
333 | network may be denied when the modification itself materially and
334 | adversely affects the operation of the network or violates the rules and
335 | protocols for communication across the network.
336 |
337 | Corresponding Source conveyed, and Installation Information provided,
338 | in accord with this section must be in a format that is publicly
339 | documented (and with an implementation available to the public in
340 | source code form), and must require no special password or key for
341 | unpacking, reading or copying.
342 |
343 | 7. Additional Terms.
344 |
345 | "Additional permissions" are terms that supplement the terms of this
346 | License by making exceptions from one or more of its conditions.
347 | Additional permissions that are applicable to the entire Program shall
348 | be treated as though they were included in this License, to the extent
349 | that they are valid under applicable law. If additional permissions
350 | apply only to part of the Program, that part may be used separately
351 | under those permissions, but the entire Program remains governed by
352 | this License without regard to the additional permissions.
353 |
354 | When you convey a copy of a covered work, you may at your option
355 | remove any additional permissions from that copy, or from any part of
356 | it. (Additional permissions may be written to require their own
357 | removal in certain cases when you modify the work.) You may place
358 | additional permissions on material, added by you to a covered work,
359 | for which you have or can give appropriate copyright permission.
360 |
361 | Notwithstanding any other provision of this License, for material you
362 | add to a covered work, you may (if authorized by the copyright holders of
363 | that material) supplement the terms of this License with terms:
364 |
365 | a) Disclaiming warranty or limiting liability differently from the
366 | terms of sections 15 and 16 of this License; or
367 |
368 | b) Requiring preservation of specified reasonable legal notices or
369 | author attributions in that material or in the Appropriate Legal
370 | Notices displayed by works containing it; or
371 |
372 | c) Prohibiting misrepresentation of the origin of that material, or
373 | requiring that modified versions of such material be marked in
374 | reasonable ways as different from the original version; or
375 |
376 | d) Limiting the use for publicity purposes of names of licensors or
377 | authors of the material; or
378 |
379 | e) Declining to grant rights under trademark law for use of some
380 | trade names, trademarks, or service marks; or
381 |
382 | f) Requiring indemnification of licensors and authors of that
383 | material by anyone who conveys the material (or modified versions of
384 | it) with contractual assumptions of liability to the recipient, for
385 | any liability that these contractual assumptions directly impose on
386 | those licensors and authors.
387 |
388 | All other non-permissive additional terms are considered "further
389 | restrictions" within the meaning of section 10. If the Program as you
390 | received it, or any part of it, contains a notice stating that it is
391 | governed by this License along with a term that is a further
392 | restriction, you may remove that term. If a license document contains
393 | a further restriction but permits relicensing or conveying under this
394 | License, you may add to a covered work material governed by the terms
395 | of that license document, provided that the further restriction does
396 | not survive such relicensing or conveying.
397 |
398 | If you add terms to a covered work in accord with this section, you
399 | must place, in the relevant source files, a statement of the
400 | additional terms that apply to those files, or a notice indicating
401 | where to find the applicable terms.
402 |
403 | Additional terms, permissive or non-permissive, may be stated in the
404 | form of a separately written license, or stated as exceptions;
405 | the above requirements apply either way.
406 |
407 | 8. Termination.
408 |
409 | You may not propagate or modify a covered work except as expressly
410 | provided under this License. Any attempt otherwise to propagate or
411 | modify it is void, and will automatically terminate your rights under
412 | this License (including any patent licenses granted under the third
413 | paragraph of section 11).
414 |
415 | However, if you cease all violation of this License, then your
416 | license from a particular copyright holder is reinstated (a)
417 | provisionally, unless and until the copyright holder explicitly and
418 | finally terminates your license, and (b) permanently, if the copyright
419 | holder fails to notify you of the violation by some reasonable means
420 | prior to 60 days after the cessation.
421 |
422 | Moreover, your license from a particular copyright holder is
423 | reinstated permanently if the copyright holder notifies you of the
424 | violation by some reasonable means, this is the first time you have
425 | received notice of violation of this License (for any work) from that
426 | copyright holder, and you cure the violation prior to 30 days after
427 | your receipt of the notice.
428 |
429 | Termination of your rights under this section does not terminate the
430 | licenses of parties who have received copies or rights from you under
431 | this License. If your rights have been terminated and not permanently
432 | reinstated, you do not qualify to receive new licenses for the same
433 | material under section 10.
434 |
435 | 9. Acceptance Not Required for Having Copies.
436 |
437 | You are not required to accept this License in order to receive or
438 | run a copy of the Program. Ancillary propagation of a covered work
439 | occurring solely as a consequence of using peer-to-peer transmission
440 | to receive a copy likewise does not require acceptance. However,
441 | nothing other than this License grants you permission to propagate or
442 | modify any covered work. These actions infringe copyright if you do
443 | not accept this License. Therefore, by modifying or propagating a
444 | covered work, you indicate your acceptance of this License to do so.
445 |
446 | 10. Automatic Licensing of Downstream Recipients.
447 |
448 | Each time you convey a covered work, the recipient automatically
449 | receives a license from the original licensors, to run, modify and
450 | propagate that work, subject to this License. You are not responsible
451 | for enforcing compliance by third parties with this License.
452 |
453 | An "entity transaction" is a transaction transferring control of an
454 | organization, or substantially all assets of one, or subdividing an
455 | organization, or merging organizations. If propagation of a covered
456 | work results from an entity transaction, each party to that
457 | transaction who receives a copy of the work also receives whatever
458 | licenses to the work the party's predecessor in interest had or could
459 | give under the previous paragraph, plus a right to possession of the
460 | Corresponding Source of the work from the predecessor in interest, if
461 | the predecessor has it or can get it with reasonable efforts.
462 |
463 | You may not impose any further restrictions on the exercise of the
464 | rights granted or affirmed under this License. For example, you may
465 | not impose a license fee, royalty, or other charge for exercise of
466 | rights granted under this License, and you may not initiate litigation
467 | (including a cross-claim or counterclaim in a lawsuit) alleging that
468 | any patent claim is infringed by making, using, selling, offering for
469 | sale, or importing the Program or any portion of it.
470 |
471 | 11. Patents.
472 |
473 | A "contributor" is a copyright holder who authorizes use under this
474 | License of the Program or a work on which the Program is based. The
475 | work thus licensed is called the contributor's "contributor version".
476 |
477 | A contributor's "essential patent claims" are all patent claims
478 | owned or controlled by the contributor, whether already acquired or
479 | hereafter acquired, that would be infringed by some manner, permitted
480 | by this License, of making, using, or selling its contributor version,
481 | but do not include claims that would be infringed only as a
482 | consequence of further modification of the contributor version. For
483 | purposes of this definition, "control" includes the right to grant
484 | patent sublicenses in a manner consistent with the requirements of
485 | this License.
486 |
487 | Each contributor grants you a non-exclusive, worldwide, royalty-free
488 | patent license under the contributor's essential patent claims, to
489 | make, use, sell, offer for sale, import and otherwise run, modify and
490 | propagate the contents of its contributor version.
491 |
492 | In the following three paragraphs, a "patent license" is any express
493 | agreement or commitment, however denominated, not to enforce a patent
494 | (such as an express permission to practice a patent or covenant not to
495 | sue for patent infringement). To "grant" such a patent license to a
496 | party means to make such an agreement or commitment not to enforce a
497 | patent against the party.
498 |
499 | If you convey a covered work, knowingly relying on a patent license,
500 | and the Corresponding Source of the work is not available for anyone
501 | to copy, free of charge and under the terms of this License, through a
502 | publicly available network server or other readily accessible means,
503 | then you must either (1) cause the Corresponding Source to be so
504 | available, or (2) arrange to deprive yourself of the benefit of the
505 | patent license for this particular work, or (3) arrange, in a manner
506 | consistent with the requirements of this License, to extend the patent
507 | license to downstream recipients. "Knowingly relying" means you have
508 | actual knowledge that, but for the patent license, your conveying the
509 | covered work in a country, or your recipient's use of the covered work
510 | in a country, would infringe one or more identifiable patents in that
511 | country that you have reason to believe are valid.
512 |
513 | If, pursuant to or in connection with a single transaction or
514 | arrangement, you convey, or propagate by procuring conveyance of, a
515 | covered work, and grant a patent license to some of the parties
516 | receiving the covered work authorizing them to use, propagate, modify
517 | or convey a specific copy of the covered work, then the patent license
518 | you grant is automatically extended to all recipients of the covered
519 | work and works based on it.
520 |
521 | A patent license is "discriminatory" if it does not include within
522 | the scope of its coverage, prohibits the exercise of, or is
523 | conditioned on the non-exercise of one or more of the rights that are
524 | specifically granted under this License. You may not convey a covered
525 | work if you are a party to an arrangement with a third party that is
526 | in the business of distributing software, under which you make payment
527 | to the third party based on the extent of your activity of conveying
528 | the work, and under which the third party grants, to any of the
529 | parties who would receive the covered work from you, a discriminatory
530 | patent license (a) in connection with copies of the covered work
531 | conveyed by you (or copies made from those copies), or (b) primarily
532 | for and in connection with specific products or compilations that
533 | contain the covered work, unless you entered into that arrangement,
534 | or that patent license was granted, prior to 28 March 2007.
535 |
536 | Nothing in this License shall be construed as excluding or limiting
537 | any implied license or other defenses to infringement that may
538 | otherwise be available to you under applicable patent law.
539 |
540 | 12. No Surrender of Others' Freedom.
541 |
542 | If conditions are imposed on you (whether by court order, agreement or
543 | otherwise) that contradict the conditions of this License, they do not
544 | excuse you from the conditions of this License. If you cannot convey a
545 | covered work so as to satisfy simultaneously your obligations under this
546 | License and any other pertinent obligations, then as a consequence you may
547 | not convey it at all. For example, if you agree to terms that obligate you
548 | to collect a royalty for further conveying from those to whom you convey
549 | the Program, the only way you could satisfy both those terms and this
550 | License would be to refrain entirely from conveying the Program.
551 |
552 | 13. Use with the GNU Affero General Public License.
553 |
554 | Notwithstanding any other provision of this License, you have
555 | permission to link or combine any covered work with a work licensed
556 | under version 3 of the GNU Affero General Public License into a single
557 | combined work, and to convey the resulting work. The terms of this
558 | License will continue to apply to the part which is the covered work,
559 | but the special requirements of the GNU Affero General Public License,
560 | section 13, concerning interaction through a network will apply to the
561 | combination as such.
562 |
563 | 14. Revised Versions of this License.
564 |
565 | The Free Software Foundation may publish revised and/or new versions of
566 | the GNU General Public License from time to time. Such new versions will
567 | be similar in spirit to the present version, but may differ in detail to
568 | address new problems or concerns.
569 |
570 | Each version is given a distinguishing version number. If the
571 | Program specifies that a certain numbered version of the GNU General
572 | Public License "or any later version" applies to it, you have the
573 | option of following the terms and conditions either of that numbered
574 | version or of any later version published by the Free Software
575 | Foundation. If the Program does not specify a version number of the
576 | GNU General Public License, you may choose any version ever published
577 | by the Free Software Foundation.
578 |
579 | If the Program specifies that a proxy can decide which future
580 | versions of the GNU General Public License can be used, that proxy's
581 | public statement of acceptance of a version permanently authorizes you
582 | to choose that version for the Program.
583 |
584 | Later license versions may give you additional or different
585 | permissions. However, no additional obligations are imposed on any
586 | author or copyright holder as a result of your choosing to follow a
587 | later version.
588 |
589 | 15. Disclaimer of Warranty.
590 |
591 | THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
592 | APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
593 | HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
594 | OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
595 | THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
596 | PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
597 | IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
598 | ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
599 |
600 | 16. Limitation of Liability.
601 |
602 | IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
603 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
604 | THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
605 | GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
606 | USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
607 | DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
608 | PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
609 | EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
610 | SUCH DAMAGES.
611 |
612 | 17. Interpretation of Sections 15 and 16.
613 |
614 | If the disclaimer of warranty and limitation of liability provided
615 | above cannot be given local legal effect according to their terms,
616 | reviewing courts shall apply local law that most closely approximates
617 | an absolute waiver of all civil liability in connection with the
618 | Program, unless a warranty or assumption of liability accompanies a
619 | copy of the Program in return for a fee.
620 |
621 | END OF TERMS AND CONDITIONS
622 |
623 | How to Apply These Terms to Your New Programs
624 |
625 | If you develop a new program, and you want it to be of the greatest
626 | possible use to the public, the best way to achieve this is to make it
627 | free software which everyone can redistribute and change under these terms.
628 |
629 | To do so, attach the following notices to the program. It is safest
630 | to attach them to the start of each source file to most effectively
631 | state the exclusion of warranty; and each file should have at least
632 | the "copyright" line and a pointer to where the full notice is found.
633 |
634 |
635 | Copyright (C)
636 |
637 | This program is free software: you can redistribute it and/or modify
638 | it under the terms of the GNU General Public License as published by
639 | the Free Software Foundation, either version 3 of the License, or
640 | (at your option) any later version.
641 |
642 | This program is distributed in the hope that it will be useful,
643 | but WITHOUT ANY WARRANTY; without even the implied warranty of
644 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
645 | GNU General Public License for more details.
646 |
647 | You should have received a copy of the GNU General Public License
648 | along with this program. If not, see .
649 |
650 | Also add information on how to contact you by electronic and paper mail.
651 |
652 | If the program does terminal interaction, make it output a short
653 | notice like this when it starts in an interactive mode:
654 |
655 | Copyright (C)
656 | This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
657 | This is free software, and you are welcome to redistribute it
658 | under certain conditions; type `show c' for details.
659 |
660 | The hypothetical commands `show w' and `show c' should show the appropriate
661 | parts of the General Public License. Of course, your program's commands
662 | might be different; for a GUI interface, you would use an "about box".
663 |
664 | You should also get your employer (if you work as a programmer) or school,
665 | if any, to sign a "copyright disclaimer" for the program, if necessary.
666 | For more information on this, and how to apply and follow the GNU GPL, see
667 | .
668 |
669 | The GNU General Public License does not permit incorporating your program
670 | into proprietary programs. If your program is a subroutine library, you
671 | may consider it more useful to permit linking proprietary applications with
672 | the library. If this is what you want to do, use the GNU Lesser General
673 | Public License instead of this License. But first, please read
674 | .
675 |
--------------------------------------------------------------------------------
/src/Osintgram.py:
--------------------------------------------------------------------------------
1 | import datetime
2 | import json
3 | import sys
4 | import urllib
5 | import os
6 | import codecs
7 | from pathlib import Path
8 | import subprocess
9 |
10 |
11 | import requests
12 | import ssl
13 | ssl._create_default_https_context = ssl._create_unverified_context
14 |
15 | from geopy.geocoders import Nominatim
16 | from instagrapi import Client as AppClient
17 | from instagrapi.exceptions import ClientError
18 | import instaloader as Loader
19 | from prettytable import PrettyTable
20 |
21 | from src import printcolors as pc
22 | from src import config
23 | client = AppClient()
24 | loader = Loader.Instaloader()
25 |
26 |
27 |
28 | class Osintgram:
29 | api = None
30 | api2 = None
31 | geolocator = Nominatim(user_agent="http")
32 | user_id = None
33 | target_id = None
34 | is_private = True
35 | following = False
36 | target = ""
37 | writeFile = False
38 | jsonDump = False
39 | cli_mode = False
40 | output_dir = "output"
41 |
42 |
43 | def __init__(self, target, is_cli):
44 | u = config.getUsername()
45 | p = config.getPassword()
46 | self.cli_mode = is_cli
47 | if not is_cli:
48 | print("\nAttempt to login...")
49 | self.login(u, p)
50 | self.setTarget(target)
51 |
52 | def setTarget(self, target):
53 | self.target = target
54 | user = self.get_user(target)
55 | self.target_id = user['id']
56 | self.is_private = user['is_private']
57 | self.following = self.check_following(config.getUsername())
58 | self.__printTargetBanner__()
59 |
60 |
61 | def __get_comments__(self, media_id):
62 | comments = []
63 |
64 | result = self.api.media_comments(str(media_id))
65 | comments.extend(result.get('comments', []))
66 |
67 | next_max_id = result.get('next_max_id')
68 | while next_max_id:
69 | results = self.api.media_comments(str(media_id), max_id=next_max_id)
70 | comments.extend(results.get('comments', []))
71 | next_max_id = results.get('next_max_id')
72 |
73 | return comments
74 |
75 | def __printTargetBanner__(self):
76 | pc.printout("\nLogged as ", pc.GREEN)
77 | pc.printout(config.getUsername(), pc.CYAN)
78 | pc.printout(". Target: ", pc.GREEN)
79 | pc.printout(str(self.target), pc.CYAN)
80 | pc.printout(" [" + str(self.target_id) + "]")
81 | if self.is_private:
82 | pc.printout(" [PRIVATE PROFILE]", pc.BLUE)
83 | if self.following:
84 | pc.printout(" [FOLLOWING]", pc.GREEN)
85 | else:
86 | pc.printout(" [NOT FOLLOWING]", pc.RED)
87 |
88 | print('\n')
89 |
90 | def change_target(self):
91 | pc.printout("Insert new target username: ", pc.YELLOW)
92 | line = input()
93 | self.setTarget(line)
94 | return
95 |
96 | # def get_addrs(self):
97 | # if self.check_private_profile():
98 | # return
99 |
100 | # pc.printout("Searching for target localizations...\n")
101 |
102 | # data = self.__get_feed__()
103 |
104 | # locations = {}
105 |
106 | # for post in data:
107 | # if 'location' in post and post['location'] is not None:
108 | # if 'lat' in post['location'] and 'lng' in post['location']:
109 | # lat = post['location']['lat']
110 | # lng = post['location']['lng']
111 | # locations[str(lat) + ', ' + str(lng)] = post.get('taken_at')
112 |
113 | # address = {}
114 | # for k, v in locations.items():
115 | # details = self.geolocator.reverse(k)
116 | # unix_timestamp = datetime.datetime.fromtimestamp(v)
117 | # address[details.address] = unix_timestamp.strftime('%Y-%m-%d %H:%M:%S')
118 |
119 | # sort_addresses = sorted(address.items(), key=lambda p: p[1], reverse=True)
120 |
121 | # if len(sort_addresses) > 0:
122 | # t = PrettyTable()
123 |
124 | # t.field_names = ['Post', 'Address', 'time']
125 | # t.align["Post"] = "l"
126 | # t.align["Address"] = "l"
127 | # t.align["Time"] = "l"
128 | # pc.printout("\nWoohoo! We found " + str(len(sort_addresses)) + " addresses\n", pc.GREEN)
129 |
130 | # i = 1
131 |
132 | # json_data = {}
133 | # addrs_list = []
134 |
135 | # for address, time in sort_addresses:
136 | # t.add_row([str(i), address, time])
137 |
138 | # if self.jsonDump:
139 | # addr = {
140 | # 'address': address,
141 | # 'time': time
142 | # }
143 | # addrs_list.append(addr)
144 |
145 | # i = i + 1
146 |
147 | # if self.writeFile:
148 | # file_name = self.output_dir + "/" + self.target + "_addrs.txt"
149 | # file = open(file_name, "w")
150 | # file.write(str(t))
151 | # file.close()
152 |
153 | # if self.jsonDump:
154 | # json_data['address'] = addrs_list
155 | # json_file_name = self.output_dir + "/" + self.target + "_addrs.json"
156 | # with open(json_file_name, 'w') as f:
157 | # json.dump(json_data, f)
158 |
159 | # print(t)
160 | # else:
161 | # pc.printout("Sorry! No results found :-(\n", pc.RED)
162 |
163 | # def get_captions(self):
164 | # if self.check_private_profile():
165 | # return
166 |
167 | # pc.printout("Searching for target captions...\n")
168 |
169 | # captions = []
170 |
171 | # data = self.__get_feed__()
172 | # counter = 0
173 |
174 | # try:
175 | # for item in data:
176 | # if "caption" in item:
177 | # if item["caption"] is not None:
178 | # text = item["caption"]["text"]
179 | # captions.append(text)
180 | # counter = counter + 1
181 | # sys.stdout.write("\rFound %i" % counter)
182 | # sys.stdout.flush()
183 |
184 | # except AttributeError:
185 | # pass
186 |
187 | # except KeyError:
188 | # pass
189 |
190 | # json_data = {}
191 |
192 | # if counter > 0:
193 | # pc.printout("\nWoohoo! We found " + str(counter) + " captions\n", pc.GREEN)
194 |
195 | # file = None
196 |
197 | # if self.writeFile:
198 | # file_name = self.output_dir + "/" + self.target + "_captions.txt"
199 | # file = open(file_name, "w")
200 |
201 | # for s in captions:
202 | # print(s + "\n")
203 |
204 | # if self.writeFile:
205 | # file.write(s + "\n")
206 |
207 | # if self.jsonDump:
208 | # json_data['captions'] = captions
209 | # json_file_name = self.output_dir + "/" + self.target + "_followings.json"
210 | # with open(json_file_name, 'w') as f:
211 | # json.dump(json_data, f)
212 |
213 | # if file is not None:
214 | # file.close()
215 |
216 | # else:
217 | # pc.printout("Sorry! No results found :-(\n", pc.RED)
218 |
219 | # return
220 |
221 | def get_total_comments(self):
222 | if self.check_private_profile():
223 | return
224 |
225 | pc.printout("Searching for target total comments...\n")
226 |
227 | comments_counter = 0
228 | posts = 0
229 |
230 | data = self.__get_feed__()
231 |
232 | for post in data:
233 | comments_counter += post['comment_count']
234 | posts += 1
235 |
236 | if self.writeFile:
237 | file_name = self.output_dir + "/" + self.target + "_comments.txt"
238 | file = open(file_name, "w")
239 | file.write(str(comments_counter) + " comments in " + str(posts) + " posts\n")
240 | file.close()
241 |
242 | if self.jsonDump:
243 | json_data = {
244 | 'comment_counter': comments_counter,
245 | 'posts': posts
246 | }
247 | json_file_name = self.output_dir + "/" + self.target + "_comments.json"
248 | with open(json_file_name, 'w') as f:
249 | json.dump(json_data, f)
250 |
251 | pc.printout(str(comments_counter), pc.MAGENTA)
252 | pc.printout(" comments in " + str(posts) + " posts\n")
253 |
254 | def get_comment_data(self):
255 | if self.check_private_profile():
256 | return
257 |
258 | pc.printout("Retrieving all comments, this may take a moment...\n")
259 | data = self.__get_feed__()
260 |
261 | _comments = []
262 | t = PrettyTable(['POST ID', 'ID', 'Username', 'Comment'])
263 | t.align["POST ID"] = "l"
264 | t.align["ID"] = "l"
265 | t.align["Username"] = "l"
266 | t.align["Comment"] = "l"
267 |
268 | for post in data:
269 | post_id = post.get('id')
270 | comments = self.api.media_n_comments(post_id)
271 | for comment in comments:
272 | t.add_row([post_id, comment.get('user_id'), comment.get('user').get('username'), comment.get('text')])
273 | comment = {
274 | "post_id": post_id,
275 | "user_id":comment.get('user_id'),
276 | "username": comment.get('user').get('username'),
277 | "comment": comment.get('text')
278 | }
279 | _comments.append(comment)
280 |
281 | print(t)
282 | if self.writeFile:
283 | file_name = self.output_dir + "/" + self.target + "_comment_data.txt"
284 | with open(file_name, 'w') as f:
285 | f.write(str(t))
286 | f.close()
287 |
288 | if self.jsonDump:
289 | file_name_json = self.output_dir + "/" + self.target + "_comment_data.json"
290 | with open(file_name_json, 'w') as f:
291 | f.write("{ \"Comments\":[ \n")
292 | f.write('\n'.join(json.dumps(comment) for comment in _comments) + ',\n')
293 | f.write("]} ")
294 |
295 |
296 | def get_followers(self):
297 | if self.check_private_profile():
298 | return
299 |
300 | pc.printout("Searching for target followers (this may take a while) ...\n")
301 |
302 | _followers = []
303 | followers = []
304 |
305 |
306 | data = client.user_followers(str(self.target_id))
307 | _followers.extend(data.values())
308 |
309 | print("\n")
310 |
311 | for user in _followers:
312 | userDict = user.dict()
313 | u = {
314 | 'id': userDict['pk'],
315 | 'username': userDict['username'],
316 | 'full_name': userDict['full_name']
317 | }
318 | followers.append(u)
319 |
320 | t = PrettyTable(['ID', 'Username', 'Full Name'])
321 | t.align["ID"] = "l"
322 | t.align["Username"] = "l"
323 | t.align["Full Name"] = "l"
324 |
325 | json_data = {}
326 | followings_list = []
327 |
328 | for node in followers:
329 | t.add_row([str(node['id']), node['username'], node['full_name']])
330 |
331 | if self.jsonDump:
332 | follow = {
333 | 'id': node['id'],
334 | 'username': node['username'],
335 | 'full_name': node['full_name']
336 | }
337 | followings_list.append(follow)
338 |
339 | if self.writeFile:
340 | file_name = self.output_dir + "/" + self.target + "_followers.txt"
341 | file = open(file_name, "w")
342 | file.write(str(t))
343 | file.close()
344 |
345 | if self.jsonDump:
346 | json_data['followers'] = followers
347 | json_file_name = self.output_dir + "/" + self.target + "_followers.json"
348 | with open(json_file_name, 'w') as f:
349 | json.dump(json_data, f)
350 |
351 | print(t)
352 |
353 | def get_followings(self):
354 | if self.check_private_profile():
355 | return
356 |
357 | pc.printout("Searching for target followings...\n")
358 |
359 | _followings = []
360 | followings = []
361 |
362 | data = client.user_following(str(self.target_id), 0)
363 | _followings.extend(data.values())
364 |
365 | print("\n")
366 |
367 | for user in _followings:
368 | userDict = user.dict()
369 | u = {
370 | 'id': userDict['pk'],
371 | 'username': userDict['username'],
372 | 'full_name': userDict['full_name']
373 | }
374 | followings.append(u)
375 |
376 | t = PrettyTable(['ID', 'Username', 'Full Name'])
377 | t.align["ID"] = "l"
378 | t.align["Username"] = "l"
379 | t.align["Full Name"] = "l"
380 |
381 | json_data = {}
382 | followings_list = []
383 |
384 | for node in followings:
385 | t.add_row([str(node['id']), node['username'], node['full_name']])
386 |
387 | if self.jsonDump:
388 | follow = {
389 | 'id': node['id'],
390 | 'username': node['username'],
391 | 'full_name': node['full_name']
392 | }
393 | followings_list.append(follow)
394 |
395 | if self.writeFile:
396 | file_name = self.output_dir + "/" + self.target + "_followings.txt"
397 | file = open(file_name, "w")
398 | file.write(str(t))
399 | file.close()
400 |
401 | if self.jsonDump:
402 | json_data['followings'] = followings_list
403 | json_file_name = self.output_dir + "/" + self.target + "_followings.json"
404 | with open(json_file_name, 'w') as f:
405 | json.dump(json_data, f)
406 |
407 | print(t)
408 |
409 | def get_hashtags(self):
410 | if self.check_private_profile():
411 | return
412 |
413 | pc.printout("Searching for target hashtags...\n")
414 |
415 | hashtags = []
416 | hashtagsDict = {}
417 | counter = 0
418 |
419 | medias = client.user_medias(str(self.target_id))
420 | for post in medias:
421 | caption = client.media_info(post.pk).dict()['caption_text']
422 | hashtags = [word for word in caption.split() if word.startswith('#')]
423 | for hashtag in hashtags:
424 | if hashtag in hashtagsDict:
425 | hashtagsDict[hashtag] += 1
426 | else:
427 | hashtagsDict[hashtag] = 1
428 | counter += 1
429 |
430 | t = PrettyTable(['Hashtag', 'Count'])
431 | t.align["Hastag"] = "l"
432 | t.align["Count"] = "l"
433 |
434 | for node in hashtagsDict:
435 | t.add_row([str(node), str(hashtagsDict[node])])
436 |
437 | if len(hashtags) > 0:
438 | pc.printout("We found " + str(counter) + " hashtags\n", pc.GREEN)
439 |
440 | print(t)
441 |
442 | # file = None
443 | # json_data = {}
444 | # hashtags_list = []
445 |
446 | # if self.writeFile:
447 | # file_name = self.output_dir + "/" + self.target + "_hashtags.txt"
448 | # file = open(file_name, "w")
449 |
450 | # if file is not None:
451 | # file.close()
452 |
453 | # if self.jsonDump:
454 | # json_data['hashtags'] = hashtags_list
455 | # json_file_name = self.output_dir + "/" + self.target + "_hashtags.json"
456 | # with open(json_file_name, 'w') as f:
457 | # json.dump(json_data, f)
458 | else:
459 | pc.printout("Sorry! No results found :-(\n", pc.RED)
460 |
461 | def get_user_info(self):
462 | try:
463 | content = client.user_info_by_username(self.target).dict()
464 |
465 | pc.printout("[ID] ", pc.GREEN)
466 | pc.printout(str(content['pk']) + '\n')
467 | pc.printout("[FULL NAME] ", pc.RED)
468 | pc.printout(str(content['full_name']) + '\n')
469 | pc.printout("[BIOGRAPHY] ", pc.CYAN)
470 | pc.printout(str(content['biography']) + '\n')
471 | pc.printout("[FOLLOWED] ", pc.BLUE)
472 | pc.printout(str(content['follower_count']) + '\n')
473 | pc.printout("[FOLLOW] ", pc.GREEN)
474 | pc.printout(str(content['following_count']) + '\n')
475 | pc.printout("[BUSINESS ACCOUNT] ", pc.RED)
476 | pc.printout(str(content['is_business']) + '\n')
477 | pc.printout("[VERIFIED ACCOUNT] ", pc.CYAN)
478 | pc.printout(str(content['is_verified']) + '\n')
479 | if 'public_email' in content and content['public_email']:
480 | pc.printout("[EMAIL] ", pc.BLUE)
481 | pc.printout(str(content['public_email']) + '\n')
482 | pc.printout("[HD PROFILE PIC] ", pc.GREEN)
483 | pc.printout(str(content['profile_pic_url']) + '\n')
484 | if 'fb_page_call_to_action_id' in content and content['fb_page_call_to_action_id']:
485 | pc.printout("[FB PAGE] ", pc.RED)
486 | pc.printout(str(content['connected_fb_page']) + '\n')
487 | if 'whatsapp_number' in content and content['whatsapp_number']:
488 | pc.printout("[WHATSAPP NUMBER] ", pc.GREEN)
489 | pc.printout(str(content['whatsapp_number']) + '\n')
490 | if 'city_name' in content and content['city_name']:
491 | pc.printout("[CITY] ", pc.YELLOW)
492 | pc.printout(str(content['city_name']) + '\n')
493 | if 'address_street' in content and content['address_street']:
494 | pc.printout("[ADDRESS STREET] ", pc.RED)
495 | pc.printout(str(content['address_street']) + '\n')
496 | if 'contact_phone_number' in content and content['contact_phone_number']:
497 | pc.printout("[CONTACT PHONE NUMBER] ", pc.CYAN)
498 | pc.printout(str(content['contact_phone_number']) + '\n')
499 | if self.jsonDump:
500 | user = {
501 | 'id': content['pk'],
502 | 'full_name': content['full_name'],
503 | 'biography': content['biography'],
504 | 'edge_followed_by': content['follower_count'],
505 | 'edge_follow': content['following_count'],
506 | 'is_business_account': content['is_business'],
507 | 'is_verified': content['is_verified'],
508 | 'profile_pic_url_hd': content['profile_pic_url']
509 | }
510 | json_file_name = self.output_dir + "/" + self.target + "_info.json"
511 | with open(json_file_name, 'w') as f:
512 | json.dump(user, f)
513 |
514 | except ClientError as e:
515 | print(e)
516 | pc.printout("Oops... " + str(self.target) + " non exist, please enter a valid username.", pc.RED)
517 | pc.printout("\n")
518 | exit(2)
519 |
520 | def get_total_likes(self):
521 | if self.check_private_profile():
522 | return
523 |
524 | pc.printout("Searching for target total likes...\n")
525 |
526 | like_counter = 0
527 | posts_counter = 0
528 |
529 | medias = client.user_medias(str(self.target_id))
530 |
531 | for post in medias:
532 | likes = client.media_info(post.pk).dict()['like_count']
533 | like_counter += likes
534 | posts_counter += 1
535 |
536 | if self.writeFile:
537 | file_name = self.output_dir + "/" + self.target + "_likes.txt"
538 | file = open(file_name, "w")
539 | file.write(str(like_counter) + " likes in " + str(like_counter) + " posts\n")
540 | file.close()
541 |
542 | if self.jsonDump:
543 | json_data = {
544 | 'like_counter': like_counter,
545 | 'posts': like_counter
546 | }
547 | json_file_name = self.output_dir + "/" + self.target + "_likes.json"
548 | with open(json_file_name, 'w') as f:
549 | json.dump(json_data, f)
550 |
551 | pc.printout(str(like_counter), pc.MAGENTA)
552 | if like_counter == 1:
553 | pc.printout(" like in " + str(posts_counter) + " post\n")
554 | else:
555 | pc.printout(" likes in " + str(posts_counter) + " posts\n")
556 |
557 | def get_media_type(self):
558 | if self.check_private_profile():
559 | return
560 |
561 | pc.printout("Searching for target captions...\n")
562 |
563 | counter = 0
564 | photo_counter = 0
565 | video_counter = 0
566 |
567 | data = self.__get_feed__()
568 |
569 | for post in data:
570 | if "media_type" in post:
571 | if post["media_type"] == 1:
572 | photo_counter = photo_counter + 1
573 | elif post["media_type"] == 2:
574 | video_counter = video_counter + 1
575 | counter = counter + 1
576 | sys.stdout.write("\rChecked %i" % counter)
577 | sys.stdout.flush()
578 |
579 | sys.stdout.write(" posts")
580 | sys.stdout.flush()
581 |
582 | if counter > 0:
583 |
584 | if self.writeFile:
585 | file_name = self.output_dir + "/" + self.target + "_mediatype.txt"
586 | file = open(file_name, "w")
587 | file.write(str(photo_counter) + " photos and " + str(video_counter) + " video posted by target\n")
588 | file.close()
589 |
590 | pc.printout("\nWoohoo! We found " + str(photo_counter) + " photos and " + str(video_counter) +
591 | " video posted by target\n", pc.GREEN)
592 |
593 | if self.jsonDump:
594 | json_data = {
595 | "photos": photo_counter,
596 | "videos": video_counter
597 | }
598 | json_file_name = self.output_dir + "/" + self.target + "_mediatype.json"
599 | with open(json_file_name, 'w') as f:
600 | json.dump(json_data, f)
601 |
602 | else:
603 | pc.printout("Sorry! No results found :-(\n", pc.RED)
604 |
605 | def get_people_who_commented(self):
606 | if self.check_private_profile():
607 | return
608 |
609 | pc.printout("Searching for users who commented...\n")
610 |
611 | data = self.__get_feed__()
612 | users = []
613 |
614 | for post in data:
615 | comments = self.__get_comments__(post['id'])
616 | for comment in comments:
617 | if not any(u['id'] == comment['user']['pk'] for u in users):
618 | user = {
619 | 'id': comment['user']['pk'],
620 | 'username': comment['user']['username'],
621 | 'full_name': comment['user']['full_name'],
622 | 'counter': 1
623 | }
624 | users.append(user)
625 | else:
626 | for user in users:
627 | if user['id'] == comment['user']['pk']:
628 | user['counter'] += 1
629 | break
630 |
631 | if len(users) > 0:
632 | ssort = sorted(users, key=lambda value: value['counter'], reverse=True)
633 |
634 | json_data = {}
635 |
636 | t = PrettyTable()
637 |
638 | t.field_names = ['Comments', 'ID', 'Username', 'Full Name']
639 | t.align["Comments"] = "l"
640 | t.align["ID"] = "l"
641 | t.align["Username"] = "l"
642 | t.align["Full Name"] = "l"
643 |
644 | for u in ssort:
645 | t.add_row([str(u['counter']), u['id'], u['username'], u['full_name']])
646 |
647 | print(t)
648 |
649 | if self.writeFile:
650 | file_name = self.output_dir + "/" + self.target + "_users_who_commented.txt"
651 | file = open(file_name, "w")
652 | file.write(str(t))
653 | file.close()
654 |
655 | if self.jsonDump:
656 | json_data['users_who_commented'] = ssort
657 | json_file_name = self.output_dir + "/" + self.target + "_users_who_commented.json"
658 | with open(json_file_name, 'w') as f:
659 | json.dump(json_data, f)
660 | else:
661 | pc.printout("Sorry! No results found :-(\n", pc.RED)
662 |
663 | def get_people_who_tagged(self):
664 | if self.check_private_profile():
665 | return
666 |
667 | pc.printout("Searching for users who tagged target...\n")
668 |
669 | posts = []
670 |
671 | result = self.api.usertag_feed(self.target_id)
672 | posts.extend(result.get('items', []))
673 |
674 | next_max_id = result.get('next_max_id')
675 | while next_max_id:
676 | results = self.api.user_feed(str(self.target_id), max_id=next_max_id)
677 | posts.extend(results.get('items', []))
678 | next_max_id = results.get('next_max_id')
679 |
680 | if len(posts) > 0:
681 | pc.printout("\nWoohoo! We found " + str(len(posts)) + " photos\n", pc.GREEN)
682 |
683 | users = []
684 |
685 | for post in posts:
686 | if not any(u['id'] == post['user']['pk'] for u in users):
687 | user = {
688 | 'id': post['user']['pk'],
689 | 'username': post['user']['username'],
690 | 'full_name': post['user']['full_name'],
691 | 'counter': 1
692 | }
693 | users.append(user)
694 | else:
695 | for user in users:
696 | if user['id'] == post['user']['pk']:
697 | user['counter'] += 1
698 | break
699 |
700 | ssort = sorted(users, key=lambda value: value['counter'], reverse=True)
701 |
702 | json_data = {}
703 |
704 | t = PrettyTable()
705 |
706 | t.field_names = ['Photos', 'ID', 'Username', 'Full Name']
707 | t.align["Photos"] = "l"
708 | t.align["ID"] = "l"
709 | t.align["Username"] = "l"
710 | t.align["Full Name"] = "l"
711 |
712 | for u in ssort:
713 | t.add_row([str(u['counter']), u['id'], u['username'], u['full_name']])
714 |
715 | print(t)
716 |
717 | if self.writeFile:
718 | file_name = self.output_dir + "/" + self.target + "_users_who_tagged.txt"
719 | file = open(file_name, "w")
720 | file.write(str(t))
721 | file.close()
722 |
723 | if self.jsonDump:
724 | json_data['users_who_tagged'] = ssort
725 | json_file_name = self.output_dir + "/" + self.target + "_users_who_tagged.json"
726 | with open(json_file_name, 'w') as f:
727 | json.dump(json_data, f)
728 | else:
729 | pc.printout("Sorry! No results found :-(\n", pc.RED)
730 |
731 | def get_photo_description(self):
732 | if self.check_private_profile():
733 | return
734 |
735 | content = requests.get("https://www.instagram.com/" + str(self.target) + "/?__a=1")
736 | data = content.json()
737 |
738 | dd = data['graphql']['user']['edge_owner_to_timeline_media']['edges']
739 |
740 | if len(dd) > 0:
741 | pc.printout("\nWoohoo! We found " + str(len(dd)) + " descriptions\n", pc.GREEN)
742 |
743 | count = 1
744 |
745 | t = PrettyTable(['Photo', 'Description'])
746 | t.align["Photo"] = "l"
747 | t.align["Description"] = "l"
748 |
749 | json_data = {}
750 | descriptions_list = []
751 |
752 | for i in dd:
753 | node = i.get('node')
754 | descr = node.get('accessibility_caption')
755 | t.add_row([str(count), descr])
756 |
757 | if self.jsonDump:
758 | description = {
759 | 'description': descr
760 | }
761 | descriptions_list.append(description)
762 |
763 | count += 1
764 |
765 | if self.writeFile:
766 | file_name = self.output_dir + "/" + self.target + "_photodes.txt"
767 | file = open(file_name, "w")
768 | file.write(str(t))
769 | file.close()
770 |
771 | if self.jsonDump:
772 | json_data['descriptions'] = descriptions_list
773 | json_file_name = self.output_dir + "/" + self.target + "_descriptions.json"
774 | with open(json_file_name, 'w') as f:
775 | json.dump(json_data, f)
776 |
777 | print(t)
778 | else:
779 | pc.printout("Sorry! No results found :-(\n", pc.RED)
780 |
781 | def get_user_photo(self):
782 | if self.check_private_profile():
783 | return
784 |
785 | pc.printout("Searching for target photos...\n")
786 | profile = Loader.Profile.from_username(loader.context, self.target)
787 | posts = profile.get_posts()
788 | try:
789 | for post in posts:
790 | loader.download_post(post, self.target)
791 | except KeyboardInterrupt:
792 | posts.freeze()
793 |
794 |
795 | def get_user_propic(self):
796 | userInfo = client.user_info_by_username(self.target).dict()
797 | url = userInfo['profile_pic_url']
798 | response = requests.get(url)
799 | #path is the root directory/username of the target folder
800 | path = self.target + "/"
801 | if not os.path.exists(path):
802 | os.makedirs(path)
803 | open(path + 'propic.jpg', 'wb').write(response.content)
804 | print("🎉 Profile picture saved in \"" + path + "propic.jpg\" 😄")
805 | def get_user_stories(self):
806 | if self.check_private_profile():
807 | return
808 |
809 | pc.printout("Searching for target stories...\n")
810 | profile = Loader.Profile.from_username(loader.context, self.target)
811 | loader.download_stories([profile])
812 |
813 | def get_user_highlights(self):
814 | if self.check_private_profile():
815 | return
816 |
817 | pc.printout("Searching for target highlights...\n")
818 | profile = Loader.Profile.from_username(loader.context, self.target)
819 | loader.download_highlights(profile)
820 |
821 |
822 | def get_people_tagged_by_user(self):
823 | pc.printout("Searching for users tagged by target...\n")
824 |
825 | ids = []
826 | username = []
827 | full_name = []
828 | postList = []
829 | counter = 1
830 |
831 | profile = Loader.Profile.from_username(loader.context, self.target)
832 | posts = profile.get_posts()
833 | try:
834 | for post in posts:
835 | taggedUsers = post.tagged_users
836 | for users in taggedUsers:
837 | profile = Loader.Profile.from_username(loader.context, users)
838 | ids.append(profile.userid)
839 | username.append(users)
840 | full_name.append(profile.full_name)
841 | postList.append(post.mediaid)
842 | # counter = counter + 1
843 | # sys.stdout.write("\rCatched %i" % counter)
844 | # sys.stdout.flush()
845 | except KeyboardInterrupt:
846 | posts.freeze()
847 |
848 | if len(ids) > 0:
849 | t = PrettyTable()
850 |
851 | t.field_names = ['Posts', 'Full Name', 'Username', 'ID']
852 | t.align["Posts"] = "l"
853 | t.align["Full Name"] = "l"
854 | t.align["Username"] = "l"
855 | t.align["ID"] = "l"
856 |
857 | pc.printout("\nWoohoo! We found " + str(len(ids)) + " (" + str(counter) + ") users\n", pc.GREEN)
858 |
859 | json_data = {}
860 | tagged_list = []
861 |
862 | for i in range(len(ids)):
863 | t.add_row([postList[i], full_name[i], username[i], str(ids[i])])
864 |
865 | if self.jsonDump:
866 | tag = {
867 | 'post': post[i],
868 | 'full_name': full_name[i],
869 | 'username': username[i],
870 | 'id': ids[i]
871 | }
872 | tagged_list.append(tag)
873 |
874 | if self.writeFile:
875 | file_name = self.output_dir + "/" + self.target + "_tagged.txt"
876 | file = open(file_name, "w")
877 | file.write(str(t))
878 | file.close()
879 |
880 | if self.jsonDump:
881 | json_data['tagged'] = tagged_list
882 | json_file_name = self.output_dir + "/" + self.target + "_tagged.json"
883 | with open(json_file_name, 'w') as f:
884 | json.dump(json_data, f)
885 |
886 | print(t)
887 | else:
888 | pc.printout("Sorry! No results found :-(\n", pc.RED)
889 |
890 | def get_user(self, username):
891 | try:
892 | user = dict()
893 | content = client.user_info_by_username(username).dict()
894 | user['id'] = content['pk']
895 | user['is_private'] = content['is_private']
896 |
897 | return user
898 | except ClientError as e:
899 | pc.printout('ClientError {0!s} (Code: {1:d}, Response: {2!s})'.format(e.code, e.error_response), pc.RED)
900 | error = json.loads(e.error_response)
901 | if 'message' in error:
902 | print(error['message'])
903 | if 'error_title' in error:
904 | print(error['error_title'])
905 | if 'challenge' in error:
906 | print("Please follow this link to complete the challenge: " + error['challenge']['url'])
907 | sys.exit(2)
908 |
909 |
910 | def set_write_file(self, flag):
911 | if flag:
912 | pc.printout("Write to file: ")
913 | pc.printout("enabled", pc.GREEN)
914 | pc.printout("\n")
915 | else:
916 | pc.printout("Write to file: ")
917 | pc.printout("disabled", pc.RED)
918 | pc.printout("\n")
919 |
920 | self.writeFile = flag
921 |
922 | def set_json_dump(self, flag):
923 | if flag:
924 | pc.printout("Export to JSON: ")
925 | pc.printout("enabled", pc.GREEN)
926 | pc.printout("\n")
927 | else:
928 | pc.printout("Export to JSON: ")
929 | pc.printout("disabled", pc.RED)
930 | pc.printout("\n")
931 |
932 | self.jsonDump = flag
933 |
934 | def login(self, u, p):
935 | try:
936 | # if file session.json exists, load it, else dump it, the file should be in the root directory
937 | if os.path.isfile('session.json'):
938 | userSettings = client.load_settings('session.json')
939 | client.login_by_sessionid(userSettings["authorization_data"]["sessionid"])
940 | print("Loaded session from session.json")
941 | else:
942 | client.login(u, p)
943 | client.dump_settings('session.json')
944 | if os.path.isfile('session_loader.json'):
945 | loader.load_session_from_file(u, "session_loader.json")
946 | else:
947 | loader.login(u, p)
948 | loader.save_session_to_file("session_loader.json")
949 |
950 |
951 | except ClientError as e:
952 | pc.printout('ClientError {0!s} (Code: {1:d}, Response: {2!s})'.format(e.msg, e.code, e.error_response), pc.RED)
953 | error = json.loads(e.error_response)
954 | pc.printout(error['message'], pc.RED)
955 | pc.printout(": ", pc.RED)
956 |
957 | pc.printout(e.msg, pc.RED)
958 | pc.printout("\n")
959 | if 'challenge' in error:
960 | print("Please follow this link to complete the challenge: " + error['challenge']['url'])
961 | exit(9)
962 |
963 | def to_json(self, python_object):
964 | if isinstance(python_object, bytes):
965 | return {'__class__': 'bytes',
966 | '__value__': codecs.encode(python_object, 'base64').decode()}
967 | raise TypeError(repr(python_object) + ' is not JSON serializable')
968 |
969 | def from_json(self, json_object):
970 | if '__class__' in json_object and json_object['__class__'] == 'bytes':
971 | return codecs.decode(json_object['__value__'].encode(), 'base64')
972 | return json_object
973 |
974 | def check_following(self, username):
975 | if str(self.target_id) == str(client.user_id_from_username(username)):
976 | return True
977 | followingDict = client.user_following(client.user_id_from_username(username))
978 | for user in followingDict:
979 | print(user)
980 | if str(self.target_id) == user:
981 | return True
982 | return False
983 |
984 | def check_private_profile(self):
985 | if self.is_private and not self.following:
986 | pc.printout("Impossible to execute command: user has private profile\n", pc.RED)
987 | send = input("Do you want send a follow request? [Y/N]: ")
988 | if send.lower() == "y":
989 | client.user_follow(self.target_id)
990 | print("Sent a follow request to target. Use this command after target accepting the request.")
991 |
992 | return True
993 | return False
994 |
995 | def get_fwersemail(self):
996 | if self.check_private_profile():
997 | return
998 |
999 | _followers = []
1000 | followersEmail = []
1001 |
1002 |
1003 | pc.printout("Searching for emails of target followers... this can take a few minutes\n")
1004 |
1005 | data = client.user_followers(str(self.target_id))
1006 | _followers.extend(data.values())
1007 | for user in _followers:
1008 | userDict = user.dict()
1009 | userInfo = client.user_info_by_username(userDict['username']).dict()
1010 | if 'email' in userDict and userDict['email']:
1011 | u = {
1012 | 'id': userDict['pk'],
1013 | 'username': userDict['username'],
1014 | 'full_name': userDict['full_name'],
1015 | 'email': userInfo['public_email']
1016 | }
1017 | followersEmail.append(u)
1018 |
1019 | print("\n")
1020 |
1021 | if len(followersEmail) > 0:
1022 | pc.printout("Do you want to get all emails? y/n: ", pc.YELLOW)
1023 | value = input()
1024 |
1025 | if value == str("y") or value == str("yes") or value == str("Yes") or value == str("YES"):
1026 | value = len(followersEmail)
1027 | elif value == str(""):
1028 | print("\n")
1029 | return
1030 | elif value == str("n") or value == str("no") or value == str("No") or value == str("NO"):
1031 | while True:
1032 | try:
1033 | pc.printout("How many emails do you want to get? ", pc.YELLOW)
1034 | new_value = int(input())
1035 | value = new_value - 1
1036 | break
1037 | except ValueError:
1038 | pc.printout("Error! Please enter a valid integer!", pc.RED)
1039 | print("\n")
1040 | return
1041 | else:
1042 | pc.printout("Error! Please enter y/n :-)", pc.RED)
1043 | print("\n")
1044 | return
1045 |
1046 | t = PrettyTable(['ID', 'Username', 'Full Name', 'Email'])
1047 | t.align["ID"] = "l"
1048 | t.align["Username"] = "l"
1049 | t.align["Full Name"] = "l"
1050 | t.align["Email"] = "l"
1051 |
1052 | json_data = {}
1053 |
1054 | for node in followersEmail:
1055 | t.add_row([str(node['id']), node['username'], node['full_name'], node['email']])
1056 |
1057 | if self.writeFile:
1058 | file_name = self.output_dir + "/" + self.target + "_fwersemail.txt"
1059 | file = open(file_name, "w")
1060 | file.write(str(t))
1061 | file.close()
1062 |
1063 | if self.jsonDump:
1064 | json_data['followers_email'] = followersEmail
1065 | json_file_name = self.output_dir + "/" + self.target + "_fwersemail.json"
1066 | with open(json_file_name, 'w') as f:
1067 | json.dump(json_data, f)
1068 |
1069 | print(t)
1070 | else:
1071 | pc.printout("Sorry! No results found :-(\n", pc.RED)
1072 |
1073 |
1074 |
1075 | def get_fwingsemail(self):
1076 | if self.check_private_profile():
1077 | return
1078 |
1079 | _followings = []
1080 | followingsEmail = []
1081 |
1082 |
1083 | pc.printout("Searching for emails of target followers... this can take a few minutes\n")
1084 |
1085 | data = client.user_following(str(self.target_id))
1086 | print(data)
1087 | _followings.extend(data.values())
1088 | for user in _followings:
1089 | userDict = user.dict()
1090 | userInfo = client.user_info_by_username(userDict['username']).dict()
1091 | print(userInfo)
1092 | if userInfo['public_email']:
1093 | u = {
1094 | 'id': userDict['pk'],
1095 | 'username': userDict['username'],
1096 | 'full_name': userDict['full_name'],
1097 | 'email': userInfo['public_email']
1098 | }
1099 | followingsEmail.append(u)
1100 |
1101 | print("\n")
1102 |
1103 | if len(followingsEmail) > 0:
1104 | pc.printout("Do you want to get all emails? y/n: ", pc.YELLOW)
1105 | value = input()
1106 |
1107 | if value == str("y") or value == str("yes") or value == str("Yes") or value == str("YES"):
1108 | value = len(followingsEmail)
1109 | elif value == str(""):
1110 | print("\n")
1111 | return
1112 | elif value == str("n") or value == str("no") or value == str("No") or value == str("NO"):
1113 | while True:
1114 | try:
1115 | pc.printout("How many emails do you want to get? ", pc.YELLOW)
1116 | new_value = int(input())
1117 | value = new_value - 1
1118 | break
1119 | except ValueError:
1120 | pc.printout("Error! Please enter a valid integer!", pc.RED)
1121 | print("\n")
1122 | return
1123 | else:
1124 | pc.printout("Error! Please enter y/n :-)", pc.RED)
1125 | print("\n")
1126 | return
1127 |
1128 | t = PrettyTable(['ID', 'Username', 'Full Name', 'Email'])
1129 | t.align["ID"] = "l"
1130 | t.align["Username"] = "l"
1131 | t.align["Full Name"] = "l"
1132 | t.align["Email"] = "l"
1133 |
1134 | json_data = {}
1135 |
1136 | for node in followingsEmail:
1137 | t.add_row([str(node['id']), node['username'], node['full_name'], node['email']])
1138 |
1139 | if self.writeFile:
1140 | file_name = self.output_dir + "/" + self.target + "_fwingsemail.txt"
1141 | file = open(file_name, "w")
1142 | file.write(str(t))
1143 | file.close()
1144 |
1145 | if self.jsonDump:
1146 | json_data['followings_email'] = followingsEmail
1147 | json_file_name = self.output_dir + "/" + self.target + "_fwingsemail.json"
1148 | with open(json_file_name, 'w') as f:
1149 | json.dump(json_data, f)
1150 |
1151 | print(t)
1152 | else:
1153 | pc.printout("Sorry! No results found :-(\n", pc.RED)
1154 |
1155 | def get_fwingsnumber(self):
1156 | if self.check_private_profile():
1157 | return
1158 |
1159 | try:
1160 |
1161 | pc.printout("Searching for phone numbers of users followed by target... this can take a few minutes\n")
1162 |
1163 | followings = []
1164 |
1165 | rank_token = AppClient.generate_uuid()
1166 | data = self.api.user_following(str(self.target_id), rank_token=rank_token)
1167 |
1168 | for user in data.get('users', []):
1169 | u = {
1170 | 'id': user['pk'],
1171 | 'username': user['username'],
1172 | 'full_name': user['full_name']
1173 | }
1174 | followings.append(u)
1175 |
1176 | next_max_id = data.get('next_max_id')
1177 |
1178 | while next_max_id:
1179 | results = self.api.user_following(str(self.target_id), rank_token=rank_token, max_id=next_max_id)
1180 |
1181 | for user in results.get('users', []):
1182 | u = {
1183 | 'id': user['pk'],
1184 | 'username': user['username'],
1185 | 'full_name': user['full_name']
1186 | }
1187 | followings.append(u)
1188 |
1189 | next_max_id = results.get('next_max_id')
1190 |
1191 | results = []
1192 |
1193 | pc.printout("Do you want to get all phone numbers? y/n: ", pc.YELLOW)
1194 | value = input()
1195 |
1196 | if value == str("y") or value == str("yes") or value == str("Yes") or value == str("YES"):
1197 | value = len(followings)
1198 | elif value == str(""):
1199 | print("\n")
1200 | return
1201 | elif value == str("n") or value == str("no") or value == str("No") or value == str("NO"):
1202 | while True:
1203 | try:
1204 | pc.printout("How many phone numbers do you want to get? ", pc.YELLOW)
1205 | new_value = int(input())
1206 | value = new_value - 1
1207 | break
1208 | except ValueError:
1209 | pc.printout("Error! Please enter a valid integer!", pc.RED)
1210 | print("\n")
1211 | return
1212 | else:
1213 | pc.printout("Error! Please enter y/n :-)", pc.RED)
1214 | print("\n")
1215 | return
1216 |
1217 | for follow in followings:
1218 | sys.stdout.write("\rCatched %i followings phone numbers" % len(results))
1219 | sys.stdout.flush()
1220 | user = self.api.user_info(str(follow['id']))
1221 | if 'contact_phone_number' in user['user'] and user['user']['contact_phone_number']:
1222 | follow['contact_phone_number'] = user['user']['contact_phone_number']
1223 | if len(results) > value:
1224 | break
1225 | results.append(follow)
1226 |
1227 | except ClientThrottledError as e:
1228 | pc.printout("\nError: Instagram blocked the requests. Please wait a few minutes before you try again.", pc.RED)
1229 | pc.printout("\n")
1230 |
1231 | print("\n")
1232 |
1233 | if len(results) > 0:
1234 | t = PrettyTable(['ID', 'Username', 'Full Name', 'Phone'])
1235 | t.align["ID"] = "l"
1236 | t.align["Username"] = "l"
1237 | t.align["Full Name"] = "l"
1238 | t.align["Phone number"] = "l"
1239 |
1240 | json_data = {}
1241 |
1242 | for node in results:
1243 | t.add_row([str(node['id']), node['username'], node['full_name'], node['contact_phone_number']])
1244 |
1245 | if self.writeFile:
1246 | file_name = self.output_dir + "/" + self.target + "_fwingsnumber.txt"
1247 | file = open(file_name, "w")
1248 | file.write(str(t))
1249 | file.close()
1250 |
1251 | if self.jsonDump:
1252 | json_data['followings_phone_numbers'] = results
1253 | json_file_name = self.output_dir + "/" + self.target + "_fwingsnumber.json"
1254 | with open(json_file_name, 'w') as f:
1255 | json.dump(json_data, f)
1256 |
1257 | print(t)
1258 | else:
1259 | pc.printout("Sorry! No results found :-(\n", pc.RED)
1260 |
1261 | def get_fwersnumber(self):
1262 | if self.check_private_profile():
1263 | return
1264 |
1265 | followings = []
1266 |
1267 | try:
1268 |
1269 | pc.printout("Searching for phone numbers of users followers... this can take a few minutes\n")
1270 |
1271 |
1272 | rank_token = AppClient.generate_uuid()
1273 | data = self.api.user_following(str(self.target_id), rank_token=rank_token)
1274 |
1275 | for user in data.get('users', []):
1276 | u = {
1277 | 'id': user['pk'],
1278 | 'username': user['username'],
1279 | 'full_name': user['full_name']
1280 | }
1281 | followings.append(u)
1282 |
1283 | next_max_id = data.get('next_max_id')
1284 |
1285 | while next_max_id:
1286 | results = self.api.user_following(str(self.target_id), rank_token=rank_token, max_id=next_max_id)
1287 |
1288 | for user in results.get('users', []):
1289 | u = {
1290 | 'id': user['pk'],
1291 | 'username': user['username'],
1292 | 'full_name': user['full_name']
1293 | }
1294 | followings.append(u)
1295 |
1296 | next_max_id = results.get('next_max_id')
1297 |
1298 | results = []
1299 |
1300 | pc.printout("Do you want to get all phone numbers? y/n: ", pc.YELLOW)
1301 | value = input()
1302 |
1303 | if value == str("y") or value == str("yes") or value == str("Yes") or value == str("YES"):
1304 | value = len(followings)
1305 | elif value == str(""):
1306 | print("\n")
1307 | return
1308 | elif value == str("n") or value == str("no") or value == str("No") or value == str("NO"):
1309 | while True:
1310 | try:
1311 | pc.printout("How many phone numbers do you want to get? ", pc.YELLOW)
1312 | new_value = int(input())
1313 | value = new_value - 1
1314 | break
1315 | except ValueError:
1316 | pc.printout("Error! Please enter a valid integer!", pc.RED)
1317 | print("\n")
1318 | return
1319 | else:
1320 | pc.printout("Error! Please enter y/n :-)", pc.RED)
1321 | print("\n")
1322 | return
1323 |
1324 | for follow in followings:
1325 | sys.stdout.write("\rCatched %i followers phone numbers" % len(results))
1326 | sys.stdout.flush()
1327 | user = self.api.user_info(str(follow['id']))
1328 | if 'contact_phone_number' in user['user'] and user['user']['contact_phone_number']:
1329 | follow['contact_phone_number'] = user['user']['contact_phone_number']
1330 | if len(results) > value:
1331 | break
1332 | results.append(follow)
1333 |
1334 | except ClientThrottledError as e:
1335 | pc.printout("\nError: Instagram blocked the requests. Please wait a few minutes before you try again.", pc.RED)
1336 | pc.printout("\n")
1337 |
1338 | print("\n")
1339 |
1340 | if len(results) > 0:
1341 | t = PrettyTable(['ID', 'Username', 'Full Name', 'Phone'])
1342 | t.align["ID"] = "l"
1343 | t.align["Username"] = "l"
1344 | t.align["Full Name"] = "l"
1345 | t.align["Phone number"] = "l"
1346 |
1347 | json_data = {}
1348 |
1349 | for node in results:
1350 | t.add_row([str(node['id']), node['username'], node['full_name'], node['contact_phone_number']])
1351 |
1352 | if self.writeFile:
1353 | file_name = self.output_dir + "/" + self.target + "_fwersnumber.txt"
1354 | file = open(file_name, "w")
1355 | file.write(str(t))
1356 | file.close()
1357 |
1358 | if self.jsonDump:
1359 | json_data['followings_phone_numbers'] = results
1360 | json_file_name = self.output_dir + "/" + self.target + "_fwerssnumber.json"
1361 | with open(json_file_name, 'w') as f:
1362 | json.dump(json_data, f)
1363 |
1364 | print(t)
1365 | else:
1366 | pc.printout("Sorry! No results found :-(\n", pc.RED)
1367 |
1368 | def get_comments(self):
1369 | if self.check_private_profile():
1370 | return
1371 |
1372 | pc.printout("Searching for users who commented...\n")
1373 |
1374 | data = self.__get_feed__()
1375 | users = []
1376 |
1377 | for post in data:
1378 | comments = self.__get_comments__(post['id'])
1379 | for comment in comments:
1380 | print(comment['text'])
1381 |
1382 | # if not any(u['id'] == comment['user']['pk'] for u in users):
1383 | # user = {
1384 | # 'id': comment['user']['pk'],
1385 | # 'username': comment['user']['username'],
1386 | # 'full_name': comment['user']['full_name'],
1387 | # 'counter': 1
1388 | # }
1389 | # users.append(user)
1390 | # else:
1391 | # for user in users:
1392 | # if user['id'] == comment['user']['pk']:
1393 | # user['counter'] += 1
1394 | # break
1395 |
1396 | if len(users) > 0:
1397 | ssort = sorted(users, key=lambda value: value['counter'], reverse=True)
1398 |
1399 | json_data = {}
1400 |
1401 | t = PrettyTable()
1402 |
1403 | t.field_names = ['Comments', 'ID', 'Username', 'Full Name']
1404 | t.align["Comments"] = "l"
1405 | t.align["ID"] = "l"
1406 | t.align["Username"] = "l"
1407 | t.align["Full Name"] = "l"
1408 |
1409 | for u in ssort:
1410 | t.add_row([str(u['counter']), u['id'], u['username'], u['full_name']])
1411 |
1412 | print(t)
1413 |
1414 | if self.writeFile:
1415 | file_name = self.output_dir + "/" + self.target + "_users_who_commented.txt"
1416 | file = open(file_name, "w")
1417 | file.write(str(t))
1418 | file.close()
1419 |
1420 | if self.jsonDump:
1421 | json_data['users_who_commented'] = ssort
1422 | json_file_name = self.output_dir + "/" + self.target + "_users_who_commented.json"
1423 | with open(json_file_name, 'w') as f:
1424 | json.dump(json_data, f)
1425 | else:
1426 | pc.printout("Sorry! No results found :-(\n", pc.RED)
1427 |
--------------------------------------------------------------------------------