Skip to content

Commit

Permalink
Remove all external IP sites except for AWS and Azure
Browse files Browse the repository at this point in the history
Virus checkers keep falsely listing ip4, I hope that by only connecting to AWS or Azure out-of-the-box it will cease tripping their [bad] pattern matching.
  • Loading branch information
Treer committed Jun 11, 2021
1 parent fbf86a5 commit c4b38ce
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 41 deletions.
37 changes: 7 additions & 30 deletions src/indoo.tools/externalIP.cs
Original file line number Diff line number Diff line change
Expand Up @@ -141,42 +141,19 @@ void setText() {

this.txt_ini += "skipExternalIPLookup = false{p}";

// http://www.google.com/search?q=what+is+my+ip
// \<div\ class\="[^"]*"\>(?<content>.*)\<\/div\>\<div\ class\="[^"]*"\>Your\ public\ IP\ address\<\/div\>
//this.txt_ini += "http://api.externalip.net/ip{p}";
//this.txt_ini += "(?<content>.*){p}";
// Removed all external IP providers except for AWS and Azure, in the hope
// of having fewer false positives from bad anti-malware software

this.txt_ini += "http://checkip.amazonaws.com/{p}";
this.txt_ini += "(?<content>.*){p}";

this.txt_ini += "https://wtfismyip.com/text{p}";
this.txt_ini += "(?<content>.*){p}";

this.txt_ini += "http://api.ipify.org/{p}";
this.txt_ini += "(?<content>.*){p}";

this.txt_ini += "http://ipv4bot.whatismyipaddress.com/{p}";
this.txt_ini += "(?<content>.*){p}";
this.txt_ini += "http://checkip.azurewebsites.net/{p}";
this.txt_ini += "(?i)Address:\\s*(?<content>[^ <]+){p}";

this.txt_ini += "http://2ip.ru/{p}";
this.txt_ini += "\\<big\\ id=\"d_clip_button\"\\>(?<content>.*?)\\<\\/big\\>{p}";

this.txt_ini += "http://whatsmyip.net/{p}";
this.txt_ini += "\\nvalue=\"(?<content>.*?)\"\\n{p}";
//this.txt_ini += "\\<input\\ type\\=\"text\"\\ value\\=\"(?<content>.*?)\"\\ \\/\\>\\<\\/h1\\>{p}"; // original scrape string for whatsmyip.net

this.txt_ini += "http://icanhazip.com/{p}";
/* for testing timeouts
this.txt_ini += "http://httpstat.us/200?sleep=50000{p}";
this.txt_ini += "(?<content>.*){p}";

this.txt_ini += "http://myip.ru/index_small.php{p}";
this.txt_ini += "\\n\\t\\<tr\\>\\<td\\>(?<content>.*?)\\<\\/td\\>\\<\\/tr\\>{p}"; // not a good way to match, very brittle!
//this.txt_ini += "\\<TD\\ bgcolor\\=white\\ align\\=center\\ valign\\=middle\\>(?<content>.*?)\\<\\/TD\\>{p}"; // original scrape string for myip.ru

/* Defunct?
this.txt_ini += "http://www.whatsmyip.us/{p}";
this.txt_ini += "copyClip\\(\\)\"\\>\\s(?<content>.*?)\\<\\/textarea\\>{p}";
*/

*/

// The help strings should not be used, as ip4 provides its own
this.txt_help = "Help error: J8";
Expand Down
25 changes: 14 additions & 11 deletions src/indoo.tools/externalIP.reflectedVB.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public partial class externalIP
internal const string cUserAgent = "debug/testing of ip4 Windows command (https://github.com/Treer/ip4)";
#else
/// <summary>
/// Some sites (such as whatismyipaddress.com/api) request a user agent
/// Some sites (such as whatismyipaddress) request a user agent
/// that could allow to the project to be contacted if neccessary.
/// </summary>
internal const string cUserAgent = "ip4 Windows command (https://github.com/Treer/ip4)";
Expand Down Expand Up @@ -306,12 +306,11 @@ public int setTimeout
}
public myWebClient()
{
this._TimeoutMS = 0;
_TimeoutMS = 0;
}
public myWebClient(int TimeoutMS)
{
this._TimeoutMS = 0;
this._TimeoutMS = TimeoutMS;
_TimeoutMS = TimeoutMS;
}
private static void TimeoutCallback(object state, bool timedOut)
{
Expand Down Expand Up @@ -2109,15 +2108,16 @@ public string getPage(string url)
this.timeStart = DateTime.Now;

externalIP.getPage2Thread getPage2Thread = null;
Thread thread;
externalIP.getPage3Thread getPage3Thread = null;

Thread thread;
if (!this.isPOSTMethod)
{
getPage2Thread = new externalIP.getPage2Thread();
getPage2Thread.isCachePreventAborted = this.isCachePreventAborted;
getPage2Thread.timeOut = this.timeOut;
getPage2Thread.url = url;
getPage2Thread.urlUniqueAdd = this.urlUniqueAdd();
getPage2Thread.urlUniqueAdd = this.urlUniqueAdd(url);
externalIP.getPage2Thread VBXt_refXS6 = getPage2Thread;
thread = new Thread((ThreadStart)delegate
{
Expand All @@ -2130,9 +2130,9 @@ public string getPage(string url)
getPage3Thread.isCachePreventAborted = this.isCachePreventAborted;
getPage3Thread.timeOut = this.timeOut;
getPage3Thread.url = url;
getPage3Thread.urlUniqueAdd = this.urlUniqueAdd();
getPage3Thread.urlUniqueAdd = this.urlUniqueAdd(url);
externalIP.getPage3Thread VBXt_refXS7 = getPage3Thread;
thread = new Thread((ThreadStart)delegate
thread = new Thread((ThreadStart)delegate
{
VBXt_refXS7.getPage();
});
Expand All @@ -2144,7 +2144,7 @@ public string getPage(string url)
do
{
Thread.Sleep(10);
num = DateTime.Now.Subtract(this.timeStart).TotalSeconds * 1000.0;
num = DateTime.Now.Subtract(this.timeStart).TotalMilliseconds;
}
while (!(num > (double)this.timeOut | !thread.IsAlive));
string text;
Expand Down Expand Up @@ -2263,13 +2263,16 @@ public string getIpFromUrl(string url)
return result;
}
}
private string urlUniqueAdd()
private string urlUniqueAdd(string url)
{
if (this.isCachePreventAborted)
{
return "";
}
return DateAndTime.Now.ToString("?yyMMddHHmmssfffffff");

return url.Contains("?")
? DateAndTime.Now.ToString("&yyMMddHHmmssfffffff")
: DateAndTime.Now.ToString("?yyMMddHHmmssfffffff");
}

public externalIP() {
Expand Down

0 comments on commit c4b38ce

Please sign in to comment.