From f84f20186b3c6a32d58150db9c31c85896b50e5d Mon Sep 17 00:00:00 2001 From: QU35T-code Date: Wed, 12 Jun 2024 20:55:04 +0200 Subject: [PATCH 01/37] chore: Add default golang application --- .github/CODEOWNERS | 1 + .github/ISSUE_TEMPLATE/bug_report.md | 24 + .github/ISSUE_TEMPLATE/feature-request.md | 20 + .github/PULL_REQUEST_TEMPLATE.md | 27 + .github/workflows/go.yml | 38 ++ .github/workflows/golangci-lint.yml | 36 ++ .github/workflows/release.yml | 32 + .gitignore | 2 + CODE_OF_CONDUCT.md | 128 ++++ CONTRIBUTING.md | 1 + LICENSE | 674 ---------------------- README.md | 20 +- SECURITY.md | 6 + cmd/root.go | 51 ++ go.mod | 9 + go.sum | 10 + golangci.yml | 46 ++ main.go | 7 + 18 files changed, 457 insertions(+), 675 deletions(-) create mode 100644 .github/CODEOWNERS create mode 100644 .github/ISSUE_TEMPLATE/bug_report.md create mode 100644 .github/ISSUE_TEMPLATE/feature-request.md create mode 100644 .github/PULL_REQUEST_TEMPLATE.md create mode 100644 .github/workflows/go.yml create mode 100644 .github/workflows/golangci-lint.yml create mode 100644 .github/workflows/release.yml create mode 100644 CODE_OF_CONDUCT.md create mode 100644 CONTRIBUTING.md create mode 100644 SECURITY.md create mode 100644 cmd/root.go create mode 100644 go.mod create mode 100644 go.sum create mode 100644 golangci.yml create mode 100644 main.go diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS new file mode 100644 index 0000000..07d11cc --- /dev/null +++ b/.github/CODEOWNERS @@ -0,0 +1 @@ +QU35T-code \ No newline at end of file diff --git a/.github/ISSUE_TEMPLATE/bug_report.md b/.github/ISSUE_TEMPLATE/bug_report.md new file mode 100644 index 0000000..f607833 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/bug_report.md @@ -0,0 +1,24 @@ +--- +name: Bug report +about: Create a report to help us improve +title: "[BUG] " +labels: bug +assignees: QU35T-code + +--- + +**Describe the bug** +A clear and concise description of what the bug is. + +**To Reproduce** +Steps to reproduce the behavior: +1. Go to '...' +2. Click on '....' +3. Scroll down to '....' +4. See error + +**Expected behavior** +A clear and concise description of what you expected to happen. + +**Screenshots** +If applicable, add screenshots to help explain your problem. diff --git a/.github/ISSUE_TEMPLATE/feature-request.md b/.github/ISSUE_TEMPLATE/feature-request.md new file mode 100644 index 0000000..c815649 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/feature-request.md @@ -0,0 +1,20 @@ +--- +name: Feature Request +about: "For feature requests. Please search for existing issues first." +title: "[FEAT] <title>" +labels: feat +assignees: QU35T-code + +--- + +**Is your feature request related to a problem? Please describe.** +A clear and concise description of what the problem is. Ex. I'm always frustrated when [...] + +**Describe the solution you'd like** +A clear and concise description of what you want to happen. + +**Describe alternatives you've considered** +A clear and concise description of any alternative solutions or features you've considered. + +**Additional context** +Add any other context or screenshots about the feature request here. diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md new file mode 100644 index 0000000..dc709e9 --- /dev/null +++ b/.github/PULL_REQUEST_TEMPLATE.md @@ -0,0 +1,27 @@ +# Description + +Please include a summary of the changes and the related issue. Please also include relevant motivation and context. List any dependencies that are required for this change. + +Fixes # (issue) + +## Type of change + +Please delete options that are not relevant. + +- [ ] Bug fix +- [ ] New feature +- [ ] This change requires a documentation update + +# How Has This Been Tested? + +Please describe the tests that you ran to verify your changes. Provide instructions so we can reproduce. Please also list any relevant details for your test configuration + +- [ ] Test A +- [ ] Test B + +# Checklist: + +- [ ] My code follows the style guidelines of this project +- [ ] I have performed a self-review of my code +- [ ] I have commented my code, particularly in hard-to-understand areas +- [ ] My changes generate no new warnings \ No newline at end of file diff --git a/.github/workflows/go.yml b/.github/workflows/go.yml new file mode 100644 index 0000000..aec8ccf --- /dev/null +++ b/.github/workflows/go.yml @@ -0,0 +1,38 @@ +name: Go + +on: + push: + branches: [ "main", "dev" ] + pull_request: + branches: [ "main", "dev" ] + types: [opened, synchronize, reopened, ready_for_review] + +permissions: + contents: write + +jobs: + + build: + if: github.event_name != 'pull_request' || (github.event_name == 'pull_request' && !github.event.pull_request.draft) + runs-on: ubuntu-latest + strategy: + matrix: + go: ['1.19', '1.20', '1.21'] + os: [ 'linux', 'windows', 'darwin' ] + arch: [ 'amd64', 'arm64' ] + outputs: + commit-hash: ${{ steps.get_commit.outputs.commit }} + + steps: + - uses: actions/checkout@v3 + + - name: Set up Go + uses: actions/setup-go@v4 + with: + go-version: ${{ matrix.go }} + + - name: Build + env: + GOOS: ${{ matrix.os }} + GOARCH: ${{ matrix.arch }} + run: go build -v ./... \ No newline at end of file diff --git a/.github/workflows/golangci-lint.yml b/.github/workflows/golangci-lint.yml new file mode 100644 index 0000000..a9f5f9c --- /dev/null +++ b/.github/workflows/golangci-lint.yml @@ -0,0 +1,36 @@ +name: golangci-lint + +on: + push: + branches: [ "main", "dev" ] + pull_request: + branches: [ "main", "dev" ] + types: [opened, synchronize, reopened, ready_for_review] + +jobs: + golangci: + name: lint + runs-on: ubuntu-latest + + steps: + - name: Checkout code + uses: actions/checkout@v3 + + - name: Set up Go + uses: actions/setup-go@v4 + with: + go-version: 1.19 + + - name: Run golangci-lint + uses: golangci/golangci-lint-action@v3 + with: + version: latest + skip-pkg-cache: true + skip-build-cache: true + + - name: Upload lint results + uses: actions/upload-artifact@v2 + if: failure() + with: + name: golangci-lint-results + path: golangci-lint-report.txt diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..39c91d8 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,32 @@ +name: Release + +on: + push: + tags: + - 'v*.*.*' + +permissions: + contents: write + +jobs: + + release: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + with: + fetch-depth: 0 + + - name: Set up Go + uses: actions/setup-go@v4 + with: + go-version: '1.20' + + - name: Release + uses: goreleaser/goreleaser-action@v4 + with: + distribution: goreleaser + version: latest + args: release --clean + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.gitignore b/.gitignore index 6f6f5e6..4e8ed77 100644 --- a/.gitignore +++ b/.gitignore @@ -20,3 +20,5 @@ # Go workspace file go.work go.work.sum +coverage.out +passfinder diff --git a/CODE_OF_CONDUCT.md b/CODE_OF_CONDUCT.md new file mode 100644 index 0000000..f9d8ad4 --- /dev/null +++ b/CODE_OF_CONDUCT.md @@ -0,0 +1,128 @@ +# Contributor Covenant Code of Conduct + +## Our Pledge + +We as members, contributors, and leaders pledge to make participation in our +community a harassment-free experience for everyone, regardless of age, body +size, visible or invisible disability, ethnicity, sex characteristics, gender +identity and expression, level of experience, education, socio-economic status, +nationality, personal appearance, race, religion, or sexual identity +and orientation. + +We pledge to act and interact in ways that contribute to an open, welcoming, +diverse, inclusive, and healthy community. + +## Our Standards + +Examples of behavior that contributes to a positive environment for our +community include: + +* Demonstrating empathy and kindness toward other people +* Being respectful of differing opinions, viewpoints, and experiences +* Giving and gracefully accepting constructive feedback +* Accepting responsibility and apologizing to those affected by our mistakes, + and learning from the experience +* Focusing on what is best not just for us as individuals, but for the + overall community + +Examples of unacceptable behavior include: + +* The use of sexualized language or imagery, and sexual attention or + advances of any kind +* Trolling, insulting or derogatory comments, and personal or political attacks +* Public or private harassment +* Publishing others' private information, such as a physical or email + address, without their explicit permission +* Other conduct which could reasonably be considered inappropriate in a + professional setting + +## Enforcement Responsibilities + +Community leaders are responsible for clarifying and enforcing our standards of +acceptable behavior and will take appropriate and fair corrective action in +response to any behavior that they deem inappropriate, threatening, offensive, +or harmful. + +Community leaders have the right and responsibility to remove, edit, or reject +comments, commits, code, wiki edits, issues, and other contributions that are +not aligned to this Code of Conduct, and will communicate reasons for moderation +decisions when appropriate. + +## Scope + +This Code of Conduct applies within all community spaces, and also applies when +an individual is officially representing the community in public spaces. +Examples of representing our community include using an official e-mail address, +posting via an official social media account, or acting as an appointed +representative at an online or offline event. + +## Enforcement + +Instances of abusive, harassing, or otherwise unacceptable behavior may be +reported to the community leaders responsible for enforcement at +github@qu35t-mail.simplelogin.com. +All complaints will be reviewed and investigated promptly and fairly. + +All community leaders are obligated to respect the privacy and security of the +reporter of any incident. + +## Enforcement Guidelines + +Community leaders will follow these Community Impact Guidelines in determining +the consequences for any action they deem in violation of this Code of Conduct: + +### 1. Correction + +**Community Impact**: Use of inappropriate language or other behavior deemed +unprofessional or unwelcome in the community. + +**Consequence**: A private, written warning from community leaders, providing +clarity around the nature of the violation and an explanation of why the +behavior was inappropriate. A public apology may be requested. + +### 2. Warning + +**Community Impact**: A violation through a single incident or series +of actions. + +**Consequence**: A warning with consequences for continued behavior. No +interaction with the people involved, including unsolicited interaction with +those enforcing the Code of Conduct, for a specified period of time. This +includes avoiding interactions in community spaces as well as external channels +like social media. Violating these terms may lead to a temporary or +permanent ban. + +### 3. Temporary Ban + +**Community Impact**: A serious violation of community standards, including +sustained inappropriate behavior. + +**Consequence**: A temporary ban from any sort of interaction or public +communication with the community for a specified period of time. No public or +private interaction with the people involved, including unsolicited interaction +with those enforcing the Code of Conduct, is allowed during this period. +Violating these terms may lead to a permanent ban. + +### 4. Permanent Ban + +**Community Impact**: Demonstrating a pattern of violation of community +standards, including sustained inappropriate behavior, harassment of an +individual, or aggression toward or disparagement of classes of individuals. + +**Consequence**: A permanent ban from any sort of public interaction within +the community. + +## Attribution + +This Code of Conduct is adapted from the [Contributor Covenant][homepage], +version 2.0, available at +https://www.contributor-covenant.org/version/2/0/code_of_conduct.html. + +Community Impact Guidelines were inspired by [Mozilla's code of conduct +enforcement ladder](https://github.com/mozilla/diversity). + +[homepage]: https://www.contributor-covenant.org + +For answers to common questions about this code of conduct, see the FAQ at +https://www.contributor-covenant.org/faq. Translations are available at +https://www.contributor-covenant.org/translations. \ No newline at end of file diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md new file mode 100644 index 0000000..a9cbad8 --- /dev/null +++ b/CONTRIBUTING.md @@ -0,0 +1 @@ +Don't hesitate to contribute to the project with a pull request. All ideas are welcome to improve the project ! \ No newline at end of file diff --git a/LICENSE b/LICENSE index f288702..e69de29 100644 --- a/LICENSE +++ b/LICENSE @@ -1,674 +0,0 @@ - GNU GENERAL PUBLIC LICENSE - Version 3, 29 June 2007 - - Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/> - Everyone is permitted to copy and distribute verbatim copies - of this license document, but changing it is not allowed. - - Preamble - - The GNU General Public License is a free, copyleft license for -software and other kinds of works. - - The licenses for most software and other practical works are designed -to take away your freedom to share and change the works. By contrast, -the GNU General Public License is intended to guarantee your freedom to -share and change all versions of a program--to make sure it remains free -software for all its users. We, the Free Software Foundation, use the -GNU General Public License for most of our software; it applies also to -any other work released this way by its authors. You can apply it to -your programs, too. - - When we speak of free software, we are referring to freedom, not -price. Our General Public Licenses are designed to make sure that you -have the freedom to distribute copies of free software (and charge for -them if you wish), that you receive source code or can get it if you -want it, that you can change the software or use pieces of it in new -free programs, and that you know you can do these things. - - To protect your rights, we need to prevent others from denying you -these rights or asking you to surrender the rights. Therefore, you have -certain responsibilities if you distribute copies of the software, or if -you modify it: responsibilities to respect the freedom of others. - - For example, if you distribute copies of such a program, whether -gratis or for a fee, you must pass on to the recipients the same -freedoms that you received. You must make sure that they, too, receive -or can get the source code. And you must show them these terms so they -know their rights. - - Developers that use the GNU GPL protect your rights with two steps: -(1) assert copyright on the software, and (2) offer you this License -giving you legal permission to copy, distribute and/or modify it. - - For the developers' and authors' protection, the GPL clearly explains -that there is no warranty for this free software. For both users' and -authors' sake, the GPL requires that modified versions be marked as -changed, so that their problems will not be attributed erroneously to -authors of previous versions. - - Some devices are designed to deny users access to install or run -modified versions of the software inside them, although the manufacturer -can do so. This is fundamentally incompatible with the aim of -protecting users' freedom to change the software. The systematic -pattern of such abuse occurs in the area of products for individuals to -use, which is precisely where it is most unacceptable. Therefore, we -have designed this version of the GPL to prohibit the practice for those -products. If such problems arise substantially in other domains, we -stand ready to extend this provision to those domains in future versions -of the GPL, as needed to protect the freedom of users. - - Finally, every program is threatened constantly by software patents. -States should not allow patents to restrict development and use of -software on general-purpose computers, but in those that do, we wish to -avoid the special danger that patents applied to a free program could -make it effectively proprietary. To prevent this, the GPL assures that -patents cannot be used to render the program non-free. - - The precise terms and conditions for copying, distribution and -modification follow. - - TERMS AND CONDITIONS - - 0. Definitions. - - "This License" refers to version 3 of the GNU General Public License. - - "Copyright" also means copyright-like laws that apply to other kinds of -works, such as semiconductor masks. - - "The Program" refers to any copyrightable work licensed under this -License. Each licensee is addressed as "you". "Licensees" and -"recipients" may be individuals or organizations. - - To "modify" a work means to copy from or adapt all or part of the work -in a fashion requiring copyright permission, other than the making of an -exact copy. The resulting work is called a "modified version" of the -earlier work or a work "based on" the earlier work. - - A "covered work" means either the unmodified Program or a work based -on the Program. - - To "propagate" a work means to do anything with it that, without -permission, would make you directly or secondarily liable for -infringement under applicable copyright law, except executing it on a -computer or modifying a private copy. Propagation includes copying, -distribution (with or without modification), making available to the -public, and in some countries other activities as well. - - To "convey" a work means any kind of propagation that enables other -parties to make or receive copies. Mere interaction with a user through -a computer network, with no transfer of a copy, is not conveying. - - An interactive user interface displays "Appropriate Legal Notices" -to the extent that it includes a convenient and prominently visible -feature that (1) displays an appropriate copyright notice, and (2) -tells the user that there is no warranty for the work (except to the -extent that warranties are provided), that licensees may convey the -work under this License, and how to view a copy of this License. If -the interface presents a list of user commands or options, such as a -menu, a prominent item in the list meets this criterion. - - 1. Source Code. - - The "source code" for a work means the preferred form of the work -for making modifications to it. "Object code" means any non-source -form of a work. - - A "Standard Interface" means an interface that either is an official -standard defined by a recognized standards body, or, in the case of -interfaces specified for a particular programming language, one that -is widely used among developers working in that language. - - The "System Libraries" of an executable work include anything, other -than the work as a whole, that (a) is included in the normal form of -packaging a Major Component, but which is not part of that Major -Component, and (b) serves only to enable use of the work with that -Major Component, or to implement a Standard Interface for which an -implementation is available to the public in source code form. A -"Major Component", in this context, means a major essential component -(kernel, window system, and so on) of the specific operating system -(if any) on which the executable work runs, or a compiler used to -produce the work, or an object code interpreter used to run it. - - The "Corresponding Source" for a work in object code form means all -the source code needed to generate, install, and (for an executable -work) run the object code and to modify the work, including scripts to -control those activities. However, it does not include the work's -System Libraries, or general-purpose tools or generally available free -programs which are used unmodified in performing those activities but -which are not part of the work. For example, Corresponding Source -includes interface definition files associated with source files for -the work, and the source code for shared libraries and dynamically -linked subprograms that the work is specifically designed to require, -such as by intimate data communication or control flow between those -subprograms and other parts of the work. - - The Corresponding Source need not include anything that users -can regenerate automatically from other parts of the Corresponding -Source. - - The Corresponding Source for a work in source code form is that -same work. - - 2. Basic Permissions. - - All rights granted under this License are granted for the term of -copyright on the Program, and are irrevocable provided the stated -conditions are met. This License explicitly affirms your unlimited -permission to run the unmodified Program. The output from running a -covered work is covered by this License only if the output, given its -content, constitutes a covered work. This License acknowledges your -rights of fair use or other equivalent, as provided by copyright law. - - You may make, run and propagate covered works that you do not -convey, without conditions so long as your license otherwise remains -in force. You may convey covered works to others for the sole purpose -of having them make modifications exclusively for you, or provide you -with facilities for running those works, provided that you comply with -the terms of this License in conveying all material for which you do -not control copyright. Those thus making or running the covered works -for you must do so exclusively on your behalf, under your direction -and control, on terms that prohibit them from making any copies of -your copyrighted material outside their relationship with you. - - Conveying under any other circumstances is permitted solely under -the conditions stated below. Sublicensing is not allowed; section 10 -makes it unnecessary. - - 3. Protecting Users' Legal Rights From Anti-Circumvention Law. - - No covered work shall be deemed part of an effective technological -measure under any applicable law fulfilling obligations under article -11 of the WIPO copyright treaty adopted on 20 December 1996, or -similar laws prohibiting or restricting circumvention of such -measures. - - When you convey a covered work, you waive any legal power to forbid -circumvention of technological measures to the extent such circumvention -is effected by exercising rights under this License with respect to -the covered work, and you disclaim any intention to limit operation or -modification of the work as a means of enforcing, against the work's -users, your or third parties' legal rights to forbid circumvention of -technological measures. - - 4. Conveying Verbatim Copies. - - You may convey verbatim copies of the Program's source code as you -receive it, in any medium, provided that you conspicuously and -appropriately publish on each copy an appropriate copyright notice; -keep intact all notices stating that this License and any -non-permissive terms added in accord with section 7 apply to the code; -keep intact all notices of the absence of any warranty; and give all -recipients a copy of this License along with the Program. - - You may charge any price or no price for each copy that you convey, -and you may offer support or warranty protection for a fee. - - 5. Conveying Modified Source Versions. - - You may convey a work based on the Program, or the modifications to -produce it from the Program, in the form of source code under the -terms of section 4, provided that you also meet all of these conditions: - - a) The work must carry prominent notices stating that you modified - it, and giving a relevant date. - - b) The work must carry prominent notices stating that it is - released under this License and any conditions added under section - 7. This requirement modifies the requirement in section 4 to - "keep intact all notices". - - c) You must license the entire work, as a whole, under this - License to anyone who comes into possession of a copy. This - License will therefore apply, along with any applicable section 7 - additional terms, to the whole of the work, and all its parts, - regardless of how they are packaged. This License gives no - permission to license the work in any other way, but it does not - invalidate such permission if you have separately received it. - - d) If the work has interactive user interfaces, each must display - Appropriate Legal Notices; however, if the Program has interactive - interfaces that do not display Appropriate Legal Notices, your - work need not make them do so. - - A compilation of a covered work with other separate and independent -works, which are not by their nature extensions of the covered work, -and which are not combined with it such as to form a larger program, -in or on a volume of a storage or distribution medium, is called an -"aggregate" if the compilation and its resulting copyright are not -used to limit the access or legal rights of the compilation's users -beyond what the individual works permit. Inclusion of a covered work -in an aggregate does not cause this License to apply to the other -parts of the aggregate. - - 6. Conveying Non-Source Forms. - - You may convey a covered work in object code form under the terms -of sections 4 and 5, provided that you also convey the -machine-readable Corresponding Source under the terms of this License, -in one of these ways: - - a) Convey the object code in, or embodied in, a physical product - (including a physical distribution medium), accompanied by the - Corresponding Source fixed on a durable physical medium - customarily used for software interchange. - - b) Convey the object code in, or embodied in, a physical product - (including a physical distribution medium), accompanied by a - written offer, valid for at least three years and valid for as - long as you offer spare parts or customer support for that product - model, to give anyone who possesses the object code either (1) a - copy of the Corresponding Source for all the software in the - product that is covered by this License, on a durable physical - medium customarily used for software interchange, for a price no - more than your reasonable cost of physically performing this - conveying of source, or (2) access to copy the - Corresponding Source from a network server at no charge. - - c) Convey individual copies of the object code with a copy of the - written offer to provide the Corresponding Source. This - alternative is allowed only occasionally and noncommercially, and - only if you received the object code with such an offer, in accord - with subsection 6b. - - d) Convey the object code by offering access from a designated - place (gratis or for a charge), and offer equivalent access to the - Corresponding Source in the same way through the same place at no - further charge. You need not require recipients to copy the - Corresponding Source along with the object code. If the place to - copy the object code is a network server, the Corresponding Source - may be on a different server (operated by you or a third party) - that supports equivalent copying facilities, provided you maintain - clear directions next to the object code saying where to find the - Corresponding Source. Regardless of what server hosts the - Corresponding Source, you remain obligated to ensure that it is - available for as long as needed to satisfy these requirements. - - e) Convey the object code using peer-to-peer transmission, provided - you inform other peers where the object code and Corresponding - Source of the work are being offered to the general public at no - charge under subsection 6d. - - A separable portion of the object code, whose source code is excluded -from the Corresponding Source as a System Library, need not be -included in conveying the object code work. - - A "User Product" is either (1) a "consumer product", which means any -tangible personal property which is normally used for personal, family, -or household purposes, or (2) anything designed or sold for incorporation -into a dwelling. In determining whether a product is a consumer product, -doubtful cases shall be resolved in favor of coverage. For a particular -product received by a particular user, "normally used" refers to a -typical or common use of that class of product, regardless of the status -of the particular user or of the way in which the particular user -actually uses, or expects or is expected to use, the product. A product -is a consumer product regardless of whether the product has substantial -commercial, industrial or non-consumer uses, unless such uses represent -the only significant mode of use of the product. - - "Installation Information" for a User Product means any methods, -procedures, authorization keys, or other information required to install -and execute modified versions of a covered work in that User Product from -a modified version of its Corresponding Source. The information must -suffice to ensure that the continued functioning of the modified object -code is in no case prevented or interfered with solely because -modification has been made. - - If you convey an object code work under this section in, or with, or -specifically for use in, a User Product, and the conveying occurs as -part of a transaction in which the right of possession and use of the -User Product is transferred to the recipient in perpetuity or for a -fixed term (regardless of how the transaction is characterized), the -Corresponding Source conveyed under this section must be accompanied -by the Installation Information. But this requirement does not apply -if neither you nor any third party retains the ability to install -modified object code on the User Product (for example, the work has -been installed in ROM). - - The requirement to provide Installation Information does not include a -requirement to continue to provide support service, warranty, or updates -for a work that has been modified or installed by the recipient, or for -the User Product in which it has been modified or installed. Access to a -network may be denied when the modification itself materially and -adversely affects the operation of the network or violates the rules and -protocols for communication across the network. - - Corresponding Source conveyed, and Installation Information provided, -in accord with this section must be in a format that is publicly -documented (and with an implementation available to the public in -source code form), and must require no special password or key for -unpacking, reading or copying. - - 7. Additional Terms. - - "Additional permissions" are terms that supplement the terms of this -License by making exceptions from one or more of its conditions. -Additional permissions that are applicable to the entire Program shall -be treated as though they were included in this License, to the extent -that they are valid under applicable law. If additional permissions -apply only to part of the Program, that part may be used separately -under those permissions, but the entire Program remains governed by -this License without regard to the additional permissions. - - When you convey a copy of a covered work, you may at your option -remove any additional permissions from that copy, or from any part of -it. (Additional permissions may be written to require their own -removal in certain cases when you modify the work.) You may place -additional permissions on material, added by you to a covered work, -for which you have or can give appropriate copyright permission. - - Notwithstanding any other provision of this License, for material you -add to a covered work, you may (if authorized by the copyright holders of -that material) supplement the terms of this License with terms: - - a) Disclaiming warranty or limiting liability differently from the - terms of sections 15 and 16 of this License; or - - b) Requiring preservation of specified reasonable legal notices or - author attributions in that material or in the Appropriate Legal - Notices displayed by works containing it; or - - c) Prohibiting misrepresentation of the origin of that material, or - requiring that modified versions of such material be marked in - reasonable ways as different from the original version; or - - d) Limiting the use for publicity purposes of names of licensors or - authors of the material; or - - e) Declining to grant rights under trademark law for use of some - trade names, trademarks, or service marks; or - - f) Requiring indemnification of licensors and authors of that - material by anyone who conveys the material (or modified versions of - it) with contractual assumptions of liability to the recipient, for - any liability that these contractual assumptions directly impose on - those licensors and authors. - - All other non-permissive additional terms are considered "further -restrictions" within the meaning of section 10. If the Program as you -received it, or any part of it, contains a notice stating that it is -governed by this License along with a term that is a further -restriction, you may remove that term. If a license document contains -a further restriction but permits relicensing or conveying under this -License, you may add to a covered work material governed by the terms -of that license document, provided that the further restriction does -not survive such relicensing or conveying. - - If you add terms to a covered work in accord with this section, you -must place, in the relevant source files, a statement of the -additional terms that apply to those files, or a notice indicating -where to find the applicable terms. - - Additional terms, permissive or non-permissive, may be stated in the -form of a separately written license, or stated as exceptions; -the above requirements apply either way. - - 8. Termination. - - You may not propagate or modify a covered work except as expressly -provided under this License. Any attempt otherwise to propagate or -modify it is void, and will automatically terminate your rights under -this License (including any patent licenses granted under the third -paragraph of section 11). - - However, if you cease all violation of this License, then your -license from a particular copyright holder is reinstated (a) -provisionally, unless and until the copyright holder explicitly and -finally terminates your license, and (b) permanently, if the copyright -holder fails to notify you of the violation by some reasonable means -prior to 60 days after the cessation. - - Moreover, your license from a particular copyright holder is -reinstated permanently if the copyright holder notifies you of the -violation by some reasonable means, this is the first time you have -received notice of violation of this License (for any work) from that -copyright holder, and you cure the violation prior to 30 days after -your receipt of the notice. - - Termination of your rights under this section does not terminate the -licenses of parties who have received copies or rights from you under -this License. If your rights have been terminated and not permanently -reinstated, you do not qualify to receive new licenses for the same -material under section 10. - - 9. Acceptance Not Required for Having Copies. - - You are not required to accept this License in order to receive or -run a copy of the Program. Ancillary propagation of a covered work -occurring solely as a consequence of using peer-to-peer transmission -to receive a copy likewise does not require acceptance. However, -nothing other than this License grants you permission to propagate or -modify any covered work. These actions infringe copyright if you do -not accept this License. Therefore, by modifying or propagating a -covered work, you indicate your acceptance of this License to do so. - - 10. Automatic Licensing of Downstream Recipients. - - Each time you convey a covered work, the recipient automatically -receives a license from the original licensors, to run, modify and -propagate that work, subject to this License. You are not responsible -for enforcing compliance by third parties with this License. - - An "entity transaction" is a transaction transferring control of an -organization, or substantially all assets of one, or subdividing an -organization, or merging organizations. If propagation of a covered -work results from an entity transaction, each party to that -transaction who receives a copy of the work also receives whatever -licenses to the work the party's predecessor in interest had or could -give under the previous paragraph, plus a right to possession of the -Corresponding Source of the work from the predecessor in interest, if -the predecessor has it or can get it with reasonable efforts. - - You may not impose any further restrictions on the exercise of the -rights granted or affirmed under this License. For example, you may -not impose a license fee, royalty, or other charge for exercise of -rights granted under this License, and you may not initiate litigation -(including a cross-claim or counterclaim in a lawsuit) alleging that -any patent claim is infringed by making, using, selling, offering for -sale, or importing the Program or any portion of it. - - 11. Patents. - - A "contributor" is a copyright holder who authorizes use under this -License of the Program or a work on which the Program is based. The -work thus licensed is called the contributor's "contributor version". - - A contributor's "essential patent claims" are all patent claims -owned or controlled by the contributor, whether already acquired or -hereafter acquired, that would be infringed by some manner, permitted -by this License, of making, using, or selling its contributor version, -but do not include claims that would be infringed only as a -consequence of further modification of the contributor version. For -purposes of this definition, "control" includes the right to grant -patent sublicenses in a manner consistent with the requirements of -this License. - - Each contributor grants you a non-exclusive, worldwide, royalty-free -patent license under the contributor's essential patent claims, to -make, use, sell, offer for sale, import and otherwise run, modify and -propagate the contents of its contributor version. - - In the following three paragraphs, a "patent license" is any express -agreement or commitment, however denominated, not to enforce a patent -(such as an express permission to practice a patent or covenant not to -sue for patent infringement). To "grant" such a patent license to a -party means to make such an agreement or commitment not to enforce a -patent against the party. - - If you convey a covered work, knowingly relying on a patent license, -and the Corresponding Source of the work is not available for anyone -to copy, free of charge and under the terms of this License, through a -publicly available network server or other readily accessible means, -then you must either (1) cause the Corresponding Source to be so -available, or (2) arrange to deprive yourself of the benefit of the -patent license for this particular work, or (3) arrange, in a manner -consistent with the requirements of this License, to extend the patent -license to downstream recipients. "Knowingly relying" means you have -actual knowledge that, but for the patent license, your conveying the -covered work in a country, or your recipient's use of the covered work -in a country, would infringe one or more identifiable patents in that -country that you have reason to believe are valid. - - If, pursuant to or in connection with a single transaction or -arrangement, you convey, or propagate by procuring conveyance of, a -covered work, and grant a patent license to some of the parties -receiving the covered work authorizing them to use, propagate, modify -or convey a specific copy of the covered work, then the patent license -you grant is automatically extended to all recipients of the covered -work and works based on it. - - A patent license is "discriminatory" if it does not include within -the scope of its coverage, prohibits the exercise of, or is -conditioned on the non-exercise of one or more of the rights that are -specifically granted under this License. You may not convey a covered -work if you are a party to an arrangement with a third party that is -in the business of distributing software, under which you make payment -to the third party based on the extent of your activity of conveying -the work, and under which the third party grants, to any of the -parties who would receive the covered work from you, a discriminatory -patent license (a) in connection with copies of the covered work -conveyed by you (or copies made from those copies), or (b) primarily -for and in connection with specific products or compilations that -contain the covered work, unless you entered into that arrangement, -or that patent license was granted, prior to 28 March 2007. - - Nothing in this License shall be construed as excluding or limiting -any implied license or other defenses to infringement that may -otherwise be available to you under applicable patent law. - - 12. No Surrender of Others' Freedom. - - If conditions are imposed on you (whether by court order, agreement or -otherwise) that contradict the conditions of this License, they do not -excuse you from the conditions of this License. If you cannot convey a -covered work so as to satisfy simultaneously your obligations under this -License and any other pertinent obligations, then as a consequence you may -not convey it at all. For example, if you agree to terms that obligate you -to collect a royalty for further conveying from those to whom you convey -the Program, the only way you could satisfy both those terms and this -License would be to refrain entirely from conveying the Program. - - 13. Use with the GNU Affero General Public License. - - Notwithstanding any other provision of this License, you have -permission to link or combine any covered work with a work licensed -under version 3 of the GNU Affero General Public License into a single -combined work, and to convey the resulting work. The terms of this -License will continue to apply to the part which is the covered work, -but the special requirements of the GNU Affero General Public License, -section 13, concerning interaction through a network will apply to the -combination as such. - - 14. Revised Versions of this License. - - The Free Software Foundation may publish revised and/or new versions of -the GNU General Public License from time to time. Such new versions will -be similar in spirit to the present version, but may differ in detail to -address new problems or concerns. - - Each version is given a distinguishing version number. If the -Program specifies that a certain numbered version of the GNU General -Public License "or any later version" applies to it, you have the -option of following the terms and conditions either of that numbered -version or of any later version published by the Free Software -Foundation. If the Program does not specify a version number of the -GNU General Public License, you may choose any version ever published -by the Free Software Foundation. - - If the Program specifies that a proxy can decide which future -versions of the GNU General Public License can be used, that proxy's -public statement of acceptance of a version permanently authorizes you -to choose that version for the Program. - - Later license versions may give you additional or different -permissions. However, no additional obligations are imposed on any -author or copyright holder as a result of your choosing to follow a -later version. - - 15. Disclaimer of Warranty. - - THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY -APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT -HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY -OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, -THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM -IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF -ALL NECESSARY SERVICING, REPAIR OR CORRECTION. - - 16. Limitation of Liability. - - IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING -WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS -THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY -GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE -USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF -DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD -PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), -EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF -SUCH DAMAGES. - - 17. Interpretation of Sections 15 and 16. - - If the disclaimer of warranty and limitation of liability provided -above cannot be given local legal effect according to their terms, -reviewing courts shall apply local law that most closely approximates -an absolute waiver of all civil liability in connection with the -Program, unless a warranty or assumption of liability accompanies a -copy of the Program in return for a fee. - - END OF TERMS AND CONDITIONS - - How to Apply These Terms to Your New Programs - - If you develop a new program, and you want it to be of the greatest -possible use to the public, the best way to achieve this is to make it -free software which everyone can redistribute and change under these terms. - - To do so, attach the following notices to the program. It is safest -to attach them to the start of each source file to most effectively -state the exclusion of warranty; and each file should have at least -the "copyright" line and a pointer to where the full notice is found. - - <one line to give the program's name and a brief idea of what it does.> - Copyright (C) <year> <name of author> - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see <https://www.gnu.org/licenses/>. - -Also add information on how to contact you by electronic and paper mail. - - If the program does terminal interaction, make it output a short -notice like this when it starts in an interactive mode: - - <program> Copyright (C) <year> <name of author> - This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. - This is free software, and you are welcome to redistribute it - under certain conditions; type `show c' for details. - -The hypothetical commands `show w' and `show c' should show the appropriate -parts of the General Public License. Of course, your program's commands -might be different; for a GUI interface, you would use an "about box". - - You should also get your employer (if you work as a programmer) or school, -if any, to sign a "copyright disclaimer" for the program, if necessary. -For more information on this, and how to apply and follow the GNU GPL, see -<https://www.gnu.org/licenses/>. - - The GNU General Public License does not permit incorporating your program -into proprietary programs. If your program is a subroutine library, you -may consider it more useful to permit linking proprietary applications with -the library. If this is what you want to do, use the GNU Lesser General -Public License instead of this License. But first, please read -<https://www.gnu.org/licenses/why-not-lgpl.html>. diff --git a/README.md b/README.md index d7b4062..2600f21 100644 --- a/README.md +++ b/README.md @@ -1 +1,19 @@ -# passfinder \ No newline at end of file +# Passfinder + +![Workflows (main)](https://github.com/GoToolSharing/passfinder/actions/workflows/go.yml/badge.svg?branch=main) +![Workflows (dev)](https://github.com/GoToolSharing/passfinder/actions/workflows/go.yml/badge.svg?branch=dev) +![GitHub go.mod Go version (main)](https://img.shields.io/github/go-mod/go-version/GoToolSharing/passfinder/main) +![GitHub go.mod Go version (dev)](https://img.shields.io/github/go-mod/go-version/GoToolSharing/passfinder/dev) +![GitHub release](https://img.shields.io/github/v/release/GoToolSharing/passfinder) +![GitHub Repo stars](https://img.shields.io/github/stars/GoToolSharing/passfinder) + +<a target="_blank" rel="noopener noreferrer" href="https://twitter.com/QU35T_TV" title="Follow"><img src="https://img.shields.io/twitter/follow/QU35T_TV?label=QU35T_TV&style=social" alt="Twitter QU35T_TV"></a> + +<div> + <img alt="current version" src="https://img.shields.io/badge/linux-supported-success"> + <img alt="current version" src="https://img.shields.io/badge/WSL-supported-success"> + <img alt="current version" src="https://img.shields.io/badge/mac-supported-success"> + <br> + <img alt="amd64" src="https://img.shields.io/badge/amd64%20(x86__64)-supported-success"> + <img alt="arm64" src="https://img.shields.io/badge/arm64%20(aarch64)-supported-success"> +</div> \ No newline at end of file diff --git a/SECURITY.md b/SECURITY.md new file mode 100644 index 0000000..4575c4a --- /dev/null +++ b/SECURITY.md @@ -0,0 +1,6 @@ +# Security Policy + +## Reporting a Vulnerability + +Please report (suspected) security vulnerabilities to github@qu35t-mail.simplelogin.com. You will receive a response from us within 48 hours. If the issue is confirmed, we will release a patch as soon as possible depending on complexity. + diff --git a/cmd/root.go b/cmd/root.go new file mode 100644 index 0000000..f9f4150 --- /dev/null +++ b/cmd/root.go @@ -0,0 +1,51 @@ +/* +Copyright © 2024 NAME HERE <EMAIL ADDRESS> + +*/ +package cmd + +import ( + "os" + + "github.com/spf13/cobra" +) + + + +// rootCmd represents the base command when called without any subcommands +var rootCmd = &cobra.Command{ + Use: "passfinder", + Short: "A brief description of your application", + Long: `A longer description that spans multiple lines and likely contains +examples and usage of using your application. For example: + +Cobra is a CLI library for Go that empowers applications. +This application is a tool to generate the needed files +to quickly create a Cobra application.`, + // Uncomment the following line if your bare application + // has an action associated with it: + // Run: func(cmd *cobra.Command, args []string) { }, +} + +// Execute adds all child commands to the root command and sets flags appropriately. +// This is called by main.main(). It only needs to happen once to the rootCmd. +func Execute() { + err := rootCmd.Execute() + if err != nil { + os.Exit(1) + } +} + +func init() { + // Here you will define your flags and configuration settings. + // Cobra supports persistent flags, which, if defined here, + // will be global for your application. + + // rootCmd.PersistentFlags().StringVar(&cfgFile, "config", "", "config file (default is $HOME/.passfinder.yaml)") + + // Cobra also supports local flags, which will only run + // when this action is called directly. + rootCmd.Flags().BoolP("toggle", "t", false, "Help message for toggle") +} + + diff --git a/go.mod b/go.mod new file mode 100644 index 0000000..9a596a7 --- /dev/null +++ b/go.mod @@ -0,0 +1,9 @@ +module github.com/GoToolSharing/passfinder + +go 1.22.4 + +require ( + github.com/inconshreveable/mousetrap v1.1.0 // indirect + github.com/spf13/cobra v1.8.0 // indirect + github.com/spf13/pflag v1.0.5 // indirect +) diff --git a/go.sum b/go.sum new file mode 100644 index 0000000..d0e8c2c --- /dev/null +++ b/go.sum @@ -0,0 +1,10 @@ +github.com/cpuguy83/go-md2man/v2 v2.0.3/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o= +github.com/inconshreveable/mousetrap v1.1.0 h1:wN+x4NVGpMsO7ErUn/mUI3vEoE6Jt13X2s0bqwp9tc8= +github.com/inconshreveable/mousetrap v1.1.0/go.mod h1:vpF70FUmC8bwa3OWnCshd2FqLfsEA9PFc4w1p2J65bw= +github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM= +github.com/spf13/cobra v1.8.0 h1:7aJaZx1B85qltLMc546zn58BxxfZdR/W22ej9CFoEf0= +github.com/spf13/cobra v1.8.0/go.mod h1:WXLWApfZ71AjXPya3WOlMsY9yMs7YeiHhFVlvLyhcho= +github.com/spf13/pflag v1.0.5 h1:iy+VFUOCP1a+8yFto/drg2CJ5u0yRoB7fZw3DKv/JXA= +github.com/spf13/pflag v1.0.5/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg= +gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= diff --git a/golangci.yml b/golangci.yml new file mode 100644 index 0000000..bb669b7 --- /dev/null +++ b/golangci.yml @@ -0,0 +1,46 @@ +run: + timeout: "5m" + issue-exit-code: 1 + tests: false + skip-dirs-use-default: true + allow-parallel-runners: false + go: "1.19" +output: + print-issued-lines: true + print-linter-name: true + unique-by-line: true + path-prefix: "" +linters: + enable-all: false + disable-all: true + enable: + # Defaults linters + - errcheck + - gosimple + - govet + - ineffassign + - staticcheck + - typecheck + # - unused + # Non Default linters + - asciicheck + - bodyclose + - cyclop + - decorder + - dupl + - dupword + - errchkjson + - goconst + - gocritic + - goerr113 + - gofmt + - gosec + - loggercheck + - paralleltest + - prealloc + - revive +linters-settings: + cyclop: + skip-tests: true + max-complexity: 15 + package-average: 0 \ No newline at end of file diff --git a/main.go b/main.go new file mode 100644 index 0000000..fa2b8d3 --- /dev/null +++ b/main.go @@ -0,0 +1,7 @@ +package main + +import "github.com/GoToolSharing/passfinder/cmd" + +func main() { + cmd.Execute() +} From b957d40d64754dd7cc88034cb0bc4cd667871de0 Mon Sep 17 00:00:00 2001 From: QU35T-code <github@qu35t-mail.simplelogin.com> Date: Wed, 12 Jun 2024 20:58:01 +0200 Subject: [PATCH 02/37] chore: Update golang version to 1.22 --- .github/workflows/go.yml | 2 +- .github/workflows/golangci-lint.yml | 2 +- go.mod | 2 +- golangci.yml | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/go.yml b/.github/workflows/go.yml index aec8ccf..4a02fd3 100644 --- a/.github/workflows/go.yml +++ b/.github/workflows/go.yml @@ -17,7 +17,7 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - go: ['1.19', '1.20', '1.21'] + go: ['1.19', '1.20', '1.21', '1.22'] os: [ 'linux', 'windows', 'darwin' ] arch: [ 'amd64', 'arm64' ] outputs: diff --git a/.github/workflows/golangci-lint.yml b/.github/workflows/golangci-lint.yml index a9f5f9c..3ab171e 100644 --- a/.github/workflows/golangci-lint.yml +++ b/.github/workflows/golangci-lint.yml @@ -19,7 +19,7 @@ jobs: - name: Set up Go uses: actions/setup-go@v4 with: - go-version: 1.19 + go-version: 1.22 - name: Run golangci-lint uses: golangci/golangci-lint-action@v3 diff --git a/go.mod b/go.mod index 9a596a7..74c9eca 100644 --- a/go.mod +++ b/go.mod @@ -1,6 +1,6 @@ module github.com/GoToolSharing/passfinder -go 1.22.4 +go 1.22 require ( github.com/inconshreveable/mousetrap v1.1.0 // indirect diff --git a/golangci.yml b/golangci.yml index bb669b7..c68f99b 100644 --- a/golangci.yml +++ b/golangci.yml @@ -4,7 +4,7 @@ run: tests: false skip-dirs-use-default: true allow-parallel-runners: false - go: "1.19" + go: "1.22" output: print-issued-lines: true print-linter-name: true From fe5e6953f20bdc2d73aa45db07f45ec36f4cec01 Mon Sep 17 00:00:00 2001 From: QU35T-code <github@qu35t-mail.simplelogin.com> Date: Wed, 12 Jun 2024 21:31:34 +0200 Subject: [PATCH 03/37] feat(company): Add special characters at the end of passwords --- README.md | 18 +++++++++++++++++- lib/generate/generate.go | 12 ++++++++++++ 2 files changed, 29 insertions(+), 1 deletion(-) create mode 100644 lib/generate/generate.go diff --git a/README.md b/README.md index 2600f21..5c90e20 100644 --- a/README.md +++ b/README.md @@ -16,4 +16,20 @@ <br> <img alt="amd64" src="https://img.shields.io/badge/amd64%20(x86__64)-supported-success"> <img alt="arm64" src="https://img.shields.io/badge/arm64%20(aarch64)-supported-success"> -</div> \ No newline at end of file +</div> + +## Special + +```bash +> passfinder company -n passfinder --special + +passfinder +passfinder! +passfinder@ +passfinder# +passfinder$ +passfinder% +passfinder+ +passfinder? +passfinder= +``` \ No newline at end of file diff --git a/lib/generate/generate.go b/lib/generate/generate.go new file mode 100644 index 0000000..4b51c47 --- /dev/null +++ b/lib/generate/generate.go @@ -0,0 +1,12 @@ +package generate + +func WithSpecialChars(wordlist []string) []string { + specialChars := []string{"!", "@", "#", "$", "%", "+", "?", "="} // TODO: Configurable charset + for _, word := range wordlist { + for _, char := range specialChars { + wordlist = append(wordlist, word+char) + } + } + + return wordlist +} From 4120e27acc80759dc8c1685ee94b6a664e17f37b Mon Sep 17 00:00:00 2001 From: QU35T-code <github@qu35t-mail.simplelogin.com> Date: Wed, 12 Jun 2024 21:31:44 +0200 Subject: [PATCH 04/37] chore: Clean root file --- cmd/root.go | 33 +++------------------------------ 1 file changed, 3 insertions(+), 30 deletions(-) diff --git a/cmd/root.go b/cmd/root.go index f9f4150..2f72b89 100644 --- a/cmd/root.go +++ b/cmd/root.go @@ -1,7 +1,3 @@ -/* -Copyright © 2024 NAME HERE <EMAIL ADDRESS> - -*/ package cmd import ( @@ -10,25 +6,12 @@ import ( "github.com/spf13/cobra" ) - - -// rootCmd represents the base command when called without any subcommands var rootCmd = &cobra.Command{ Use: "passfinder", - Short: "A brief description of your application", - Long: `A longer description that spans multiple lines and likely contains -examples and usage of using your application. For example: - -Cobra is a CLI library for Go that empowers applications. -This application is a tool to generate the needed files -to quickly create a Cobra application.`, - // Uncomment the following line if your bare application - // has an action associated with it: - // Run: func(cmd *cobra.Command, args []string) { }, + Short: "TODO", + Long: `TODO`, } -// Execute adds all child commands to the root command and sets flags appropriately. -// This is called by main.main(). It only needs to happen once to the rootCmd. func Execute() { err := rootCmd.Execute() if err != nil { @@ -37,15 +20,5 @@ func Execute() { } func init() { - // Here you will define your flags and configuration settings. - // Cobra supports persistent flags, which, if defined here, - // will be global for your application. - - // rootCmd.PersistentFlags().StringVar(&cfgFile, "config", "", "config file (default is $HOME/.passfinder.yaml)") - - // Cobra also supports local flags, which will only run - // when this action is called directly. - rootCmd.Flags().BoolP("toggle", "t", false, "Help message for toggle") + rootCmd.CompletionOptions.DisableDefaultCmd = true } - - From 5cf206fc43efeafca6360ecc02cfe6cc1bdd96ea Mon Sep 17 00:00:00 2001 From: QU35T-code <github@qu35t-mail.simplelogin.com> Date: Wed, 12 Jun 2024 21:31:56 +0200 Subject: [PATCH 05/37] feat(completion): Add basic completion command --- cmd/completion.go | 47 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) create mode 100644 cmd/completion.go diff --git a/cmd/completion.go b/cmd/completion.go new file mode 100644 index 0000000..0f24cf2 --- /dev/null +++ b/cmd/completion.go @@ -0,0 +1,47 @@ +package cmd + +import ( + "fmt" + "os" + + "github.com/spf13/cobra" +) + +var completionCmd = &cobra.Command{ + Use: "completion [bash|zsh|fish|powershell]", + Short: "Generate completion script", + ValidArgs: []string{"bash", "zsh", "fish", "powershell"}, + Args: cobra.MatchAll(cobra.ExactArgs(1), cobra.OnlyValidArgs), + Run: func(cmd *cobra.Command, args []string) { + switch args[0] { + case "bash": + err := cmd.Root().GenBashCompletion(os.Stdout) + if err != nil { + fmt.Println(err) + return + } + case "zsh": + err := cmd.Root().GenZshCompletion(os.Stdout) + if err != nil { + fmt.Println(err) + return + } + case "fish": + err := cmd.Root().GenFishCompletion(os.Stdout, true) + if err != nil { + fmt.Println(err) + return + } + case "powershell": + err := cmd.Root().GenPowerShellCompletionWithDesc(os.Stdout) + if err != nil { + fmt.Println(err) + return + } + } + }, +} + +func init() { + rootCmd.AddCommand(completionCmd) +} From f91bc02b171ac9aa01cbf152c7382fe03210e93e Mon Sep 17 00:00:00 2001 From: QU35T-code <github@qu35t-mail.simplelogin.com> Date: Wed, 12 Jun 2024 21:33:11 +0200 Subject: [PATCH 06/37] wip: added idea for company command --- cmd/company.go | 112 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 112 insertions(+) create mode 100644 cmd/company.go diff --git a/cmd/company.go b/cmd/company.go new file mode 100644 index 0000000..7701033 --- /dev/null +++ b/cmd/company.go @@ -0,0 +1,112 @@ +package cmd + +import ( + "fmt" + "strings" + "time" + + "github.com/GoToolSharing/passfinder/lib/generate" + "github.com/spf13/cobra" +) + +var ( + companyName string + city string + includeYear bool + includeCity bool + includeAcronym bool + includeSpecialChars bool + includeNumericSeq bool + includeUpperCase bool + includeLowerCase bool + includeMixedCase bool +) + +var companyCmd = &cobra.Command{ + Use: "company", + Short: "Generate a passlist based on company information", + Long: `Generate a passlist based on company name, current year, city, and other relevant information.`, + Run: func(cmd *cobra.Command, args []string) { + year := time.Now().Year() + + wordlist := generateCompanyPasslist(companyName, city, year) + for _, password := range wordlist { + fmt.Println(password) + } + }, +} + +func init() { + rootCmd.AddCommand(companyCmd) + + companyCmd.Flags().StringVarP(&companyName, "name", "n", "", "Company name") + companyCmd.MarkFlagRequired("name") + // companyCmd.Flags().StringVarP(&city, "city", "c", "", "City of the company") + // companyCmd.Flags().BoolVar(&includeYear, "year", false, "Include the current year in passwords") + // companyCmd.Flags().BoolVar(&includeCity, "with-city", false, "Include the city in passwords") + // companyCmd.Flags().BoolVar(&includeAcronym, "acronym", false, "Include acronym of the company name") + // companyCmd.Flags().BoolVar(&includeNumericSeq, "numeric", false, "Include numeric sequences in passwords") + // companyCmd.Flags().BoolVar(&includeUpperCase, "uppercase", false, "Include uppercase variations") + // companyCmd.Flags().BoolVar(&includeLowerCase, "lowercase", false, "Include lowercase variations") + // companyCmd.Flags().BoolVar(&includeMixedCase, "mixedcase", false, "Include mixed case variations") + companyCmd.Flags().BoolVar(&includeSpecialChars, "special", false, "Include special characters at the end of the passwords") +} + +func generateCompanyPasslist(name, city string, year int) []string { + var wordlist []string + + wordlist = append(wordlist, strings.ToLower(name)) // Init the wordlist + + if includeUpperCase { + wordlist = append(wordlist, strings.ToUpper(name)) + } + + if includeLowerCase { + wordlist = append(wordlist, strings.ToLower(name)) + } + + if includeMixedCase { + wordlist = append(wordlist, name) + wordlist = append(wordlist, strings.Title(name)) + } + + if includeYear { + wordlist = append(wordlist, fmt.Sprintf("%s%d", name, year)) + wordlist = append(wordlist, fmt.Sprintf("%s%d", strings.ToLower(name), year)) + wordlist = append(wordlist, fmt.Sprintf("%s%d", strings.ToUpper(name), year)) + } + + if includeCity && city != "" { + wordlist = append(wordlist, fmt.Sprintf("%s%s", name, city)) + wordlist = append(wordlist, fmt.Sprintf("%s%s", city, name)) + } + + if includeAcronym { + acronym := getAcronym(name) + wordlist = append(wordlist, acronym) + } + + if includeNumericSeq { + for i := 1; i <= 3; i++ { + wordlist = append(wordlist, fmt.Sprintf("%s%d", name, i)) + wordlist = append(wordlist, fmt.Sprintf("%s%d", strings.ToLower(name), i)) + wordlist = append(wordlist, fmt.Sprintf("%s%d", strings.ToUpper(name), i)) + } + } + + // Last permutation + if includeSpecialChars { + wordlist = generate.WithSpecialChars(wordlist) + } + + return wordlist +} + +func getAcronym(name string) string { + words := strings.Fields(name) + acronym := "" + for _, word := range words { + acronym += strings.ToUpper(string(word[0])) + } + return acronym +} From db8ba8602f07e00861ff5b643acde09a0733149c Mon Sep 17 00:00:00 2001 From: QU35T-code <github@qu35t-mail.simplelogin.com> Date: Wed, 12 Jun 2024 21:33:24 +0200 Subject: [PATCH 07/37] wip: added idea for company command --- cmd/company.go | 106 ++++++++++++++++++++++++------------------------- 1 file changed, 53 insertions(+), 53 deletions(-) diff --git a/cmd/company.go b/cmd/company.go index 7701033..9934637 100644 --- a/cmd/company.go +++ b/cmd/company.go @@ -10,16 +10,16 @@ import ( ) var ( - companyName string - city string - includeYear bool - includeCity bool - includeAcronym bool + companyName string + city string + // includeYear bool + // includeCity bool + // includeAcronym bool includeSpecialChars bool - includeNumericSeq bool - includeUpperCase bool - includeLowerCase bool - includeMixedCase bool + // includeNumericSeq bool + // includeUpperCase bool + // includeLowerCase bool + // includeMixedCase bool ) var companyCmd = &cobra.Command{ @@ -57,42 +57,42 @@ func generateCompanyPasslist(name, city string, year int) []string { wordlist = append(wordlist, strings.ToLower(name)) // Init the wordlist - if includeUpperCase { - wordlist = append(wordlist, strings.ToUpper(name)) - } - - if includeLowerCase { - wordlist = append(wordlist, strings.ToLower(name)) - } - - if includeMixedCase { - wordlist = append(wordlist, name) - wordlist = append(wordlist, strings.Title(name)) - } - - if includeYear { - wordlist = append(wordlist, fmt.Sprintf("%s%d", name, year)) - wordlist = append(wordlist, fmt.Sprintf("%s%d", strings.ToLower(name), year)) - wordlist = append(wordlist, fmt.Sprintf("%s%d", strings.ToUpper(name), year)) - } - - if includeCity && city != "" { - wordlist = append(wordlist, fmt.Sprintf("%s%s", name, city)) - wordlist = append(wordlist, fmt.Sprintf("%s%s", city, name)) - } - - if includeAcronym { - acronym := getAcronym(name) - wordlist = append(wordlist, acronym) - } - - if includeNumericSeq { - for i := 1; i <= 3; i++ { - wordlist = append(wordlist, fmt.Sprintf("%s%d", name, i)) - wordlist = append(wordlist, fmt.Sprintf("%s%d", strings.ToLower(name), i)) - wordlist = append(wordlist, fmt.Sprintf("%s%d", strings.ToUpper(name), i)) - } - } + // if includeUpperCase { + // wordlist = append(wordlist, strings.ToUpper(name)) + // } + + // if includeLowerCase { + // wordlist = append(wordlist, strings.ToLower(name)) + // } + + // if includeMixedCase { + // wordlist = append(wordlist, name) + // wordlist = append(wordlist, strings.Title(name)) + // } + + // if includeYear { + // wordlist = append(wordlist, fmt.Sprintf("%s%d", name, year)) + // wordlist = append(wordlist, fmt.Sprintf("%s%d", strings.ToLower(name), year)) + // wordlist = append(wordlist, fmt.Sprintf("%s%d", strings.ToUpper(name), year)) + // } + + // if includeCity && city != "" { + // wordlist = append(wordlist, fmt.Sprintf("%s%s", name, city)) + // wordlist = append(wordlist, fmt.Sprintf("%s%s", city, name)) + // } + + // if includeAcronym { + // acronym := getAcronym(name) + // wordlist = append(wordlist, acronym) + // } + + // if includeNumericSeq { + // for i := 1; i <= 3; i++ { + // wordlist = append(wordlist, fmt.Sprintf("%s%d", name, i)) + // wordlist = append(wordlist, fmt.Sprintf("%s%d", strings.ToLower(name), i)) + // wordlist = append(wordlist, fmt.Sprintf("%s%d", strings.ToUpper(name), i)) + // } + // } // Last permutation if includeSpecialChars { @@ -102,11 +102,11 @@ func generateCompanyPasslist(name, city string, year int) []string { return wordlist } -func getAcronym(name string) string { - words := strings.Fields(name) - acronym := "" - for _, word := range words { - acronym += strings.ToUpper(string(word[0])) - } - return acronym -} +// func getAcronym(name string) string { +// words := strings.Fields(name) +// acronym := "" +// for _, word := range words { +// acronym += strings.ToUpper(string(word[0])) +// } +// return acronym +// } From d559112f74443925fcaa8233753d085d6476e726 Mon Sep 17 00:00:00 2001 From: QU35T-code <github@qu35t-mail.simplelogin.com> Date: Wed, 12 Jun 2024 21:35:24 +0200 Subject: [PATCH 08/37] chore: Fix lint --- cmd/company.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/cmd/company.go b/cmd/company.go index 9934637..791f790 100644 --- a/cmd/company.go +++ b/cmd/company.go @@ -40,7 +40,10 @@ func init() { rootCmd.AddCommand(companyCmd) companyCmd.Flags().StringVarP(&companyName, "name", "n", "", "Company name") - companyCmd.MarkFlagRequired("name") + err := companyCmd.MarkFlagRequired("name") + if err != nil { + return + } // companyCmd.Flags().StringVarP(&city, "city", "c", "", "City of the company") // companyCmd.Flags().BoolVar(&includeYear, "year", false, "Include the current year in passwords") // companyCmd.Flags().BoolVar(&includeCity, "with-city", false, "Include the city in passwords") From 9a309a3c9e091f6571af7c6df34daae56bb1d4a5 Mon Sep 17 00:00:00 2001 From: QU35T-code <github@qu35t-mail.simplelogin.com> Date: Wed, 12 Jun 2024 21:36:50 +0200 Subject: [PATCH 09/37] chore: Downgrade golang version --- go.mod | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/go.mod b/go.mod index 74c9eca..9971669 100644 --- a/go.mod +++ b/go.mod @@ -1,9 +1,10 @@ module github.com/GoToolSharing/passfinder -go 1.22 +go 1.20 + +require github.com/spf13/cobra v1.8.0 require ( github.com/inconshreveable/mousetrap v1.1.0 // indirect - github.com/spf13/cobra v1.8.0 // indirect github.com/spf13/pflag v1.0.5 // indirect ) From 12ddb5b25c6c66f8253bde4d87147629d1a71881 Mon Sep 17 00:00:00 2001 From: QU35T-code <github@qu35t-mail.simplelogin.com> Date: Wed, 12 Jun 2024 21:40:54 +0200 Subject: [PATCH 10/37] chore: Updating Github actions dependencies --- .github/workflows/go.yml | 4 ++-- .github/workflows/golangci-lint.yml | 8 ++++---- .github/workflows/release.yml | 6 +++--- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/.github/workflows/go.yml b/.github/workflows/go.yml index 4a02fd3..9eac6dd 100644 --- a/.github/workflows/go.yml +++ b/.github/workflows/go.yml @@ -24,10 +24,10 @@ jobs: commit-hash: ${{ steps.get_commit.outputs.commit }} steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: Set up Go - uses: actions/setup-go@v4 + uses: actions/setup-go@v5 with: go-version: ${{ matrix.go }} diff --git a/.github/workflows/golangci-lint.yml b/.github/workflows/golangci-lint.yml index 3ab171e..f1d1334 100644 --- a/.github/workflows/golangci-lint.yml +++ b/.github/workflows/golangci-lint.yml @@ -14,22 +14,22 @@ jobs: steps: - name: Checkout code - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: Set up Go - uses: actions/setup-go@v4 + uses: actions/setup-go@v5 with: go-version: 1.22 - name: Run golangci-lint - uses: golangci/golangci-lint-action@v3 + uses: golangci/golangci-lint-action@v4 with: version: latest skip-pkg-cache: true skip-build-cache: true - name: Upload lint results - uses: actions/upload-artifact@v2 + uses: actions/upload-artifact@v4 if: failure() with: name: golangci-lint-results diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 39c91d8..cf370da 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -13,17 +13,17 @@ jobs: release: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 with: fetch-depth: 0 - name: Set up Go - uses: actions/setup-go@v4 + uses: actions/setup-go@v5 with: go-version: '1.20' - name: Release - uses: goreleaser/goreleaser-action@v4 + uses: goreleaser/goreleaser-action@v6 with: distribution: goreleaser version: latest From 5639594bed61891dbd4c03bdadb328d3a6af386c Mon Sep 17 00:00:00 2001 From: QU35T-code <github@qu35t-mail.simplelogin.com> Date: Thu, 13 Jun 2024 08:09:58 +0200 Subject: [PATCH 11/37] feat(company): Add mixedcase flag --- README.md | 43 ++++++++++++++++++++++++++++++++++++++++ cmd/company.go | 16 +++++++-------- lib/generate/generate.go | 30 ++++++++++++++++++++++++++++ lib/utils/utils.go | 14 +++++++++++++ 4 files changed, 94 insertions(+), 9 deletions(-) create mode 100644 lib/utils/utils.go diff --git a/README.md b/README.md index 5c90e20..f96ef81 100644 --- a/README.md +++ b/README.md @@ -32,4 +32,47 @@ passfinder% passfinder+ passfinder? passfinder= +``` + +## Mixedcase + +```bash +> passfinder company -n passfinder --mixedcase + +PAssFINDER +PAsSfinder +PAsSfindeR +PAsSfindEr +PAsSfindER +PAsSfinDer +PAsSfinDeR +PAsSfinDEr +PAsSfinDER +PAsSfiNder +PAsSfiNdeR +PAsSfiNdEr +PAsSfiNdER +PAsSfiNDer +PAsSfiNDeR +PAsSfiNDEr +PAsSfiNDER +PAsSfInder +PAsSfIndeR +PAsSfIndEr +PAsSfIndER +PAsSfInDer +PAsSfInDeR +PAsSfInDEr +PAsSfInDER +PAsSfINder +PAsSfINdeR +PAsSfINdEr +PAsSfINdER +PAsSfINDer +PAsSfINDeR +PAsSfINDEr +PAsSfINDER +PAsSFinder +PAsSFindeR +PAsSFindEr ``` \ No newline at end of file diff --git a/cmd/company.go b/cmd/company.go index 791f790..13a71ec 100644 --- a/cmd/company.go +++ b/cmd/company.go @@ -19,7 +19,7 @@ var ( // includeNumericSeq bool // includeUpperCase bool // includeLowerCase bool - // includeMixedCase bool + includeMixedCase bool ) var companyCmd = &cobra.Command{ @@ -51,8 +51,8 @@ func init() { // companyCmd.Flags().BoolVar(&includeNumericSeq, "numeric", false, "Include numeric sequences in passwords") // companyCmd.Flags().BoolVar(&includeUpperCase, "uppercase", false, "Include uppercase variations") // companyCmd.Flags().BoolVar(&includeLowerCase, "lowercase", false, "Include lowercase variations") - // companyCmd.Flags().BoolVar(&includeMixedCase, "mixedcase", false, "Include mixed case variations") - companyCmd.Flags().BoolVar(&includeSpecialChars, "special", false, "Include special characters at the end of the passwords") + companyCmd.Flags().BoolVar(&includeMixedCase, "mixedcase", false, "Include mixed case variations") + companyCmd.Flags().BoolVar(&includeSpecialChars, "end-special", false, "Include special characters at the end of the passwords") } func generateCompanyPasslist(name, city string, year int) []string { @@ -68,11 +68,6 @@ func generateCompanyPasslist(name, city string, year int) []string { // wordlist = append(wordlist, strings.ToLower(name)) // } - // if includeMixedCase { - // wordlist = append(wordlist, name) - // wordlist = append(wordlist, strings.Title(name)) - // } - // if includeYear { // wordlist = append(wordlist, fmt.Sprintf("%s%d", name, year)) // wordlist = append(wordlist, fmt.Sprintf("%s%d", strings.ToLower(name), year)) @@ -97,7 +92,10 @@ func generateCompanyPasslist(name, city string, year int) []string { // } // } - // Last permutation + if includeMixedCase { + wordlist = generate.WithMixedCase(wordlist) + } + if includeSpecialChars { wordlist = generate.WithSpecialChars(wordlist) } diff --git a/lib/generate/generate.go b/lib/generate/generate.go index 4b51c47..7670d80 100644 --- a/lib/generate/generate.go +++ b/lib/generate/generate.go @@ -1,5 +1,7 @@ package generate +import "github.com/GoToolSharing/passfinder/lib/utils" + func WithSpecialChars(wordlist []string) []string { specialChars := []string{"!", "@", "#", "$", "%", "+", "?", "="} // TODO: Configurable charset for _, word := range wordlist { @@ -10,3 +12,31 @@ func WithSpecialChars(wordlist []string) []string { return wordlist } + +func WithMixedCase(wordlist []string) []string { + var newWordlist []string + for _, word := range wordlist { + caseVariations := generateCaseVariations(word) + newWordlist = append(newWordlist, caseVariations...) + } + return utils.RemoveDuplicates(newWordlist) +} + +func generateCaseVariations(word string) []string { + var result []string + helper(word, "", 0, &result) + return result +} + +func helper(word, current string, index int, result *[]string) { + if index == len(word) { + *result = append(*result, current) + return + } + helper(word, current+string(word[index]), index+1, result) + if word[index] >= 'a' && word[index] <= 'z' { + helper(word, current+string(word[index]-'a'+'A'), index+1, result) + } else if word[index] >= 'A' && word[index] <= 'Z' { + helper(word, current+string(word[index]-'A'+'a'), index+1, result) + } +} diff --git a/lib/utils/utils.go b/lib/utils/utils.go new file mode 100644 index 0000000..c3f386f --- /dev/null +++ b/lib/utils/utils.go @@ -0,0 +1,14 @@ +package utils + +func RemoveDuplicates(elements []string) []string { + encountered := map[string]bool{} + var result []string + + for v := range elements { + if !encountered[elements[v]] { + encountered[elements[v]] = true + result = append(result, elements[v]) + } + } + return result +} From 46ee219c700097d6bbd7601acae953b0c53a6874 Mon Sep 17 00:00:00 2001 From: QU35T-code <github@qu35t-mail.simplelogin.com> Date: Thu, 13 Jun 2024 08:15:29 +0200 Subject: [PATCH 12/37] feat(company): Add year flag --- README.md | 35 +++++++++-------------------------- cmd/company.go | 14 ++++++-------- lib/generate/generate.go | 16 +++++++++++++++- 3 files changed, 30 insertions(+), 35 deletions(-) diff --git a/README.md b/README.md index f96ef81..5158130 100644 --- a/README.md +++ b/README.md @@ -49,30 +49,13 @@ PAsSfinDeR PAsSfinDEr PAsSfinDER PAsSfiNder -PAsSfiNdeR -PAsSfiNdEr -PAsSfiNdER -PAsSfiNDer -PAsSfiNDeR -PAsSfiNDEr -PAsSfiNDER -PAsSfInder -PAsSfIndeR -PAsSfIndEr -PAsSfIndER -PAsSfInDer -PAsSfInDeR -PAsSfInDEr -PAsSfInDER -PAsSfINder -PAsSfINdeR -PAsSfINdEr -PAsSfINdER -PAsSfINDer -PAsSfINDeR -PAsSfINDEr -PAsSfINDER -PAsSFinder -PAsSFindeR -PAsSFindEr +[...] +``` + +## Year + +```bash +> passfinder company -n passfinder --year + +passfinder2024 ``` \ No newline at end of file diff --git a/cmd/company.go b/cmd/company.go index 13a71ec..1b55a23 100644 --- a/cmd/company.go +++ b/cmd/company.go @@ -12,7 +12,7 @@ import ( var ( companyName string city string - // includeYear bool + includeYear bool // includeCity bool // includeAcronym bool includeSpecialChars bool @@ -45,7 +45,7 @@ func init() { return } // companyCmd.Flags().StringVarP(&city, "city", "c", "", "City of the company") - // companyCmd.Flags().BoolVar(&includeYear, "year", false, "Include the current year in passwords") + companyCmd.Flags().BoolVar(&includeYear, "year", false, "Include the current year in passwords") // companyCmd.Flags().BoolVar(&includeCity, "with-city", false, "Include the city in passwords") // companyCmd.Flags().BoolVar(&includeAcronym, "acronym", false, "Include acronym of the company name") // companyCmd.Flags().BoolVar(&includeNumericSeq, "numeric", false, "Include numeric sequences in passwords") @@ -68,12 +68,6 @@ func generateCompanyPasslist(name, city string, year int) []string { // wordlist = append(wordlist, strings.ToLower(name)) // } - // if includeYear { - // wordlist = append(wordlist, fmt.Sprintf("%s%d", name, year)) - // wordlist = append(wordlist, fmt.Sprintf("%s%d", strings.ToLower(name), year)) - // wordlist = append(wordlist, fmt.Sprintf("%s%d", strings.ToUpper(name), year)) - // } - // if includeCity && city != "" { // wordlist = append(wordlist, fmt.Sprintf("%s%s", name, city)) // wordlist = append(wordlist, fmt.Sprintf("%s%s", city, name)) @@ -92,6 +86,10 @@ func generateCompanyPasslist(name, city string, year int) []string { // } // } + if includeYear { + wordlist = generate.WithYear(wordlist) + } + if includeMixedCase { wordlist = generate.WithMixedCase(wordlist) } diff --git a/lib/generate/generate.go b/lib/generate/generate.go index 7670d80..0d2250d 100644 --- a/lib/generate/generate.go +++ b/lib/generate/generate.go @@ -1,6 +1,11 @@ package generate -import "github.com/GoToolSharing/passfinder/lib/utils" +import ( + "fmt" + "time" + + "github.com/GoToolSharing/passfinder/lib/utils" +) func WithSpecialChars(wordlist []string) []string { specialChars := []string{"!", "@", "#", "$", "%", "+", "?", "="} // TODO: Configurable charset @@ -40,3 +45,12 @@ func helper(word, current string, index int, result *[]string) { helper(word, current+string(word[index]-'A'+'a'), index+1, result) } } + +func WithYear(wordlist []string) []string { + currentYear := time.Now().Year() + var newWordlist []string + for _, word := range wordlist { + newWordlist = append(newWordlist, fmt.Sprintf("%s%d", word, currentYear)) + } + return newWordlist +} From 98dbf095b071c5552bde9aaa1ab6749b8193412d Mon Sep 17 00:00:00 2001 From: QU35T-code <github@qu35t-mail.simplelogin.com> Date: Thu, 13 Jun 2024 08:37:04 +0200 Subject: [PATCH 13/37] feat(company): Add year-separators --- README.md | 4 ++-- cmd/company.go | 32 ++++++++++++++++++++------------ lib/generate/generate.go | 15 +++++++++------ 3 files changed, 31 insertions(+), 20 deletions(-) diff --git a/README.md b/README.md index 5158130..d8c3fd5 100644 --- a/README.md +++ b/README.md @@ -34,10 +34,10 @@ passfinder? passfinder= ``` -## Mixedcase +## mixed-case ```bash -> passfinder company -n passfinder --mixedcase +> passfinder company -n passfinder --mixed-case PAssFINDER PAsSfinder diff --git a/cmd/company.go b/cmd/company.go index 1b55a23..f8a203c 100644 --- a/cmd/company.go +++ b/cmd/company.go @@ -10,9 +10,10 @@ import ( ) var ( - companyName string - city string - includeYear bool + companyName string + city string + yearSeparators bool + includeYear bool // includeCity bool // includeAcronym bool includeSpecialChars bool @@ -27,6 +28,12 @@ var companyCmd = &cobra.Command{ Short: "Generate a passlist based on company information", Long: `Generate a passlist based on company name, current year, city, and other relevant information.`, Run: func(cmd *cobra.Command, args []string) { + + if !includeYear && yearSeparators { + fmt.Println("You cannot use --year-separators without --year") + return + } + year := time.Now().Year() wordlist := generateCompanyPasslist(companyName, city, year) @@ -46,12 +53,9 @@ func init() { } // companyCmd.Flags().StringVarP(&city, "city", "c", "", "City of the company") companyCmd.Flags().BoolVar(&includeYear, "year", false, "Include the current year in passwords") - // companyCmd.Flags().BoolVar(&includeCity, "with-city", false, "Include the city in passwords") - // companyCmd.Flags().BoolVar(&includeAcronym, "acronym", false, "Include acronym of the company name") // companyCmd.Flags().BoolVar(&includeNumericSeq, "numeric", false, "Include numeric sequences in passwords") - // companyCmd.Flags().BoolVar(&includeUpperCase, "uppercase", false, "Include uppercase variations") - // companyCmd.Flags().BoolVar(&includeLowerCase, "lowercase", false, "Include lowercase variations") - companyCmd.Flags().BoolVar(&includeMixedCase, "mixedcase", false, "Include mixed case variations") + companyCmd.Flags().BoolVar(&includeMixedCase, "mixed-case", false, "Include mixed case variations") + companyCmd.Flags().BoolVar(&yearSeparators, "year-separators", false, "Special characters to separate the company name and the year") companyCmd.Flags().BoolVar(&includeSpecialChars, "end-special", false, "Include special characters at the end of the passwords") } @@ -86,14 +90,18 @@ func generateCompanyPasslist(name, city string, year int) []string { // } // } - if includeYear { - wordlist = generate.WithYear(wordlist) - } - if includeMixedCase { wordlist = generate.WithMixedCase(wordlist) } + if includeYear { + var separators string + if yearSeparators { + separators = "!@#$%+?=" + } + wordlist = generate.WithYearAndSeparators(wordlist, year, separators) + } + if includeSpecialChars { wordlist = generate.WithSpecialChars(wordlist) } diff --git a/lib/generate/generate.go b/lib/generate/generate.go index 0d2250d..bd71210 100644 --- a/lib/generate/generate.go +++ b/lib/generate/generate.go @@ -2,7 +2,7 @@ package generate import ( "fmt" - "time" + "strings" "github.com/GoToolSharing/passfinder/lib/utils" ) @@ -46,11 +46,14 @@ func helper(word, current string, index int, result *[]string) { } } -func WithYear(wordlist []string) []string { - currentYear := time.Now().Year() - var newWordlist []string +func WithYearAndSeparators(wordlist []string, year int, separators string) []string { + separatorsList := strings.Split(separators, "") + for _, word := range wordlist { - newWordlist = append(newWordlist, fmt.Sprintf("%s%d", word, currentYear)) + wordlist = append(wordlist, fmt.Sprintf("%s%d", word, year)) + for _, separator := range separatorsList { + wordlist = append(wordlist, fmt.Sprintf("%s%s%d", word, separator, year)) + } } - return newWordlist + return wordlist } From cbd3a29e133bf3fbcc855d1689d156f3ae071fa0 Mon Sep 17 00:00:00 2001 From: QU35T-code <github@qu35t-mail.simplelogin.com> Date: Thu, 13 Jun 2024 08:38:08 +0200 Subject: [PATCH 14/37] feat(company): Update the documentation --- README.md | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/README.md b/README.md index d8c3fd5..7dcbbd4 100644 --- a/README.md +++ b/README.md @@ -58,4 +58,21 @@ PAsSfiNder > passfinder company -n passfinder --year passfinder2024 +``` + +## year-separator + +```bash +> passfinder company -n passfinder --year --year-separators + +passfinder +passfinder2024 +passfinder!2024 +passfinder@2024 +passfinder#2024 +passfinder$2024 +passfinder%2024 +passfinder+2024 +passfinder?2024 +passfinder=2024 ``` \ No newline at end of file From 212cc7c39cd13a77a213a1737513f066c80169e0 Mon Sep 17 00:00:00 2001 From: QU35T-code <github@qu35t-mail.simplelogin.com> Date: Thu, 13 Jun 2024 09:04:49 +0200 Subject: [PATCH 15/37] feat(company): Add * as special char + Add --all flag --- README.md | 20 +++++++++++++++++++- cmd/company.go | 21 ++++++++++++++++----- lib/generate/generate.go | 2 +- 3 files changed, 36 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index 7dcbbd4..93bd3f4 100644 --- a/README.md +++ b/README.md @@ -75,4 +75,22 @@ passfinder%2024 passfinder+2024 passfinder?2024 passfinder=2024 -``` \ No newline at end of file +``` + +## all + +```bash +> passfinder company -n passfinder --all + +PASSFINdEr!2024? +PASSFINdEr!2024= +PASSFINdEr!2024* +PASSFINdEr@2024! +PASSFINdEr@2024@ +PASSFINdEr@2024# +PASSFINdEr@2024$ +PASSFINdEr@2024% +PASSFINdEr@2024+ +PASSFINdEr@2024? +``` + diff --git a/cmd/company.go b/cmd/company.go index f8a203c..ced1761 100644 --- a/cmd/company.go +++ b/cmd/company.go @@ -10,10 +10,11 @@ import ( ) var ( - companyName string - city string - yearSeparators bool - includeYear bool + companyName string + city string + yearSeparators bool + includeYear bool + includeAllPermutations bool // includeCity bool // includeAcronym bool includeSpecialChars bool @@ -57,6 +58,9 @@ func init() { companyCmd.Flags().BoolVar(&includeMixedCase, "mixed-case", false, "Include mixed case variations") companyCmd.Flags().BoolVar(&yearSeparators, "year-separators", false, "Special characters to separate the company name and the year") companyCmd.Flags().BoolVar(&includeSpecialChars, "end-special", false, "Include special characters at the end of the passwords") + companyCmd.Flags().BoolVar(&includeAllPermutations, "all", false, "Run all permutations") + // companyCmd.Flags().BoolVar(&includeSpecialChars, "start-caps", false, "First letter in caps") + // companyCmd.Flags().BoolVar(&includeSpecialChars, "pass-pol", false, "Password Policy (remove bad passwords)") } func generateCompanyPasslist(name, city string, year int) []string { @@ -64,6 +68,13 @@ func generateCompanyPasslist(name, city string, year int) []string { wordlist = append(wordlist, strings.ToLower(name)) // Init the wordlist + if includeAllPermutations { + includeMixedCase = true + includeYear = true + yearSeparators = true + includeSpecialChars = true + } + // if includeUpperCase { // wordlist = append(wordlist, strings.ToUpper(name)) // } @@ -97,7 +108,7 @@ func generateCompanyPasslist(name, city string, year int) []string { if includeYear { var separators string if yearSeparators { - separators = "!@#$%+?=" + separators = "!@#$%+?=*" } wordlist = generate.WithYearAndSeparators(wordlist, year, separators) } diff --git a/lib/generate/generate.go b/lib/generate/generate.go index bd71210..d7d2827 100644 --- a/lib/generate/generate.go +++ b/lib/generate/generate.go @@ -8,7 +8,7 @@ import ( ) func WithSpecialChars(wordlist []string) []string { - specialChars := []string{"!", "@", "#", "$", "%", "+", "?", "="} // TODO: Configurable charset + specialChars := []string{"!", "@", "#", "$", "%", "+", "?", "=", "*"} // TODO: Configurable charset for _, word := range wordlist { for _, char := range specialChars { wordlist = append(wordlist, word+char) From 1b378a9bc8a9a0e6fb3427e994e801ae26fa6b20 Mon Sep 17 00:00:00 2001 From: QU35T-code <github@qu35t-mail.simplelogin.com> Date: Thu, 13 Jun 2024 09:11:51 +0200 Subject: [PATCH 16/37] feat(company): Add start caps flag + remove duplicate wordlists --- README.md | 9 +++++++++ cmd/company.go | 9 ++++++++- lib/generate/generate.go | 16 +++++++++++++--- 3 files changed, 30 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 93bd3f4..e5bb06f 100644 --- a/README.md +++ b/README.md @@ -94,3 +94,12 @@ PASSFINdEr@2024+ PASSFINdEr@2024? ``` +## Start caps + +```bash +> passfinder company -n passfinder --start-caps + +passfinder +Passfinder +``` + diff --git a/cmd/company.go b/cmd/company.go index ced1761..0444af1 100644 --- a/cmd/company.go +++ b/cmd/company.go @@ -15,6 +15,7 @@ var ( yearSeparators bool includeYear bool includeAllPermutations bool + startCaps bool // includeCity bool // includeAcronym bool includeSpecialChars bool @@ -38,6 +39,8 @@ var companyCmd = &cobra.Command{ year := time.Now().Year() wordlist := generateCompanyPasslist(companyName, city, year) + + // TODO: Remove duplicates for _, password := range wordlist { fmt.Println(password) } @@ -59,7 +62,7 @@ func init() { companyCmd.Flags().BoolVar(&yearSeparators, "year-separators", false, "Special characters to separate the company name and the year") companyCmd.Flags().BoolVar(&includeSpecialChars, "end-special", false, "Include special characters at the end of the passwords") companyCmd.Flags().BoolVar(&includeAllPermutations, "all", false, "Run all permutations") - // companyCmd.Flags().BoolVar(&includeSpecialChars, "start-caps", false, "First letter in caps") + companyCmd.Flags().BoolVar(&startCaps, "start-caps", false, "First letter in caps") // companyCmd.Flags().BoolVar(&includeSpecialChars, "pass-pol", false, "Password Policy (remove bad passwords)") } @@ -75,6 +78,10 @@ func generateCompanyPasslist(name, city string, year int) []string { includeSpecialChars = true } + if startCaps { + wordlist = generate.WithStartCaps(wordlist) + } + // if includeUpperCase { // wordlist = append(wordlist, strings.ToUpper(name)) // } diff --git a/lib/generate/generate.go b/lib/generate/generate.go index d7d2827..23b40a9 100644 --- a/lib/generate/generate.go +++ b/lib/generate/generate.go @@ -19,12 +19,11 @@ func WithSpecialChars(wordlist []string) []string { } func WithMixedCase(wordlist []string) []string { - var newWordlist []string for _, word := range wordlist { caseVariations := generateCaseVariations(word) - newWordlist = append(newWordlist, caseVariations...) + wordlist = append(wordlist, caseVariations...) } - return utils.RemoveDuplicates(newWordlist) + return utils.RemoveDuplicates(wordlist) } func generateCaseVariations(word string) []string { @@ -57,3 +56,14 @@ func WithYearAndSeparators(wordlist []string, year int, separators string) []str } return wordlist } + +func WithStartCaps(wordlist []string) []string { + for _, word := range wordlist { + if len(word) > 0 { + wordlist = append(wordlist, strings.ToUpper(string(word[0]))+word[1:]) + } else { + wordlist = append(wordlist, word) + } + } + return wordlist +} From b027831ab4341ff2cca407f284d28be0114d493a Mon Sep 17 00:00:00 2001 From: QU35T-code <github@qu35t-mail.simplelogin.com> Date: Thu, 13 Jun 2024 09:46:31 +0200 Subject: [PATCH 17/37] feat(company): Add short year flag --- README.md | 32 +++++++++++++++++++++++++++++--- cmd/company.go | 29 ++++++++++++++++++++++------- lib/generate/generate.go | 4 +--- 3 files changed, 52 insertions(+), 13 deletions(-) diff --git a/README.md b/README.md index e5bb06f..4e138da 100644 --- a/README.md +++ b/README.md @@ -60,7 +60,16 @@ PAsSfiNder passfinder2024 ``` -## year-separator +## Short year + +```bash +> passfinder company -n passfinder --short-year + +passfinder +passfinder24 +``` + +## year-separators ```bash > passfinder company -n passfinder --year --year-separators @@ -77,11 +86,28 @@ passfinder?2024 passfinder=2024 ``` +```bash +> passfinder company -n passfinder --short-year --year-separators + +passfinder +passfinder24 +passfinder!24 +passfinder@24 +passfinder#24 +passfinder$24 +passfinder%24 +passfinder+24 +passfinder?24 +passfinder=24 +passfinder*24 +``` + ## all ```bash > passfinder company -n passfinder --all +[...] PASSFINdEr!2024? PASSFINdEr!2024= PASSFINdEr!2024* @@ -92,6 +118,7 @@ PASSFINdEr@2024$ PASSFINdEr@2024% PASSFINdEr@2024+ PASSFINdEr@2024? +[...] ``` ## Start caps @@ -101,5 +128,4 @@ PASSFINdEr@2024? passfinder Passfinder -``` - +``` \ No newline at end of file diff --git a/cmd/company.go b/cmd/company.go index 0444af1..a8d3abf 100644 --- a/cmd/company.go +++ b/cmd/company.go @@ -6,6 +6,7 @@ import ( "time" "github.com/GoToolSharing/passfinder/lib/generate" + "github.com/GoToolSharing/passfinder/lib/utils" "github.com/spf13/cobra" ) @@ -16,6 +17,7 @@ var ( includeYear bool includeAllPermutations bool startCaps bool + shortYear bool // includeCity bool // includeAcronym bool includeSpecialChars bool @@ -31,16 +33,19 @@ var companyCmd = &cobra.Command{ Long: `Generate a passlist based on company name, current year, city, and other relevant information.`, Run: func(cmd *cobra.Command, args []string) { - if !includeYear && yearSeparators { - fmt.Println("You cannot use --year-separators without --year") + if (!includeYear && !shortYear) && yearSeparators { + fmt.Println("You cannot use --year-separators without --year or --short-year") return } - year := time.Now().Year() + if includeYear && shortYear { + fmt.Println("You cannot use both --year and --short-year") + return + } - wordlist := generateCompanyPasslist(companyName, city, year) + wordlist := generateCompanyPasslist(companyName, city) - // TODO: Remove duplicates + wordlist = utils.RemoveDuplicates(wordlist) for _, password := range wordlist { fmt.Println(password) } @@ -57,16 +62,16 @@ func init() { } // companyCmd.Flags().StringVarP(&city, "city", "c", "", "City of the company") companyCmd.Flags().BoolVar(&includeYear, "year", false, "Include the current year in passwords") - // companyCmd.Flags().BoolVar(&includeNumericSeq, "numeric", false, "Include numeric sequences in passwords") companyCmd.Flags().BoolVar(&includeMixedCase, "mixed-case", false, "Include mixed case variations") companyCmd.Flags().BoolVar(&yearSeparators, "year-separators", false, "Special characters to separate the company name and the year") companyCmd.Flags().BoolVar(&includeSpecialChars, "end-special", false, "Include special characters at the end of the passwords") companyCmd.Flags().BoolVar(&includeAllPermutations, "all", false, "Run all permutations") companyCmd.Flags().BoolVar(&startCaps, "start-caps", false, "First letter in caps") + companyCmd.Flags().BoolVar(&shortYear, "short-year", false, "Truncate the year to two digits") // companyCmd.Flags().BoolVar(&includeSpecialChars, "pass-pol", false, "Password Policy (remove bad passwords)") } -func generateCompanyPasslist(name, city string, year int) []string { +func generateCompanyPasslist(name, city string) []string { var wordlist []string wordlist = append(wordlist, strings.ToLower(name)) // Init the wordlist @@ -112,7 +117,17 @@ func generateCompanyPasslist(name, city string, year int) []string { wordlist = generate.WithMixedCase(wordlist) } + if shortYear { + year := time.Now().Year() % 100 + var separators string + if yearSeparators { + separators = "!@#$%+?=*" + } + wordlist = generate.WithYearAndSeparators(wordlist, year, separators) + } + if includeYear { + year := time.Now().Year() var separators string if yearSeparators { separators = "!@#$%+?=*" diff --git a/lib/generate/generate.go b/lib/generate/generate.go index 23b40a9..df9f14e 100644 --- a/lib/generate/generate.go +++ b/lib/generate/generate.go @@ -3,8 +3,6 @@ package generate import ( "fmt" "strings" - - "github.com/GoToolSharing/passfinder/lib/utils" ) func WithSpecialChars(wordlist []string) []string { @@ -23,7 +21,7 @@ func WithMixedCase(wordlist []string) []string { caseVariations := generateCaseVariations(word) wordlist = append(wordlist, caseVariations...) } - return utils.RemoveDuplicates(wordlist) + return wordlist } func generateCaseVariations(word string) []string { From 3d18c43ade7c594023b60f9afdf0d55f063f9e06 Mon Sep 17 00:00:00 2001 From: QU35T-code <github@qu35t-mail.simplelogin.com> Date: Thu, 13 Jun 2024 09:58:46 +0200 Subject: [PATCH 18/37] feat(company): Clean code --- cmd/company.go | 45 +++------------------------------------------ 1 file changed, 3 insertions(+), 42 deletions(-) diff --git a/cmd/company.go b/cmd/company.go index a8d3abf..ff1240d 100644 --- a/cmd/company.go +++ b/cmd/company.go @@ -18,13 +18,8 @@ var ( includeAllPermutations bool startCaps bool shortYear bool - // includeCity bool - // includeAcronym bool - includeSpecialChars bool - // includeNumericSeq bool - // includeUpperCase bool - // includeLowerCase bool - includeMixedCase bool + includeSpecialChars bool + includeMixedCase bool ) var companyCmd = &cobra.Command{ @@ -80,6 +75,7 @@ func generateCompanyPasslist(name, city string) []string { includeMixedCase = true includeYear = true yearSeparators = true + shortYear = false // We cannot have both year and shortYear includeSpecialChars = true } @@ -87,32 +83,6 @@ func generateCompanyPasslist(name, city string) []string { wordlist = generate.WithStartCaps(wordlist) } - // if includeUpperCase { - // wordlist = append(wordlist, strings.ToUpper(name)) - // } - - // if includeLowerCase { - // wordlist = append(wordlist, strings.ToLower(name)) - // } - - // if includeCity && city != "" { - // wordlist = append(wordlist, fmt.Sprintf("%s%s", name, city)) - // wordlist = append(wordlist, fmt.Sprintf("%s%s", city, name)) - // } - - // if includeAcronym { - // acronym := getAcronym(name) - // wordlist = append(wordlist, acronym) - // } - - // if includeNumericSeq { - // for i := 1; i <= 3; i++ { - // wordlist = append(wordlist, fmt.Sprintf("%s%d", name, i)) - // wordlist = append(wordlist, fmt.Sprintf("%s%d", strings.ToLower(name), i)) - // wordlist = append(wordlist, fmt.Sprintf("%s%d", strings.ToUpper(name), i)) - // } - // } - if includeMixedCase { wordlist = generate.WithMixedCase(wordlist) } @@ -141,12 +111,3 @@ func generateCompanyPasslist(name, city string) []string { return wordlist } - -// func getAcronym(name string) string { -// words := strings.Fields(name) -// acronym := "" -// for _, word := range words { -// acronym += strings.ToUpper(string(word[0])) -// } -// return acronym -// } From e10f342e4aedda0bd37fc76a63b75073ebb45a44 Mon Sep 17 00:00:00 2001 From: QU35T-code <github@qu35t-mail.simplelogin.com> Date: Thu, 13 Jun 2024 10:53:57 +0200 Subject: [PATCH 19/37] chore(company): Add leet flag --- README.md | 19 +++++++++++++++++++ cmd/company.go | 7 +++++++ lib/generate/generate.go | 40 ++++++++++++++++++++++++++++++++++++++++ 3 files changed, 66 insertions(+) diff --git a/README.md b/README.md index 4e138da..6dd8cf5 100644 --- a/README.md +++ b/README.md @@ -128,4 +128,23 @@ PASSFINdEr@2024? passfinder Passfinder +``` + +## Leet + +```bash +> passfinder company -n passfinder --leet + +[...] +p@5$f!nder +p@5$find3r +p@5$finder +p@5sf1nd3r +p@5sf1nder +p@5sf!nd3r +p@5sf!nder +p@5sfind3r +p@5sfinder +p@$5f1nd3r +[...] ``` \ No newline at end of file diff --git a/cmd/company.go b/cmd/company.go index ff1240d..092ab4e 100644 --- a/cmd/company.go +++ b/cmd/company.go @@ -20,6 +20,7 @@ var ( shortYear bool includeSpecialChars bool includeMixedCase bool + includeLeetCode bool ) var companyCmd = &cobra.Command{ @@ -63,6 +64,7 @@ func init() { companyCmd.Flags().BoolVar(&includeAllPermutations, "all", false, "Run all permutations") companyCmd.Flags().BoolVar(&startCaps, "start-caps", false, "First letter in caps") companyCmd.Flags().BoolVar(&shortYear, "short-year", false, "Truncate the year to two digits") + companyCmd.Flags().BoolVar(&includeLeetCode, "leet", false, "Add leet code") // companyCmd.Flags().BoolVar(&includeSpecialChars, "pass-pol", false, "Password Policy (remove bad passwords)") } @@ -77,6 +79,7 @@ func generateCompanyPasslist(name, city string) []string { yearSeparators = true shortYear = false // We cannot have both year and shortYear includeSpecialChars = true + includeLeetCode = true } if startCaps { @@ -87,6 +90,10 @@ func generateCompanyPasslist(name, city string) []string { wordlist = generate.WithMixedCase(wordlist) } + if includeLeetCode { + wordlist = generate.WithLeetCode(wordlist) + } + if shortYear { year := time.Now().Year() % 100 var separators string diff --git a/lib/generate/generate.go b/lib/generate/generate.go index df9f14e..08f85b7 100644 --- a/lib/generate/generate.go +++ b/lib/generate/generate.go @@ -65,3 +65,43 @@ func WithStartCaps(wordlist []string) []string { } return wordlist } + +func WithLeetCode(wordlist []string) []string { + leetMap := map[rune][]string{ + 'a': {"4", "@"}, 'A': {"4", "@"}, + 'e': {"3"}, 'E': {"3"}, + 'i': {"1", "!"}, 'I': {"1", "!"}, + 'o': {"0"}, 'O': {"0"}, + 's': {"5", "$"}, 'S': {"5", "$"}, + 't': {"7"}, 'T': {"7"}, + 'l': {"1"}, 'L': {"1"}, + } + + for _, word := range wordlist { + leetVariations := generateLeetVariations(word, leetMap) + wordlist = append(wordlist, leetVariations...) + } + + return wordlist +} + +func generateLeetVariations(word string, leetMap map[rune][]string) []string { + var result []string + helperLeet(word, "", 0, &result, leetMap) + return result +} + +func helperLeet(word, current string, index int, result *[]string, leetMap map[rune][]string) { + if index == len(word) { + *result = append(*result, current) + return + } + + char := rune(word[index]) + if leetChars, ok := leetMap[char]; ok { + for _, leetChar := range leetChars { + helperLeet(word, current+leetChar, index+1, result, leetMap) + } + } + helperLeet(word, current+string(char), index+1, result, leetMap) +} From 0d89079185f7195b4722a6b9232e3547206a59e1 Mon Sep 17 00:00:00 2001 From: QU35T-code <github@qu35t-mail.simplelogin.com> Date: Thu, 13 Jun 2024 12:11:45 +0200 Subject: [PATCH 20/37] feat(company): Add mask flag --- README.md | 21 +++++++++++++++ cmd/company.go | 6 +++++ lib/generate/generate.go | 55 ++++++++++++++++++++++++++++++++++++++++ 3 files changed, 82 insertions(+) diff --git a/README.md b/README.md index 6dd8cf5..e83c62a 100644 --- a/README.md +++ b/README.md @@ -18,6 +18,8 @@ <img alt="arm64" src="https://img.shields.io/badge/arm64%20(aarch64)-supported-success"> </div> +# Company + ## Special ```bash @@ -147,4 +149,23 @@ p@5sfind3r p@5sfinder p@$5f1nd3r [...] +``` + +## mask + +```bash +> passfinder company -n passfinder --mask "%w202%d%s" + +[...] +passfinder2027< +passfinder2027> +passfinder2027? +passfinder2027/ +passfinder2027\ +passfinder2028! +passfinder2028@ +passfinder2028# +passfinder2028$ +passfinder2028% +[...] ``` \ No newline at end of file diff --git a/cmd/company.go b/cmd/company.go index 092ab4e..c681101 100644 --- a/cmd/company.go +++ b/cmd/company.go @@ -21,6 +21,7 @@ var ( includeSpecialChars bool includeMixedCase bool includeLeetCode bool + includeMask string ) var companyCmd = &cobra.Command{ @@ -66,6 +67,7 @@ func init() { companyCmd.Flags().BoolVar(&shortYear, "short-year", false, "Truncate the year to two digits") companyCmd.Flags().BoolVar(&includeLeetCode, "leet", false, "Add leet code") // companyCmd.Flags().BoolVar(&includeSpecialChars, "pass-pol", false, "Password Policy (remove bad passwords)") + companyCmd.Flags().StringVar(&includeMask, "mask", "", "Add mask to the list (e.g., '%w%s')") } func generateCompanyPasslist(name, city string) []string { @@ -116,5 +118,9 @@ func generateCompanyPasslist(name, city string) []string { wordlist = generate.WithSpecialChars(wordlist) } + if includeMask != "" { + wordlist = generate.WithMask(wordlist, includeMask) + } + return wordlist } diff --git a/lib/generate/generate.go b/lib/generate/generate.go index 08f85b7..edafccf 100644 --- a/lib/generate/generate.go +++ b/lib/generate/generate.go @@ -105,3 +105,58 @@ func helperLeet(word, current string, index int, result *[]string, leetMap map[r } helperLeet(word, current+string(char), index+1, result, leetMap) } + +func WithMask(wordlist []string, mask string) []string { + specialChars := []rune("!@#$%^&*()_+-=[]{}|;:'\",.<>?/\\") + digits := []rune("0123456789") + lowercase := []rune("abcdefghijklmnopqrstuvwxyz") + uppercase := []rune("ABCDEFGHIJKLMNOPQRSTUVWXYZ") + allChars := append(append(append(lowercase, uppercase...), digits...), specialChars...) + + for _, word := range wordlist { + var maskedWords []string + applyMask(word, mask, "", &maskedWords, specialChars, digits, lowercase, uppercase, allChars) + wordlist = append(wordlist, maskedWords...) + } + + return wordlist +} + +func applyMask(word, mask, current string, result *[]string, specialChars, digits, lowercase, uppercase, allChars []rune) { + if len(mask) == 0 { + *result = append(*result, current) + return + } + + switch mask[0] { + case '%': + if len(mask) > 1 { + switch mask[1] { + case 'w': + applyMask(word, mask[2:], current+word, result, specialChars, digits, lowercase, uppercase, allChars) + case 's': + for _, char := range specialChars { + applyMask(word, mask[2:], current+string(char), result, specialChars, digits, lowercase, uppercase, allChars) + } + case 'l': + for _, char := range lowercase { + applyMask(word, mask[2:], current+string(char), result, specialChars, digits, lowercase, uppercase, allChars) + } + case 'u': + for _, char := range uppercase { + applyMask(word, mask[2:], current+string(char), result, specialChars, digits, lowercase, uppercase, allChars) + } + case 'd': + for _, char := range digits { + applyMask(word, mask[2:], current+string(char), result, specialChars, digits, lowercase, uppercase, allChars) + } + case 'a': + for _, char := range allChars { + applyMask(word, mask[2:], current+string(char), result, specialChars, digits, lowercase, uppercase, allChars) + } + } + } + default: + applyMask(word, mask[1:], current+string(mask[0]), result, specialChars, digits, lowercase, uppercase, allChars) + } +} From c6b1bbb80f42efd1a81f39b455d3d54baab55b5d Mon Sep 17 00:00:00 2001 From: QU35T-code <github@qu35t-mail.simplelogin.com> Date: Thu, 13 Jun 2024 12:33:14 +0200 Subject: [PATCH 21/37] feat(company): Add global output file flag --- README.md | 15 +++++++++++++++ cmd/company.go | 23 +++++++++++++++++++++-- cmd/root.go | 2 ++ config/config.go | 7 +++++++ 4 files changed, 45 insertions(+), 2 deletions(-) create mode 100644 config/config.go diff --git a/README.md b/README.md index e83c62a..d3654bb 100644 --- a/README.md +++ b/README.md @@ -18,6 +18,21 @@ <img alt="arm64" src="https://img.shields.io/badge/arm64%20(aarch64)-supported-success"> </div> + +# Installation + +## Stable + +```bash +go install https://github.com/GoToolSharing/passfinder +``` + +## Dev + +```bash +go install https://github.com/GoToolSharing/passfinder@dev +``` + # Company ## Special diff --git a/cmd/company.go b/cmd/company.go index c681101..9a3304d 100644 --- a/cmd/company.go +++ b/cmd/company.go @@ -2,9 +2,12 @@ package cmd import ( "fmt" + "log" + "os" "strings" "time" + "github.com/GoToolSharing/passfinder/config" "github.com/GoToolSharing/passfinder/lib/generate" "github.com/GoToolSharing/passfinder/lib/utils" "github.com/spf13/cobra" @@ -43,8 +46,23 @@ var companyCmd = &cobra.Command{ wordlist := generateCompanyPasslist(companyName, city) wordlist = utils.RemoveDuplicates(wordlist) - for _, password := range wordlist { - fmt.Println(password) + if config.GlobalConfig.OutputFile != "" { + file, err := os.OpenFile(config.GlobalConfig.OutputFile, os.O_APPEND|os.O_CREATE|os.O_WRONLY, 0644) + if err != nil { + log.Fatal(err) + } + defer file.Close() + for _, password := range wordlist { + _, err := file.WriteString(password + "\n") + if err != nil { + log.Fatal(err) + break + } + } + } else { + for _, password := range wordlist { + fmt.Println(password) + } } }, } @@ -82,6 +100,7 @@ func generateCompanyPasslist(name, city string) []string { shortYear = false // We cannot have both year and shortYear includeSpecialChars = true includeLeetCode = true + startCaps = true } if startCaps { diff --git a/cmd/root.go b/cmd/root.go index 2f72b89..0fd38a6 100644 --- a/cmd/root.go +++ b/cmd/root.go @@ -3,6 +3,7 @@ package cmd import ( "os" + "github.com/GoToolSharing/passfinder/config" "github.com/spf13/cobra" ) @@ -21,4 +22,5 @@ func Execute() { func init() { rootCmd.CompletionOptions.DisableDefaultCmd = true + rootCmd.PersistentFlags().StringVarP(&config.GlobalConfig.OutputFile, "output", "", "", "Output file") } diff --git a/config/config.go b/config/config.go new file mode 100644 index 0000000..ca4b9bd --- /dev/null +++ b/config/config.go @@ -0,0 +1,7 @@ +package config + +type Settings struct { + OutputFile string +} + +var GlobalConfig Settings From f307b97d565211a2fd532f400564f9cafa8786da Mon Sep 17 00:00:00 2001 From: QU35T-code <github@qu35t-mail.simplelogin.com> Date: Fri, 14 Jun 2024 15:53:38 +0200 Subject: [PATCH 22/37] chore: Update README.md and add check to golangci --- README.md | 194 ++++++--------------------------------------------- golangci.yml | 2 +- 2 files changed, 22 insertions(+), 174 deletions(-) diff --git a/README.md b/README.md index d3654bb..d961c1e 100644 --- a/README.md +++ b/README.md @@ -1,186 +1,34 @@ # Passfinder -![Workflows (main)](https://github.com/GoToolSharing/passfinder/actions/workflows/go.yml/badge.svg?branch=main) -![Workflows (dev)](https://github.com/GoToolSharing/passfinder/actions/workflows/go.yml/badge.svg?branch=dev) -![GitHub go.mod Go version (main)](https://img.shields.io/github/go-mod/go-version/GoToolSharing/passfinder/main) -![GitHub go.mod Go version (dev)](https://img.shields.io/github/go-mod/go-version/GoToolSharing/passfinder/dev) -![GitHub release](https://img.shields.io/github/v/release/GoToolSharing/passfinder) -![GitHub Repo stars](https://img.shields.io/github/stars/GoToolSharing/passfinder) -<a target="_blank" rel="noopener noreferrer" href="https://twitter.com/QU35T_TV" title="Follow"><img src="https://img.shields.io/twitter/follow/QU35T_TV?label=QU35T_TV&style=social" alt="Twitter QU35T_TV"></a> -<div> +<div align="center"> + <img alt="Workflows (main)" src="https://github.com/GoToolSharing/passfinder/actions/workflows/go.yml/badge.svg?branch=main"> + <img alt="Workflows (dev)" src="https://github.com/GoToolSharing/passfinder/actions/workflows/go.yml/badge.svg?branch=dev"> +</div> +<div align="center"> + <img alt="GitHub go.mod Go version (main)" src="https://img.shields.io/github/go-mod/go-version/GoToolSharing/passfinder/main"> + <img alt="GitHub go.mod Go version (dev)" src="https://img.shields.io/github/go-mod/go-version/GoToolSharing/passfinder/dev"> +</div> +<div align="center"> + <img alt="GitHub release" src="https://img.shields.io/github/v/release/GoToolSharing/passfinder"> + <img alt="GitHub Repo stars" src="https://img.shields.io/github/stars/GoToolSharing/passfinder"> + <a target="_blank" rel="noopener noreferrer" href="https://twitter.com/QU35T_TV" title="Follow"><img src="https://img.shields.io/twitter/follow/QU35T_TV?label=QU35T_TV&style=social" alt="Twitter QU35T_TV"></a> +</div> +<div align="center"> <img alt="current version" src="https://img.shields.io/badge/linux-supported-success"> <img alt="current version" src="https://img.shields.io/badge/WSL-supported-success"> <img alt="current version" src="https://img.shields.io/badge/mac-supported-success"> - <br> +</div> +<div align="center"> <img alt="amd64" src="https://img.shields.io/badge/amd64%20(x86__64)-supported-success"> <img alt="arm64" src="https://img.shields.io/badge/arm64%20(aarch64)-supported-success"> </div> +<!-- <div align="center"> + <img src="./assets/logo.png" alt="Alt text" width="400"> +</div></br> --> -# Installation - -## Stable - -```bash -go install https://github.com/GoToolSharing/passfinder -``` - -## Dev - -```bash -go install https://github.com/GoToolSharing/passfinder@dev -``` - -# Company - -## Special - -```bash -> passfinder company -n passfinder --special - -passfinder -passfinder! -passfinder@ -passfinder# -passfinder$ -passfinder% -passfinder+ -passfinder? -passfinder= -``` - -## mixed-case - -```bash -> passfinder company -n passfinder --mixed-case - -PAssFINDER -PAsSfinder -PAsSfindeR -PAsSfindEr -PAsSfindER -PAsSfinDer -PAsSfinDeR -PAsSfinDEr -PAsSfinDER -PAsSfiNder -[...] -``` - -## Year - -```bash -> passfinder company -n passfinder --year - -passfinder2024 -``` - -## Short year - -```bash -> passfinder company -n passfinder --short-year - -passfinder -passfinder24 -``` - -## year-separators - -```bash -> passfinder company -n passfinder --year --year-separators - -passfinder -passfinder2024 -passfinder!2024 -passfinder@2024 -passfinder#2024 -passfinder$2024 -passfinder%2024 -passfinder+2024 -passfinder?2024 -passfinder=2024 -``` - -```bash -> passfinder company -n passfinder --short-year --year-separators - -passfinder -passfinder24 -passfinder!24 -passfinder@24 -passfinder#24 -passfinder$24 -passfinder%24 -passfinder+24 -passfinder?24 -passfinder=24 -passfinder*24 -``` - -## all - -```bash -> passfinder company -n passfinder --all - -[...] -PASSFINdEr!2024? -PASSFINdEr!2024= -PASSFINdEr!2024* -PASSFINdEr@2024! -PASSFINdEr@2024@ -PASSFINdEr@2024# -PASSFINdEr@2024$ -PASSFINdEr@2024% -PASSFINdEr@2024+ -PASSFINdEr@2024? -[...] -``` - -## Start caps - -```bash -> passfinder company -n passfinder --start-caps - -passfinder -Passfinder -``` - -## Leet - -```bash -> passfinder company -n passfinder --leet - -[...] -p@5$f!nder -p@5$find3r -p@5$finder -p@5sf1nd3r -p@5sf1nder -p@5sf!nd3r -p@5sf!nder -p@5sfind3r -p@5sfinder -p@$5f1nd3r -[...] -``` - -## mask - -```bash -> passfinder company -n passfinder --mask "%w202%d%s" +# Official Documentation -[...] -passfinder2027< -passfinder2027> -passfinder2027? -passfinder2027/ -passfinder2027\ -passfinder2028! -passfinder2028@ -passfinder2028# -passfinder2028$ -passfinder2028% -[...] -``` \ No newline at end of file +The official documentation for passfinder is hosted on Github Pages and can be accessed via the following link: <a href="https://docs.passfinder.qu35t.pw" target="_blank">https://docs.passfinder.qu35t.pw</a> \ No newline at end of file diff --git a/golangci.yml b/golangci.yml index c68f99b..8da3ff0 100644 --- a/golangci.yml +++ b/golangci.yml @@ -21,7 +21,7 @@ linters: - ineffassign - staticcheck - typecheck - # - unused + - unused # Non Default linters - asciicheck - bodyclose From cc5e1395f0dbf76cfa1c8f0e7b719b9334e75499 Mon Sep 17 00:00:00 2001 From: QU35T-code <github@qu35t-mail.simplelogin.com> Date: Fri, 14 Jun 2024 15:53:57 +0200 Subject: [PATCH 23/37] feat(company): Clean code and change all flag description --- cmd/company.go | 48 ++++++++++++++++++++++++------------------------ cmd/root.go | 5 ++--- 2 files changed, 26 insertions(+), 27 deletions(-) diff --git a/cmd/company.go b/cmd/company.go index 9a3304d..c50ed23 100644 --- a/cmd/company.go +++ b/cmd/company.go @@ -16,11 +16,11 @@ import ( var ( companyName string city string - yearSeparators bool + includeYearSeparators bool includeYear bool includeAllPermutations bool - startCaps bool - shortYear bool + includeStartCaps bool + includeShortYear bool includeSpecialChars bool includeMixedCase bool includeLeetCode bool @@ -33,15 +33,17 @@ var companyCmd = &cobra.Command{ Long: `Generate a passlist based on company name, current year, city, and other relevant information.`, Run: func(cmd *cobra.Command, args []string) { - if (!includeYear && !shortYear) && yearSeparators { + // Temp + if (!includeYear && !includeShortYear) && includeYearSeparators { fmt.Println("You cannot use --year-separators without --year or --short-year") return } - if includeYear && shortYear { + if includeYear && includeShortYear { fmt.Println("You cannot use both --year and --short-year") return } + // End Temp wordlist := generateCompanyPasslist(companyName, city) @@ -75,35 +77,33 @@ func init() { if err != nil { return } - // companyCmd.Flags().StringVarP(&city, "city", "c", "", "City of the company") - companyCmd.Flags().BoolVar(&includeYear, "year", false, "Include the current year in passwords") - companyCmd.Flags().BoolVar(&includeMixedCase, "mixed-case", false, "Include mixed case variations") - companyCmd.Flags().BoolVar(&yearSeparators, "year-separators", false, "Special characters to separate the company name and the year") - companyCmd.Flags().BoolVar(&includeSpecialChars, "end-special", false, "Include special characters at the end of the passwords") - companyCmd.Flags().BoolVar(&includeAllPermutations, "all", false, "Run all permutations") - companyCmd.Flags().BoolVar(&startCaps, "start-caps", false, "First letter in caps") - companyCmd.Flags().BoolVar(&shortYear, "short-year", false, "Truncate the year to two digits") - companyCmd.Flags().BoolVar(&includeLeetCode, "leet", false, "Add leet code") - // companyCmd.Flags().BoolVar(&includeSpecialChars, "pass-pol", false, "Password Policy (remove bad passwords)") - companyCmd.Flags().StringVar(&includeMask, "mask", "", "Add mask to the list (e.g., '%w%s')") + companyCmd.Flags().BoolVarP(&includeYear, "year", "y", false, "Include the current year in the passwords") + companyCmd.Flags().BoolVar(&includeMixedCase, "mixed-case", false, "Include variations with mixed case") + companyCmd.Flags().BoolVar(&includeYearSeparators, "year-separators", false, "Add special characters between the company name and the year") + companyCmd.Flags().BoolVarP(&includeSpecialChars, "end-special", "s", false, "Add special characters at the end of the passwords") + companyCmd.Flags().BoolVarP(&includeAllPermutations, "all", "a", false, "Generate all possible permutations of the password") + companyCmd.Flags().BoolVar(&includeStartCaps, "start-caps", false, "Capitalize the first letter of the passwords") + companyCmd.Flags().BoolVar(&includeShortYear, "short-year", false, "Truncate the year to the last two digits") + companyCmd.Flags().BoolVarP(&includeLeetCode, "leet", "l", false, "Convert characters to leet speak") + companyCmd.Flags().StringVarP(&includeMask, "mask", "m", "", "Apply a custom mask to the passwords") } func generateCompanyPasslist(name, city string) []string { var wordlist []string - wordlist = append(wordlist, strings.ToLower(name)) // Init the wordlist + wordlist = append(wordlist, strings.ToLower(name)) if includeAllPermutations { includeMixedCase = true includeYear = true - yearSeparators = true - shortYear = false // We cannot have both year and shortYear + includeYearSeparators = true + includeShortYear = false includeSpecialChars = true includeLeetCode = true - startCaps = true + includeStartCaps = true } - if startCaps { + if includeStartCaps { wordlist = generate.WithStartCaps(wordlist) } @@ -115,10 +115,10 @@ func generateCompanyPasslist(name, city string) []string { wordlist = generate.WithLeetCode(wordlist) } - if shortYear { + if includeShortYear { year := time.Now().Year() % 100 var separators string - if yearSeparators { + if includeYearSeparators { separators = "!@#$%+?=*" } wordlist = generate.WithYearAndSeparators(wordlist, year, separators) @@ -127,7 +127,7 @@ func generateCompanyPasslist(name, city string) []string { if includeYear { year := time.Now().Year() var separators string - if yearSeparators { + if includeYearSeparators { separators = "!@#$%+?=*" } wordlist = generate.WithYearAndSeparators(wordlist, year, separators) diff --git a/cmd/root.go b/cmd/root.go index 0fd38a6..00d591f 100644 --- a/cmd/root.go +++ b/cmd/root.go @@ -9,8 +9,7 @@ import ( var rootCmd = &cobra.Command{ Use: "passfinder", - Short: "TODO", - Long: `TODO`, + Short: "Generate password wordlists with customizable options for security testing !", } func Execute() { @@ -22,5 +21,5 @@ func Execute() { func init() { rootCmd.CompletionOptions.DisableDefaultCmd = true - rootCmd.PersistentFlags().StringVarP(&config.GlobalConfig.OutputFile, "output", "", "", "Output file") + rootCmd.PersistentFlags().StringVarP(&config.GlobalConfig.OutputFile, "output", "o", "", "Write to output file") } From d7fcbebff9a286925c4c0034005a0ea781eb0955 Mon Sep 17 00:00:00 2001 From: QU35T-code <github@qu35t-mail.simplelogin.com> Date: Fri, 14 Jun 2024 16:36:17 +0200 Subject: [PATCH 24/37] feat(company): Add uppercase option Closes https://github.com/GoToolSharing/passfinder/issues/1 --- cmd/company.go | 6 ++++++ lib/generate/generate.go | 7 +++++++ 2 files changed, 13 insertions(+) diff --git a/cmd/company.go b/cmd/company.go index c50ed23..097a31b 100644 --- a/cmd/company.go +++ b/cmd/company.go @@ -24,6 +24,7 @@ var ( includeSpecialChars bool includeMixedCase bool includeLeetCode bool + includeUppercase bool includeMask string ) @@ -85,6 +86,7 @@ func init() { companyCmd.Flags().BoolVar(&includeStartCaps, "start-caps", false, "Capitalize the first letter of the passwords") companyCmd.Flags().BoolVar(&includeShortYear, "short-year", false, "Truncate the year to the last two digits") companyCmd.Flags().BoolVarP(&includeLeetCode, "leet", "l", false, "Convert characters to leet speak") + companyCmd.Flags().BoolVarP(&includeUppercase, "uppercase", "u", false, "Capitalize all letters of the passwords") companyCmd.Flags().StringVarP(&includeMask, "mask", "m", "", "Apply a custom mask to the passwords") } @@ -115,6 +117,10 @@ func generateCompanyPasslist(name, city string) []string { wordlist = generate.WithLeetCode(wordlist) } + if includeUppercase { + wordlist = generate.WithUppercase(wordlist) + } + if includeShortYear { year := time.Now().Year() % 100 var separators string diff --git a/lib/generate/generate.go b/lib/generate/generate.go index edafccf..7205436 100644 --- a/lib/generate/generate.go +++ b/lib/generate/generate.go @@ -160,3 +160,10 @@ func applyMask(word, mask, current string, result *[]string, specialChars, digit applyMask(word, mask[1:], current+string(mask[0]), result, specialChars, digits, lowercase, uppercase, allChars) } } + +func WithUppercase(wordlist []string) []string { + for _, word := range wordlist { + wordlist = append(wordlist, strings.ToUpper(word)) + } + return wordlist +} From c8f21157eb98431698a7db02dee94666cb5a426a Mon Sep 17 00:00:00 2001 From: QU35T-code <github@qu35t-mail.simplelogin.com> Date: Fri, 14 Jun 2024 17:06:10 +0200 Subject: [PATCH 25/37] feat(company): Add year-range flag --- cmd/company.go | 22 ++++++++++++---------- lib/generate/generate.go | 24 +++++++++++++++++++----- 2 files changed, 31 insertions(+), 15 deletions(-) diff --git a/cmd/company.go b/cmd/company.go index 097a31b..3724ffb 100644 --- a/cmd/company.go +++ b/cmd/company.go @@ -26,6 +26,7 @@ var ( includeLeetCode bool includeUppercase bool includeMask string + includeYearRange int ) var companyCmd = &cobra.Command{ @@ -44,6 +45,11 @@ var companyCmd = &cobra.Command{ fmt.Println("You cannot use both --year and --short-year") return } + + if (!includeYear && !includeShortYear) && includeYearRange != 0 { + fmt.Println("You cannot use --year-range without --year or --short-year") + return + } // End Temp wordlist := generateCompanyPasslist(companyName, city) @@ -79,8 +85,9 @@ func init() { return } companyCmd.Flags().BoolVarP(&includeYear, "year", "y", false, "Include the current year in the passwords") - companyCmd.Flags().BoolVar(&includeMixedCase, "mixed-case", false, "Include variations with mixed case") companyCmd.Flags().BoolVar(&includeYearSeparators, "year-separators", false, "Add special characters between the company name and the year") + companyCmd.Flags().IntVar(&includeYearRange, "year-range", 0, "Include a range of years around the current year") + companyCmd.Flags().BoolVar(&includeMixedCase, "mixed-case", false, "Include variations with mixed case") companyCmd.Flags().BoolVarP(&includeSpecialChars, "end-special", "s", false, "Add special characters at the end of the passwords") companyCmd.Flags().BoolVarP(&includeAllPermutations, "all", "a", false, "Generate all possible permutations of the password") companyCmd.Flags().BoolVar(&includeStartCaps, "start-caps", false, "Capitalize the first letter of the passwords") @@ -121,22 +128,17 @@ func generateCompanyPasslist(name, city string) []string { wordlist = generate.WithUppercase(wordlist) } + year := time.Now().Year() if includeShortYear { - year := time.Now().Year() % 100 - var separators string - if includeYearSeparators { - separators = "!@#$%+?=*" - } - wordlist = generate.WithYearAndSeparators(wordlist, year, separators) + year = year % 100 } - if includeYear { - year := time.Now().Year() + if includeYear || includeShortYear { var separators string if includeYearSeparators { separators = "!@#$%+?=*" } - wordlist = generate.WithYearAndSeparators(wordlist, year, separators) + wordlist = generate.WithYearAndSeparators(wordlist, year, separators, includeYearRange) } if includeSpecialChars { diff --git a/lib/generate/generate.go b/lib/generate/generate.go index 7205436..3e8cfcf 100644 --- a/lib/generate/generate.go +++ b/lib/generate/generate.go @@ -43,16 +43,30 @@ func helper(word, current string, index int, result *[]string) { } } -func WithYearAndSeparators(wordlist []string, year int, separators string) []string { +func WithYearAndSeparators(wordlist []string, year int, separators string, yearRange int) []string { + var newWordlist []string separatorsList := strings.Split(separators, "") - for _, word := range wordlist { - wordlist = append(wordlist, fmt.Sprintf("%s%d", word, year)) + addYearWithSeparators := func(word string, year int) { + newWordlist = append(newWordlist, fmt.Sprintf("%s%d", word, year)) for _, separator := range separatorsList { - wordlist = append(wordlist, fmt.Sprintf("%s%s%d", word, separator, year)) + newWordlist = append(newWordlist, fmt.Sprintf("%s%s%d", word, separator, year)) } } - return wordlist + + if yearRange > 0 { + for i := year - yearRange; i <= year+yearRange; i++ { + for _, word := range wordlist { + addYearWithSeparators(word, i) + } + } + } else { + for _, word := range wordlist { + addYearWithSeparators(word, year) + } + } + + return append(wordlist, newWordlist...) } func WithStartCaps(wordlist []string) []string { From ce6d85b688ec8abcf81fcf3ab5b5bb0536b2c015 Mon Sep 17 00:00:00 2001 From: QU35T-code <github@qu35t-mail.simplelogin.com> Date: Fri, 14 Jun 2024 22:01:15 +0200 Subject: [PATCH 26/37] tests: Add basic company tests and add tests to the pipeline --- .github/workflows/go.yml | 8 +- cmd/company_test.go | 195 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 202 insertions(+), 1 deletion(-) create mode 100644 cmd/company_test.go diff --git a/.github/workflows/go.yml b/.github/workflows/go.yml index 9eac6dd..3d98ccf 100644 --- a/.github/workflows/go.yml +++ b/.github/workflows/go.yml @@ -35,4 +35,10 @@ jobs: env: GOOS: ${{ matrix.os }} GOARCH: ${{ matrix.arch }} - run: go build -v ./... \ No newline at end of file + run: go build -v ./... + + - name: test + env: + GOOS: ${{ matrix.os }} + GOARCH: ${{ matrix.arch }} + run: go test -v ./... \ No newline at end of file diff --git a/cmd/company_test.go b/cmd/company_test.go new file mode 100644 index 0000000..5ffa974 --- /dev/null +++ b/cmd/company_test.go @@ -0,0 +1,195 @@ +package cmd + +import ( + "strings" + "testing" +) + +func cleanup() { + includeYearSeparators = false + includeYear = false + includeStartCaps = false + includeShortYear = false + includeEndSpecial = false + includeMixedCase = false + includeLeetCode = false + includeUppercase = false + includeMask = "" + includeYearRange = 0 +} + +func TestWithoutFlag(t *testing.T) { + wordlist := generateCompanyPasslist("demo") + + got := strings.Join(wordlist, "\n") + + expected := "demo" + + if got != expected { + t.Errorf("Expected %q, but got %q", expected, got) + } + + t.Cleanup(cleanup) +} + +func TestYearFlag(t *testing.T) { + includeYear = true + + wordlist := generateCompanyPasslist("demo") + + got := strings.Join(wordlist, "\n") + + expected := "demo\ndemo2024" + + if got != expected { + t.Errorf("Expected %q, but got %q", expected, got) + } + + t.Cleanup(cleanup) +} + +func TestYearRangeFlag(t *testing.T) { + includeYear = true + includeYearRange = 3 + + wordlist := generateCompanyPasslist("demo") + + got := strings.Join(wordlist, "\n") + + expected := "demo\ndemo2021\ndemo2022\ndemo2023\ndemo2024\ndemo2025\ndemo2026\ndemo2027" + + if got != expected { + t.Errorf("Expected %q, but got %q", expected, got) + } + + t.Cleanup(cleanup) +} + +func TestEndSpecialFlag(t *testing.T) { + includeEndSpecial = true + + wordlist := generateCompanyPasslist("demo") + + got := strings.Join(wordlist, "\n") + + expected := "demo\ndemo!\ndemo@\ndemo#\ndemo$\ndemo%\ndemo+\ndemo?\ndemo=\ndemo*" + + if got != expected { + t.Errorf("Expected %q, but got %q", expected, got) + } + + t.Cleanup(cleanup) +} + +func TestUppercaseFlag(t *testing.T) { + includeUppercase = true + + wordlist := generateCompanyPasslist("demo") + + got := strings.Join(wordlist, "\n") + + expected := "demo\nDEMO" + + if got != expected { + t.Errorf("Expected %q, but got %q", expected, got) + } + + t.Cleanup(cleanup) +} + +func TestLeetFlag(t *testing.T) { + includeLeetCode = true + + wordlist := generateCompanyPasslist("demo") + + got := strings.Join(wordlist, "\n") + + expected := "demo\nd3m0\nd3mo\ndem0" + + if got != expected { + t.Errorf("Expected %q, but got %q", expected, got) + } + + t.Cleanup(cleanup) +} + +func TestStartCapsFlag(t *testing.T) { + includeStartCaps = true + + wordlist := generateCompanyPasslist("demo") + + got := strings.Join(wordlist, "\n") + + expected := "demo\nDemo" + + if got != expected { + t.Errorf("Expected %q, but got %q", expected, got) + } + + t.Cleanup(cleanup) +} + +func TestShortYearFlag(t *testing.T) { + includeShortYear = true + + wordlist := generateCompanyPasslist("demo") + + got := strings.Join(wordlist, "\n") + + expected := "demo\ndemo24" + + if got != expected { + t.Errorf("Expected %q, but got %q", expected, got) + } + + t.Cleanup(cleanup) +} + +func TestMixedCaseFlag(t *testing.T) { + includeMixedCase = true + + wordlist := generateCompanyPasslist("demo") + + got := strings.Join(wordlist, "\n") + + expected := "demo\ndemO\ndeMo\ndeMO\ndEmo\ndEmO\ndEMo\ndEMO\nDemo\nDemO\nDeMo\nDeMO\nDEmo\nDEmO\nDEMo\nDEMO" + + if got != expected { + t.Errorf("Expected %q, but got %q", expected, got) + } + + t.Cleanup(cleanup) +} + +func TestYearSeparatorsFlag(t *testing.T) { + includeYear = true + includeYearSeparators = true + + wordlist := generateCompanyPasslist("demo") + + got := strings.Join(wordlist, "\n") + + expected := "demo\ndemo2024\ndemo!2024\ndemo@2024\ndemo#2024\ndemo$2024\ndemo%2024\ndemo+2024\ndemo?2024\ndemo=2024\ndemo*2024" + + if got != expected { + t.Errorf("Expected %q, but got %q", expected, got) + } + + t.Cleanup(cleanup) +} + +func TestMaskFlag(t *testing.T) { + includeMask = "%w%d" + + wordlist := generateCompanyPasslist("demo") + + got := strings.Join(wordlist, "\n") + + expected := "demo\ndemo0\ndemo1\ndemo2\ndemo3\ndemo4\ndemo5\ndemo6\ndemo7\ndemo8\ndemo9" + + if got != expected { + t.Errorf("Expected %q, but got %q", expected, got) + } + + t.Cleanup(cleanup) +} From db0417bda013ced8623a65018c2a172ec9858047 Mon Sep 17 00:00:00 2001 From: QU35T-code <github@qu35t-mail.simplelogin.com> Date: Fri, 14 Jun 2024 22:01:29 +0200 Subject: [PATCH 27/37] feat(company): Clean code --- cmd/company.go | 46 ++++++++++++++++------------------------------ 1 file changed, 16 insertions(+), 30 deletions(-) diff --git a/cmd/company.go b/cmd/company.go index 3724ffb..c5bfd7a 100644 --- a/cmd/company.go +++ b/cmd/company.go @@ -14,19 +14,17 @@ import ( ) var ( - companyName string - city string - includeYearSeparators bool - includeYear bool - includeAllPermutations bool - includeStartCaps bool - includeShortYear bool - includeSpecialChars bool - includeMixedCase bool - includeLeetCode bool - includeUppercase bool - includeMask string - includeYearRange int + companyName string + includeYearSeparators bool + includeYear bool + includeStartCaps bool + includeShortYear bool + includeEndSpecial bool + includeMixedCase bool + includeLeetCode bool + includeUppercase bool + includeMask string + includeYearRange int ) var companyCmd = &cobra.Command{ @@ -52,9 +50,8 @@ var companyCmd = &cobra.Command{ } // End Temp - wordlist := generateCompanyPasslist(companyName, city) + wordlist := generateCompanyPasslist(companyName) - wordlist = utils.RemoveDuplicates(wordlist) if config.GlobalConfig.OutputFile != "" { file, err := os.OpenFile(config.GlobalConfig.OutputFile, os.O_APPEND|os.O_CREATE|os.O_WRONLY, 0644) if err != nil { @@ -88,8 +85,7 @@ func init() { companyCmd.Flags().BoolVar(&includeYearSeparators, "year-separators", false, "Add special characters between the company name and the year") companyCmd.Flags().IntVar(&includeYearRange, "year-range", 0, "Include a range of years around the current year") companyCmd.Flags().BoolVar(&includeMixedCase, "mixed-case", false, "Include variations with mixed case") - companyCmd.Flags().BoolVarP(&includeSpecialChars, "end-special", "s", false, "Add special characters at the end of the passwords") - companyCmd.Flags().BoolVarP(&includeAllPermutations, "all", "a", false, "Generate all possible permutations of the password") + companyCmd.Flags().BoolVarP(&includeEndSpecial, "end-special", "s", false, "Add special characters at the end of the passwords") companyCmd.Flags().BoolVar(&includeStartCaps, "start-caps", false, "Capitalize the first letter of the passwords") companyCmd.Flags().BoolVar(&includeShortYear, "short-year", false, "Truncate the year to the last two digits") companyCmd.Flags().BoolVarP(&includeLeetCode, "leet", "l", false, "Convert characters to leet speak") @@ -97,21 +93,11 @@ func init() { companyCmd.Flags().StringVarP(&includeMask, "mask", "m", "", "Apply a custom mask to the passwords") } -func generateCompanyPasslist(name, city string) []string { +func generateCompanyPasslist(name string) []string { var wordlist []string wordlist = append(wordlist, strings.ToLower(name)) - if includeAllPermutations { - includeMixedCase = true - includeYear = true - includeYearSeparators = true - includeShortYear = false - includeSpecialChars = true - includeLeetCode = true - includeStartCaps = true - } - if includeStartCaps { wordlist = generate.WithStartCaps(wordlist) } @@ -141,7 +127,7 @@ func generateCompanyPasslist(name, city string) []string { wordlist = generate.WithYearAndSeparators(wordlist, year, separators, includeYearRange) } - if includeSpecialChars { + if includeEndSpecial { wordlist = generate.WithSpecialChars(wordlist) } @@ -149,5 +135,5 @@ func generateCompanyPasslist(name, city string) []string { wordlist = generate.WithMask(wordlist, includeMask) } - return wordlist + return utils.RemoveDuplicates(wordlist) } From 443173929e1996f6260eb08b682e92886b0b46cd Mon Sep 17 00:00:00 2001 From: QU35T-code <github@qu35t-mail.simplelogin.com> Date: Fri, 14 Jun 2024 22:05:01 +0200 Subject: [PATCH 28/37] pipeline: Fix tests removing GOARCH flag --- .github/workflows/go.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/go.yml b/.github/workflows/go.yml index 3d98ccf..b9ab321 100644 --- a/.github/workflows/go.yml +++ b/.github/workflows/go.yml @@ -40,5 +40,4 @@ jobs: - name: test env: GOOS: ${{ matrix.os }} - GOARCH: ${{ matrix.arch }} run: go test -v ./... \ No newline at end of file From cd2a57d477abfc743975108f0e6306f21cfaaa59 Mon Sep 17 00:00:00 2001 From: QU35T-code <github@qu35t-mail.simplelogin.com> Date: Fri, 14 Jun 2024 22:07:58 +0200 Subject: [PATCH 29/37] chore: Upgrade to the last golang version (1.22) --- .github/workflows/go.yml | 1 + go.mod | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/go.yml b/.github/workflows/go.yml index b9ab321..3d98ccf 100644 --- a/.github/workflows/go.yml +++ b/.github/workflows/go.yml @@ -40,4 +40,5 @@ jobs: - name: test env: GOOS: ${{ matrix.os }} + GOARCH: ${{ matrix.arch }} run: go test -v ./... \ No newline at end of file diff --git a/go.mod b/go.mod index 9971669..d12a327 100644 --- a/go.mod +++ b/go.mod @@ -1,6 +1,6 @@ module github.com/GoToolSharing/passfinder -go 1.20 +go 1.22 require github.com/spf13/cobra v1.8.0 From 682f5a4039f55f9f98b6372c89afbbbe3dbe4a52 Mon Sep 17 00:00:00 2001 From: QU35T-code <github@qu35t-mail.simplelogin.com> Date: Fri, 14 Jun 2024 22:09:09 +0200 Subject: [PATCH 30/37] chore: Downgrade to 1.19 --- go.mod | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/go.mod b/go.mod index d12a327..3fedd30 100644 --- a/go.mod +++ b/go.mod @@ -1,6 +1,6 @@ module github.com/GoToolSharing/passfinder -go 1.22 +go 1.19 require github.com/spf13/cobra v1.8.0 From 0fac3cbe5bba7123f4bafe4a5af52e0ebbdca9ae Mon Sep 17 00:00:00 2001 From: QU35T-code <github@qu35t-mail.simplelogin.com> Date: Fri, 14 Jun 2024 22:10:20 +0200 Subject: [PATCH 31/37] chore: Remove go.mod version --- go.mod | 2 -- 1 file changed, 2 deletions(-) diff --git a/go.mod b/go.mod index 3fedd30..62809c9 100644 --- a/go.mod +++ b/go.mod @@ -1,7 +1,5 @@ module github.com/GoToolSharing/passfinder -go 1.19 - require github.com/spf13/cobra v1.8.0 require ( From ae05e0b4e2af793f9161ab6344f81747872425e2 Mon Sep 17 00:00:00 2001 From: QU35T-code <github@qu35t-mail.simplelogin.com> Date: Fri, 14 Jun 2024 22:16:10 +0200 Subject: [PATCH 32/37] chore: Hardcode go test version and arch --- .github/workflows/go.yml | 4 ++-- go.mod | 2 ++ 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/.github/workflows/go.yml b/.github/workflows/go.yml index 3d98ccf..ab78a1c 100644 --- a/.github/workflows/go.yml +++ b/.github/workflows/go.yml @@ -39,6 +39,6 @@ jobs: - name: test env: - GOOS: ${{ matrix.os }} - GOARCH: ${{ matrix.arch }} + GOOS: 1.22 + GOARCH: amd64 run: go test -v ./... \ No newline at end of file diff --git a/go.mod b/go.mod index 62809c9..9971669 100644 --- a/go.mod +++ b/go.mod @@ -1,5 +1,7 @@ module github.com/GoToolSharing/passfinder +go 1.20 + require github.com/spf13/cobra v1.8.0 require ( From 102d90f8e57930855260864295435ee634d2d382 Mon Sep 17 00:00:00 2001 From: QU35T-code <github@qu35t-mail.simplelogin.com> Date: Fri, 14 Jun 2024 22:18:29 +0200 Subject: [PATCH 33/37] chore: Fix pipeline --- .github/workflows/go.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/go.yml b/.github/workflows/go.yml index ab78a1c..25b3f12 100644 --- a/.github/workflows/go.yml +++ b/.github/workflows/go.yml @@ -39,6 +39,8 @@ jobs: - name: test env: - GOOS: 1.22 + GOOS: linux GOARCH: amd64 + with: + go-version: 1.22 run: go test -v ./... \ No newline at end of file From 3dcb4798917cc2101da9f8c9458eb4ac1d39ef6a Mon Sep 17 00:00:00 2001 From: QU35T-code <github@qu35t-mail.simplelogin.com> Date: Fri, 14 Jun 2024 22:20:06 +0200 Subject: [PATCH 34/37] chore: Add another matrix to test --- .github/workflows/go.yml | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/.github/workflows/go.yml b/.github/workflows/go.yml index 25b3f12..54503eb 100644 --- a/.github/workflows/go.yml +++ b/.github/workflows/go.yml @@ -11,7 +11,6 @@ permissions: contents: write jobs: - build: if: github.event_name != 'pull_request' || (github.event_name == 'pull_request' && !github.event.pull_request.draft) runs-on: ubuntu-latest @@ -20,9 +19,7 @@ jobs: go: ['1.19', '1.20', '1.21', '1.22'] os: [ 'linux', 'windows', 'darwin' ] arch: [ 'amd64', 'arm64' ] - outputs: - commit-hash: ${{ steps.get_commit.outputs.commit }} - + steps: - uses: actions/checkout@v4 @@ -37,10 +34,16 @@ jobs: GOARCH: ${{ matrix.arch }} run: go build -v ./... - - name: test - env: - GOOS: linux - GOARCH: amd64 + test: + runs-on: ubuntu-latest + if: matrix.go == '1.22' && matrix.os == 'linux' && matrix.arch == 'amd64' + steps: + - uses: actions/checkout@v4 + + - name: Set up Go + uses: actions/setup-go@v5 with: go-version: 1.22 - run: go test -v ./... \ No newline at end of file + + - name: Test + run: go test -v ./... From f65651533f137357d0b4aeb1edbaa1f7e9f79493 Mon Sep 17 00:00:00 2001 From: QU35T-code <github@qu35t-mail.simplelogin.com> Date: Fri, 14 Jun 2024 22:21:19 +0200 Subject: [PATCH 35/37] chore: Fix again --- .github/workflows/go.yml | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/.github/workflows/go.yml b/.github/workflows/go.yml index 54503eb..476d537 100644 --- a/.github/workflows/go.yml +++ b/.github/workflows/go.yml @@ -34,9 +34,17 @@ jobs: GOARCH: ${{ matrix.arch }} run: go build -v ./... + - name: Set outputs + id: set-outputs + run: | + echo "::set-output name=go::${{ matrix.go }}" + echo "::set-output name=os::${{ matrix.os }}" + echo "::set-output name=arch::${{ matrix.arch }}" + test: runs-on: ubuntu-latest - if: matrix.go == '1.22' && matrix.os == 'linux' && matrix.arch == 'amd64' + needs: build + if: needs.build.outputs.go == '1.22' && needs.build.outputs.os == 'linux' && needs.build.outputs.arch == 'amd64' steps: - uses: actions/checkout@v4 From 6617dcb8bda8f09b913b8f090339e24844d1e364 Mon Sep 17 00:00:00 2001 From: QU35T-code <github@qu35t-mail.simplelogin.com> Date: Fri, 14 Jun 2024 22:24:54 +0200 Subject: [PATCH 36/37] chore: Update gh outputs --- .github/workflows/go.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/go.yml b/.github/workflows/go.yml index 476d537..58176b4 100644 --- a/.github/workflows/go.yml +++ b/.github/workflows/go.yml @@ -37,9 +37,9 @@ jobs: - name: Set outputs id: set-outputs run: | - echo "::set-output name=go::${{ matrix.go }}" - echo "::set-output name=os::${{ matrix.os }}" - echo "::set-output name=arch::${{ matrix.arch }}" + echo "name=go::${{ matrix.go }}" >> $GITHUB_OUTPUT + echo "name=os::${{ matrix.os }}" >> $GITHUB_OUTPUT + echo "name=arch::${{ matrix.arch }}" >> $GITHUB_OUTPUT test: runs-on: ubuntu-latest From 93d736f8a5c444289bc4a5c9aa518c53148be9e8 Mon Sep 17 00:00:00 2001 From: QU35T-code <github@qu35t-mail.simplelogin.com> Date: Fri, 14 Jun 2024 22:27:52 +0200 Subject: [PATCH 37/37] chore: Remove if condition --- .github/workflows/go.yml | 1 - lib/generate/generate.go | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/workflows/go.yml b/.github/workflows/go.yml index 58176b4..30ea20b 100644 --- a/.github/workflows/go.yml +++ b/.github/workflows/go.yml @@ -44,7 +44,6 @@ jobs: test: runs-on: ubuntu-latest needs: build - if: needs.build.outputs.go == '1.22' && needs.build.outputs.os == 'linux' && needs.build.outputs.arch == 'amd64' steps: - uses: actions/checkout@v4 diff --git a/lib/generate/generate.go b/lib/generate/generate.go index 3e8cfcf..e10c55b 100644 --- a/lib/generate/generate.go +++ b/lib/generate/generate.go @@ -6,7 +6,7 @@ import ( ) func WithSpecialChars(wordlist []string) []string { - specialChars := []string{"!", "@", "#", "$", "%", "+", "?", "=", "*"} // TODO: Configurable charset + specialChars := []string{"!", "@", "#", "$", "%", "+", "?", "=", "*"} for _, word := range wordlist { for _, char := range specialChars { wordlist = append(wordlist, word+char)