Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make possible to get the password via Curl #36

Open
ebuildy opened this issue Oct 24, 2016 · 12 comments
Open

Make possible to get the password via Curl #36

ebuildy opened this issue Oct 24, 2016 · 12 comments

Comments

@ebuildy
Copy link
Contributor

ebuildy commented Oct 24, 2016

Feature Request:

"With the secured link, make possible to retrieve raw password via a simple Linux curl command"

@jameswthorne
Copy link
Contributor

I'm been maintaining my own fork of snappass that includes an API. I'm working on rebasing all of my changes on top of the latest changes in pinterest/snappass.

Stay tuned =)

@nichochar
Copy link
Collaborator

It would be very nice tom separate the code out and have an API and a default web client. This way we could start building multiple clients, like:

  • curl
  • slack
  • web
  • ios
  • android

@jameswthorne
Copy link
Contributor

Just pushed PR #51 to accomplish this.

@wooyek
Copy link

wooyek commented Oct 13, 2021

For anyone that will need this:

curl -d "password=secret&ttl=day" -X POST https://snappass.herokuapp.com | grep "value" | awk -F '"' '{print $8}'

@Kav7
Copy link

Kav7 commented Apr 22, 2022

thanks @wooyek , based on your comment I converted to PowerShell for the system admins out there:

$Password = 'something1122'
$RawPasswordLink = Invoke-WebRequest -Method POST -Body "password=$Password&ttl=day" -Uri https://snappass.herokuapp.com/ -UseBasicParsing

$Link = $RawPasswordLink.RawContent.Substring($RawPasswordLink.RawContent.IndexOf('value="') + 7)
$Link = $Link.Substring(0, $link.IndexOf(' ') - 1)

$Link

@silverl
Copy link

silverl commented Apr 22, 2022

Here's my PowerShell function taking advantage of the recent addition of JSON support.

function Get-OneTimeUsePasswordLink {
    param
    (
        [String] $password,
        [ValidateSet("Week", "Day", "Hour")]
        [String]
        $ttl
    )
    $postParams = @{password = $password; ttl = $ttl }
    $response = Invoke-WebRequest -Uri "https://your.site.here" -Method Post -ContentType "application/x-www-form-urlencoded" -Body $postParams -Headers @{"accept"="application/json"}
    $json = $response | ConvertFrom-Json
    return $json.Link
}

@yuval-katzman-digsec
Copy link

For anyone that will need this:

curl -d "password=secret&ttl=day" -X POST https://snappass.herokuapp.com[](https://snappass.herokuapp.com) | grep "value" | awk -F '"' '{print $8}'

is there a way to pull the secret content using a curl command and the generated URL?

@reinoud
Copy link
Contributor

reinoud commented Jan 10, 2024

I've created a PR that adds a /api endpoint that might facilitate this:

@Kav7
Copy link

Kav7 commented Jul 3, 2024

Here's my PowerShell function taking advantage of the recent addition of JSON support.

function Get-OneTimeUsePasswordLink {
    param
    (
        [String] $password,
        [ValidateSet("Week", "Day", "Hour")]
        [String]
        $ttl
    )
    $postParams = @{password = $password; ttl = $ttl }
    $response = Invoke-WebRequest -Uri "https://your.site.here" -Method Post -ContentType "application/x-www-form-urlencoded" -Body $postParams -Headers @{"accept"="application/json"}
    $json = $response | ConvertFrom-Json
    return $json.Link
}

Hey, do you know what the TTL parameter is for 2 weeks expiry?

@silverl
Copy link

silverl commented Jul 3, 2024

Hey, do you know what the TTL parameter is for 2 weeks expiry?

Looks like it's "Two Weeks". I checked the code.

@silverl
Copy link

silverl commented Jul 3, 2024

Here's the PowerShell function rewritten to use the new API:

function Get-OneTimeUsePasswordLink {
    param
    (
        [String] $password,
        [int] $ttl = 604800 # one week default
    )

    $ErrorActionPreference = "Stop"

    # Define the request body as a hashtable and convert it to JSON
    $body = @{
        password = $password
        ttl = $ttl
    } | ConvertTo-Json


    # Define the headers
    $headers = @{
        "Content-Type" = "application/json"
    }

    # Make the POST request
    $response = Invoke-RestMethod -Uri "http://your.site.here/api/set_password/" -Method 'Post' -Headers $headers -Body $body
    # Return just the link
    $response.link
}

@Kav7
Copy link

Kav7 commented Jul 3, 2024

Hey, do you know what the TTL parameter is for 2 weeks expiry?

Looks like it's "Two Weeks". I checked the code.

Amazing thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

8 participants