Luigi Auriemma

aluigi.org (ARCHIVE-ONLY FORUM!)
It is currently 19 Jul 2012 11:41

All times are UTC [ DST ]





Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 24 posts ] 
Author Message
 Post subject: myproxocket.dll Bind to Ip
PostPosted: 16 Sep 2010 05:15 

Joined: 16 Sep 2010 05:12
Posts: 10
Hello, I am currently trying to figure out how to bind a program to an IP address.

Currently, I have tried this:

http://pastebin.com/dTFMuN9M

But the program once its ran, seems to start twice and neither work. Can anyone point to me what I am doing wrong? Would appreciate it!

I do get this issue compiling, unsure if related:

$ gcc -o myproxocket.dll myproxocket.c -shared
In file included from myproxocket.c:65:
/usr/lib/gcc/i686-pc-cygwin/3.4.4/../../../../include/w32api/winsock.h:82:2: war
ning: #warning "fd_set and associated macros have been defined in sys/types.
This can cause runtime problems with W32 sockets"


Top
 Profile  
 
 
 Post subject: Re: myproxocket.dll Bind to Ip
PostPosted: 16 Sep 2010 08:25 

Joined: 13 Aug 2007 21:44
Posts: 4068
Location: http://aluigi.org
Code:
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <winsock.h>
#include <windows.h>


int __cdecl mybind(SOCKET s, const struct sockaddr *name, int namelen) {
    // replace "127.0.0.1" with the IP address of the interface you want to bind
    ((struct sockaddr_in *)name)->sin_addr.s_addr = inet_addr("127.0.0.1");
    return(0);
}


BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpReserved) {
    switch(fdwReason) {
        case DLL_PROCESS_ATTACH: {
            DisableThreadLibraryCalls(hinstDLL);
            break;
        }
        default: break;
    }
    return(TRUE);
}


Top
 Profile  
 
 Post subject: Re: myproxocket.dll Bind to Ip
PostPosted: 16 Sep 2010 12:00 

Joined: 24 Sep 2007 02:12
Posts: 1114
Location: http://sethioz.co.uk
you can also use "forcebindip", its free.
look here > ForceBindIp

usually i prefer luigi's tools, but in this case i prefer ForceBindIp, but you need to realize that it does not work on xp, on some wierd reasons.

this is long issue and i asked Luigi many times to help, but all failed. i have Ethernet and Wireless, if i enable BOTH at same time, XP always uses ethernet, no way to force it on wireless, just not happening.
however if you have 2 ethernets or 2 wireless, then it would probably work fine.

and this note goes for both, never got it working properly. let us know what is your case and if one or other works.


Top
 Profile  
 
 Post subject: Re: myproxocket.dll Bind to Ip
PostPosted: 16 Sep 2010 19:14 

Joined: 16 Sep 2010 05:12
Posts: 10
Forcebindip does me no good, as this has to run as a service, so this needs to be seamless.

Alugi: Code will not compile:

$ gcc -o myproxocket.dll myproxocket.c -shared
In file included from myproxocket.c:4:
/usr/lib/gcc/i686-pc-cygwin/3.4.4/../../../../include/w32api/winsock.h:82:2: war
ning: #warning "fd_set and associated macros have been defined in sys/types.
This can cause runtime problems with W32 sockets"
/tmp/ccuoygEG.o:myproxocket.c:(.text+0x12): undefined reference to `_inet_addr@4
'
collect2: ld returned 1 exit status


Top
 Profile  
 
 Post subject: Re: myproxocket.dll Bind to Ip
PostPosted: 16 Sep 2010 19:18 

Joined: 16 Sep 2010 05:12
Posts: 10
Code:
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <winsock.h>
#include <windows.h>

#define inet_addr   str2ip

u_int str2ip(u_char *data) {
    unsigned    a, b, c, d;

    if(!data[0]) return(0);
    sscanf(data, "%u.%u.%u.%u", &a, &b, &c, &d);
    return((a & 0xff) | ((b & 0xff) << 8) | ((c & 0xff) << 16) | ((d & 0xff) << 24));
}

int __cdecl mybind(SOCKET s, const struct sockaddr *name, int namelen) {
    // replace "127.0.0.1" with the IP address of the interface you want to bind
    ((struct sockaddr_in *)name)->sin_addr.s_addr = inet_addr("208.167.249.27");
    return(0);
}


BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpReserved) {
    switch(fdwReason) {
        case DLL_PROCESS_ATTACH: {
            DisableThreadLibraryCalls(hinstDLL);
            break;
        }
        default: break;
    }
    return(TRUE);
}


Got it to compile bringing over a few more lines from the original mypoxocket.c However, I have the same result. the process splits in two, and neither one works.

I still get this error tho, is it related?

Quote:
$ gcc -o myproxocket.dll myproxocket.c -shared
In file included from myproxocket.c:4:
/usr/lib/gcc/i686-pc-cygwin/3.4.4/../../../../include/w32api/winsock.h:82:2: war
ning: #warning "fd_set and associated macros have been defined in sys/types.
This can cause runtime problems with W32 sockets"


Top
 Profile  
 
 Post subject: Re: myproxocket.dll Bind to Ip
PostPosted: 16 Sep 2010 19:59 

Joined: 13 Aug 2007 21:44
Posts: 4068
Location: http://aluigi.org
probably depends by the program, here works.
have you copied only ws2_32.dll in the folder of the program?
do not copy both ws2_32.dll and wsock32.dll, they may conflict


Top
 Profile  
 
 Post subject: Re: myproxocket.dll Bind to Ip
PostPosted: 16 Sep 2010 20:04 

Joined: 16 Sep 2010 05:12
Posts: 10
With only ws2_32.dll: Process launches, no hook happened.
With only wsock32.dll: Process splits in two and breaks.

Programs tried with this:

Firefox
ArmA2

As stated, I am compiling under Cygwin and do get this message:

Quote:
$ gcc -o myproxocket.dll myproxocket.c -shared
In file included from myproxocket.c:4:
/usr/lib/gcc/i686-pc-cygwin/3.4.4/../../../../include/w32api/winsock.h:82:2: war
ning: #warning "fd_set and associated macros have been defined in sys/types.
This can cause runtime problems with W32 sockets"


Top
 Profile  
 
 Post subject: Re: myproxocket.dll Bind to Ip
PostPosted: 16 Sep 2010 21:34 

Joined: 16 Sep 2010 05:12
Posts: 10
I just got it working, I had to compile with mingw instead of cygwin, and it started working. Final code is the one I posted up for now, I will probably try to tweak it slightly to load the Ip from a config file so I don't have to compile unique myproxocket for each process.


Top
 Profile  
 
 Post subject: Re: myproxocket.dll Bind to Ip
PostPosted: 17 Sep 2010 16:24 

Joined: 13 Aug 2007 21:44
Posts: 4068
Location: http://aluigi.org
interesting that thing about cygwin.
it was a fault of mine to have not noticed it and alterted about that possible incompatibility in using that compiler (indeed cygwin is not a "native" compiler, that's the reason of the problem)


Top
 Profile  
 
 Post subject: Re: myproxocket.dll Bind to Ip
PostPosted: 17 Sep 2010 16:39 

Joined: 16 Sep 2010 05:12
Posts: 10
Yea, maybe add a note somewhere on it to help people avoid issues like me in the future? :)


Top
 Profile  
 
 Post subject: Re: myproxocket.dll Bind to Ip
PostPosted: 17 Sep 2010 16:55 

Joined: 24 Sep 2007 02:12
Posts: 1114
Location: http://sethioz.co.uk
forcebindip is not a service. it is a cmd tool, you will have to run your application using following command:

Code:
forcebindip 192.168.1.1 "C:/Program Files/firefox/firefox.exe"


this is just example. this will start firefox and forces it to use the interface you specified. it can also use the GUID of interface, which i never understood, i dont understand what is the GUID of interface, where i get it.

i have tested it and when im using 2 wireless cards, like USB and PCI wireless adapters, then it works perfectly.


Top
 Profile  
 
 Post subject: Re: myproxocket.dll Bind to Ip
PostPosted: 17 Sep 2010 16:56 

Joined: 16 Sep 2010 05:12
Posts: 10
Sethioz,

The program I am running I run as a service.

When you start forcebindip, it forks the process out and exists. As far as the service is concerned the program crashed beginning to launch more and more.

This approach from aluigi is seamless and works with the process running as a service.


Top
 Profile  
 
 Post subject: Re: myproxocket.dll Bind to Ip
PostPosted: 17 Sep 2010 17:00 

Joined: 24 Sep 2007 02:12
Posts: 1114
Location: http://sethioz.co.uk
Quote:
, as this has to run as a service,


from this i read out that you referred to forcebindip.
in this case, yes it's no good for you, unless you want to stop the service and start it via forcebindip.
also it is possible to make a batch file and put it into startup.

but it does not matter if you got it working, so problem solved.


Top
 Profile  
 
 Post subject: Re: myproxocket.dll Bind to Ip
PostPosted: 17 Sep 2010 17:03 

Joined: 16 Sep 2010 05:12
Posts: 10
Yea, forcebind just wasn't as clean as Aluigis method =D


Top
 Profile  
 
 Post subject: Re: myproxocket.dll Bind to Ip
PostPosted: 01 Dec 2010 03:57 

Joined: 16 Sep 2010 05:12
Posts: 10
As a weird update, this has just stopped working out of nowhere. I checked the registry for the dev override, but nothing is happening. It is not even attempting to load local overrides anymore today.

Any ideas?


Top
 Profile  
 
 Post subject: Re: myproxocket.dll Bind to Ip
PostPosted: 01 Dec 2010 08:55 

Joined: 13 Aug 2007 21:44
Posts: 4068
Location: http://aluigi.org
uhmmm, if it no longer loads the local ws2_32.dll means that the main program has forced the loading of ws2_32.dll from the windows folder.
so I guess the program has been updated recently to a new version, right?


Top
 Profile  
 
 Post subject: Re: myproxocket.dll Bind to Ip
PostPosted: 01 Dec 2010 15:13 

Joined: 16 Sep 2010 05:12
Posts: 10
It was, but not a single program will load the winsock32. Not even a copy of the old program.


Top
 Profile  
 
 Post subject: Re: myproxocket.dll Bind to Ip
PostPosted: 03 Dec 2010 22:20 

Joined: 24 Sep 2007 02:12
Posts: 1114
Location: http://sethioz.co.uk
thts because you have to use ws2_32.dll, not winsock32.dll (wsock32.dll ???)
what if you replace the ws2_32.dll in windows folder ? or if thats not possible, then how about appending info to existing ws2_32.dll in windows folder ? so it would have the proxocket command in it.


Top
 Profile  
 
 Post subject: Re: myproxocket.dll Bind to Ip
PostPosted: 04 Dec 2010 01:16 

Joined: 13 Aug 2007 21:44
Posts: 4068
Location: http://aluigi.org
> what if you replace the ws2_32.dll in windows folder ?

are you crazy?
NEVER do it with proxocket!!!
you will kill your OS if you do it!

anyway I guess he means that an update of his operating system has avoided also the registry work-around, so there is no longer a way to load ws2_32.dll locally


Top
 Profile  
 
 Post subject: Re: myproxocket.dll Bind to Ip
PostPosted: 05 Dec 2010 18:59 

Joined: 24 Sep 2007 02:12
Posts: 1114
Location: http://sethioz.co.uk
you know i am :)
i know that ws2_32.dll handles internet stuff in windows, but i have never done so much research, so i wasnt sure about it.
this is why said, what about appending data to existing one ?

In case it fucks up, you can always use other OS, like live cd with linux to mount the win partition and replace it back. so i dont see problem there.

back to the other part, what if you modifiy ws2_32.dll and try adding the bind part ( or whatever function you want to use). ?


if its update to OS, then its extremely retarded and stupid to enable updates. thats all microsoft does, they prevent usage of such tools at all costs. they limit ppl, just like phone companys are locking phones to their networks. this is the reason why im still on my old custom XP.


Top
 Profile  
 
 Post subject: Re: myproxocket.dll Bind to Ip
PostPosted: 05 Dec 2010 19:07 

Joined: 13 Aug 2007 21:44
Posts: 4068
Location: http://aluigi.org
I guess this particular limitation is intended for security reasons probably to avoid some types of viruses that use it to sniff data without touching the original process.

so basically it's not a bad idea but should be ever left a possibility to disable it to the user otherwise a great idea like proxocket could no longer work


Top
 Profile  
 
 Post subject: Re: myproxocket.dll Bind to Ip
PostPosted: 05 Dec 2010 20:10 

Joined: 24 Sep 2007 02:12
Posts: 1114
Location: http://sethioz.co.uk
ppl should stop downloading and running shit in their pcs, best solution against any type of malware. microsoft just limits everything, its so stupid, always makes me angry and then ppl are complaining that this doesnt work and that doesnt work. ofc nothing works on crappiest OS and/or update ever.

Luigi what do you think about appending data to ws2_32.dll ? any chance it might work or its another crazy idea ?
anyways i have nothing more to add, than stop using shit OS


Top
 Profile  
 
 Post subject: Re: myproxocket.dll Bind to Ip
PostPosted: 07 Dec 2010 11:09 

Joined: 13 Aug 2007 21:44
Posts: 4068
Location: http://aluigi.org
yeah it's a crazy idea first because being a system file you need permissions and avoid the re-overwriting done by the automatic windows repair.
then it's an important file so doing similar modifications it's out of idea.


Top
 Profile  
 
 Post subject: Re: myproxocket.dll Bind to Ip
PostPosted: 08 Dec 2010 22:20 

Joined: 24 Sep 2007 02:12
Posts: 1114
Location: http://sethioz.co.uk
those you named are no problems to me. i dont have any protection on system files, i can modify or delete them on demand.
my OS also has no automatic updates. i dont mean disabled, but it doesnt have the whole feature. it cannot be enabled. its grayed out in options (just the text is there).

so on my case, if modification is successful, it would work, but i cant imagine how you can append data to .dll like this, that is out of my field.

my interest in this, is purely curiousity and to learn


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 24 posts ] 

All times are UTC [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for: