亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? proxy.c

?? 遠程登陸工具軟件源碼 用于遠程登陸unix
?? C
?? 第 1 頁 / 共 3 頁
字號:

	    if (bufchain_size(&p->pending_input_data) < 2)
		return 1;	       /* not got anything yet */

	    /* get the response */
	    bufchain_fetch(&p->pending_input_data, data, 2);

	    if (data[0] != 1) {
		plug_closing(p->plug, "Proxy error: SOCKS password "
			     "subnegotiation contained wrong version number",
			     PROXY_ERROR_GENERAL, 0);
		return 1;
	    }

	    if (data[1] != 0) {

		plug_closing(p->plug, "Proxy error: SOCKS proxy refused"
			     " password authentication",
			     PROXY_ERROR_GENERAL, 0);
		return 1;
	    }

	    bufchain_consume(&p->pending_input_data, 2);
	    p->state = 2;	       /* now proceed as authenticated */
	}

	if (p->state == 2) {

	    /* request format:
	     *  version number (1 byte) = 5
	     *  command code (1 byte)
	     *    1 = CONNECT
	     *    2 = BIND
	     *    3 = UDP ASSOCIATE
	     *  reserved (1 byte) = 0x00
	     *  address type (1 byte)
	     *    1 = IPv4
	     *    3 = domainname (first byte has length, no terminating null)
	     *    4 = IPv6
	     *  dest. address (variable)
	     *  dest. port (2 bytes) [network order]
	     */

	    char command[512];
	    int len;
	    int type;

	    type = sk_addrtype(p->remote_addr);
	    if (type == ADDRTYPE_IPV4) {
		len = 10;	       /* 4 hdr + 4 addr + 2 trailer */
		command[3] = 1; /* IPv4 */
		sk_addrcopy(p->remote_addr, command+4);
	    } else if (type == ADDRTYPE_IPV6) {
		len = 22;	       /* 4 hdr + 16 addr + 2 trailer */
		command[3] = 4; /* IPv6 */
		sk_addrcopy(p->remote_addr, command+4);
	    } else {
		assert(type == ADDRTYPE_NAME);
		command[3] = 3;
		sk_getaddr(p->remote_addr, command+5, 256);
		command[4] = strlen(command+5);
		len = 7 + command[4];  /* 4 hdr, 1 len, N addr, 2 trailer */
	    }

	    command[0] = 5; /* version 5 */
	    command[1] = 1; /* CONNECT command */
	    command[2] = 0x00;

	    /* port */
	    command[len-2] = (char) (p->remote_port >> 8) & 0xff;
	    command[len-1] = (char) p->remote_port & 0xff;

	    sk_write(p->sub_socket, command, len);

	    p->state = 3;
	    return 1;
	}

	if (p->state == 3) {

	    /* reply format:
	     *  version number (1 bytes) = 5
	     *  reply code (1 byte)
	     *    0 = succeeded
	     *    1 = general SOCKS server failure
	     *    2 = connection not allowed by ruleset
	     *    3 = network unreachable
	     *    4 = host unreachable
	     *    5 = connection refused
	     *    6 = TTL expired
	     *    7 = command not supported
	     *    8 = address type not supported
	     * reserved (1 byte) = x00
	     * address type (1 byte)
	     *    1 = IPv4
	     *    3 = domainname (first byte has length, no terminating null)
	     *    4 = IPv6
	     * server bound address (variable)
	     * server bound port (2 bytes) [network order]
	     */
	    char data[5];
	    int len;

	    /* First 5 bytes of packet are enough to tell its length. */ 
	    if (bufchain_size(&p->pending_input_data) < 5)
		return 1;	       /* not got anything yet */

	    /* get the response */
	    bufchain_fetch(&p->pending_input_data, data, 5);

	    if (data[0] != 5) {
		plug_closing(p->plug, "Proxy error: SOCKS proxy returned wrong version number",
			     PROXY_ERROR_GENERAL, 0);
		return 1;
	    }

	    if (data[1] != 0) {
		char buf[256];

		strcpy(buf, "Proxy error: ");

		switch (data[1]) {
		  case 1: strcat(buf, "General SOCKS server failure"); break;
		  case 2: strcat(buf, "Connection not allowed by ruleset"); break;
		  case 3: strcat(buf, "Network unreachable"); break;
		  case 4: strcat(buf, "Host unreachable"); break;
		  case 5: strcat(buf, "Connection refused"); break;
		  case 6: strcat(buf, "TTL expired"); break;
		  case 7: strcat(buf, "Command not supported"); break;
		  case 8: strcat(buf, "Address type not supported"); break;
		  default: sprintf(buf+strlen(buf),
				   "Unrecognised SOCKS error code %d",
				   data[1]);
		    break;
		}
		plug_closing(p->plug, buf, PROXY_ERROR_GENERAL, 0);

		return 1;
	    }

	    /*
	     * Eat the rest of the reply packet.
	     */
	    len = 6;		       /* first 4 bytes, last 2 */
	    switch (data[3]) {
	      case 1: len += 4; break; /* IPv4 address */
	      case 4: len += 16; break;/* IPv6 address */
	      case 3: len += (unsigned char)data[4]; break; /* domain name */
	      default:
		plug_closing(p->plug, "Proxy error: SOCKS proxy returned "
			     "unrecognised address format",
			     PROXY_ERROR_GENERAL, 0);
		return 1;
	    }
	    if (bufchain_size(&p->pending_input_data) < len)
		return 1;	       /* not got whole reply yet */
	    bufchain_consume(&p->pending_input_data, len);

	    /* we're done */
	    proxy_activate(p);
	    return 1;
	}

	if (p->state == 4) {
	    /* TODO: Handle GSSAPI authentication */
	    plug_closing(p->plug, "Proxy error: We don't support GSSAPI authentication",
			 PROXY_ERROR_GENERAL, 0);
	    return 1;
	}

	if (p->state == 5) {
	    if (p->cfg.proxy_username[0] || p->cfg.proxy_password[0]) {
		char userpwbuf[514];
		int ulen, plen;
		ulen = strlen(p->cfg.proxy_username);
		if (ulen > 255) ulen = 255; if (ulen < 1) ulen = 1;
		plen = strlen(p->cfg.proxy_password);
		if (plen > 255) plen = 255; if (plen < 1) plen = 1;
		userpwbuf[0] = 1;      /* version number of subnegotiation */
		userpwbuf[1] = ulen;
		memcpy(userpwbuf+2, p->cfg.proxy_username, ulen);
		userpwbuf[ulen+2] = plen;
		memcpy(userpwbuf+ulen+3, p->cfg.proxy_password, plen);
		sk_write(p->sub_socket, userpwbuf, ulen + plen + 3);
		p->state = 7;
	    } else 
		plug_closing(p->plug, "Proxy error: Server chose "
			     "username/password authentication but we "
			     "didn't offer it!",
			 PROXY_ERROR_GENERAL, 0);
	    return 1;
	}

	if (p->state == 6) {
	    /* TODO: Handle CHAP authentication */
	    plug_closing(p->plug, "Proxy error: We don't support CHAP authentication",
			 PROXY_ERROR_GENERAL, 0);
	    return 1;
	}

    }

    plug_closing(p->plug, "Proxy error: Unexpected proxy error",
		 PROXY_ERROR_UNEXPECTED, 0);
    return 1;
}

