Ir para conteúdo
Fórum Script Brasil

Cheaster

Membros
  • Total de itens

    9
  • Registro em

  • Última visita

Sobre Cheaster

Cheaster's Achievements

0

Reputação

  1. Hey galera. Estou fazendo um cliente bittorrent em python baseado no ABC. Então é o seguinte estou tentado encriptar um sistema RC4 de forma a contornar o Traffic Shaping dos ISP's. A ideia é encriptar o mais possivel o tráfego bittorrent para que este não seja identificado pela operadora e seja bloqueado. Deixo aqui o meu código RC4. Por favor ajudem-me a melhorar e tornar o código mais eficiente. Aceito todo o tipo de truques e dicas. Ficheiro ARC4.py """From TLS Lite: Pure-Python RC4 implementation""" import array def bytesToString(bytes): return bytes.tostring() def createByteArrayZeros(howMany): return array.array('B', [0] * howMany) def stringToBytes(s): bytes = createByteArrayZeros(0) bytes.fromstring(s) return bytes def new(key): return RC4(key) class RC4: def __init__(self, key): keyBytes = stringToBytes(key) S = [i for i in range(256)] j = 0 for i in range(256): j = (j + S[i] + keyBytes[i % len(keyBytes)]) % 256 S[i], S[j] = S[j], S[i] self.S = S self.i = 0 self.j = 0 def encrypt(self, plaintext): plaintextBytes = stringToBytes(plaintext) S = self.S i = self.i j = self.j for x in range(len(plaintextBytes)): i = (i + 1) % 256 j = (j + S[i]) % 256 S[i], S[j] = S[j], S[i] t = (S[i] + S[j]) % 256 plaintextBytes[x] ^= S[t] self.i = i self.j = j return bytesToString(plaintextBytes) def decrypt(self, ciphertext): return self.encrypt(ciphertext) Ficheiro BTcrypto.py # Written by John Hoffman # based on code by Uoti Urpala # see LICENSE.txt for license information from __future__ import generators # for python 2.2 from random import randrange,randint,seed try: from os import urandom except: seed() urandom = lambda x: ''.join([chr(randint(0,255)) for i in xrange(x)]) from sha import sha try: True except: True = 1 False = 0 try: from Crypto.Cipher import ARC4 CRYPTO_OK = True except: import ARC4 CRYPTO_OK = False KEY_LENGTH = 160 DH_PRIME = 0xFFFFFFFFFFFFFFFFC90FDAA22168C234C4C6628B80DC1CD129024E088A67CC74020BBEA63B139B22514A08798E3404DDEF9519B3CD3A431B302B0A6DF25F14374FE1356D6D51C245E485B576625E7EC6F44C42E9A63A36210000000000090563 PAD_MAX = 200 # less than protocol maximum, and later assumed to be < 256 DH_BYTES = 96 def bytetonum(x): return long(x.encode('hex'), 16) def numtobyte(x): x = hex(x).lstrip('0x').rstrip('Ll') x = '0'*(192 - len(x)) + x return x.decode('hex') class Crypto: def __init__(self, initiator, disable_crypto = False): self.initiator = initiator self.disable_crypto = disable_crypto # if not disable_crypto and not CRYPTO_OK: # raise NotImplementedError, "attempt to run encryption w/ none installed" self.privkey = bytetonum(urandom(KEY_LENGTH/8)) self.pubkey = numtobyte(pow(2, self.privkey, DH_PRIME)) self.keylength = DH_BYTES self._VC_pattern = None def received_key(self, k): self.S = numtobyte(pow(bytetonum(k), self.privkey, DH_PRIME)) self.block3a = sha('req1'+self.S).digest() self.block3bkey = sha('req3'+self.S).digest() self.block3b = None def _gen_block3b(self, SKEY): a = sha('req2'+SKEY).digest() return ''.join([ chr(ord(a[i])^ord(self.block3bkey[i])) for i in xrange(20) ]) def test_skey(self, s, SKEY): block3b = self._gen_block3b(SKEY) if block3b != s: return False self.block3b = block3b if not self.disable_crypto: self.set_skey(SKEY) return True def set_skey(self, SKEY): if not self.block3b: self.block3b = self._gen_block3b(SKEY) crypta = ARC4.new(sha('keyA'+self.S+SKEY).digest()) cryptb = ARC4.new(sha('keyB'+self.S+SKEY).digest()) if self.initiator: self.encrypt = crypta.encrypt self.decrypt = cryptb.decrypt else: self.encrypt = cryptb.encrypt self.decrypt = crypta.decrypt self.encrypt('x'*1024) # discard first 1024 bytes self.decrypt('x'*1024) def VC_pattern(self): if not self._VC_pattern: self._VC_pattern = self.decrypt('\x00'*8) return self._VC_pattern def read(self, s): self._read(self.decrypt(s)) def write(self, s): self._write(self.encrypt(s)) def setrawaccess(self, _read, _write): self._read = _read self._write = _write def padding(self): return urandom(randrange(PAD_MAX-16)+16) Por favor me ajudem-me com o meu programa. Contacto MSN: geral@bt-revolution.net Cumps
  2. Boa noite o meu servidor (Mysql Version: 5.0.67-community / PHP Version: 5.2.5) tem a função parse_ini_file desactivada como posso fazer para activar? Alguém me pode ajudar? Obrigado
  3. Ainda não consegui alinhar o menu ao centro, alguém me poderia ajudar=? Muito obrigado Galera pela vossa atenção!
  4. Pelo o que eu percebi deste script ele faz "output" através disto: <body onload="initjsDOMenu()"> certo? Está "função" está presente neste ficheiro: jsdomenu.js Mas reparei noutra coisa mais interessante ele tem uma "função" que alinha à esquerda, que está presente no ficheiro: jsdomenubar.js Get the left position of the menu bar menu. */ function getMainMenuBarMenuLeftPos(menuBarObj, menuBarItemObj, menuObj, x) { // Private method if (x + menuObj.offsetWidth <= getClientWidth()) { return x; } else { return x + menuBarItemObj.offsetWidth - menuObj.offsetWidth + getPropIntVal(menuObj, blw) + getPropIntVal(menuObj, brw); } } /* Get the top position of the menu bar menu. */ function getMainMenuBarMenuTopPos(menuBarObj, menuBarItemObj, menuObj, y) { // Private method if (y + menuObj.offsetHeight <= getClientHeight()) { return y; } else { if ((ie55 || ie6) && menuBarObj.mode == "static" && pageMode == 0) { y = menuBarObj.offsetTop + menuBarObj.offsetHeight - getScrollTop(); } if ((ie55 || ie6) && menuBarObj.mode == "static" && pageMode == 1) { return menuBarItemObj.offsetTop - menuObj.offsetHeight - getPropIntVal(menuBarObj, pt) - getPropIntVal(menuBarObj, btw) + getPropIntVal(menuBarItemObj, pt) + getPropIntVal(menuBarItemObj, btw) - getScrollTop(); } else { return y - menuObj.offsetHeight - menuBarObj.offsetHeight; } } } /* Pop up the menu bar menu. */ function popUpMenuBarMenu(menuBarObj, menuBarItemObj, menuObj) { // Private method var x; var y; if (menuBarObj.style.position == "fixed") { x = menuBarObj.offsetLeft + menuBarItemObj.offsetLeft + getPropIntVal(menuBarObj, blw) - getPropIntVal(menuObj, blw); y = menuBarObj.offsetTop + menuBarObj.offsetHeight; if (opera || safari) { x -= getPropIntVal(menuBarObj, blw); } menuObj.style.position = "absolute"; menuObj.style.left = getMainMenuBarMenuLeftPos(menuBarObj, menuBarItemObj, menuObj, x) + px; menuObj.style.top = getMainMenuBarMenuTopPos(menuBarObj, menuBarItemObj, menuObj, y) + px; menuObj.style.position = "fixed"; } else { if (menuBarObj.mode == "static") { x = menuBarItemObj.offsetLeft - getPropIntVal(menuObj, blw) - getScrollLeft(); y = menuBarObj.offsetTop + menuBarObj.offsetHeight - getScrollTop(); if (ie55 || ie6) { y = menuBarItemObj.offsetTop + menuBarItemObj.offsetHeight + getPropIntVal(menuBarObj, bbw) + getPropIntVal(menuBarObj, pb) - getPropIntVal(menuBarItemObj, pb) - getPropIntVal(menuBarItemObj, bbw) - getScrollTop(); } if (safari) { x += 8; y += 13; } menuObj.style.left = (getMainMenuBarMenuLeftPos(menuBarObj, menuBarItemObj, menuObj, x) + getScrollLeft()) + px; menuObj.style.top = (getMainMenuBarMenuTopPos(menuBarObj, menuBarItemObj, menuObj, y) + getScrollTop()) + px; } else { x = menuBarObj.offsetLeft + menuBarItemObj.offsetLeft + getPropIntVal(menuBarObj, blw) - getPropIntVal(menuObj, blw) - getScrollLeft(); y = menuBarObj.offsetTop + menuBarObj.offsetHeight - getScrollTop(); if (opera || safari) { x -= getPropIntVal(menuBarObj, blw); } menuObj.style.left = (getMainMenuBarMenuLeftPos(menuBarObj, menuBarItemObj, menuObj, x) + getScrollLeft()) + px; menuObj.style.top = (getMainMenuBarMenuTopPos(menuBarObj, menuBarItemObj, menuObj, y) + getScrollTop()) + px; } } if (ie && menuObj.mode == "fixed") { menuObj.initialLeft = parseInt(menuObj.style.left) - getScrollLeft(); menuObj.initialTop = parseInt(menuObj.style.top) - getScrollTop(); } menuObj.style.visibility = "visible"; }Ou seja isto é que vai definir a posição inicial do menu, existe como alterar o tal "get left" para "get center" ? Cumps
  5. O link certo do menu: download Eu já tentei meter em vez de absolute , center mas n deu!
  6. lenowds O código HTML é esse: <html> <head> <link rel="stylesheet" type="text/css" href="demo.css" /> <link rel="stylesheet" type="text/css" href="classic.css" /> <script type="text/javascript" src="jsdomenu.js"></script> <script type="text/javascript" src="jsdomenubar.js"></script> <script type="text/javascript" src="demo3.inc.js"></script> </head> <body onload="initjsDOMenu()"> </body> </html> Thanks ;)
  7. É que eu já tentei editar o css do menu mas sem sucesso :( Será que você me podia ajudar? É que eu já tentei tudo o que sabia e nada :( Classic.css .jsdomenubardiv { background-color: #ffffff; background-position: center; background-repeat: no-repeat; border: 0px outset; border-bottom-color: #FFFFFF; border-left-color: #FFFFFF; border-right-color: #FFFFFF; border-top-color: #FFFFFF; cursor: default; padding-bottom: 1px; padding-left: 2px; padding-right: 2px; padding-top: 1px; position: absolute; /* Do not alter this line! */ visibility: visible; } .jsdomenubardragdiv { cursor: move; display: inline; font-family: Arial; font-size: 9pt; font-weight: 700; padding-bottom: 2px; padding-left: 5px; padding-right: 5px; padding-top: 2px; position: relative; /* Do not alter this line! */ visibility: hidden; width: 9px; } .jsdomenubaritem { background-color: #E9E9E9; border: 1px outset; border-bottom-color: #CCCCCC; border-left-color: #CCCCCC; border-right-color: #CCCCCC; border-top-color: #CCCCCC; color: #000000; display: inline; font-family: Arial; font-size: 9pt; font-weight: 700; padding-bottom: 1px; padding-left: 10px; padding-right: 10px; padding-top: 1px; position: relative; /* Do not alter this line! */ } .jsdomenubaritemclick { background-color: #E9E9E9; border: 1px outset; color: #000000; display: inline; font-family: Arial; font-size: 9pt; font-weight: 700; padding-bottom: 1px; padding-left: 10px; padding-right: 10px; padding-top: 1px; position: relative; /* Do not alter this line! */ } .jsdomenubaritemover { background-color: #FFFFFF; border: 1px outset; color: #000000; display: inline; font-family: Arial; font-size: 9pt; font-weight: 700; padding-bottom: 1px; padding-left: 10px; padding-right: 10px; padding-top: 1px; position: relative; /* Do not alter this line! */ } .jsdomenudiv { background-color: #FFFFFF; border: 1px outset; border-bottom-color: #CCCCCC; border-left-color: #CCCCCC; border-right-color: #CCCCCC; border-top-color: #CCCCCC; cursor: default; position: absolute; /* Do not alter this line! */ visibility: hidden; z-index: 10; } .jsdomenuitem { background-color: transparent; border: none; color: #000000; font-family: Arial; font-size: 9pt; font-weight: 700; padding-bottom: 1px; padding-left: 10px; padding-right: 15px; padding-top: 1px; position: relative; /* Do not alter this line! */ } .jsdomenuitemover { background-color: #666666; border: none; color: #FFFFFF; font-family: Arial; font-size: 9pt; font-weight: 700; padding-bottom: 1px; padding-left: 10px; padding-right: 15px; padding-top: 1px; position: relative; /* Do not alter this line! */ } .jsdomenusep { } .jsdomenusep hr { text-align: center; width: 95%; } demo.css --> penso que seja do texto este body { background-color: #F3F3F3; font-family: Georgia, Verdana, Arial, sans-serif; font-size: small; text-align: center; } code { background-color: #E5E5E5; border: 1px dashed #009966; display: block; font-size: 12px; padding: 10px; text-align: center; } h1 { border-bottom: 1px solid #990000; color: #CCCC33; font-family: Georgia, Arial, Helvetica, sans-serif; font-size: 200%; text-align: right; text-align: center; } Valeu a todos pela atenção. Abraço ;)
  8. demo3.inc.js function f_clientWidth() { return f_filterResults ( window.innerWidth ? window.innerWidth : 0, document.documentElement ? document.documentElement.clientWidth : 0, document.body ? document.body.clientWidth : 0 ); } function f_filterResults(n_win, n_docel, n_body) { var n_result = n_win ? n_win : 0; if (n_docel && (!n_result || (n_result > n_docel))) n_result = n_docel; return n_body && (!n_result || (n_result > n_body)) ? n_body : n_result; } function createjsDOMenu() { absoluteMenu1 = new jsDOMenu(100, "", "absolute"); with (absoluteMenu1) { addMenuItem(new menuItem("Hoje", "", "?a=5&c=aaaaba")); addMenuItem(new menuItem("Ontem", "", "?a=5&c=abaaba")); } addMenuBarItem(new menuBarItem("Música", absoluteMenu1)); moveTo((f_clientWidth() - 770)/2, 390); } } Penso que é nesse ficheiro que ele faz o alinhamento, eu até já acrescentei uma função: function f_clientWidth() { return f_filterResults ( window.innerWidth ? window.innerWidth : 0, document.documentElement ? document.documentElement.clientWidth : 0, document.body ? document.body.clientWidth : 0 ); } function f_filterResults(n_win, n_docel, n_body) { var n_result = n_win ? n_win : 0; if (n_docel && (!n_result || (n_result > n_docel))) n_result = n_docel; return n_body && (!n_result || (n_result > n_body)) ? n_body : n_result; } Mas mesmo assim ainda não alinha ao centro... Eu deixei o link do menu no primeiro post. Não tenho a certeza se estou a fazer isto bem :X Só queria alinhar o menu ao centro pois ele vem à esquerda por defeito :( Ninguém sabe como alinhar ao centro..? Eu já desisti :/
  9. Boas pessoal! Precisava de uma pequena ajuda vossa :) Estava a tentar implementar este drop menu em javscript no meu site: http://www.dynamicdrive.com/dynamici...menu/index.htm O problema é que este vem alinhado ao à esquerda. Estou farto de tentar alinha-lo ao centro e nada. Nem com tabelas ele vai lá. Alguém poderia me ajudar? Nota: Estou a tentar a implementar o demo3 Abraço!
×
×
  • Criar Novo...