2

Everything is normal. But it gives an error. I could not solve it.

try.sh:

#!/bin/sh

website="http://lastofdead.xyz"
ipaddress=$( ifconfig | grep -v 'eth0:' | grep -A 1 'eth0' | \
             tail -1 | cut -d ':' -f 2 | cut -d ' ' -f 1)
mlicense=$(curl -s $website/lodscript/special/lisans.php?lisans)

if [ "$mlicense" = "$ipaddress" ];
then 
    echo "Positive"
else
    echo "Negative"
fi

lisans.php:

<?php 
if(isset($_GET['lisans'])) {
echo "188.166.92.168" . $_GET['lisans'];
}
?>

Result:

root@ubuntu:~# bash -x s.sh
+ website=http://lastofdead.xyz
++ cut -d ' ' -f 1
++ cut -d : -f 2
++ tail -1
++ grep -A 1 eth0
++ grep -v eth0:
++ ifconfig
+ ipaddress=188.166.92.168
++ curl -s 'http://lastofdead.xyz/lodscript/special/lisans.php?lisans'
+ mlicense=188.166.92.168
+ '[' 188.166.92.168 = 188.166.92.168 ']'
+ echo Negative
Negative

https://i.stack.imgur.com/jNMNq.jpg

agc
  • 7,973
  • 2
  • 29
  • 50
Can
  • 83
  • 12

1 Answers1

4

Oh, thank you very much for posting the code. Well, having tried to see myself the differences between the two strings, it turned out that the problem was something called Byte Order Mark (BOM). For more info about this, see this answer: https://stackoverflow.com/a/3256014.

The string returned by curl, when piping it to an hex dump, shows this:

$ curl -s 'http://lastofdead.xyz/lodscript/special/lisans.php?lisans'
188.166.92.168
$ curl -s 'http://lastofdead.xyz/lodscript/special/lisans.php?lisans' | xxd -c 17 -g 1 -u
0000000: EF BB BF 31 38 38 2E 31 36 36 2E 39 32 2E 31 36 38  ...188.166.92.168

Can you see them? Those three bytes, 0xEF,0xBB,0xBF, are the UTF-8 representation of the BOM, and that's what makes the strings differ. The question page linked above shows some ways to strip it, like using grep, or you could pipe the curl output to cut -c 2-, or even through a simple substitution after the curl line: mlicense="${mlicense:1}". And, to make sure that what we strip is the BOM, we could use two lines of substitution: bom="$(echo -en '\xEF\xBB\xBF')"; mlicense="$(echo -n "${mlicense#${bom}}")", or even turn them into one: mlicense="$(echo -n "${mlicense#$(echo -en '\xEF\xBB\xBF')}")".

Community
  • 1
  • 1
Lutarisco
  • 181
  • 4