├── .dockerignore
├── .github
└── workflows
│ └── lint_python.yml
├── .gitignore
├── .img
├── carbon.png
└── carbon.svg
├── Dockerfile
├── LICENSE
├── Makefile
├── README.md
├── config
├── credentials.ini
└── settings.json
├── doc
├── CHANGELOG.md
└── COMMANDS.md
├── docker-compose.yml
├── docker_reqs.txt
├── main.py
├── output
└── dont_delete_this_folder.txt
├── requirements.txt
└── src
├── Osintgram.py
├── artwork.py
├── config.py
└── printcolors.py
/.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
--------------------------------------------------------------------------------
/.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 flake8 isort mypy pytest pyupgrade safety
10 | - run: bandit -r . || true
11 | - run: black --check . || true
12 | - run: codespell --ignore-words-list="followings" --quiet-level=2
13 | - run: flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
14 | - run: isort --check-only --profile black . || true
15 | - run: pip install -r requirements.txt
16 | - run: mypy --ignore-missing-imports .
17 | - run: pytest . || true
18 | - run: pytest --doctest-modules . || true
19 | - run: shopt -s globstar && pyupgrade --py36-plus **/*.py || true
20 | - run: safety check
21 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | config/
2 | __pycache__/
3 | output/
4 | *.pyc
5 | *.json
6 | venv/
7 | credentials.ini
--------------------------------------------------------------------------------
/.img/carbon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/blackhatethicalhacking/Osintgram/cf31d33c8993b0f705a0129208b3385d82301141/.img/carbon.png
--------------------------------------------------------------------------------
/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 |
--------------------------------------------------------------------------------
/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 |
--------------------------------------------------------------------------------
/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"
--------------------------------------------------------------------------------
/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://t.me/osintgram)
7 | [](https://img.shields.io/badge/Docker-Supported-blue)
8 |
9 | Osintgram is a **OSINT** tool on Instagram to collect, analyze, and run reconnaissance.
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 | - addrs Get all registered addressed by target photos
25 | - captions Get user's photos captions
26 | - comments Get total comments of target's posts
27 | - followers Get target followers
28 | - followings Get users followed by target
29 | - fwersemail Get email of target followers
30 | - fwingsemail Get email of users followed by target
31 | - fwersnumber Get phone number of target followers
32 | - fwingsnumber Get phone number of users followed by target
33 | - hashtags Get hashtags used by target
34 | - info Get target info
35 | - likes Get total likes of target's posts
36 | - mediatype Get user's posts type (photo or video)
37 | - photodes Get description of target's photos
38 | - photos Download user's photos in output folder
39 | - propic Download user's profile picture
40 | - stories Download user's stories
41 | - tagged Get list of users tagged by target
42 | - wcommented Get a list of user who commented target's photos
43 | - wtagged Get a list of user who tagged target
44 | ```
45 |
46 | You can find detailed commands usage [here](doc/COMMANDS.md).
47 |
48 | [**Latest version**](https://github.com/Datalux/Osintgram/releases/tag/1.3) |
49 | [Commands](doc/COMMANDS.md) |
50 | [CHANGELOG](doc/CHANGELOG.md)
51 |
52 | ## FAQ
53 | 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!
54 | 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)
55 |
56 |
57 | ## Installation ⚙️
58 |
59 | 1. Fork/Clone/Download this repo
60 |
61 | `git clone https://github.com/Datalux/Osintgram.git`
62 |
63 | 2. Navigate to the directory
64 |
65 | `cd Osintgram`
66 |
67 | 3. Create a virtual environment for this project
68 |
69 | `python3 -m venv venv`
70 |
71 | 4. Load the virtual environment
72 | - On Windows Powershell: `.\venv\Scripts\activate.ps1`
73 | - On Linux and Git Bash: `source venv/bin/activate`
74 |
75 | 5. Run `pip install -r requirements.txt`
76 |
77 | 6. Open the `credentials.ini` file in the `config` folder and write your Instagram account username and password in the corresponding fields
78 |
79 | Alternatively, you can run the `make setup` command to populate this file for you.
80 |
81 | 7. Run the main.py script in one of two ways
82 |
83 | * As an interactive prompt `python3 main.py `
84 | * Or execute your command straight away `python3 main.py --command `
85 |
86 | ## Docker Quick Start 🐳
87 |
88 | This section will explain how you can quickly use this image with `Docker` or `Docker-compose`.
89 |
90 | ### Prerequisites
91 |
92 | Before you can use either `Docker` or `Docker-compose`, please ensure you do have the following prerequisites met.
93 |
94 | 1. **Docker** installed - [link](https://docs.docker.com/get-docker/)
95 | 2. **Docker-composed** installed (if using Docker-compose) - [link](https://docs.docker.com/compose/install/)
96 | 3. **Credentials** configured - This can be done manually or by running the `make setup` command from the root of this repo
97 |
98 | **Important**: Your container will fail if you do not do step #3 and configure your credentials
99 |
100 | ### Docker
101 |
102 | If docker is installed you can build an image and run this as a container.
103 |
104 | Build:
105 |
106 | ```bash
107 | docker build -t osintgram .
108 | ```
109 |
110 | Run:
111 |
112 | ```bash
113 | docker run --rm -it -v "$PWD/output:/home/osintgram/output" osintgram
114 | ```
115 |
116 | - The `` is the Instagram account you wish to use as your target for recon.
117 | - 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)
118 | - 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)
119 | - 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)
120 | - The optional `-t` flag allocates a pseudo-TTY which allows colored output. [docs](https://docs.docker.com/engine/reference/run/#foreground)
121 |
122 | ### Using `docker-compose`
123 |
124 | You can use the `docker-compose.yml` file this single command:
125 |
126 | ```bash
127 | docker-compose run osintgram
128 | ```
129 |
130 | Where `target` is the Instagram target for recon.
131 |
132 | Alternatively you may run `docker-compose` with the `Makefile`:
133 |
134 | `make run` - Builds and Runs with compose. Prompts for a `target` before running.
135 |
136 | ### Makefile (easy mode)
137 |
138 | For ease of use with Docker-compose, a `Makefile` has been provided.
139 |
140 | Here is a sample work flow to spin up a container and run `osintgram` with just two commands!
141 |
142 | 1. `make setup` - Sets up your Instagram credentials
143 | 2. `make run` - Builds and Runs a osintgram container and prompts for a target
144 |
145 | Sample workflow for development:
146 |
147 | 1. `make setup` - Sets up your Instagram credentials
148 | 2. `make build-run-testing` - Builds an Runs a container without invoking the `main.py` script. Useful for an `it` Docker session for development
149 | 3. `make cleanup-testing` - Cleans up the testing container created from `build-run-testing`
150 |
151 | ## Development version 💻
152 |
153 | To use the development version with the latest feature and fixes just switch to `development` branch using Git:
154 |
155 | `git checkout development`
156 |
157 | and update to last version using:
158 |
159 | `git pull origin development`
160 |
161 |
162 | ## Updating ⬇️
163 |
164 | To update Osintgram with the stable release just pull the latest commit using Git.
165 |
166 | 1. Make sure you are in the master branch running: `git checkout master`
167 | 2. Download the latest version: `git pull origin master`
168 |
169 |
170 | ## Contributing 💡
171 |
172 | You can propose a feature request opening an issue or a pull request.
173 |
174 | Here is a list of Osintgram's contributors:
175 |
176 |
177 |
178 |
179 |
180 | ## External library 🔗
181 |
182 | [Instagram API](https://github.com/ping/instagram_private_api)
183 |
--------------------------------------------------------------------------------
/config/credentials.ini:
--------------------------------------------------------------------------------
1 | [Credentials]
2 | username =
3 | password =
--------------------------------------------------------------------------------
/config/settings.json:
--------------------------------------------------------------------------------
1 | {"uuid": "49ed550a-b30f-11eb-ab45-00155d9a47a8", "device_id": "android-49ed5762b30f11eb", "ad_id": "00ea607f-90b5-01af-95ac-c6f37ac93fbd", "session_id": "49ed5848-b30f-11eb-ab45-00155d9a47a8", "cookie": {"__class__": "bytes", "__value__": "gASVRwMAAAAAAAB9lIwOLmluc3RhZ3JhbS5jb22UfZSMAS+UfZQojAljc3JmdG9rZW6UjA5odHRw\nLmNvb2tpZWphcpSMBkNvb2tpZZSTlCmBlH2UKIwHdmVyc2lvbpRLAIwEbmFtZZSMCWNzcmZ0b2tl\nbpSMBXZhbHVllIwgemxlTm5zWjBJeUFPa0NPTzkwVG5rOUc0RHJDbFIzcHCUjARwb3J0lE6MDnBv\ncnRfc3BlY2lmaWVklImMBmRvbWFpbpSMDi5pbnN0YWdyYW0uY29tlIwQZG9tYWluX3NwZWNpZmll\nZJSIjBJkb21haW5faW5pdGlhbF9kb3SUiIwEcGF0aJRoA4wOcGF0aF9zcGVjaWZpZWSUiIwGc2Vj\ndXJllIiMB2V4cGlyZXOUSgCUe2KMB2Rpc2NhcmSUiYwHY29tbWVudJROjAtjb21tZW50X3VybJRO\njAdyZmMyMTA5lImMBV9yZXN0lH2UdWKMA21pZJRoCCmBlH2UKGgLSwBoDGggaA6MHFlKdXhfUUFC\nQUFHUmtGeFRzblNuek5DakpCdXCUaBBOaBGJaBKMDi5pbnN0YWdyYW0uY29tlGgUiGgViGgWaANo\nF4hoGIhoGUr9GF5kaBqJaBtOaBxOaB2JaB59lHVijANydXKUaAgpgZR9lChoC0sAaAxoJmgOjANO\nQU+UaBBOaBGJaBKMDi5pbnN0YWdyYW0uY29tlGgUiGgViGgWaANoF4hoGIhoGU5oGohoG05oHE5o\nHYloHn2UjAhIdHRwT25seZROc3VijApkc191c2VyX2lklGgIKYGUfZQoaAtLAGgMaC1oDowLNDc2\nNTU2NjY1MjeUaBBOaBGJaBKMDi5pbnN0YWdyYW0uY29tlGgUiGgViGgWaANoF4hoGIhoGUoAWRJh\naBqJaBtOaBxOaB2JaB59lHVijAlzZXNzaW9uaWSUaAgpgZR9lChoC0sAaAxoM2gOjCA0NzY1NTY2\nNjUyNyUzQUFkSjZxZkhDZGt2SHdpJTNBM5RoEE5oEYloEowOLmluc3RhZ3JhbS5jb22UaBSIaBWI\naBZoA2gXiGgYiGgZSoDlfGJoGoloG05oHE5oHYloHn2UjAhIdHRwT25seZROc3VidXNzLg==\n"}, "created_ts": 1620816384}
--------------------------------------------------------------------------------
/doc/CHANGELOG.md:
--------------------------------------------------------------------------------
1 | # Changelog
2 |
3 | ## [1.3](https://github.com/Datalux/Osintgram/releases/tag/1.3)
4 | **Enhancements**
5 | - Artwork refactoring (#149)
6 | - Added command line mode (#155)
7 | - Added output limiter (#201)
8 |
9 | **Bug fixes**
10 | - Losing collected data (#156)
11 | - JSON user info (#202)
12 | - Issue #198 (#200)
13 | - Issue #204 (12e730e)
14 |
15 |
16 | ## [1.2](https://github.com/Datalux/Osintgram/releases/tag/1.2)
17 | **Enhancements**
18 | - Added virtual environment (#126)
19 | - Removed some typos (#129, #118)
20 | - Added new configuration (#125)
21 | - Added new `commentdata` command (#131)
22 | - Added Docker support (#141)
23 |
24 |
25 | **Bug fixes**
26 | - Fix bug #138 (fc2a6be)
27 | - SSL certificate error (#136)
28 |
29 |
30 | ## [1.1](https://github.com/Datalux/Osintgram/releases/tag/1.1)
31 | **Enhancements**
32 | - Improved command parser (#86)
33 | - Improved errors handling (8bd1abc)
34 | - Add new line when input command is empty (f5211eb)
35 | - Added new commands to catch phone number of users (#111)
36 | - Added support for Windows (#100)
37 |
38 |
39 | **Bug fixes**
40 | - Fix commands output limit bug (#87)
41 | - Fix setting target with "." in username (9082990)
42 | - Readline installing error (#94 )
43 |
44 |
45 | ## [1.0.1](https://github.com/Datalux/Osintgram/releases/tag/1.0.1)
46 | **Bug fixes**
47 | - Set itself as target by param
48 |
49 | ## [1.0](https://github.com/Datalux/Osintgram/releases/tag/1.0)
50 | **Enhancements**
51 | - Set itself as target (#53)
52 | - Get others info from user (`info` command):
53 | - Whats'App number (if available)
54 | - City Name (if available)
55 | - Address Street (if available)
56 | - Contact phone number (if available)
57 |
58 | **Bug fixes**
59 | - Fix login issue (#79, #80, #81)
60 |
61 | ## [0.9](https://github.com/Datalux/Osintgram/releases/tag/0.9)
62 |
63 | **Enhancements**
64 | - Send a follow request if user not following target (#44)
65 | - Added new `fwingsemail` command (#50)
66 | - Added autocomplete with TAB (07e0fe8)
67 |
68 | **Bug fixes**
69 | - Decoding error of response [bug #46] (f9c5f73)
70 | - `stories` command not working (#49)
71 |
72 | ## [0.8](https://github.com/Datalux/Osintgram/releases/tag/0.8)
73 |
74 | **Enhancements**
75 | - Added `wtagged` command (#38)
76 | - Added `fwersemail` command (#40)
77 | - Access private profiles if you following targets (#37)
78 | - Added more info in `info` command (#36)
79 |
80 |
81 | **Bug fixes**
82 | - Minor bug fix in `addrs` commands (9b9086a)
83 |
84 | ## [0.7](https://github.com/Datalux/Osintgram/releases/tag/0.7)
85 |
86 | **Enhancements**
87 | - banner now show target ID (#30)
88 | - persistent login (#33)
89 | - error handler (85e390b)
90 | - added CTRL+C handler (c2c3c3e)
91 |
92 | **Bug fixes**
93 | - fix likes and comments posts counter bug (44b7534)
94 |
95 |
96 |
97 | ## [0.6](https://github.com/Datalux/Osintgram/releases/tag/0.6)
98 |
99 | **Enhancements**
100 |
101 | - new `wcommented` command (#27)
102 | - new `target` command
103 | - added json dump also for captions command
104 | - added options as arguments (#24)
105 | - new Instagram APIs (#26)
106 |
107 | **Bug fixes**
108 |
109 | - fix empty addrs bug (#12)
110 |
111 |
112 | ## [0.5](https://github.com/Datalux/Osintgram/releases/tag/0.5)
113 |
114 | **Enhancements**
115 |
116 | - added JSON export feature
117 |
118 | **Bug fixes**
119 |
120 | - Fix #2
121 |
122 | ## [0.4](https://github.com/Datalux/Osintgram/releases/tag/0.4)
123 |
124 | **Enhancements**
125 |
126 | - added `stories` command (#8)
127 | - added `target` command (#9)
128 |
129 | **Bug fixes**
130 |
131 | - added a check if the target has a private profile to avoid tool crash (#10)
132 | - fixed `tagged` bug (#5)
133 |
134 | ## [0.3](https://github.com/Datalux/Osintgram/releases/tag/0.3)
135 |
136 | **Enhancements**
137 |
138 | - added `photos` command
139 | - added `captions` command
140 | - added `mediatype` command
141 | - added `propic` command
142 |
143 | ## 0.2
144 |
145 | **Enhancements**
146 |
147 | - write in file the output of commands
148 |
149 | ## 0.1
150 |
151 | **Initial release**
152 |
153 |
154 |
--------------------------------------------------------------------------------
/doc/COMMANDS.md:
--------------------------------------------------------------------------------
1 | # Commands list and usage
2 | ```
3 | - addrs Get all registered addressed by target photos
4 | - captions Get user's photos captions
5 | - commentdata Get a list of all the comments on the target's posts
6 | - comments Get total comments of target's posts
7 | - followers Get target followers
8 | - followings Get users followed by target
9 | - fwersemail Get email of target followers
10 | - fwingsemail Get email of users followed by target
11 | - hashtags Get hashtags used by target
12 | - info Get target info
13 | - likes Get total likes of target's posts
14 | - mediatype Get user's posts type (photo or video)
15 | - photodes Get description of target's photos
16 | - photos Download user's photos in output folder
17 | - propic Download user's profile picture
18 | - stories Download user's stories
19 | - tagged Get list of users tagged by target
20 | - wcommented Get a list of user who commented target's photos
21 | - wtagged Get a list of user who tagged target
22 | ```
23 |
24 | ### addrs
25 | Return a list with address (GPS) tagged by target in his photos.
26 | The list has post, address and date fields.
27 |
28 | ### captions
29 | Return a list of all captions used by target in his photos.
30 |
31 | ### comments
32 | Return the total number of comments in target's posts
33 |
34 | ### exit
35 | Exit from Osintgram
36 |
37 | ### FILE
38 | Can set preference to save commands output in output folder. It save output in `_.txt` file.
39 |
40 | With `FILE=y` you can enable saving in file.
41 |
42 | With `FILE=n` you can disable saving in file.
43 |
44 | ### followers
45 | Return a list with target followers with id, nickname and full name
46 |
47 | ### followings
48 | Return a list with users followed by target with id, nickname and full name
49 |
50 | ### fwersemail
51 | Return a list of emails of target followers
52 |
53 | ### fwingsemail
54 | Return a list of emails of user followed by target
55 |
56 | ### fwersnumber
57 | Return a list of phone number of target followers
58 |
59 | ### fwingsnumber
60 | Return a list of phone number of user followed by target
61 |
62 | ### hashtags
63 | Return a list with all hashtag used by target in his photos
64 |
65 | ### info
66 | Show target info like:
67 | - id
68 | - full name
69 | - biography
70 | - followed
71 | - follow
72 | - is business account?
73 | - business category (if target has business account)
74 | - is verified?
75 | - business email (if available)
76 | - HD profile picture url
77 | - connected Facebook page (if available)
78 | - Whats'App number (if available)
79 | - City Name (if available)
80 | - Address Street (if available)
81 | - Contact phone number (if available)
82 |
83 | ### JSON
84 | Can set preference to export commands output as JSON in output folder. It save output in `_.JSON` file.
85 |
86 | With `JSON=y` you can enable JSON exporting.
87 |
88 | With `JSON=n` you can disable JSON exporting.
89 |
90 | ### likes
91 | Return the total number of likes in target's posts
92 |
93 | ### list (or help)
94 | Show all commands available.
95 |
96 | ### mediatype
97 | Return the number of photos and video shared by target
98 |
99 | ### photodes
100 | Return a list with the description of the content of target's photos
101 |
102 | ### photos
103 | Download all target's photos in output folder.
104 | When you run the command, script ask you how many photos you want to download.
105 | Type ENTER to download all photos available or type a number to choose how many photos you want download.
106 | ```
107 | Run a command: photos
108 | How many photos you want to download (default all):
109 | ```
110 |
111 | ### propic
112 | Download target profile picture (HD if is available)
113 |
114 | ### stories
115 | Download all target's stories in output folder.
116 |
117 | ## tagged
118 | Return a list of users tagged by target with ID, username and full name
119 |
120 | ## wcommented
121 | Return a list of users who commented target's photos sorted by number of comments
122 |
123 | ## wtagged
124 | Return a list of users who tagged target sorted by number of photos
125 |
126 |
127 |
--------------------------------------------------------------------------------
/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
--------------------------------------------------------------------------------
/docker_reqs.txt:
--------------------------------------------------------------------------------
1 | requests==2.24.0
2 | requests-toolbelt==0.9.1
3 | geopy>=2.0.0
4 | prettytable==0.7.2
5 | instagram-private-api==1.6.0
6 | gnureadline>=8.0.0
--------------------------------------------------------------------------------
/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 | is_windows = False
11 |
12 | try:
13 | import gnureadline
14 | except:
15 | is_windows = True
16 | import pyreadline
17 |
18 |
19 | def printlogo():
20 | pc.printout(artwork.ascii_art, pc.YELLOW)
21 | pc.printout("\nVersion 1.1 - Developed by Giuseppe Criscione\n\n", pc.YELLOW)
22 | pc.printout("Type 'list' to show all allowed commands\n")
23 | pc.printout("Type 'FILE=y' to save results to files like '_.txt (default is disabled)'\n")
24 | pc.printout("Type 'FILE=n' to disable saving to files'\n")
25 | pc.printout("Type 'JSON=y' to export results to a JSON files like '_.json (default is "
26 | "disabled)'\n")
27 | pc.printout("Type 'JSON=n' to disable exporting to files'\n")
28 |
29 |
30 | def cmdlist():
31 | pc.printout("FILE=y/n\t")
32 | print("Enable/disable output in a '_.txt' file'")
33 | pc.printout("JSON=y/n\t")
34 | print("Enable/disable export in a '_.json' file'")
35 | pc.printout("addrs\t\t")
36 | print("Get all registered addressed by target photos")
37 | pc.printout("cache\t\t")
38 | print("Clear cache of the tool")
39 | pc.printout("captions\t")
40 | print("Get target's photos captions")
41 | pc.printout("commentdata\t")
42 | print("Get a list of all the comments on the target's posts")
43 | pc.printout("comments\t")
44 | print("Get total comments of target's posts")
45 | pc.printout("followers\t")
46 | print("Get target followers")
47 | pc.printout("followings\t")
48 | print("Get users followed by target")
49 | pc.printout("fwersemail\t")
50 | print("Get email of target followers")
51 | pc.printout("fwingsemail\t")
52 | print("Get email of users followed by target")
53 | pc.printout("fwersnumber\t")
54 | print("Get phone number of target followers")
55 | pc.printout("fwingsnumber\t")
56 | print("Get phone number of users followed by target")
57 | pc.printout("hashtags\t")
58 | print("Get hashtags used by target")
59 | pc.printout("info\t\t")
60 | print("Get target info")
61 | pc.printout("likes\t\t")
62 | print("Get total likes of target's posts")
63 | pc.printout("mediatype\t")
64 | print("Get target's posts type (photo or video)")
65 | pc.printout("photodes\t")
66 | print("Get description of target's photos")
67 | pc.printout("photos\t\t")
68 | print("Download target's photos in output folder")
69 | pc.printout("propic\t\t")
70 | print("Download target's profile picture")
71 | pc.printout("stories\t\t")
72 | print("Download target's stories")
73 | pc.printout("tagged\t\t")
74 | print("Get list of users tagged by target")
75 | pc.printout("target\t\t")
76 | print("Set new target")
77 | pc.printout("wcommented\t")
78 | print("Get a list of user who commented target's photos")
79 | pc.printout("wtagged\t\t")
80 | print("Get a list of user who tagged target")
81 |
82 |
83 | def signal_handler(sig, frame):
84 | pc.printout("\nGoodbye!\n", pc.RED)
85 | sys.exit(0)
86 |
87 |
88 | def completer(text, state):
89 | options = [i for i in commands if i.startswith(text)]
90 | if state < len(options):
91 | return options[state]
92 | else:
93 | return None
94 |
95 | def _quit():
96 | pc.printout("Goodbye!\n", pc.RED)
97 | sys.exit(0)
98 |
99 |
100 | signal.signal(signal.SIGINT, signal_handler)
101 | if is_windows:
102 | pyreadline.Readline().parse_and_bind("tab: complete")
103 | pyreadline.Readline().set_completer(completer)
104 | else:
105 | gnureadline.parse_and_bind("tab: complete")
106 | gnureadline.set_completer(completer)
107 |
108 | parser = argparse.ArgumentParser(description='Osintgram is a OSINT tool on Instagram. It offers an interactive shell '
109 | 'to perform analysis on Instagram account of any users by its nickname ')
110 | parser.add_argument('id', type=str, # var = id
111 | help='username')
112 | parser.add_argument('-C','--cookies', help='clear\'s previous cookies', action="store_true")
113 | parser.add_argument('-j', '--json', help='save commands output as JSON file', action='store_true')
114 | parser.add_argument('-f', '--file', help='save output in a file', action='store_true')
115 | parser.add_argument('-c', '--command', help='run in single command mode & execute provided command', action='store')
116 | parser.add_argument('-o', '--output', help='where to store photos', action='store')
117 |
118 | args = parser.parse_args()
119 |
120 |
121 | api = Osintgram(args.id, args.file, args.json, args.command, args.output, args.cookies)
122 |
123 |
124 |
125 | commands = {
126 | 'list': cmdlist,
127 | 'help': cmdlist,
128 | 'quit': _quit,
129 | 'exit': _quit,
130 | 'addrs': api.get_addrs,
131 | 'cache': api.clear_cache,
132 | 'captions': api.get_captions,
133 | "commentdata": api.get_comment_data,
134 | 'comments': api.get_total_comments,
135 | 'followers': api.get_followers,
136 | 'followings': api.get_followings,
137 | 'fwersemail': api.get_fwersemail,
138 | 'fwingsemail': api.get_fwingsemail,
139 | 'fwersnumber': api.get_fwersnumber,
140 | 'fwingsnumber': api.get_fwingsnumber,
141 | 'hashtags': api.get_hashtags,
142 | 'info': api.get_user_info,
143 | 'likes': api.get_total_likes,
144 | 'mediatype': api.get_media_type,
145 | 'photodes': api.get_photo_description,
146 | 'photos': api.get_user_photo,
147 | 'propic': api.get_user_propic,
148 | 'stories': api.get_user_stories,
149 | 'tagged': api.get_people_tagged_by_user,
150 | 'target': api.change_target,
151 | 'wcommented': api.get_people_who_commented,
152 | 'wtagged': api.get_people_who_tagged
153 | }
154 |
155 |
156 | signal.signal(signal.SIGINT, signal_handler)
157 | if is_windows:
158 | pyreadline.Readline().parse_and_bind("tab: complete")
159 | pyreadline.Readline().set_completer(completer)
160 | else:
161 | gnureadline.parse_and_bind("tab: complete")
162 | gnureadline.set_completer(completer)
163 |
164 | if not args.command:
165 | printlogo()
166 |
167 |
168 | while True:
169 | if args.command:
170 | cmd = args.command
171 | _cmd = commands.get(args.command)
172 | else:
173 | signal.signal(signal.SIGINT, signal_handler)
174 | if is_windows:
175 | pyreadline.Readline().parse_and_bind("tab: complete")
176 | pyreadline.Readline().set_completer(completer)
177 | else:
178 | gnureadline.parse_and_bind("tab: complete")
179 | gnureadline.set_completer(completer)
180 | pc.printout("Run a command: ", pc.YELLOW)
181 | cmd = input()
182 |
183 | _cmd = commands.get(cmd)
184 |
185 | if _cmd:
186 | _cmd()
187 | elif cmd == "FILE=y":
188 | api.set_write_file(True)
189 | elif cmd == "FILE=n":
190 | api.set_write_file(False)
191 | elif cmd == "JSON=y":
192 | api.set_json_dump(True)
193 | elif cmd == "JSON=n":
194 | api.set_json_dump(False)
195 | elif cmd == "":
196 | print("")
197 | else:
198 | pc.printout("Unknown command\n", pc.RED)
199 |
200 | if args.command:
201 | break
202 |
--------------------------------------------------------------------------------
/output/dont_delete_this_folder.txt:
--------------------------------------------------------------------------------
1 | Please don't delete this folder.
--------------------------------------------------------------------------------
/requirements.txt:
--------------------------------------------------------------------------------
1 | requests==2.24.0
2 | requests-toolbelt==0.9.1
3 | geopy>=2.0.0
4 | prettytable==0.7.2
5 | instagram-private-api==1.6.0
6 | gnureadline>=8.0.0; platform_system != "Windows"
7 | pyreadline==2.1; platform_system == "Windows"
--------------------------------------------------------------------------------
/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 |
9 | import requests
10 | import ssl
11 | ssl._create_default_https_context = ssl._create_unverified_context
12 |
13 | from geopy.geocoders import Nominatim
14 | from instagram_private_api import Client as AppClient
15 | from instagram_private_api import ClientCookieExpiredError, ClientLoginRequiredError, ClientError, ClientThrottledError
16 |
17 | from prettytable import PrettyTable
18 |
19 | from src import printcolors as pc
20 | from src import config
21 |
22 |
23 | class Osintgram:
24 | api = None
25 | api2 = None
26 | geolocator = Nominatim(user_agent="http")
27 | user_id = None
28 | target_id = None
29 | is_private = True
30 | following = False
31 | target = ""
32 | writeFile = False
33 | jsonDump = False
34 | cli_mode = False
35 | output_dir = "output"
36 |
37 |
38 | def __init__(self, target, is_file, is_json, is_cli, output_dir, clear_cookies):
39 | self.output_dir = output_dir or self.output_dir
40 | Path(self.output_dir).mkdir(parents=True, exist_ok=True)
41 | u = config.getUsername()
42 | p = config.getPassword()
43 | self.clear_cookies(clear_cookies)
44 | self.cli_mode = is_cli
45 | if not is_cli:
46 | print("\nAttempt to login...")
47 | self.login(u, p)
48 | self.setTarget(target)
49 | self.writeFile = is_file
50 | self.jsonDump = is_json
51 |
52 | def clear_cookies(self,clear_cookies):
53 | if clear_cookies:
54 | self.clear_cache()
55 |
56 | def setTarget(self, target):
57 | self.target = target
58 | user = self.get_user(target)
59 | self.target_id = user['id']
60 | self.is_private = user['is_private']
61 | self.following = self.check_following()
62 | self.__printTargetBanner__()
63 |
64 | def __get_feed__(self):
65 | data = []
66 |
67 | result = self.api.user_feed(str(self.target_id))
68 | data.extend(result.get('items', []))
69 |
70 | next_max_id = result.get('next_max_id')
71 | while next_max_id:
72 | results = self.api.user_feed(str(self.target_id), max_id=next_max_id)
73 | data.extend(results.get('items', []))
74 | next_max_id = results.get('next_max_id')
75 |
76 | return data
77 |
78 | def __get_comments__(self, media_id):
79 | comments = []
80 |
81 | result = self.api.media_comments(str(media_id))
82 | comments.extend(result.get('comments', []))
83 |
84 | next_max_id = result.get('next_max_id')
85 | while next_max_id:
86 | results = self.api.media_comments(str(media_id), max_id=next_max_id)
87 | comments.extend(results.get('comments', []))
88 | next_max_id = results.get('next_max_id')
89 |
90 | return comments
91 |
92 | def __printTargetBanner__(self):
93 | pc.printout("\nLogged as ", pc.GREEN)
94 | pc.printout(self.api.username, pc.CYAN)
95 | pc.printout(". Target: ", pc.GREEN)
96 | pc.printout(str(self.target), pc.CYAN)
97 | pc.printout(" [" + str(self.target_id) + "]")
98 | if self.is_private:
99 | pc.printout(" [PRIVATE PROFILE]", pc.BLUE)
100 | if self.following:
101 | pc.printout(" [FOLLOWING]", pc.GREEN)
102 | else:
103 | pc.printout(" [NOT FOLLOWING]", pc.RED)
104 |
105 | print('\n')
106 |
107 | def change_target(self):
108 | pc.printout("Insert new target username: ", pc.YELLOW)
109 | line = input()
110 | self.setTarget(line)
111 | return
112 |
113 | def get_addrs(self):
114 | if self.check_private_profile():
115 | return
116 |
117 | pc.printout("Searching for target localizations...\n")
118 |
119 | data = self.__get_feed__()
120 |
121 | locations = {}
122 |
123 | for post in data:
124 | if 'location' in post and post['location'] is not None:
125 | if 'lat' in post['location'] and 'lng' in post['location']:
126 | lat = post['location']['lat']
127 | lng = post['location']['lng']
128 | locations[str(lat) + ', ' + str(lng)] = post.get('taken_at')
129 |
130 | address = {}
131 | for k, v in locations.items():
132 | details = self.geolocator.reverse(k)
133 | unix_timestamp = datetime.datetime.fromtimestamp(v)
134 | address[details.address] = unix_timestamp.strftime('%Y-%m-%d %H:%M:%S')
135 |
136 | sort_addresses = sorted(address.items(), key=lambda p: p[1], reverse=True)
137 |
138 | if len(sort_addresses) > 0:
139 | t = PrettyTable()
140 |
141 | t.field_names = ['Post', 'Address', 'time']
142 | t.align["Post"] = "l"
143 | t.align["Address"] = "l"
144 | t.align["Time"] = "l"
145 | pc.printout("\nWoohoo! We found " + str(len(sort_addresses)) + " addresses\n", pc.GREEN)
146 |
147 | i = 1
148 |
149 | json_data = {}
150 | addrs_list = []
151 |
152 | for address, time in sort_addresses:
153 | t.add_row([str(i), address, time])
154 |
155 | if self.jsonDump:
156 | addr = {
157 | 'address': address,
158 | 'time': time
159 | }
160 | addrs_list.append(addr)
161 |
162 | i = i + 1
163 |
164 | if self.writeFile:
165 | file_name = self.output_dir + "/" + self.target + "_addrs.txt"
166 | file = open(file_name, "w")
167 | file.write(str(t))
168 | file.close()
169 |
170 | if self.jsonDump:
171 | json_data['address'] = addrs_list
172 | json_file_name = self.output_dir + "/" + self.target + "_addrs.json"
173 | with open(json_file_name, 'w') as f:
174 | json.dump(json_data, f)
175 |
176 | print(t)
177 | else:
178 | pc.printout("Sorry! No results found :-(\n", pc.RED)
179 |
180 | def get_captions(self):
181 | if self.check_private_profile():
182 | return
183 |
184 | pc.printout("Searching for target captions...\n")
185 |
186 | captions = []
187 |
188 | data = self.__get_feed__()
189 | counter = 0
190 |
191 | try:
192 | for item in data:
193 | if "caption" in item:
194 | if item["caption"] is not None:
195 | text = item["caption"]["text"]
196 | captions.append(text)
197 | counter = counter + 1
198 | sys.stdout.write("\rFound %i" % counter)
199 | sys.stdout.flush()
200 |
201 | except AttributeError:
202 | pass
203 |
204 | except KeyError:
205 | pass
206 |
207 | json_data = {}
208 |
209 | if counter > 0:
210 | pc.printout("\nWoohoo! We found " + str(counter) + " captions\n", pc.GREEN)
211 |
212 | file = None
213 |
214 | if self.writeFile:
215 | file_name = self.output_dir + "/" + self.target + "_captions.txt"
216 | file = open(file_name, "w")
217 |
218 | for s in captions:
219 | print(s + "\n")
220 |
221 | if self.writeFile:
222 | file.write(s + "\n")
223 |
224 | if self.jsonDump:
225 | json_data['captions'] = captions
226 | json_file_name = self.output_dir + "/" + self.target + "_followings.json"
227 | with open(json_file_name, 'w') as f:
228 | json.dump(json_data, f)
229 |
230 | if file is not None:
231 | file.close()
232 |
233 | else:
234 | pc.printout("Sorry! No results found :-(\n", pc.RED)
235 |
236 | return
237 |
238 | def get_total_comments(self):
239 | if self.check_private_profile():
240 | return
241 |
242 | pc.printout("Searching for target total comments...\n")
243 |
244 | comments_counter = 0
245 | posts = 0
246 |
247 | data = self.__get_feed__()
248 |
249 | for post in data:
250 | comments_counter += post['comment_count']
251 | posts += 1
252 |
253 | if self.writeFile:
254 | file_name = self.output_dir + "/" + self.target + "_comments.txt"
255 | file = open(file_name, "w")
256 | file.write(str(comments_counter) + " comments in " + str(posts) + " posts\n")
257 | file.close()
258 |
259 | if self.jsonDump:
260 | json_data = {
261 | 'comment_counter': comments_counter,
262 | 'posts': posts
263 | }
264 | json_file_name = self.output_dir + "/" + self.target + "_comments.json"
265 | with open(json_file_name, 'w') as f:
266 | json.dump(json_data, f)
267 |
268 | pc.printout(str(comments_counter), pc.MAGENTA)
269 | pc.printout(" comments in " + str(posts) + " posts\n")
270 |
271 | def get_comment_data(self):
272 | if self.check_private_profile():
273 | return
274 |
275 | pc.printout("Retrieving all comments, this may take a moment...\n")
276 | data = self.__get_feed__()
277 |
278 | _comments = []
279 | t = PrettyTable(['POST ID', 'ID', 'Username', 'Comment'])
280 | t.align["POST ID"] = "l"
281 | t.align["ID"] = "l"
282 | t.align["Username"] = "l"
283 | t.align["Comment"] = "l"
284 |
285 | for post in data:
286 | post_id = post.get('id')
287 | comments = self.api.media_n_comments(post_id)
288 | for comment in comments:
289 | t.add_row([post_id, comment.get('user_id'), comment.get('user').get('username'), comment.get('text')])
290 | comment = {
291 | "post_id": post_id,
292 | "user_id":comment.get('user_id'),
293 | "username": comment.get('user').get('username'),
294 | "comment": comment.get('text')
295 | }
296 | _comments.append(comment)
297 |
298 | print(t)
299 | if self.writeFile:
300 | file_name = self.output_dir + "/" + self.target + "_comment_data.txt"
301 | with open(file_name, 'w') as f:
302 | f.write(str(t))
303 | f.close()
304 |
305 | if self.jsonDump:
306 | file_name_json = self.output_dir + "/" + self.target + "_comment_data.json"
307 | with open(file_name_json, 'w') as f:
308 | f.write("{ \"Comments\":[ \n")
309 | f.write('\n'.join(json.dumps(comment) for comment in _comments) + ',\n')
310 | f.write("]} ")
311 |
312 |
313 | def get_followers(self):
314 | if self.check_private_profile():
315 | return
316 |
317 | pc.printout("Searching for target followers...\n")
318 |
319 | _followers = []
320 | followers = []
321 |
322 |
323 | rank_token = AppClient.generate_uuid()
324 | data = self.api.user_followers(str(self.target_id), rank_token=rank_token)
325 |
326 | _followers.extend(data.get('users', []))
327 |
328 | next_max_id = data.get('next_max_id')
329 | while next_max_id:
330 | sys.stdout.write("\rCatched %i followers" % len(_followers))
331 | sys.stdout.flush()
332 | results = self.api.user_followers(str(self.target_id), rank_token=rank_token, max_id=next_max_id)
333 | _followers.extend(results.get('users', []))
334 | next_max_id = results.get('next_max_id')
335 |
336 | print("\n")
337 |
338 | for user in _followers:
339 | u = {
340 | 'id': user['pk'],
341 | 'username': user['username'],
342 | 'full_name': user['full_name']
343 | }
344 | followers.append(u)
345 |
346 | t = PrettyTable(['ID', 'Username', 'Full Name'])
347 | t.align["ID"] = "l"
348 | t.align["Username"] = "l"
349 | t.align["Full Name"] = "l"
350 |
351 | json_data = {}
352 | followings_list = []
353 |
354 | for node in followers:
355 | t.add_row([str(node['id']), node['username'], node['full_name']])
356 |
357 | if self.jsonDump:
358 | follow = {
359 | 'id': node['id'],
360 | 'username': node['username'],
361 | 'full_name': node['full_name']
362 | }
363 | followings_list.append(follow)
364 |
365 | if self.writeFile:
366 | file_name = self.output_dir + "/" + self.target + "_followers.txt"
367 | file = open(file_name, "w")
368 | file.write(str(t))
369 | file.close()
370 |
371 | if self.jsonDump:
372 | json_data['followers'] = followers
373 | json_file_name = self.output_dir + "/" + self.target + "_followers.json"
374 | with open(json_file_name, 'w') as f:
375 | json.dump(json_data, f)
376 |
377 | print(t)
378 |
379 | def get_followings(self):
380 | if self.check_private_profile():
381 | return
382 |
383 | pc.printout("Searching for target followings...\n")
384 |
385 | _followings = []
386 | followings = []
387 |
388 | rank_token = AppClient.generate_uuid()
389 | data = self.api.user_following(str(self.target_id), rank_token=rank_token)
390 |
391 | _followings.extend(data.get('users', []))
392 |
393 | next_max_id = data.get('next_max_id')
394 | while next_max_id:
395 | sys.stdout.write("\rCatched %i followings" % len(_followings))
396 | sys.stdout.flush()
397 | results = self.api.user_following(str(self.target_id), rank_token=rank_token, max_id=next_max_id)
398 | _followings.extend(results.get('users', []))
399 | next_max_id = results.get('next_max_id')
400 |
401 | print("\n")
402 |
403 | for user in _followings:
404 | u = {
405 | 'id': user['pk'],
406 | 'username': user['username'],
407 | 'full_name': user['full_name']
408 | }
409 | followings.append(u)
410 |
411 | t = PrettyTable(['ID', 'Username', 'Full Name'])
412 | t.align["ID"] = "l"
413 | t.align["Username"] = "l"
414 | t.align["Full Name"] = "l"
415 |
416 | json_data = {}
417 | followings_list = []
418 |
419 | for node in followings:
420 | t.add_row([str(node['id']), node['username'], node['full_name']])
421 |
422 | if self.jsonDump:
423 | follow = {
424 | 'id': node['id'],
425 | 'username': node['username'],
426 | 'full_name': node['full_name']
427 | }
428 | followings_list.append(follow)
429 |
430 | if self.writeFile:
431 | file_name = self.output_dir + "/" + self.target + "_followings.txt"
432 | file = open(file_name, "w")
433 | file.write(str(t))
434 | file.close()
435 |
436 | if self.jsonDump:
437 | json_data['followings'] = followings_list
438 | json_file_name = self.output_dir + "/" + self.target + "_followings.json"
439 | with open(json_file_name, 'w') as f:
440 | json.dump(json_data, f)
441 |
442 | print(t)
443 |
444 | def get_hashtags(self):
445 | if self.check_private_profile():
446 | return
447 |
448 | pc.printout("Searching for target hashtags...\n")
449 |
450 | hashtags = []
451 | counter = 1
452 | texts = []
453 |
454 | data = self.api.user_feed(str(self.target_id))
455 | texts.extend(data.get('items', []))
456 |
457 | next_max_id = data.get('next_max_id')
458 | while next_max_id:
459 | results = self.api.user_feed(str(self.target_id), max_id=next_max_id)
460 | texts.extend(results.get('items', []))
461 | next_max_id = results.get('next_max_id')
462 |
463 | for post in texts:
464 | if post['caption'] is not None:
465 | caption = post['caption']['text']
466 | for s in caption.split():
467 | if s.startswith('#'):
468 | hashtags.append(s.encode('UTF-8'))
469 | counter += 1
470 |
471 | if len(hashtags) > 0:
472 | hashtag_counter = {}
473 |
474 | for i in hashtags:
475 | if i in hashtag_counter:
476 | hashtag_counter[i] += 1
477 | else:
478 | hashtag_counter[i] = 1
479 |
480 | ssort = sorted(hashtag_counter.items(), key=lambda value: value[1], reverse=True)
481 |
482 | file = None
483 | json_data = {}
484 | hashtags_list = []
485 |
486 | if self.writeFile:
487 | file_name = self.output_dir + "/" + self.target + "_hashtags.txt"
488 | file = open(file_name, "w")
489 |
490 | for k, v in ssort:
491 | hashtag = str(k.decode('utf-8'))
492 | print(str(v) + ". " + hashtag)
493 | if self.writeFile:
494 | file.write(str(v) + ". " + hashtag + "\n")
495 | if self.jsonDump:
496 | hashtags_list.append(hashtag)
497 |
498 | if file is not None:
499 | file.close()
500 |
501 | if self.jsonDump:
502 | json_data['hashtags'] = hashtags_list
503 | json_file_name = self.output_dir + "/" + self.target + "_hashtags.json"
504 | with open(json_file_name, 'w') as f:
505 | json.dump(json_data, f)
506 | else:
507 | pc.printout("Sorry! No results found :-(\n", pc.RED)
508 |
509 | def get_user_info(self):
510 | try:
511 | endpoint = 'users/{user_id!s}/full_detail_info/'.format(**{'user_id': self.target_id})
512 | content = self.api._call_api(endpoint)
513 |
514 | data = content['user_detail']['user']
515 |
516 | pc.printout("[ID] ", pc.GREEN)
517 | pc.printout(str(data['pk']) + '\n')
518 | pc.printout("[FULL NAME] ", pc.RED)
519 | pc.printout(str(data['full_name']) + '\n')
520 | pc.printout("[BIOGRAPHY] ", pc.CYAN)
521 | pc.printout(str(data['biography']) + '\n')
522 | pc.printout("[FOLLOWED] ", pc.BLUE)
523 | pc.printout(str(data['follower_count']) + '\n')
524 | pc.printout("[FOLLOW] ", pc.GREEN)
525 | pc.printout(str(data['following_count']) + '\n')
526 | pc.printout("[BUSINESS ACCOUNT] ", pc.RED)
527 | pc.printout(str(data['is_business']) + '\n')
528 | if data['is_business']:
529 | if not data['can_hide_category']:
530 | pc.printout("[BUSINESS CATEGORY] ")
531 | pc.printout(str(data['category']) + '\n')
532 | pc.printout("[VERIFIED ACCOUNT] ", pc.CYAN)
533 | pc.printout(str(data['is_verified']) + '\n')
534 | if 'public_email' in data and data['public_email']:
535 | pc.printout("[EMAIL] ", pc.BLUE)
536 | pc.printout(str(data['public_email']) + '\n')
537 | pc.printout("[HD PROFILE PIC] ", pc.GREEN)
538 | pc.printout(str(data['hd_profile_pic_url_info']['url']) + '\n')
539 | if 'fb_page_call_to_action_id' in data and data['fb_page_call_to_action_id']:
540 | pc.printout("[FB PAGE] ", pc.RED)
541 | pc.printout(str(data['connected_fb_page']) + '\n')
542 | if 'whatsapp_number' in data and data['whatsapp_number']:
543 | pc.printout("[WHATSAPP NUMBER] ", pc.GREEN)
544 | pc.printout(str(data['whatsapp_number']) + '\n')
545 | if 'city_name' in data and data['city_name']:
546 | pc.printout("[CITY] ", pc.YELLOW)
547 | pc.printout(str(data['city_name']) + '\n')
548 | if 'address_street' in data and data['address_street']:
549 | pc.printout("[ADDRESS STREET] ", pc.RED)
550 | pc.printout(str(data['address_street']) + '\n')
551 | if 'contact_phone_number' in data and data['contact_phone_number']:
552 | pc.printout("[CONTACT PHONE NUMBER] ", pc.CYAN)
553 | pc.printout(str(data['contact_phone_number']) + '\n')
554 |
555 | if self.jsonDump:
556 | user = {
557 | 'id': data['pk'],
558 | 'full_name': data['full_name'],
559 | 'biography': data['biography'],
560 | 'edge_followed_by': data['follower_count'],
561 | 'edge_follow': data['following_count'],
562 | 'is_business_account': data['is_business'],
563 | 'is_verified': data['is_verified'],
564 | 'profile_pic_url_hd': data['hd_profile_pic_url_info']['url']
565 | }
566 | if 'public_email' in data and data['public_email']:
567 | user['email'] = data['public_email']
568 | if 'fb_page_call_to_action_id' in data and data['fb_page_call_to_action_id']:
569 | user['connected_fb_page'] = data['fb_page_call_to_action_id']
570 | if 'whatsapp_number' in data and data['whatsapp_number']:
571 | user['whatsapp_number'] = data['whatsapp_number']
572 | if 'city_name' in data and data['city_name']:
573 | user['city_name'] = data['city_name']
574 | if 'address_street' in data and data['address_street']:
575 | user['address_street'] = data['address_street']
576 | if 'contact_phone_number' in data and data['contact_phone_number']:
577 | user['contact_phone_number'] = data['contact_phone_number']
578 |
579 | json_file_name = self.output_dir + "/" + self.target + "_info.json"
580 | with open(json_file_name, 'w') as f:
581 | json.dump(user, f)
582 |
583 | except ClientError as e:
584 | print(e)
585 | pc.printout("Oops... " + str(self.target) + " non exist, please enter a valid username.", pc.RED)
586 | pc.printout("\n")
587 | exit(2)
588 |
589 | def get_total_likes(self):
590 | if self.check_private_profile():
591 | return
592 |
593 | pc.printout("Searching for target total likes...\n")
594 |
595 | like_counter = 0
596 | posts = 0
597 |
598 | data = self.__get_feed__()
599 |
600 | for post in data:
601 | like_counter += post['like_count']
602 | posts += 1
603 |
604 | if self.writeFile:
605 | file_name = self.output_dir + "/" + self.target + "_likes.txt"
606 | file = open(file_name, "w")
607 | file.write(str(like_counter) + " likes in " + str(like_counter) + " posts\n")
608 | file.close()
609 |
610 | if self.jsonDump:
611 | json_data = {
612 | 'like_counter': like_counter,
613 | 'posts': like_counter
614 | }
615 | json_file_name = self.output_dir + "/" + self.target + "_likes.json"
616 | with open(json_file_name, 'w') as f:
617 | json.dump(json_data, f)
618 |
619 | pc.printout(str(like_counter), pc.MAGENTA)
620 | pc.printout(" likes in " + str(posts) + " posts\n")
621 |
622 | def get_media_type(self):
623 | if self.check_private_profile():
624 | return
625 |
626 | pc.printout("Searching for target captions...\n")
627 |
628 | counter = 0
629 | photo_counter = 0
630 | video_counter = 0
631 |
632 | data = self.__get_feed__()
633 |
634 | for post in data:
635 | if "media_type" in post:
636 | if post["media_type"] == 1:
637 | photo_counter = photo_counter + 1
638 | elif post["media_type"] == 2:
639 | video_counter = video_counter + 1
640 | counter = counter + 1
641 | sys.stdout.write("\rChecked %i" % counter)
642 | sys.stdout.flush()
643 |
644 | sys.stdout.write(" posts")
645 | sys.stdout.flush()
646 |
647 | if counter > 0:
648 |
649 | if self.writeFile:
650 | file_name = self.output_dir + "/" + self.target + "_mediatype.txt"
651 | file = open(file_name, "w")
652 | file.write(str(photo_counter) + " photos and " + str(video_counter) + " video posted by target\n")
653 | file.close()
654 |
655 | pc.printout("\nWoohoo! We found " + str(photo_counter) + " photos and " + str(video_counter) +
656 | " video posted by target\n", pc.GREEN)
657 |
658 | if self.jsonDump:
659 | json_data = {
660 | "photos": photo_counter,
661 | "videos": video_counter
662 | }
663 | json_file_name = self.output_dir + "/" + self.target + "_mediatype.json"
664 | with open(json_file_name, 'w') as f:
665 | json.dump(json_data, f)
666 |
667 | else:
668 | pc.printout("Sorry! No results found :-(\n", pc.RED)
669 |
670 | def get_people_who_commented(self):
671 | if self.check_private_profile():
672 | return
673 |
674 | pc.printout("Searching for users who commented...\n")
675 |
676 | data = self.__get_feed__()
677 | users = []
678 |
679 | for post in data:
680 | comments = self.__get_comments__(post['id'])
681 | for comment in comments:
682 | if not any(u['id'] == comment['user']['pk'] for u in users):
683 | user = {
684 | 'id': comment['user']['pk'],
685 | 'username': comment['user']['username'],
686 | 'full_name': comment['user']['full_name'],
687 | 'counter': 1
688 | }
689 | users.append(user)
690 | else:
691 | for user in users:
692 | if user['id'] == comment['user']['pk']:
693 | user['counter'] += 1
694 | break
695 |
696 | if len(users) > 0:
697 | ssort = sorted(users, key=lambda value: value['counter'], reverse=True)
698 |
699 | json_data = {}
700 |
701 | t = PrettyTable()
702 |
703 | t.field_names = ['Comments', 'ID', 'Username', 'Full Name']
704 | t.align["Comments"] = "l"
705 | t.align["ID"] = "l"
706 | t.align["Username"] = "l"
707 | t.align["Full Name"] = "l"
708 |
709 | for u in ssort:
710 | t.add_row([str(u['counter']), u['id'], u['username'], u['full_name']])
711 |
712 | print(t)
713 |
714 | if self.writeFile:
715 | file_name = self.output_dir + "/" + self.target + "_users_who_commented.txt"
716 | file = open(file_name, "w")
717 | file.write(str(t))
718 | file.close()
719 |
720 | if self.jsonDump:
721 | json_data['users_who_commented'] = ssort
722 | json_file_name = self.output_dir + "/" + self.target + "_users_who_commented.json"
723 | with open(json_file_name, 'w') as f:
724 | json.dump(json_data, f)
725 | else:
726 | pc.printout("Sorry! No results found :-(\n", pc.RED)
727 |
728 | def get_people_who_tagged(self):
729 | if self.check_private_profile():
730 | return
731 |
732 | pc.printout("Searching for users who tagged target...\n")
733 |
734 | posts = []
735 |
736 | result = self.api.usertag_feed(self.target_id)
737 | posts.extend(result.get('items', []))
738 |
739 | next_max_id = result.get('next_max_id')
740 | while next_max_id:
741 | results = self.api.user_feed(str(self.target_id), max_id=next_max_id)
742 | posts.extend(results.get('items', []))
743 | next_max_id = results.get('next_max_id')
744 |
745 | if len(posts) > 0:
746 | pc.printout("\nWoohoo! We found " + str(len(posts)) + " photos\n", pc.GREEN)
747 |
748 | users = []
749 |
750 | for post in posts:
751 | if not any(u['id'] == post['user']['pk'] for u in users):
752 | user = {
753 | 'id': post['user']['pk'],
754 | 'username': post['user']['username'],
755 | 'full_name': post['user']['full_name'],
756 | 'counter': 1
757 | }
758 | users.append(user)
759 | else:
760 | for user in users:
761 | if user['id'] == post['user']['pk']:
762 | user['counter'] += 1
763 | break
764 |
765 | ssort = sorted(users, key=lambda value: value['counter'], reverse=True)
766 |
767 | json_data = {}
768 |
769 | t = PrettyTable()
770 |
771 | t.field_names = ['Photos', 'ID', 'Username', 'Full Name']
772 | t.align["Photos"] = "l"
773 | t.align["ID"] = "l"
774 | t.align["Username"] = "l"
775 | t.align["Full Name"] = "l"
776 |
777 | for u in ssort:
778 | t.add_row([str(u['counter']), u['id'], u['username'], u['full_name']])
779 |
780 | print(t)
781 |
782 | if self.writeFile:
783 | file_name = self.output_dir + "/" + self.target + "_users_who_tagged.txt"
784 | file = open(file_name, "w")
785 | file.write(str(t))
786 | file.close()
787 |
788 | if self.jsonDump:
789 | json_data['users_who_tagged'] = ssort
790 | json_file_name = self.output_dir + "/" + self.target + "_users_who_tagged.json"
791 | with open(json_file_name, 'w') as f:
792 | json.dump(json_data, f)
793 | else:
794 | pc.printout("Sorry! No results found :-(\n", pc.RED)
795 |
796 | def get_photo_description(self):
797 | if self.check_private_profile():
798 | return
799 |
800 | content = requests.get("https://www.instagram.com/" + str(self.target) + "/?__a=1")
801 | data = content.json()
802 |
803 | dd = data['graphql']['user']['edge_owner_to_timeline_media']['edges']
804 |
805 | if len(dd) > 0:
806 | pc.printout("\nWoohoo! We found " + str(len(dd)) + " descriptions\n", pc.GREEN)
807 |
808 | count = 1
809 |
810 | t = PrettyTable(['Photo', 'Description'])
811 | t.align["Photo"] = "l"
812 | t.align["Description"] = "l"
813 |
814 | json_data = {}
815 | descriptions_list = []
816 |
817 | for i in dd:
818 | node = i.get('node')
819 | descr = node.get('accessibility_caption')
820 | t.add_row([str(count), descr])
821 |
822 | if self.jsonDump:
823 | description = {
824 | 'description': descr
825 | }
826 | descriptions_list.append(description)
827 |
828 | count += 1
829 |
830 | if self.writeFile:
831 | file_name = self.output_dir + "/" + self.target + "_photodes.txt"
832 | file = open(file_name, "w")
833 | file.write(str(t))
834 | file.close()
835 |
836 | if self.jsonDump:
837 | json_data['descriptions'] = descriptions_list
838 | json_file_name = self.output_dir + "/" + self.target + "_descriptions.json"
839 | with open(json_file_name, 'w') as f:
840 | json.dump(json_data, f)
841 |
842 | print(t)
843 | else:
844 | pc.printout("Sorry! No results found :-(\n", pc.RED)
845 |
846 | def get_user_photo(self):
847 | if self.check_private_profile():
848 | return
849 |
850 | limit = -1
851 | if self.cli_mode:
852 | user_input = ""
853 | else:
854 | pc.printout("How many photos you want to download (default all): ", pc.YELLOW)
855 | user_input = input()
856 |
857 | try:
858 | if user_input == "":
859 | pc.printout("Downloading all photos available...\n")
860 | else:
861 | limit = int(user_input)
862 | pc.printout("Downloading " + user_input + " photos...\n")
863 |
864 | except ValueError:
865 | pc.printout("Wrong value entered\n", pc.RED)
866 | return
867 |
868 | data = []
869 | counter = 0
870 |
871 | result = self.api.user_feed(str(self.target_id))
872 | data.extend(result.get('items', []))
873 |
874 | next_max_id = result.get('next_max_id')
875 | while next_max_id:
876 | results = self.api.user_feed(str(self.target_id), max_id=next_max_id)
877 | data.extend(results.get('items', []))
878 | next_max_id = results.get('next_max_id')
879 |
880 | try:
881 | for item in data:
882 | if counter == limit:
883 | break
884 | if "image_versions2" in item:
885 | counter = counter + 1
886 | url = item["image_versions2"]["candidates"][0]["url"]
887 | photo_id = item["id"]
888 | end = self.output_dir + "/" + self.target + "_" + photo_id + ".jpg"
889 | urllib.request.urlretrieve(url, end)
890 | sys.stdout.write("\rDownloaded %i" % counter)
891 | sys.stdout.flush()
892 | else:
893 | carousel = item["carousel_media"]
894 | for i in carousel:
895 | if counter == limit:
896 | break
897 | counter = counter + 1
898 | url = i["image_versions2"]["candidates"][0]["url"]
899 | photo_id = i["id"]
900 | end = self.output_dir + "/" + self.target + "_" + photo_id + ".jpg"
901 | urllib.request.urlretrieve(url, end)
902 | sys.stdout.write("\rDownloaded %i" % counter)
903 | sys.stdout.flush()
904 |
905 | except AttributeError:
906 | pass
907 |
908 | except KeyError:
909 | pass
910 |
911 | sys.stdout.write(" photos")
912 | sys.stdout.flush()
913 |
914 | pc.printout("\nWoohoo! We downloaded " + str(counter) + " photos (saved in " + self.output_dir + " folder) \n", pc.GREEN)
915 |
916 | def get_user_propic(self):
917 |
918 | try:
919 | endpoint = 'users/{user_id!s}/full_detail_info/'.format(**{'user_id': self.target_id})
920 | content = self.api._call_api(endpoint)
921 |
922 | data = content['user_detail']['user']
923 |
924 | if "hd_profile_pic_url_info" in data:
925 | URL = data["hd_profile_pic_url_info"]['url']
926 | else:
927 | #get better quality photo
928 | items = len(data['hd_profile_pic_versions'])
929 | URL = data["hd_profile_pic_versions"][items-1]['url']
930 |
931 | if URL != "":
932 | end = self.output_dir + "/" + self.target + "_propic.jpg"
933 | urllib.request.urlretrieve(URL, end)
934 | pc.printout("Target propic saved in output folder\n", pc.GREEN)
935 |
936 | else:
937 | pc.printout("Sorry! No results found :-(\n", pc.RED)
938 |
939 | except ClientError as e:
940 | error = json.loads(e.error_response)
941 | print(error['message'])
942 | print(error['error_title'])
943 | exit(2)
944 |
945 | def get_user_stories(self):
946 | if self.check_private_profile():
947 | return
948 |
949 | pc.printout("Searching for target stories...\n")
950 |
951 | data = self.api.user_reel_media(str(self.target_id))
952 |
953 | counter = 0
954 |
955 | if data['items'] is not None: # no stories avaibile
956 | counter = data['media_count']
957 | for i in data['items']:
958 | story_id = i["id"]
959 | if i["media_type"] == 1: # it's a photo
960 | url = i['image_versions2']['candidates'][0]['url']
961 | end = self.output_dir + "/" + self.target + "_" + story_id + ".jpg"
962 | urllib.request.urlretrieve(url, end)
963 |
964 | elif i["media_type"] == 2: # it's a gif or video
965 | url = i['video_versions'][0]['url']
966 | end = self.output_dir + "/" + self.target + "_" + story_id + ".mp4"
967 | urllib.request.urlretrieve(url, end)
968 |
969 | if counter > 0:
970 | pc.printout(str(counter) + " target stories saved in output folder\n", pc.GREEN)
971 | else:
972 | pc.printout("Sorry! No results found :-(\n", pc.RED)
973 |
974 | def get_people_tagged_by_user(self):
975 | pc.printout("Searching for users tagged by target...\n")
976 |
977 | ids = []
978 | username = []
979 | full_name = []
980 | post = []
981 | counter = 1
982 |
983 | data = self.__get_feed__()
984 |
985 | try:
986 | for i in data:
987 | if "usertags" in i:
988 | c = i.get('usertags').get('in')
989 | for cc in c:
990 | if cc.get('user').get('pk') not in ids:
991 | ids.append(cc.get('user').get('pk'))
992 | username.append(cc.get('user').get('username'))
993 | full_name.append(cc.get('user').get('full_name'))
994 | post.append(1)
995 | else:
996 | index = ids.index(cc.get('user').get('pk'))
997 | post[index] += 1
998 | counter = counter + 1
999 | except AttributeError as ae:
1000 | pc.printout("\nERROR: an error occurred: ", pc.RED)
1001 | print(ae)
1002 | print("")
1003 | pass
1004 |
1005 | if len(ids) > 0:
1006 | t = PrettyTable()
1007 |
1008 | t.field_names = ['Posts', 'Full Name', 'Username', 'ID']
1009 | t.align["Posts"] = "l"
1010 | t.align["Full Name"] = "l"
1011 | t.align["Username"] = "l"
1012 | t.align["ID"] = "l"
1013 |
1014 | pc.printout("\nWoohoo! We found " + str(len(ids)) + " (" + str(counter) + ") users\n", pc.GREEN)
1015 |
1016 | json_data = {}
1017 | tagged_list = []
1018 |
1019 | for i in range(len(ids)):
1020 | t.add_row([post[i], full_name[i], username[i], str(ids[i])])
1021 |
1022 | if self.jsonDump:
1023 | tag = {
1024 | 'post': post[i],
1025 | 'full_name': full_name[i],
1026 | 'username': username[i],
1027 | 'id': ids[i]
1028 | }
1029 | tagged_list.append(tag)
1030 |
1031 | if self.writeFile:
1032 | file_name = self.output_dir + "/" + self.target + "_tagged.txt"
1033 | file = open(file_name, "w")
1034 | file.write(str(t))
1035 | file.close()
1036 |
1037 | if self.jsonDump:
1038 | json_data['tagged'] = tagged_list
1039 | json_file_name = self.output_dir + "/" + self.target + "_tagged.json"
1040 | with open(json_file_name, 'w') as f:
1041 | json.dump(json_data, f)
1042 |
1043 | print(t)
1044 | else:
1045 | pc.printout("Sorry! No results found :-(\n", pc.RED)
1046 |
1047 | def get_user(self, username):
1048 | try:
1049 | content = self.api.username_info(username)
1050 | if self.writeFile:
1051 | file_name = self.output_dir + "/" + self.target + "_user_id.txt"
1052 | file = open(file_name, "w")
1053 | file.write(str(content['user']['pk']))
1054 | file.close()
1055 |
1056 | user = dict()
1057 | user['id'] = content['user']['pk']
1058 | user['is_private'] = content['user']['is_private']
1059 |
1060 | return user
1061 | except ClientError as e:
1062 | pc.printout('ClientError {0!s} (Code: {1:d}, Response: {2!s})'.format(e.msg, e.code, e.error_response), pc.RED)
1063 | error = json.loads(e.error_response)
1064 | if 'message' in error:
1065 | print(error['message'])
1066 | if 'error_title' in error:
1067 | print(error['error_title'])
1068 | if 'challenge' in error:
1069 | print("Please follow this link to complete the challenge: " + error['challenge']['url'])
1070 | sys.exit(2)
1071 |
1072 |
1073 | def set_write_file(self, flag):
1074 | if flag:
1075 | pc.printout("Write to file: ")
1076 | pc.printout("enabled", pc.GREEN)
1077 | pc.printout("\n")
1078 | else:
1079 | pc.printout("Write to file: ")
1080 | pc.printout("disabled", pc.RED)
1081 | pc.printout("\n")
1082 |
1083 | self.writeFile = flag
1084 |
1085 | def set_json_dump(self, flag):
1086 | if flag:
1087 | pc.printout("Export to JSON: ")
1088 | pc.printout("enabled", pc.GREEN)
1089 | pc.printout("\n")
1090 | else:
1091 | pc.printout("Export to JSON: ")
1092 | pc.printout("disabled", pc.RED)
1093 | pc.printout("\n")
1094 |
1095 | self.jsonDump = flag
1096 |
1097 | def login(self, u, p):
1098 | try:
1099 | settings_file = "config/settings.json"
1100 | if not os.path.isfile(settings_file):
1101 | # settings file does not exist
1102 | print(f'Unable to find file: {settings_file!s}')
1103 |
1104 | # login new
1105 | self.api = AppClient(auto_patch=True, authenticate=True, username=u, password=p,
1106 | on_login=lambda x: self.onlogin_callback(x, settings_file))
1107 |
1108 | else:
1109 | with open(settings_file) as file_data:
1110 | cached_settings = json.load(file_data, object_hook=self.from_json)
1111 | # print('Reusing settings: {0!s}'.format(settings_file))
1112 |
1113 | # reuse auth settings
1114 | self.api = AppClient(
1115 | username=u, password=p,
1116 | settings=cached_settings,
1117 | on_login=lambda x: self.onlogin_callback(x, settings_file))
1118 |
1119 | except (ClientCookieExpiredError, ClientLoginRequiredError) as e:
1120 | print(f'ClientCookieExpiredError/ClientLoginRequiredError: {e!s}')
1121 |
1122 | # Login expired
1123 | # Do relogin but use default ua, keys and such
1124 | self.api = AppClient(auto_patch=True, authenticate=True, username=u, password=p,
1125 | on_login=lambda x: self.onlogin_callback(x, settings_file))
1126 |
1127 | except ClientError as e:
1128 | pc.printout('ClientError {0!s} (Code: {1:d}, Response: {2!s})'.format(e.msg, e.code, e.error_response), pc.RED)
1129 | error = json.loads(e.error_response)
1130 | pc.printout(error['message'], pc.RED)
1131 | pc.printout(": ", pc.RED)
1132 | pc.printout(e.msg, pc.RED)
1133 | pc.printout("\n")
1134 | if 'challenge' in error:
1135 | print("Please follow this link to complete the challenge: " + error['challenge']['url'])
1136 | exit(9)
1137 |
1138 | def to_json(self, python_object):
1139 | if isinstance(python_object, bytes):
1140 | return {'__class__': 'bytes',
1141 | '__value__': codecs.encode(python_object, 'base64').decode()}
1142 | raise TypeError(repr(python_object) + ' is not JSON serializable')
1143 |
1144 | def from_json(self, json_object):
1145 | if '__class__' in json_object and json_object['__class__'] == 'bytes':
1146 | return codecs.decode(json_object['__value__'].encode(), 'base64')
1147 | return json_object
1148 |
1149 | def onlogin_callback(self, api, new_settings_file):
1150 | cache_settings = api.settings
1151 | with open(new_settings_file, 'w') as outfile:
1152 | json.dump(cache_settings, outfile, default=self.to_json)
1153 | # print('SAVED: {0!s}'.format(new_settings_file))
1154 |
1155 | def check_following(self):
1156 | if str(self.target_id) == self.api.authenticated_user_id:
1157 | return True
1158 | endpoint = 'users/{user_id!s}/full_detail_info/'.format(**{'user_id': self.target_id})
1159 | return self.api._call_api(endpoint)['user_detail']['user']['friendship_status']['following']
1160 |
1161 | def check_private_profile(self):
1162 | if self.is_private and not self.following:
1163 | pc.printout("Impossible to execute command: user has private profile\n", pc.RED)
1164 | send = input("Do you want send a follow request? [Y/N]: ")
1165 | if send.lower() == "y":
1166 | self.api.friendships_create(self.target_id)
1167 | print("Sent a follow request to target. Use this command after target accepting the request.")
1168 |
1169 | return True
1170 | return False
1171 |
1172 | def get_fwersemail(self):
1173 | if self.check_private_profile():
1174 | return
1175 |
1176 | followers = []
1177 |
1178 | try:
1179 |
1180 | pc.printout("Searching for emails of target followers... this can take a few minutes\n")
1181 |
1182 | rank_token = AppClient.generate_uuid()
1183 | data = self.api.user_followers(str(self.target_id), rank_token=rank_token)
1184 |
1185 | for user in data.get('users', []):
1186 | u = {
1187 | 'id': user['pk'],
1188 | 'username': user['username'],
1189 | 'full_name': user['full_name']
1190 | }
1191 | followers.append(u)
1192 |
1193 | next_max_id = data.get('next_max_id')
1194 | while next_max_id:
1195 | sys.stdout.write("\rCatched %i followers email" % len(followers))
1196 | sys.stdout.flush()
1197 | results = self.api.user_followers(str(self.target_id), rank_token=rank_token, max_id=next_max_id)
1198 |
1199 | for user in results.get('users', []):
1200 | u = {
1201 | 'id': user['pk'],
1202 | 'username': user['username'],
1203 | 'full_name': user['full_name']
1204 | }
1205 | followers.append(u)
1206 |
1207 | next_max_id = results.get('next_max_id')
1208 |
1209 | print("\n")
1210 |
1211 | results = []
1212 |
1213 | pc.printout("Do you want to get all emails? y/n: ", pc.YELLOW)
1214 | value = input()
1215 |
1216 | if value == str("y") or value == str("yes") or value == str("Yes") or value == str("YES"):
1217 | value = len(followers)
1218 | elif value == str(""):
1219 | print("\n")
1220 | return
1221 | elif value == str("n") or value == str("no") or value == str("No") or value == str("NO"):
1222 | while True:
1223 | try:
1224 | pc.printout("How many emails do you want to get? ", pc.YELLOW)
1225 | new_value = int(input())
1226 | value = new_value - 1
1227 | break
1228 | except ValueError:
1229 | pc.printout("Error! Please enter a valid integer!", pc.RED)
1230 | print("\n")
1231 | return
1232 | else:
1233 | pc.printout("Error! Please enter y/n :-)", pc.RED)
1234 | print("\n")
1235 | return
1236 |
1237 | for follow in followers:
1238 | user = self.api.user_info(str(follow['id']))
1239 | if 'public_email' in user['user'] and user['user']['public_email']:
1240 | follow['email'] = user['user']['public_email']
1241 | if len(results) > value:
1242 | break
1243 | results.append(follow)
1244 |
1245 | except ClientThrottledError as e:
1246 | pc.printout("\nError: Instagram blocked the requests. Please wait a few minutes before you try again.", pc.RED)
1247 | pc.printout("\n")
1248 |
1249 | if len(results) > 0:
1250 |
1251 | t = PrettyTable(['ID', 'Username', 'Full Name', 'Email'])
1252 | t.align["ID"] = "l"
1253 | t.align["Username"] = "l"
1254 | t.align["Full Name"] = "l"
1255 | t.align["Email"] = "l"
1256 |
1257 | json_data = {}
1258 |
1259 | for node in results:
1260 | t.add_row([str(node['id']), node['username'], node['full_name'], node['email']])
1261 |
1262 | if self.writeFile:
1263 | file_name = self.output_dir + "/" + self.target + "_fwersemail.txt"
1264 | file = open(file_name, "w")
1265 | file.write(str(t))
1266 | file.close()
1267 |
1268 | if self.jsonDump:
1269 | json_data['followers_email'] = results
1270 | json_file_name = self.output_dir + "/" + self.target + "_fwersemail.json"
1271 | with open(json_file_name, 'w') as f:
1272 | json.dump(json_data, f)
1273 |
1274 | print(t)
1275 | else:
1276 | pc.printout("Sorry! No results found :-(\n", pc.RED)
1277 |
1278 | def get_fwingsemail(self):
1279 | if self.check_private_profile():
1280 | return
1281 |
1282 | followings = []
1283 |
1284 | try:
1285 |
1286 | pc.printout("Searching for emails of users followed by target... this can take a few minutes\n")
1287 |
1288 | rank_token = AppClient.generate_uuid()
1289 | data = self.api.user_following(str(self.target_id), rank_token=rank_token)
1290 |
1291 | for user in data.get('users', []):
1292 | u = {
1293 | 'id': user['pk'],
1294 | 'username': user['username'],
1295 | 'full_name': user['full_name']
1296 | }
1297 | followings.append(u)
1298 |
1299 | next_max_id = data.get('next_max_id')
1300 |
1301 | while next_max_id:
1302 | results = self.api.user_following(str(self.target_id), rank_token=rank_token, max_id=next_max_id)
1303 |
1304 | for user in results.get('users', []):
1305 | u = {
1306 | 'id': user['pk'],
1307 | 'username': user['username'],
1308 | 'full_name': user['full_name']
1309 | }
1310 | followings.append(u)
1311 |
1312 | next_max_id = results.get('next_max_id')
1313 |
1314 | results = []
1315 |
1316 | pc.printout("Do you want to get all emails? y/n: ", pc.YELLOW)
1317 | value = input()
1318 |
1319 | if value == str("y") or value == str("yes") or value == str("Yes") or value == str("YES"):
1320 | value = len(followings)
1321 | elif value == str(""):
1322 | print("\n")
1323 | return
1324 | elif value == str("n") or value == str("no") or value == str("No") or value == str("NO"):
1325 | while True:
1326 | try:
1327 | pc.printout("How many emails do you want to get? ", pc.YELLOW)
1328 | new_value = int(input())
1329 | value = new_value - 1
1330 | break
1331 | except ValueError:
1332 | pc.printout("Error! Please enter a valid integer!", pc.RED)
1333 | print("\n")
1334 | return
1335 | else:
1336 | pc.printout("Error! Please enter y/n :-)", pc.RED)
1337 | print("\n")
1338 | return
1339 |
1340 | for follow in followings:
1341 | sys.stdout.write("\rCatched %i followings email" % len(results))
1342 | sys.stdout.flush()
1343 | user = self.api.user_info(str(follow['id']))
1344 | if 'public_email' in user['user'] and user['user']['public_email']:
1345 | follow['email'] = user['user']['public_email']
1346 | if len(results) > value:
1347 | break
1348 | results.append(follow)
1349 |
1350 | except ClientThrottledError as e:
1351 | pc.printout("\nError: Instagram blocked the requests. Please wait a few minutes before you try again.", pc.RED)
1352 | pc.printout("\n")
1353 |
1354 | print("\n")
1355 |
1356 | if len(results) > 0:
1357 | t = PrettyTable(['ID', 'Username', 'Full Name', 'Email'])
1358 | t.align["ID"] = "l"
1359 | t.align["Username"] = "l"
1360 | t.align["Full Name"] = "l"
1361 | t.align["Email"] = "l"
1362 |
1363 | json_data = {}
1364 |
1365 | for node in results:
1366 | t.add_row([str(node['id']), node['username'], node['full_name'], node['email']])
1367 |
1368 | if self.writeFile:
1369 | file_name = self.output_dir + "/" + self.target + "_fwingsemail.txt"
1370 | file = open(file_name, "w")
1371 | file.write(str(t))
1372 | file.close()
1373 |
1374 | if self.jsonDump:
1375 | json_data['followings_email'] = results
1376 | json_file_name = self.output_dir + "/" + self.target + "_fwingsemail.json"
1377 | with open(json_file_name, 'w') as f:
1378 | json.dump(json_data, f)
1379 |
1380 | print(t)
1381 | else:
1382 | pc.printout("Sorry! No results found :-(\n", pc.RED)
1383 |
1384 | def get_fwingsnumber(self):
1385 | if self.check_private_profile():
1386 | return
1387 |
1388 | try:
1389 |
1390 | pc.printout("Searching for phone numbers of users followed by target... this can take a few minutes\n")
1391 |
1392 | followings = []
1393 |
1394 | rank_token = AppClient.generate_uuid()
1395 | data = self.api.user_following(str(self.target_id), rank_token=rank_token)
1396 |
1397 | for user in data.get('users', []):
1398 | u = {
1399 | 'id': user['pk'],
1400 | 'username': user['username'],
1401 | 'full_name': user['full_name']
1402 | }
1403 | followings.append(u)
1404 |
1405 | next_max_id = data.get('next_max_id')
1406 |
1407 | while next_max_id:
1408 | results = self.api.user_following(str(self.target_id), rank_token=rank_token, max_id=next_max_id)
1409 |
1410 | for user in results.get('users', []):
1411 | u = {
1412 | 'id': user['pk'],
1413 | 'username': user['username'],
1414 | 'full_name': user['full_name']
1415 | }
1416 | followings.append(u)
1417 |
1418 | next_max_id = results.get('next_max_id')
1419 |
1420 | results = []
1421 |
1422 | pc.printout("Do you want to get all phone numbers? y/n: ", pc.YELLOW)
1423 | value = input()
1424 |
1425 | if value == str("y") or value == str("yes") or value == str("Yes") or value == str("YES"):
1426 | value = len(followings)
1427 | elif value == str(""):
1428 | print("\n")
1429 | return
1430 | elif value == str("n") or value == str("no") or value == str("No") or value == str("NO"):
1431 | while True:
1432 | try:
1433 | pc.printout("How many phone numbers do you want to get? ", pc.YELLOW)
1434 | new_value = int(input())
1435 | value = new_value - 1
1436 | break
1437 | except ValueError:
1438 | pc.printout("Error! Please enter a valid integer!", pc.RED)
1439 | print("\n")
1440 | return
1441 | else:
1442 | pc.printout("Error! Please enter y/n :-)", pc.RED)
1443 | print("\n")
1444 | return
1445 |
1446 | for follow in followings:
1447 | sys.stdout.write("\rCatched %i followings phone numbers" % len(results))
1448 | sys.stdout.flush()
1449 | user = self.api.user_info(str(follow['id']))
1450 | if 'contact_phone_number' in user['user'] and user['user']['contact_phone_number']:
1451 | follow['contact_phone_number'] = user['user']['contact_phone_number']
1452 | if len(results) > value:
1453 | break
1454 | results.append(follow)
1455 |
1456 | except ClientThrottledError as e:
1457 | pc.printout("\nError: Instagram blocked the requests. Please wait a few minutes before you try again.", pc.RED)
1458 | pc.printout("\n")
1459 |
1460 | print("\n")
1461 |
1462 | if len(results) > 0:
1463 | t = PrettyTable(['ID', 'Username', 'Full Name', 'Phone'])
1464 | t.align["ID"] = "l"
1465 | t.align["Username"] = "l"
1466 | t.align["Full Name"] = "l"
1467 | t.align["Phone number"] = "l"
1468 |
1469 | json_data = {}
1470 |
1471 | for node in results:
1472 | t.add_row([str(node['id']), node['username'], node['full_name'], node['contact_phone_number']])
1473 |
1474 | if self.writeFile:
1475 | file_name = self.output_dir + "/" + self.target + "_fwingsnumber.txt"
1476 | file = open(file_name, "w")
1477 | file.write(str(t))
1478 | file.close()
1479 |
1480 | if self.jsonDump:
1481 | json_data['followings_phone_numbers'] = results
1482 | json_file_name = self.output_dir + "/" + self.target + "_fwingsnumber.json"
1483 | with open(json_file_name, 'w') as f:
1484 | json.dump(json_data, f)
1485 |
1486 | print(t)
1487 | else:
1488 | pc.printout("Sorry! No results found :-(\n", pc.RED)
1489 |
1490 | def get_fwersnumber(self):
1491 | if self.check_private_profile():
1492 | return
1493 |
1494 | followings = []
1495 |
1496 | try:
1497 |
1498 | pc.printout("Searching for phone numbers of users followers... this can take a few minutes\n")
1499 |
1500 |
1501 | rank_token = AppClient.generate_uuid()
1502 | data = self.api.user_following(str(self.target_id), rank_token=rank_token)
1503 |
1504 | for user in data.get('users', []):
1505 | u = {
1506 | 'id': user['pk'],
1507 | 'username': user['username'],
1508 | 'full_name': user['full_name']
1509 | }
1510 | followings.append(u)
1511 |
1512 | next_max_id = data.get('next_max_id')
1513 |
1514 | while next_max_id:
1515 | results = self.api.user_following(str(self.target_id), rank_token=rank_token, max_id=next_max_id)
1516 |
1517 | for user in results.get('users', []):
1518 | u = {
1519 | 'id': user['pk'],
1520 | 'username': user['username'],
1521 | 'full_name': user['full_name']
1522 | }
1523 | followings.append(u)
1524 |
1525 | next_max_id = results.get('next_max_id')
1526 |
1527 | results = []
1528 |
1529 | pc.printout("Do you want to get all phone numbers? y/n: ", pc.YELLOW)
1530 | value = input()
1531 |
1532 | if value == str("y") or value == str("yes") or value == str("Yes") or value == str("YES"):
1533 | value = len(followings)
1534 | elif value == str(""):
1535 | print("\n")
1536 | return
1537 | elif value == str("n") or value == str("no") or value == str("No") or value == str("NO"):
1538 | while True:
1539 | try:
1540 | pc.printout("How many phone numbers do you want to get? ", pc.YELLOW)
1541 | new_value = int(input())
1542 | value = new_value - 1
1543 | break
1544 | except ValueError:
1545 | pc.printout("Error! Please enter a valid integer!", pc.RED)
1546 | print("\n")
1547 | return
1548 | else:
1549 | pc.printout("Error! Please enter y/n :-)", pc.RED)
1550 | print("\n")
1551 | return
1552 |
1553 | for follow in followings:
1554 | sys.stdout.write("\rCatched %i followers phone numbers" % len(results))
1555 | sys.stdout.flush()
1556 | user = self.api.user_info(str(follow['id']))
1557 | if 'contact_phone_number' in user['user'] and user['user']['contact_phone_number']:
1558 | follow['contact_phone_number'] = user['user']['contact_phone_number']
1559 | if len(results) > value:
1560 | break
1561 | results.append(follow)
1562 |
1563 | except ClientThrottledError as e:
1564 | pc.printout("\nError: Instagram blocked the requests. Please wait a few minutes before you try again.", pc.RED)
1565 | pc.printout("\n")
1566 |
1567 | print("\n")
1568 |
1569 | if len(results) > 0:
1570 | t = PrettyTable(['ID', 'Username', 'Full Name', 'Phone'])
1571 | t.align["ID"] = "l"
1572 | t.align["Username"] = "l"
1573 | t.align["Full Name"] = "l"
1574 | t.align["Phone number"] = "l"
1575 |
1576 | json_data = {}
1577 |
1578 | for node in results:
1579 | t.add_row([str(node['id']), node['username'], node['full_name'], node['contact_phone_number']])
1580 |
1581 | if self.writeFile:
1582 | file_name = self.output_dir + "/" + self.target + "_fwersnumber.txt"
1583 | file = open(file_name, "w")
1584 | file.write(str(t))
1585 | file.close()
1586 |
1587 | if self.jsonDump:
1588 | json_data['followings_phone_numbers'] = results
1589 | json_file_name = self.output_dir + "/" + self.target + "_fwerssnumber.json"
1590 | with open(json_file_name, 'w') as f:
1591 | json.dump(json_data, f)
1592 |
1593 | print(t)
1594 | else:
1595 | pc.printout("Sorry! No results found :-(\n", pc.RED)
1596 |
1597 | def get_comments(self):
1598 | if self.check_private_profile():
1599 | return
1600 |
1601 | pc.printout("Searching for users who commented...\n")
1602 |
1603 | data = self.__get_feed__()
1604 | users = []
1605 |
1606 | for post in data:
1607 | comments = self.__get_comments__(post['id'])
1608 | for comment in comments:
1609 | print(comment['text'])
1610 |
1611 | # if not any(u['id'] == comment['user']['pk'] for u in users):
1612 | # user = {
1613 | # 'id': comment['user']['pk'],
1614 | # 'username': comment['user']['username'],
1615 | # 'full_name': comment['user']['full_name'],
1616 | # 'counter': 1
1617 | # }
1618 | # users.append(user)
1619 | # else:
1620 | # for user in users:
1621 | # if user['id'] == comment['user']['pk']:
1622 | # user['counter'] += 1
1623 | # break
1624 |
1625 | if len(users) > 0:
1626 | ssort = sorted(users, key=lambda value: value['counter'], reverse=True)
1627 |
1628 | json_data = {}
1629 |
1630 | t = PrettyTable()
1631 |
1632 | t.field_names = ['Comments', 'ID', 'Username', 'Full Name']
1633 | t.align["Comments"] = "l"
1634 | t.align["ID"] = "l"
1635 | t.align["Username"] = "l"
1636 | t.align["Full Name"] = "l"
1637 |
1638 | for u in ssort:
1639 | t.add_row([str(u['counter']), u['id'], u['username'], u['full_name']])
1640 |
1641 | print(t)
1642 |
1643 | if self.writeFile:
1644 | file_name = self.output_dir + "/" + self.target + "_users_who_commented.txt"
1645 | file = open(file_name, "w")
1646 | file.write(str(t))
1647 | file.close()
1648 |
1649 | if self.jsonDump:
1650 | json_data['users_who_commented'] = ssort
1651 | json_file_name = self.output_dir + "/" + self.target + "_users_who_commented.json"
1652 | with open(json_file_name, 'w') as f:
1653 | json.dump(json_data, f)
1654 | else:
1655 | pc.printout("Sorry! No results found :-(\n", pc.RED)
1656 |
1657 | def clear_cache(self):
1658 | try:
1659 | f = open("config/settings.json",'w')
1660 | f.write("{}")
1661 | pc.printout("Cache Cleared.\n",pc.GREEN)
1662 | except FileNotFoundError:
1663 | pc.printout("Settings.json don't exist.\n",pc.RED)
1664 | finally:
1665 | f.close()
1666 |
--------------------------------------------------------------------------------
/src/artwork.py:
--------------------------------------------------------------------------------
1 | ascii_art = r"""
2 | ________ .__ __
3 | \_____ \ _____|__| _____/ |_ ________________ _____
4 | / | \ / ___/ |/ \ __\/ ___\_ __ \__ \ / \
5 | / | \\___ \| | | \ | / /_/ > | \// __ \| Y Y \
6 | \_______ /____ >__|___| /__| \___ /|__| (____ /__|_| /
7 | \/ \/ \/ /_____/ \/ \/
8 | """
9 |
--------------------------------------------------------------------------------
/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 |
--------------------------------------------------------------------------------
/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 |
--------------------------------------------------------------------------------