/* ----------------------------------------------------------------------
 * `Telnet' proxy type.
 *
 * (This is for ad-hoc proxies where you connect to the proxy's
 * telnet port and send a command such as `connect host port'. The
 * command is configurable, since this proxy type is typically not
 * standardised or at all well-defined.)
 */

char *format_telnet_command(SockAddr addr, int port, const Config *cfg)
{
    char *ret = NULL;
    int retlen = 0, retsize = 0;
    int so = 0, eo = 0;
#define ENSURE(n) do { \
    if (retsize < retlen + n) { \
	retsize = retlen + n + 512; \
	ret = sresize(ret, retsize, char); \
    } \
} while (0)

    /* we need to escape \\, \%, \r, \n, \t, \x??, \0???, 
     * %%, %host, %port, %user, and %pass
     */

    while (cfg->proxy_telnet_command[eo] != 0) {

	/* scan forward until we hit end-of-line,
	 * or an escape character (\ or %) */
	while (cfg->proxy_telnet_command[eo] != 0 &&
	       cfg->proxy_telnet_command[eo] != '%' &&
	       cfg->proxy_telnet_command[eo] != '\\') eo++;

	/* if we hit eol, break out of our escaping loop */
	if (cfg->proxy_telnet_command[eo] == 0) break;

	/* if there was any unescaped text before the escape
	 * character, send that now */
	if (eo != so) {
	    ENSURE(eo - so);
	    memcpy(ret + retlen, cfg->proxy_telnet_command + so, eo - so);
	    retlen += eo - so;
	}

	so = eo++;

	/* if the escape character was the last character of
	 * the line, we'll just stop and send it. */
	if (cfg->proxy_telnet_command[eo] == 0) break;

	if (cfg->proxy_telnet_command[so] == '\\') {

	    /* we recognize \\, \%, \r, \n, \t, \x??.
	     * anything else, we just send unescaped (including the \).
	     */

	    switch (cfg->proxy_telnet_command[eo]) {

	      case '\\':
		ENSURE(1);
		ret[retlen++] = '\\';
		eo++;
		break;

	      case '%':
		ENSURE(1);
		ret[retlen++] = '%';
		eo++;
		break;

	      case 'r':
		ENSURE(1);
		ret[retlen++] = '\r';
		eo++;
		break;

	      case 'n':
		ENSURE(1);
		ret[retlen++] = '\n';
		eo++;
		break;

	      case 't':
		ENSURE(1);
		ret[retlen++] = '\t';
		eo++;
		break;

	      case 'x':
	      case 'X':
		{
		    /* escaped hexadecimal value (ie. \xff) */
		    unsigned char v = 0;
		    int i = 0;

		    for (;;) {
			eo++;
			if (cfg->proxy_telnet_command[eo] >= '0' &&
			    cfg->proxy_telnet_command[eo] <= '9')
			    v += cfg->proxy_telnet_command[eo] - '0';
			else if (cfg->proxy_telnet_command[eo] >= 'a' &&
				 cfg->proxy_telnet_command[eo] <= 'f')
			    v += cfg->proxy_telnet_command[eo] - 'a' + 10;
			else if (cfg->proxy_telnet_command[eo] >= 'A' &&
				 cfg->proxy_telnet_command[eo] <= 'F')
			    v += cfg->proxy_telnet_command[eo] - 'A' + 10;
			else {
			    /* non hex character, so we abort and just
			     * send the whole thing unescaped (including \x)
			     */
			    ENSURE(1);
			    ret[retlen++] = '\\';
			    eo = so + 1;
			    break;
			}

			/* we only extract two hex characters */
			if (i == 1) {
			    ENSURE(1);
			    ret[retlen++] = v;
			    eo++;
			    break;
			}

			i++;
			v <<= 4;
		    }
		}
		break;

	      default:
		ENSURE(2);
		memcpy(ret+retlen, cfg->proxy_telnet_command + so, 2);
		retlen += 2;
		eo++;
		break;
	    }
	} else {

	    /* % escape. we recognize %%, %host, %port, %user, %pass.
	     * anything else, we just send unescaped (including the %).
	     */

	    if (cfg->proxy_telnet_command[eo] == '%') {
		ENSURE(1);
		ret[retlen++] = '%';
		eo++;
	    }
	    else if (strnicmp(cfg->proxy_telnet_command + eo,
			      "host", 4) == 0) {
		char dest[512];
		int destlen;
		sk_getaddr(addr, dest, lenof(dest));
		destlen = strlen(dest);
		ENSURE(destlen);
		memcpy(ret+retlen, dest, destlen);
		retlen += destlen;
		eo += 4;
	    }
	    else if (strnicmp(cfg->proxy_telnet_command + eo,
			      "port", 4) == 0) {
		char portstr[8], portlen;
		portlen = sprintf(portstr, "%i", port);
		ENSURE(portlen);
		memcpy(ret + retlen, portstr, portlen);
		retlen += portlen;
		eo += 4;
	    }
	    else if (strnicmp(cfg->proxy_telnet_command + eo,
			      "user", 4) == 0) {
		int userlen = strlen(cfg->proxy_username);
		ENSURE(userlen);
		memcpy(ret+retlen, cfg->proxy_username, userlen);
		retlen += userlen;
		eo += 4;
	    }
	    else if (strnicmp(cfg->proxy_telnet_command + eo,
			      "pass", 4) == 0) {
		int passlen = strlen(cfg->proxy_password);
		ENSURE(passlen);
		memcpy(ret+retlen, cfg->proxy_password, passlen);
		retlen += passlen;
		eo += 4;
	    }
	    else {
		/* we don't escape this, so send the % now, and
		 * don't advance eo, so that we'll consider the
		 * text immediately following the % as unescaped.
		 */
		ENSURE(1);
		ret[retlen++] = '%';
	    }
	}

	/* resume scanning for additional escapes after this one. */
	so = eo;
    }

    /* if there is any unescaped text at the end of the line, send it */
    if (eo != so) {
	ENSURE(eo - so);
	memcpy(ret + retlen, cfg->proxy_telnet_command + so, eo - so);
	retlen += eo - so;
    }

    ENSURE(1);
    ret[retlen] = '\0';
    return ret;

#undef ENSURE
}

int proxy_telnet_negotiate (Proxy_Socket p, int change)
{
    if (p->state == PROXY_CHANGE_NEW) {
	char *formatted_cmd;

	formatted_cmd = format_telnet_command(p->remote_addr, p->remote_port,
					      &p->cfg);

	sk_write(p->sub_socket, formatted_cmd, strlen(formatted_cmd));
	sfree(formatted_cmd);

	p->state = 1;
	return 0;
    }

    if (change == PROXY_CHANGE_CLOSING) {
	/* if our proxy negotiation process involves closing and opening
	 * new sockets, then we would want to intercept this closing
	 * callback when we were expecting it. if we aren't anticipating
	 * a socket close, then some error must have occurred. we'll
	 * just pass those errors up to the backend.
	 */
	return plug_closing(p->plug, p->closing_error_msg,
			    p->closing_error_code,
			    p->closing_calling_back);
    }

    if (change == PROXY_CHANGE_SENT) {
	/* some (or all) of what we wrote to the proxy was sent.
	 * we don't do anything new, however, until we receive the
	 * proxy's response. we might want to set a timer so we can
	 * timeout the proxy negotiation after a while...
	 */
	return 0;
    }

    if (change == PROXY_CHANGE_ACCEPTING) {
	/* we should _never_ see this, as we are using our socket to
	 * connect to a proxy, not accepting inbound connections.
	 * what should we do? close the socket with an appropriate
	 * error message?
	 */
	return plug_accepting(p->plug, p->accepting_sock);
    }

    if (change == PROXY_CHANGE_RECEIVE) {
	/* we have received data from the underlying socket, which
	 * we'll need to parse, process, and respond to appropriately.
	 */

	/* we're done */
	proxy_activate(p);
	/* proxy activate will have dealt with
	 * whatever is left of the buffer */
	return 1;
    }

    plug_closing(p->plug, "Proxy error: Unexpected proxy error",
		 PROXY_ERROR_UNEXPECTED, 0);
    return 1;
}

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
久久国产精品99久久久久久老狼 | 强制捆绑调教一区二区| 日韩中文字幕亚洲一区二区va在线| 美女脱光内衣内裤视频久久网站| 国产精选一区二区三区| 欧美性生活久久| 亚洲超碰精品一区二区| 久久91精品国产91久久小草| 91麻豆国产在线观看| 久久久青草青青国产亚洲免观| 亚洲精品国产一区二区精华液| 国产真实乱对白精彩久久| 欧美日韩国产另类一区| 亚洲素人一区二区| 国产露脸91国语对白| 欧美视频在线一区| 国产精品大尺度| 国产一区二区网址| 欧美狂野另类xxxxoooo| 依依成人综合视频| 成人h动漫精品一区二| 精品国产91久久久久久久妲己 | 亚洲人成伊人成综合网小说| 国产一区二区三区观看| 91精品国产丝袜白色高跟鞋| 亚洲综合激情网| 97精品超碰一区二区三区| 久久一区二区三区国产精品| 日本成人中文字幕在线视频| 欧美色网一区二区| 夜夜嗨av一区二区三区中文字幕| 99久久久精品| 亚洲色大成网站www久久九九| 成人免费三级在线| 日本一区二区三区电影| 国产成人精品一区二区三区四区| 日韩一区二区三区三四区视频在线观看| 一区二区三区欧美在线观看| 色欧美片视频在线观看在线视频| 亚洲天堂免费看| 色哟哟欧美精品| 亚洲欧美日韩在线不卡| 一本久久综合亚洲鲁鲁五月天| 亚洲欧美综合网| 色哟哟一区二区在线观看 | 亚洲综合另类小说| 欧美中文字幕一二三区视频| 亚洲午夜精品在线| 91精品国产综合久久小美女| 日本欧美大码aⅴ在线播放| 精品伦理精品一区| 国产成人午夜视频| 最新高清无码专区| 欧美色综合网站| 老司机免费视频一区二区三区| 精品久久一区二区三区| 成人亚洲精品久久久久软件| 美女视频第一区二区三区免费观看网站| 欧美浪妇xxxx高跟鞋交| 精品中文字幕一区二区| 国产欧美日本一区视频| 99国产精品久久久久久久久久久| 一区二区三区日韩在线观看| 欧美日韩久久一区| 韩国v欧美v日本v亚洲v| 中文字幕在线观看不卡视频| 欧美日韩视频在线一区二区| 蜜桃av噜噜一区| 日韩一区在线看| 在线播放欧美女士性生活| 精品一区二区三区免费| 亚洲色图视频网| 欧美va亚洲va香蕉在线| eeuss影院一区二区三区| 午夜视频一区二区| 欧美国产日产图区| 欧美人牲a欧美精品| 粉嫩av一区二区三区粉嫩| 亚洲国产中文字幕| 国产欧美日韩久久| 欧美美女激情18p| 成人性生交大片免费| 日本不卡免费在线视频| √…a在线天堂一区| 欧美不卡视频一区| 欧美性色黄大片手机版| 国产传媒久久文化传媒| 日韩主播视频在线| 亚洲精品水蜜桃| 国产日韩精品视频一区| 日韩一区二区视频| 在线观看成人小视频| 成人永久aaa| 激情综合网最新| 天天色天天爱天天射综合| 国产精品国产三级国产普通话99| 欧美一区二区在线看| 日本福利一区二区| 本田岬高潮一区二区三区| 精品一区二区免费在线观看| 午夜精品福利一区二区三区av| 国产精品欧美久久久久一区二区| 亚洲欧美日韩中文播放| 国产日本欧美一区二区| 日韩欧美不卡在线观看视频| 在线视频一区二区三| 白白色亚洲国产精品| 国产成人免费9x9x人网站视频| 久久国产精品色| 人妖欧美一区二区| 日韩精彩视频在线观看| 亚洲伊人色欲综合网| 一区二区久久久久久| 亚洲激情综合网| 一区二区三区四区不卡在线| 亚洲欧美色图小说| 亚洲情趣在线观看| 亚洲色欲色欲www| 亚洲日本乱码在线观看| 国产精品夫妻自拍| 亚洲天堂av一区| 日韩美女啊v在线免费观看| 亚洲三级久久久| 亚洲精品伦理在线| 亚洲一区二区三区视频在线| 樱桃国产成人精品视频| 一二三区精品福利视频| 婷婷成人激情在线网| 欧美aaa在线| 久久99热国产| 国产福利91精品一区| 成人h精品动漫一区二区三区| 99天天综合性| 欧美性色aⅴ视频一区日韩精品| 欧美日韩一区久久| 91精品中文字幕一区二区三区| 欧美一级黄色片| 久久久久久夜精品精品免费| 国产精品三级久久久久三级| 亚洲女厕所小便bbb| 午夜精品视频一区| 国产真实乱偷精品视频免| 国产99久久久精品| 日本韩国精品在线| 国产蜜臀97一区二区三区| 日本一区二区在线不卡| 亚洲嫩草精品久久| 免费国产亚洲视频| 成人永久aaa| 欧美日韩综合在线| 亚洲精品一线二线三线无人区| 国产亚洲精品超碰| 亚洲人成精品久久久久久| 日韩成人一级片| 国产91丝袜在线播放九色| 在线观看国产日韩| 久久久国产午夜精品 | 久久亚洲欧美国产精品乐播| 国产精品二三区| 日韩av网站免费在线| 成人一级黄色片| 欧美一级理论性理论a| 中文字幕日韩一区| 麻豆久久一区二区| 色哟哟亚洲精品| 久久亚洲综合色一区二区三区| 亚洲激情自拍视频| 国产成人av电影在线| 8x8x8国产精品| 国产精品不卡视频| 精品一区二区三区视频在线观看| 91麻豆国产在线观看| 国产亚洲精品福利| 奇米精品一区二区三区四区| 一本大道综合伊人精品热热| 亚洲精品在线电影| 日韩激情在线观看| 欧洲国内综合视频| 中文字幕亚洲区| 国产成人综合亚洲91猫咪| 91精品国产欧美一区二区18 | 久久精品夜色噜噜亚洲a∨| 亚洲图片自拍偷拍| 99re热这里只有精品免费视频| 日韩精品中文字幕一区二区三区| 亚洲亚洲人成综合网络| 91日韩在线专区| 中日韩av电影| 国产精品18久久久| 精品国精品国产| 美美哒免费高清在线观看视频一区二区 | 国产福利精品一区| 日韩精品一区二区三区在线| 亚洲444eee在线观看| 91黄色激情网站| 亚洲天堂网中文字| 99re8在线精品视频免费播放| 丝袜亚洲精品中文字幕一区| 色一情一乱一乱一91av| 亚洲天堂福利av|