-
-
Notifications
You must be signed in to change notification settings - Fork 49
Solved issue #607 - Allow to query for passwords in CowrieSession API #611
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Solved issue #607 - Allow to query for passwords in CowrieSession API #611
Conversation
* adjusted dependabot config * Bump library/nginx from 1.21.1-alpine to 1.23.4-alpine in /docker (intelowlproject#118) Bumps library/nginx from 1.21.1-alpine to 1.23.4-alpine. --- updated-dependencies: - dependency-name: library/nginx dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <[email protected]> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * Update drf-spectacular requirement in /requirements (intelowlproject#119) Updates the requirements on [drf-spectacular](https://github.com/tfranzel/drf-spectacular) to permit the latest version. - [Release notes](https://github.com/tfranzel/drf-spectacular/releases) - [Changelog](https://github.com/tfranzel/drf-spectacular/blob/master/CHANGELOG.rst) - [Commits](tfranzel/drf-spectacular@0.22.0...0.26.1) --- updated-dependencies: - dependency-name: drf-spectacular dependency-type: direct:production ... Signed-off-by: dependabot[bot] <[email protected]> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * added twitter publish * Update certego-saas requirement from ~=0.2.0 to ~=0.5.0 in /requirements (intelowlproject#124) Updates the requirements on [certego-saas](https://github.com/certego/certego-saas) to permit the latest version. - [Release notes](https://github.com/certego/certego-saas/releases) - [Commits](certego/certego-saas@0.2.0...0.5.0) --- updated-dependencies: - dependency-name: certego-saas dependency-type: direct:production ... Signed-off-by: dependabot[bot] <[email protected]> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * Bump myst-parser from 0.17.0 to 1.0.0 in /requirements (intelowlproject#120) Bumps [myst-parser](https://github.com/executablebooks/MyST-Parser) from 0.17.0 to 1.0.0. - [Release notes](https://github.com/executablebooks/MyST-Parser/releases) - [Changelog](https://github.com/executablebooks/MyST-Parser/blob/master/CHANGELOG.md) - [Commits](executablebooks/MyST-Parser@v0.17.0...v1.0.0) --- updated-dependencies: - dependency-name: myst-parser dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] <[email protected]> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * added healthchecks * fixed nginx location * added back uwsgi and uwsgitop * added stag override * uwsgi adjustments * adjusted uwsgi path and removed healthcheck for celery * fixed uwsgi installation in alpine --------- Signed-off-by: dependabot[bot] <[email protected]> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
* adjusted messages for the registration (intelowlproject#184) * adjusted messages * runned prettier --------- Co-authored-by: Martina Carella <[email protected]> * added recaptcha on login page (intelowlproject#185) * adjusted messages * runned prettier * added recaptcha on login page * adjusted tests * adjusted docs --------- Co-authored-by: Matteo Lodi <[email protected]> * updated dependencies * Bump celery from 5.3.0 to 5.3.1 in /requirements (intelowlproject#192) Bumps [celery](https://github.com/celery/celery) from 5.3.0 to 5.3.1. - [Release notes](https://github.com/celery/celery/releases) - [Changelog](https://github.com/celery/celery/blob/main/Changelog.rst) - [Commits](celery/celery@v5.3.0...v5.3.1) --- updated-dependencies: - dependency-name: celery dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] <[email protected]> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * Bump library/nginx from 1.25.0-alpine to 1.25.1-alpine in /docker (intelowlproject#193) Bumps library/nginx from 1.25.0-alpine to 1.25.1-alpine. --- updated-dependencies: - dependency-name: library/nginx dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] <[email protected]> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * Bump django from 4.1.9 to 4.1.10 in /requirements (intelowlproject#200) Bumps [django](https://github.com/django/django) from 4.1.9 to 4.1.10. - [Commits](django/django@4.1.9...4.1.10) --- updated-dependencies: - dependency-name: django dependency-type: direct:production ... Signed-off-by: dependabot[bot] <[email protected]> Co-authored-by: Matteo Lodi <[email protected]> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * Bump uwsgi from 2.0.21 to 2.0.22 in /requirements (intelowlproject#217) Bumps [uwsgi](https://github.com/unbit/uwsgi-docs) from 2.0.21 to 2.0.22. - [Commits](https://github.com/unbit/uwsgi-docs/commits) --- updated-dependencies: - dependency-name: uwsgi dependency-type: direct:production ... Signed-off-by: dependabot[bot] <[email protected]> Co-authored-by: Matteo Lodi <[email protected]> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * Bump library/nginx from 1.25.1-alpine to 1.25.2-alpine in /docker (intelowlproject#216) Bumps library/nginx from 1.25.1-alpine to 1.25.2-alpine. --- updated-dependencies: - dependency-name: library/nginx dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] <[email protected]> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * Bump certego-saas from 0.6.0 to 0.7.0 in /requirements (intelowlproject#213) Bumps [certego-saas](https://github.com/certego/certego-saas) from 0.6.0 to 0.7.0. - [Release notes](https://github.com/certego/certego-saas/releases) - [Commits](certego/certego-saas@0.6.0...0.7.0) --- updated-dependencies: - dependency-name: certego-saas dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <[email protected]> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * tweak * Bump psycopg2-binary from 2.9.6 to 2.9.7 in /requirements (intelowlproject#212) Bumps [psycopg2-binary](https://github.com/psycopg/psycopg2) from 2.9.6 to 2.9.7. - [Changelog](https://github.com/psycopg/psycopg2/blob/master/NEWS) - [Commits](psycopg/psycopg2@2.9.6...2.9.7) --- updated-dependencies: - dependency-name: psycopg2-binary dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] <[email protected]> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * updated read the docs * Moved * Squashed '.github/' content from commit 492bd6d git-subtree-dir: .github git-subtree-split: 492bd6d16d1620011d5ed428d5325538ee83f6ad * merge * Bump django from 4.1.10 to 4.1.11 in /requirements (intelowlproject#219) Bumps [django](https://github.com/django/django) from 4.1.10 to 4.1.11. - [Commits](django/django@4.1.10...4.1.11) --- updated-dependencies: - dependency-name: django dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] <[email protected]> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * Bump celery from 5.3.1 to 5.3.4 in /requirements (intelowlproject#220) Bumps [celery](https://github.com/celery/celery) from 5.3.1 to 5.3.4. - [Release notes](https://github.com/celery/celery/releases) - [Changelog](https://github.com/celery/celery/blob/main/Changelog.rst) - [Commits](celery/celery@v5.3.1...v5.3.4) --- updated-dependencies: - dependency-name: celery dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] <[email protected]> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * Django admin autologin (intelowlproject#222) * django admin auto login * bump alpine from 3.14 to 3.18 in dockerfile --------- Signed-off-by: dependabot[bot] <[email protected]> Co-authored-by: Martina Carella <[email protected]> Co-authored-by: Daniele Rosetti <[email protected]> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: 0ssigeno <[email protected]> Co-authored-by: Martina Carella <[email protected]>
Bumps [axios](https://github.com/axios/axios) from 0.27.2 to 0.28.0. - [Release notes](https://github.com/axios/axios/releases) - [Changelog](https://github.com/axios/axios/blob/v0.28.0/CHANGELOG.md) - [Commits](axios/axios@v0.27.2...v0.28.0) --- updated-dependencies: - dependency-name: axios dependency-type: direct:production ... Signed-off-by: dependabot[bot] <[email protected]> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
…t#270)" (intelowlproject#286) This reverts commit 080321e.
* Command sequences. Closes intelowlproject#457 (intelowlproject#468) * add CommandSequence model * add CommandSequence model to admin page * make migration file * add unique constraint to commands hash in CommandSequence model * add extraction of command sequences * add tests * add clustering task for command sequences * limit single command length during extraction * add tests for clustering * add 10 second delay to extraction jobs (will hopefully fix intelowlproject#451) * removed twitter publish cause not working * Deliver scores in Feeds API (intelowlproject#473) * add scores to serializer * fix docstring * add scores to required fields in deeds_response function * adapt tests * fix constant assignments (see intelowlproject#469) * make pending migration * skip empty IP address fields when extracting attacker data fixes intelowlproject#475 * Advanced feeds integration (intelowlproject#476) * Rename "age" to "prioritize" in backend code and add new prioritization mechanisms * Rename "age" to "prioritize" in frontend code * fix tests * adapt frontend tests * Bump numpy from 2.2.2 to 2.2.3 in /requirements (intelowlproject#465) Bumps [numpy](https://github.com/numpy/numpy) from 2.2.2 to 2.2.3. - [Release notes](https://github.com/numpy/numpy/releases) - [Changelog](https://github.com/numpy/numpy/blob/main/doc/RELEASE_WALKTHROUGH.rst) - [Commits](numpy/numpy@v2.2.2...v2.2.3) --- updated-dependencies: - dependency-name: numpy dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] <[email protected]> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * bump --------- Signed-off-by: dependabot[bot] <[email protected]> Co-authored-by: tim <[email protected]> Co-authored-by: tim <[email protected]> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
* Bump joblib from 1.5.0 to 1.5.1 in /requirements (intelowlproject#515) Bumps [joblib](https://github.com/joblib/joblib) from 1.5.0 to 1.5.1. - [Release notes](https://github.com/joblib/joblib/releases) - [Changelog](https://github.com/joblib/joblib/blob/main/CHANGES.rst) - [Commits](joblib/joblib@1.5.0...1.5.1) --- updated-dependencies: - dependency-name: joblib dependency-version: 1.5.1 dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] <[email protected]> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * bump 1.6.3 and removed support for ARM builds --------- Signed-off-by: dependabot[bot] <[email protected]> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Matteo Lodi <[email protected]>
* Include mass scanners in advanced API by default. Closes intelowlproject#580 (intelowlproject#581) * Partly revert "added mass scanner exclusion as default" This reverts commit f953887. * adapt tests * add "tor exit nodes" to default excludes * add test case for tor exit node inclusion * add test case for tor exit node inclusion (ii) * fix syntax * rename method * Upgrade Django to 5.2. Closes intelowlproject#502 (intelowlproject#579) * bump django-rest-email-auth * bump django to 5.2 * bump postgres to 18 (this requires manual manual intervention when upgrading GreedyBear) * Link to admin interface for staff users. Closes intelowlproject#529 (intelowlproject#582) * remove restriction to only show link to superusers * fix indentation * bump 2.0.0 * adapt CI
adjusting commit history
…elowlproject#595) Bumps the pip group with 1 update in the /requirements directory: [django](https://github.com/django/django). Updates `django` from 5.2.7 to 5.2.8 - [Commits](django/django@5.2.7...5.2.8) --- updated-dependencies: - dependency-name: django dependency-version: 5.2.8 dependency-type: direct:production dependency-group: pip ... Signed-off-by: dependabot[bot] <[email protected]> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
|
| GitGuardian id | GitGuardian status | Secret | Commit | Filename | |
|---|---|---|---|---|---|
| 20141940 | Triggered | Username Password | 127d67a | tests/authentication/test_auth.py | View secret |
🛠 Guidelines to remediate hardcoded secrets
- Understand the implications of revoking this secret by investigating where it is used in your code.
- Replace and store your secret safely. Learn here the best practices.
- Revoke and rotate this secret.
- If possible, rewrite git history. Rewriting git history is not a trivial act. You might completely break other contributing developers' workflow and you risk accidentally deleting legitimate data.
To avoid such incidents in the future consider
- following these best practices for managing and storing secrets including API keys and other credentials
- install secret detection on pre-commit to catch secret before it leaves your machine and ease remediation.
🦉 GitGuardian detects secrets in your source code to help developers and security teams secure the modern development process. You are seeing this because you or someone else with access to this repository has authorized GitGuardian to scan your pull request.
| else: | ||
| return HttpResponseBadRequest("Query must be a valid IP address or SHA-256 hash") | ||
| if len(observable) == 64: | ||
| if not is_sha256hash(observable): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
At this point we are sure that observable is no sha256 hash, because we already tested it in line 83, right? So no need to check it again.
| if not is_ip_address(observable): | ||
| return HttpResponseBadRequest("Query must be a valid IP address or SHA-256 hash") | ||
|
|
||
| if any(char in observable for char in ["<", ">", "}", "{"]): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do you exclude those characters? And why do you exclude "."? There might be passwords containing these characters.
| operations = [ | ||
| migrations.AddIndex( | ||
| model_name="cowriesession", | ||
| index=GinIndex( | ||
| fields=["credentials"], | ||
| name="greedybear_credentials_gin_idx", | ||
| ), | ||
| ), | ||
| ] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why did you manually make a migration instead of adding the index to models.py?
| with connection.cursor() as cursor: | ||
| cursor.execute( | ||
| """ | ||
| SELECT session_id | ||
| FROM greedybear_cowriesession | ||
| WHERE duration > 0 | ||
| AND EXISTS ( | ||
| SELECT 1 | ||
| FROM unnest(credentials) AS cred | ||
| WHERE cred LIKE %s | ||
| ) | ||
| """, | ||
| [password_pattern], | ||
| ) | ||
| session_ids = [row[0] for row in cursor.fetchall()] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please do not execute raw SQL code on the database. Django has an excellent object-relational mapper for querying the database. Use it.
| return HttpResponseBadRequest("Query must be a valid IP address or SHA-256 hash") | ||
|
|
||
| if "." in observable: | ||
| if not is_ip_address(observable): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same: at this point we already know it is not an IP address (checked in line 78).
|
Hey @IshaanXCoder ! Thank you for your contribution. :) I looked at your code and made a few comments. I really don't think we should use raw SQL in this project. You have to change it in order to get this PR merged. |
|
Are you still working on this PR, @IshaanXCoder ? |
|
Yes I'm interested to continue my work on this, right now i'm working on anotehr issue, will be back on this right after completing the current one. sorry for the delay. |
|
No problem, take your time. Just wanted to make sure you're still interested. |
|
Heyy @regulartim i've made the required changes, to solve the issue of this "full history of the main branch", i'm closing this PR and creating a new PR if that's okay? |
|
yep, feel free to close and reopen a clean PR |
|
Closing this PR, the clean version is #641 |
Solved #607
Description
This PR adds the ability to query CowrieSession API by password, in addition to the existing IP address and SHA-256 hash query methods.
Changes Made
Added password query support to
/api/cowrie_sessionendpoint:" | {password}"in the credentials array fieldAdded GIN index on
CowrieSession.credentialsfield:0023_add_gin_index_credentials.pycreates a GIN index for efficient array searchesAdded input validation:
Tested the functions i added:
test_password_query: Valid password query returns correct resultstest_password_query_not_found: Non-existent password returns 404test_password_query_with_session_data: Password query with session data includedType of change
Checklist
develop. (Please verify this is correct)cowrie_session_view)Black,Flake,Isort) gave 0 errors. If you have correctly installed pre-commit, it does these checks and adjustments on your behalf.