Модераторы: feodorv

Поиск:

Ответ в темуСоздание новой темы Создание опроса
> проверка Proxy 
:(
    Опции темы
_par
Дата 8.4.2007, 11:18 (ссылка) | (нет голосов) Загрузка ... Загрузка ... Быстрая цитата Цитата


Новичок



Профиль
Группа: Участник
Сообщений: 49
Регистрация: 25.1.2007

Репутация: нет
Всего: нет



Нужно проанализировать какой прокси сервер.

1.А как проверить жива ли прокси...я создавал сокет указывал адрес и порт прокси сервера
и пытался соединиться с помощью функции connect();
2.как определить это Socks или HTTP?
3.как узнать какая anonymous или transparent? (ну тут вроде бы надо сравнивать по HTTP_X_FORWARDED_FOR выдаёт ли она настоящий ип... но не могу понять когда появляются эти константы. после подключения ?)

PM MAIL   Вверх
nerezus
Дата 8.4.2007, 11:31 (ссылка) | (нет голосов) Загрузка ... Загрузка ... Быстрая цитата Цитата


Вселенский отказник
****


Профиль
Группа: Участник
Сообщений: 3330
Регистрация: 15.6.2005

Репутация: нет
Всего: 43



1) верно, однако не факт, что там прокси
2) Послать запросы согласно протоколу.
3) Сконнектиться через прокси на свою страницу, которая определяет, что передает прокси.


--------------------
Сообщество художников Artsociety.ru
PM MAIL WWW   Вверх
_par
Дата 8.4.2007, 19:28 (ссылка) | (нет голосов) Загрузка ... Загрузка ... Быстрая цитата Цитата


Новичок



Профиль
Группа: Участник
Сообщений: 49
Регистрация: 25.1.2007

Репутация: нет
Всего: нет



Блин у меня даже к винграду на 80 порту неполучается подключиться...
Код

  #include <stdio.h>
  #include <string.h>
  #include <winsock2.h>
  #include <windows.h>
  #include <iostream>
  #include <conio.h>

  using namespace std;
  #define PORT 80
  #define PROXY "62.75.204.171" // Vingrad

  int main(int argc, char* argv[])
  {
    char buff[1024];
    if (WSAStartup(0x202,(WSADATA *)&buff[0]))
    {
      printf("WSAStart error0%d\n"+WSAGetLastError());
      return -1;
    }

    SOCKET my_sock;
    my_sock=socket(AF_INET,SOCK_STREAM,0);
    if (my_sock < 0)
    {
    printf("Socket() error1 %d\n",WSAGetLastError());
      return -1;
    }

    sockaddr_in dest_addr;
    dest_addr.sin_family=AF_INET;
    dest_addr.sin_port=htons(PORT);
    HOSTENT *hst;

   
    if (inet_addr(PROXY)!=INADDR_NONE)
      dest_addr.sin_addr.s_addr=inet_addr(PROXY);
    else 
      {
        printf("Invalid address %s\n",PROXY);
        closesocket(my_sock);
        WSACleanup();
        return -1;
      }

    if (connect(my_sock,(sockaddr *)&dest_addr,
                sizeof(dest_addr)) == SOCKET_ERROR)          // Тут вылетает с ошибкой 
    {                                                                       
      printf("Connect error2 %d\n",WSAGetLastError());   // connection refused (10061)
      
      return -1;
    }
    
   
 closesocket(my_sock);
 WSACleanup();   
 getch();   
 return 1;   
}



Цитата

2) Послать запросы согласно протоколу.


Можешь привести пример Socks4 протакола, а то немогу найти... :(

Цитата

3) Сконнектиться через прокси на свою страницу, которая определяет, что передает прокси. 

Хмм сначала тоже хотел так реализовать, а без дополнительной страницы нельзя ?
PM MAIL   Вверх
nerezus
Дата 8.4.2007, 20:30 (ссылка) | (нет голосов) Загрузка ... Загрузка ... Быстрая цитата Цитата


Вселенский отказник
****


Профиль
Группа: Участник
Сообщений: 3330
Регистрация: 15.6.2005

Репутация: нет
Всего: 43



Цитата

