So what I mean to say is that I want to send get/post requests to invalid url (e.g. https://this-is-a-fake-url.com) I know it will give error because url does not exist but I want to know a way so that it would give a 200 response code. So that if someone use wireshark or something to capture api requests, he would see many requests all having return code 200, no matter if the link is valid or not. Is it even possible? If so, please help :)
Asked
Active
Viewed 294 times
1 Answers
0
You can start a local server, and add it into hosts
file. More specific, if you are on a linux machine:
- Run the following command, it will resolve
this-is-a-fake-url.com
to your localhost
sudo cat '127.0.0.1 this-is-a-fake-url.com' >> /etc/hosts
# In windows, write to C:\Windows\System32\drivers\etc
- Start a server on your local host
sudo python3 -m http.server
# Serving HTTP on 0.0.0.0 port 8000 (http://0.0.0.0:8000/) ...
- Access your fake host
curl http://this-is-a-fake-url.com:8000 -v
# * Trying 127.0.0.1:8000...
# * TCP_NODELAY set
# * Connected to this-is-a-fake-url.com (127.0.0.1) port 8000 (#0)
# > GET / HTTP/1.1
# > Host: this-is-a-fake-url.com:8000
# > User-Agent: curl/7.68.0
# > Accept: */*
# >
# * Mark bundle as not supporting multiuse
# * HTTP 1.0, assume close after body
# < HTTP/1.0 200 OK
# ...

Zheng Bowen
- 339
- 2
- 7
-
Thx for answering but I forgot to mention its for windows programs and also I cannot make every user of my script to create a host file – Blank Mar 21 '22 at 14:24
-
You can just append to `C:\Windows\System32\drivers\etc\hosts` in windows. – Zheng Bowen Mar 21 '22 at 14:30
-
still any another way? – Blank Mar 22 '22 at 01:45
-
There are some other ways, but maybe too complex, to make a fake domain, you may modify the `hosts` file, or you should create a fake DNS server that resolves the fake domain. The capture and modify mechanism won't help too much, because only a DNS resolve thing will help here. – Zheng Bowen Mar 22 '22 at 03:32