Giter VIP home page Giter VIP logo

qsreplace's Introduction

qsreplace

Accept URLs on stdin, replace all query string values with a user-supplied value, only output each combination of query string parameters once per host and path.

Usage

Example input file:

▶ cat urls.txt 
https://example.com/path?one=1&two=2
https://example.com/path?two=2&one=1
https://example.com/pathtwo?two=2&one=1
https://example.net/a/path?two=2&one=1

Replace Query String Values

▶ cat urls.txt | qsreplace newval
https://example.com/path?one=newval&two=newval
https://example.com/pathtwo?one=newval&two=newval
https://example.net/a/path?one=newval&two=newval

Append to Query String Values

▶ cat urls.txt | qsreplace -a newval
https://example.com/path?one=1newval&two=2newval
https://example.com/pathtwo?one=1newval&two=2newval
https://example.net/a/path?one=1newval&two=2newval

Remove Duplicate URL and Parameter Combinations

You can omit the argument to -a to only output each combination of URL and query string parameters once:

▶ cat urls.txt | qsreplace -a 
https://example.com/path?one=1&two=2
https://example.com/pathtwo?one=1&two=2
https://example.net/a/path?one=1&two=2

Install

With Go:

▶ go install github.com/tomnomnom/qsreplace@latest

Or download a release and put it somewhere in your $PATH (e.g. in /usr/local/bin).

qsreplace's People

Contributors

tomnomnom avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

qsreplace's Issues

Unexpected replacing

Trying these while processing path-queries with unexpected output.
First case:

echo "?set_city=%D0%91%D0%B0%D0%BB%D0%B0%D1%88%D0%B8%D1%85%D0%B0&back_url=/" | qsreplace http://127.0.0.1:8080

Out:

?back_url=http%3A%2F%2F127.0.0.1%3A8080&set_city=http%3A%2F%2F127.0.0.1%3A8080

Second case:

echo "/?set_city=back_url="  | qsreplace http://127.0.0.1:8080

Out:

/?set_city=http%3A%2F%2F127.0.0.1%3A8080

System: Mac Big Sur (11.2.1)
Снимок экрана 2021-02-14 в 17 52 32

There's no way to target specific params

Copy+paste from Slack convo:

I've got a few ideas to make it more useful
Mostly, match (with regex) the param name or the value to replace

So you could, for example, do something like cat urls.txt | qsreplace --match-value='^https?://' https://lksjdklsdg.burpcollab or something like that

or cat urls.txt | qsreplace --match-key='.*redirect.*' //evil.com

Or cat urls.txt | qsreplace --match-value='[0-9]+' -a '+sleep(1)'

Does not work with *

does not work with * char for some reason.

example: cat urls.txt | qsreplace *

[question][feature request] Do we need one more positional parameter

Hi there,
Test data from wayback machine and noted the next actual behavior:

echo "fr/prendre-rendez-vous?pageId" | qsreplace http://127.0.0.1:8080
fr/prendre-rendez-vous?pageId=http%3A%2F%2F127.0.0.1%3A8080

I expected the behavior to be:

fr/prendre-rendez-vous?pageId=http://127.0.0.1:8080

Any ideas? Please share your thoughts! Thanks!

qsreplace does not replace each parameter only once

Perhaps I am misunderstanding how qsreplace is intended to work, but considering the description of the tool, I am receiving unexpected output. qsreplace is replacing every parameter value, not individually.

~ % cat urls.txt 
https://www.evildojo.com/index.php?q=search&name=darkmage
https://www.evildojo.com/index.php?q=search
https://www.evildojo.com/index.php
https://www.evildojo.com

~ % cat urls.txt | qsreplace d3v
https://www.evildojo.com/index.php?name=d3v&q=d3v
https://www.evildojo.com/index.php?q=d3v
https://www.evildojo.com/index.php
https://www.evildojo.com

The output I am expecting, however, is below:

https://www.evildojo.com/index.php?q=d3v
https://www.evildojo.com/index.php?q=d3v&name=darkmage
https://www.evildojo.com/index.php?q=search&name=d3v

I am releasing a tool to achieve this functionality, but I think it would be nice if this tool did it instead.

Install with go

Install with go get is no longer working with the latest go version

qsreplace does not use with file

Hello Tomnomnom,

You Know That this tool using for replace just text not a file ,In some case the user need to replace file instead text.

Best Regards..

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.