Можешь привести пример Socks4 протакола, а то немогу найти... :(
 Да socks5 юзай, обычно только s4 проксей нету.

Код

    SOCKS: A protocol for TCP proxy across firewalls

            Ying-Da Lee
        Principal Member Technical Staff
          NEC Systems Laboratory, CSTC
            [email protected]

SOCKS was originally developed by David Koblas and subsequently modified
and extended by me to its current running version -- version 4. It is a
protocol that relays TCP sessions at a firewall host to allow application
users transparent access across the firewall. Because the protocol is
independent of application protocols, it can be (and has been) used for
many different services, such as telnet, ftp, finger, whois, gopher, WWW,
etc. Access control can be applied at the beginning of each TCP session;
thereafter the server simply relays the data between the client and the
application server, incurring minimum processing overhead. Since SOCKS
never has to know anything about the application protocol, it should also
be easy for it to accommodate applications which use encryption to protect
their traffic from nosey snoopers.

Two operations are defined: CONNECT and BIND.

1) CONNECT

The client connects to the SOCKS server and sends a CONNECT request when
it wants to establish a connection to an application server. The client
includes in the request packet the IP address and the port number of the
destination host, and userid, in the following format.

        +----+----+----+----+----+----+----+----+----+----+....+----+
        | VN | CD | DSTPORT |      DSTIP        | USERID       |NULL|
        +----+----+----+----+----+----+----+----+----+----+....+----+
 # of bytes:       1    1      2              4           variable       1

VN is the SOCKS protocol version number and should be 4. CD is the
SOCKS command code and should be 1 for CONNECT request. NULL is a byte
of all zero bits.

The SOCKS server checks to see whether such a request should be granted
based on any combination of source IP address, destination IP address,
destination port number, the userid, and information it may obtain by
consulting IDENT, cf. RFC 1413.  If the request is granted, the SOCKS
server makes a connection to the specified port of the destination host.
A reply packet is sent to the client when this connection is established,
or when the request is rejected or the operation fails. 

        +----+----+----+----+----+----+----+----+
        | VN | CD | DSTPORT |      DSTIP        |
        +----+----+----+----+----+----+----+----+
 # of bytes:       1    1      2              4

VN is the version of the reply code and should be 0. CD is the result
code with one of the following values:

    90: request granted
    91: request rejected or failed
    92: request rejected becasue SOCKS server cannot connect to
        identd on the client
    93: request rejected because the client program and identd
        report different user-ids

The remaining fields are ignored.

The SOCKS server closes its connection immediately after notifying
the client of a failed or rejected request. For a successful request,
the SOCKS server gets ready to relay traffic on both directions. This
enables the client to do I/O on its connection as if it were directly
connected to the application server.


2) BIND

The client connects to the SOCKS server and sends a BIND request when
it wants to prepare for an inbound connection from an application server.
This should only happen after a primary connection to the application
server has been established with a CONNECT.  Typically, this is part of
the sequence of actions:

-bind(): obtain a socket
-getsockname(): get the IP address and port number of the socket
-listen(): ready to accept call from the application server
-use the primary connection to inform the application server of
 the IP address and the port number that it should connect to.
-accept(): accept a connection from the application server

The purpose of SOCKS BIND operation is to support such a sequence
but using a socket on the SOCKS server rather than on the client.

The client includes in the request packet the IP address of the
application server, the destination port used in the primary connection,
and the userid.

        +----+----+----+----+----+----+----+----+----+----+....+----+
        | VN | CD | DSTPORT |      DSTIP        | USERID       |NULL|
        +----+----+----+----+----+----+----+----+----+----+....+----+
 # of bytes:       1    1      2              4           variable       1

VN is again 4 for the SOCKS protocol version number. CD must be 2 to
indicate BIND request.

The SOCKS server uses the client information to decide whether the
request is to be granted. The reply it sends back to the client has
the same format as the reply for CONNECT request, i.e.,

        +----+----+----+----+----+----+----+----+
        | VN | CD | DSTPORT |      DSTIP        |
        +----+----+----+----+----+----+----+----+
 # of bytes:       1    1      2              4

VN is the version of the reply code and should be 0. CD is the result
code with one of the following values:

    90: request granted
    91: request rejected or failed
    92: request rejected becasue SOCKS server cannot connect to
        identd on the client
    93: request rejected because the client program and identd
        report different user-ids.

However, for a granted request (CD is 90), the DSTPORT and DSTIP fields
are meaningful.  In that case, the SOCKS server obtains a socket to wait
for an incoming connection and sends the port number and the IP address
of that socket to the client in DSTPORT and DSTIP, respectively. If the
DSTIP in the reply is 0 (the value of constant INADDR_ANY), then the
client should replace it by the IP address of the SOCKS server to which
the cleint is connected. (This happens if the SOCKS server is not a
multi-homed host.)  In the typical scenario, these two numbers are
made available to the application client prgram via the result of the
subsequent getsockname() call.  The application protocol must provide a
way for these two pieces of information to be sent from the client to
the application server so that it can initiate the connection, which
connects it to the SOCKS server rather than directly to the application
client as it normally would.

The SOCKS server sends a second reply packet to the client when the
anticipated connection from the application server is established.
The SOCKS server checks the IP address of the originating host against
the value of DSTIP specified in the client's BIND request.  If a mismatch
is found, the CD field in the second reply is set to 91 and the SOCKS
server closes both connections.  If the two match, CD in the second
reply is set to 90 and the SOCKS server gets ready to relay the traffic
on its two connections. From then on the client does I/O on its connection
to the SOCKS server as if it were directly connected to the application
server.



For both CONNECT and BIND operations, the server sets a time limit
(2 minutes in current CSTC implementation) for the establishment of its
connection with the application server. If the connection is still not
establiched when the time limit expires, the server closes its connection
to the client and gives up.



Код

    SOCKS 4A: A  Simple Extension to SOCKS 4 Protocol

            Ying-Da Lee
        [email protected]  or  [email protected]

Please read SOCKS4.protocol first for an description of the version 4
protocol. This extension is intended to allow the use of SOCKS on hosts
which are not capable of resolving all domain names.

In version 4, the client sends the following packet to the SOCKS server
to request a CONNECT or a BIND operation:

        +----+----+----+----+----+----+----+----+----+----+....+----+
        | VN | CD | DSTPORT |      DSTIP        | USERID       |NULL|
        +----+----+----+----+----+----+----+----+----+----+....+----+
 # of bytes:       1    1      2              4           variable       1

VN is the SOCKS protocol version number and should be 4. CD is the
SOCKS command code and should be 1 for CONNECT or 2 for BIND. NULL
is a byte of all zero bits.

For version 4A, if the client cannot resolve the destination host's
domain name to find its IP address, it should set the first three bytes
of DSTIP to NULL and the last byte to a non-zero value. (This corresponds
to IP address 0.0.0.x, with x nonzero. As decreed by IANA  -- The
Internet Assigned Numbers Authority -- such an address is inadmissible
as a destination IP address and thus should never occur if the client
can resolve the domain name.) Following the NULL byte terminating
USERID, the client must sends the destination domain name and termiantes
it with another NULL byte. This is used for both CONNECT and BIND requests.

A server using protocol 4A must check the DSTIP in the request packet.
If it represent address 0.0.0.x with nonzero x, the server must read
in the domain name that the client sends in the packet. The server
should resolve the domain name and make connection to the destination
host if it can. 

SOCKSified sockd may pass domain names that it cannot resolve to
the next-hop SOCKS server.




--------------------
Сообщество художников Artsociety.ru
PM MAIL WWW   Вверх
_par
Дата 9.4.2007, 01:50 (ссылка) | (нет голосов) Загрузка ... Загрузка ... Быстрая цитата Цитата


Новичок



Профиль
Группа: Участник
Сообщений: 49
Регистрация: 25.1.2007

Репутация: нет
Всего: нет



nerezus спасибо!! 
ещё вопрос по Socks5 : вот я собрал запрос помоему так 0x05, 0x01, 0x00 с такими данными надо послать, только в каком виде? надо ли как то запаковать ? и когда отослал проста слушать сокет?

если я неправ пожалуйста поправьте меня
PM MAIL   Вверх
nerezus
Дата 9.4.2007, 07:31 (ссылка) | (нет голосов) Загрузка ... Загрузка ... Быстрая цитата Цитата


Вселенский отказник
****


Профиль
Группа: Участник
Сообщений: 3330
Регистрация: 15.6.2005

Репутация: нет
Всего: 43



Цитата

только в каком виде?
 Ну а как ты думаешь? Знаешь, что означает запись 0x** ?


--------------------
Сообщество художников Artsociety.ru
PM MAIL WWW   Вверх
_par
Дата 9.4.2007, 13:49 (ссылка) | (нет голосов) Загрузка ... Загрузка ... Быстрая цитата Цитата


Новичок



Профиль
Группа: Участник
Сообщений: 49
Регистрация: 25.1.2007

Репутация: нет
Всего: нет



0x это приставка обозначающяя шестнадцотеричные числа в C/C++ =\

Вот кажится надо отправить "\x05\x01\x00" , когда палучаем ответ как обратится к версии или к методу как примерно будет выглядеть ответ?
PM MAIL   Вверх
nerezus
Дата 9.4.2007, 15:07 (ссылка) | (нет голосов) Загрузка ... Загрузка ... Быстрая цитата Цитата


Вселенский отказник
****


Профиль
Группа: Участник
Сообщений: 3330
Регистрация: 15.6.2005

Репутация: нет
Всего: 43



Цитата

как примерно будет выглядеть ответ? 
 массив char'ов
Просто работай с ними, как с числами


--------------------
Сообщество художников Artsociety.ru
PM MAIL WWW   Вверх
_par
Дата 9.4.2007, 19:03 (ссылка) | (нет голосов) Загрузка ... Загрузка ... Быстрая цитата Цитата


Новичок



Профиль
Группа: Участник
Сообщений: 49
Регистрация: 25.1.2007

Репутация: нет
Всего: нет



блин опять неполучается..
Вот... вроде беру рабочие проксики socks5

кусок кода где идёт отправка
Код

 if (connect(my_sock,(sockaddr *)&dest_addr,
     sizeof(dest_addr)) == SOCKET_ERROR)
 {
     printf("Connect error2 %d\n",WSAGetLastError());
     return -1;
 }
 
 char sc[] = "\x05\x01\x00";
 bind(my_sock,(sockaddr *)&dest_addr,sizeof(dest_addr));
 send(my_sock, sc, sizeof(sc), 0);

 if(listen(my_sock,1) < 0 ) // вот тут 2 параметр нада вроде 2 , но когда ставлю 2 он вылетает выше
 {                                      // где проверка на connect();
   cout << "[-]Failure";
   closesocket(my_sock);
   WSACleanup();   
   getch();
   return -1;                     
 }  



уже разобрался =\ надабыло recv(); вместо listen();

Это сообщение отредактировал(а) _par - 9.4.2007, 19:16
PM MAIL   Вверх
Спец
Дата 23.4.2007, 21:40 (ссылка) | (нет голосов) Загрузка ... Загрузка ... Быстрая цитата Цитата


Шустрый
*


Профиль
Группа: Участник
Сообщений: 79
Регистрация: 2.11.2006

Репутация: -2
Всего: -2



Всем привет!
Люди подскажите что делать когда socks5 прокси вернул ip и порт, коннектиться к ним? Что-то я всё ни как не разбирусь, пробовал конектиться, но ничего не выходит, пробовал без коннекта отправить запрос

send(sk, "GET http://test.ru/ HTTP/1.0\r\n\r\n", 30, 0);

но я низнаю каким местом я чую, но чую что нужно http  запрос перекодировать для socks или нет?
Разъяните плиз что да как.

заранее спасибо.
з.ы. сокс рабочий, localhost всётакиsmile
PM MAIL   Вверх
nerezus
Дата 24.4.2007, 07:49 (ссылка) | (нет голосов) Загрузка ... Загрузка ... Быстрая цитата Цитата


Вселенский отказник
****


Профиль
Группа: Участник
Сообщений: 3330
Регистрация: 15.6.2005

Репутация: нет
Всего: 43



Цитата

но чую что нужно http  запрос перекодировать для socks или нет?
 нет


P.S. а слабо wireshark'ом все отснифать и просто посмотреть? Работы на 5 минут!


--------------------
Сообщество художников Artsociety.ru
PM MAIL WWW   Вверх
Спец
Дата 24.4.2007, 09:24 (ссылка) | (нет голосов) Загрузка ... Загрузка ... Быстрая цитата Цитата


Шустрый
*


Профиль
Группа: Участник
Сообщений: 79
Регистрация: 2.11.2006

Репутация: -2
Всего: -2



nerezus    
что снифить?)) 
а слобо ответить на вопрос нужно ли конектиться еще раз к ip который вернул socks?
з.ы. и на этом спасибо
PM MAIL   Вверх
nerezus
Дата 24.4.2007, 10:23 (ссылка) | (нет голосов) Загрузка ... Загрузка ... Быстрая цитата Цитата


Вселенский отказник
****


Профиль
Группа: Участник
Сообщений: 3330
Регистрация: 15.6.2005

Репутация: нет
Всего: 43



Спец
1) Запускаешь сокссервер(возможно на другом  компе, чтобы wireshark поймал).
2) Настраиваешь файрфокс через сокссервер.
3) Запускаешь wireshark, выбираешь сетевой интерфейс, начинаешь снифать
4) Коненектишься через сокссервер файрфоксом.
5) Останавливаешь снифер.
6) Внимательно смотришь логи и радуешься результату.

Отвечать на последний вопрос не буду, т.к.
1) Тебе надо, но ты не сделал. Значит тебе не надо.
2) Не помню, а за тебя делать элеметрарно лень.


--------------------
Сообщество художников Artsociety.ru
PM MAIL WWW   Вверх
Спец
Дата 24.4.2007, 12:19 (ссылка) | (нет голосов) Загрузка ... Загрузка ... Быстрая цитата Цитата


Шустрый
*


Профиль
Группа: Участник
Сообщений: 79
Регистрация: 2.11.2006

Репутация: -2
Всего: -2



Цитата(nerezus @ 24.4.2007,  10:23)
Спец
Отвечать на последний вопрос не буду, т.к.
1) Тебе надо, но ты не сделал. Значит тебе не надо.

Железо-битонная логика)
я ниче никогда не делаю не понимая что зачем когда и куда, не ну бывает что и приходится так поступать, но это имхо не нормально
PM MAIL   Вверх
Спец
Дата 24.4.2007, 14:42 (ссылка) | (нет голосов) Загрузка ... Загрузка ... Быстрая цитата Цитата


Шустрый
*


Профиль
Группа: Участник
Сообщений: 79
Регистрация: 2.11.2006

Репутация: -2
Всего: -2



nerezus    
четы как баба чес слово, так трудно сказать: "да (или) нет"? снифер особой ясности не внёс в происходящее
PM MAIL   Вверх
Спец
Дата 24.4.2007, 19:26 (ссылка) | (нет голосов) Загрузка ... Загрузка ... Быстрая цитата Цитата


Шустрый
*


Профиль
Группа: Участник
Сообщений: 79
Регистрация: 2.11.2006

Репутация: -2
Всего: -2



Цитата

1) Тебе надо, но ты не сделал. Значит тебе не надо.

оказывается ответ на этот вопрос и было решение, зачем же еще тогда сокс передаёт ip.. но ведь коннектился, не работало, а неработало потому, что локальный сокс сервер был "растроенн" - как гитара..

nerezus
гнилой ты чел

Добавлено через 1 минуту и 17 секунд
вообще не уважаю
PM MAIL   Вверх
Страницы: (2) [Все] 1 2 
Ответ в темуСоздание новой темы Создание опроса
1 Пользователей читают эту тему (1 Гостей и 0 Скрытых Пользователей)
0 Пользователей:
« Предыдущая тема | C/C++: Сети | Следующая тема »


 




[ Время генерации скрипта: 0.1057 ]   [ Использовано запросов: 21 ]   [ GZIP включён ]


Реклама на сайте     Информационное спонсорство

 
По вопросам размещения рекламы пишите на vladimir(sobaka)vingrad.ru
Отказ от ответственности     Powered by Invision Power Board(R) 1.3 © 2003  IPS, Inc.