Subversion Repositories pub

Compare Revisions

Ignore whitespace Rev 692 → Rev 693

/relevation/trunk/CHANGELOG
1,5 → 1,8
$Date$
 
1.3.1 (2020-02-11):
- Port to Python3
 
1.3 (2014-05-24):
- Check file magic [#230] and reject unsupported data formats
- Support the new data file format [#228]
/relevation/trunk/debian/changelog
1,8 → 1,8
relevation (1.3-pon.2) stable; urgency=medium
relevation (1.3.1-pon.1) stable; urgency=medium
 
* Updated build dependencies
* New version
 
-- Toni Corvera <outlyer@gmail.com> Tue, 11 Feb 2020 13:13:46 +0100
-- Toni Corvera <outlyer@gmail.com> Tue, 11 Feb 2020 19:27:25 +0100
 
relevation (1.3-pon.1) unstable; urgency=medium
 
/relevation/trunk/debian/control
2,16 → 2,16
Section: contrib/utils
Priority: extra
Maintainer: Toni Corvera <outlyer@gmail.com>
Build-Depends: debhelper (>= 7.0.50~), python (>= 2.5)
X-Python-Version: >= 2.5
Build-Depends: debhelper (>= 7.0.50~), python3 (>= 3.7)
X-Python-Version: >= 3.7
Standards-Version: 3.9.1
Homepage: http://p.outlyer.net/relevation/
Homepage: https://p.outlyer.net/relevation/
Vcs-Svn: https://svn.outlyer.net/svn/pub/relevation
Vcs-Browser: https://svn.outlyer.net/websvn/wsvn/pub/relevation/
 
Package: relevation
Architecture: all
Depends: ${shlibs:Depends}, ${misc:Depends}, python-lxml, python-crypto, ${python:Depends}
Depends: ${shlibs:Depends}, ${misc:Depends}, python3-lxml, python3-crypto, ${python:Depends}
Recommends: revelation
Description: Command-line interface to query Revelation files
This is a command-line tool capable of retrieving passwords from
/relevation/trunk/relevation.spec.in
20,10 → 20,10
Source: http://p.outlyer.net/relevation/files/relevation-%{version}.tar.gz
BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root
BuildArch: noarch
BuildRequires: python2-devel
Requires: libxml2-python
Requires: python-crypto
Requires: python-lxml
BuildRequires: python3-devel, make
Requires: python3-libxml2
Requires: python3-crypto
Requires: python3-lxml
 
%description
Relevation is a tool to retrieve passwords stored in a password file in the
53,6 → 53,9
%{python2_sitelib}/relevation-*.egg-info
 
%changelog
* Tue 11 Feb 2020 Toni Corvera <outlyer@gmail.com> 1.3.1-1.pon
- Updated to use Python 3
 
* Fri May 23 2014 Toni Corvera <outlyer@gmail.com> 1.3-1.pon
- Handle installation of new module
 
/relevation/trunk/src/relevation.py
1,4 → 1,4
#!/usr/bin/env python
#!/usr/bin/env python3
# -*- coding: UTF-8 -*-
 
"""
18,7 → 18,7
"""
# Relevation Password Printer
#
# Copyright (c) 2011,2012,2013,2014 Toni Corvera
# Copyright (c) 2011,2012,2013,2014,2020 Toni Corvera
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
42,7 → 42,7
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE.
 
import ConfigParser
import configparser
import getopt
import getpass
from lxml import etree
49,7 → 49,6
import locale
import os
import stat
import string
import sys
import zlib
# Help py2exe in packaging lxml
77,7 → 76,7
__author__ = 'Toni Corvera'
__date__ = '$Date$'
__revision__ = '$Rev$'
__version_info__ = ( 1, 3 ) #, 0 ) # Note: For x.y.0, only x and y are kept
__version_info__ = ( 1, 3, 1 ) #, 0 ) # Note: For x.y.0, only x and y are kept
if not RELEASE:
import traceback
__version_info__ += ( '0-pre1', )
92,7 → 91,7
codes = { 'EX_OK': 0, 'EX_USAGE': 64, 'EX_DATAERR': 65,
'EX_NOINPUT': 66, 'EX_SOFTWARE': 70, 'EX_IOERR': 74,
}
for (k,v) in codes.items():
for (k,v) in list(codes.items()):
setattr(os, k, v)
del codes, k, v
 
193,13 → 192,13
needles = search_text
else:
# FIXME: Used for OR's
assert type(search_text) == str or type(search_text) == unicode
assert type(search_text) == str or type(search_text) == str
needles = [ search_text, ]
selector = ''
for search in needles:
if ignore_case:
# must pass lowercase to actually be case insensitive
search = string.lower(search)
search = search.lower()
# XPath 2.0 has lower-case, upper-case, matches(..., -i) etc.
selector += '//text()[contains(translate(., "ABCDEFGHIJKLMNOPQRSTUVWXYZ", "abcdefghijklmnopqrstuvwxyz"), "%s")]/../..' % search
else:
246,7 → 245,7
def dump_single_result(typeName, name, descr, notes, fields):
''' dump_single_result(str, unicode, unicode, list) -> None '''
printe('-------------------------------------------------------------------------------')
s = u'\n'
s = '\n'
s += 'Type: %s\n' % typeName
s += 'Name: %s\n' % name
s += 'Description: %s\n' % descr
255,12 → 254,15
s += '%s %s\n' % field # field, value
try:
# sys.stdout.encoding will be None if piped
print s.encode(sys.stdout.encoding or locale.getpreferredencoding())
#print(s.encode(sys.stdout.encoding or locale.getpreferredencoding()))
print(s)
except UnicodeEncodeError:
# XXX: In Python 2 there were unicode conversions, no longer needed in Python 3
# TODO: This branch shouldn't be entered anymore, but needs testing
# E.g. console in ASCII ($ LC_ALL=C relevation)
# TODO: Flag for notification
#printe("WARNING: The console doesn't have a compatible encoding, falling back to UTF-8")
print s.encode('utf8')
print(s.encode('utf8'))
 
def dump_result(res, query_desc, dumpfn=dump_single_result):
''' Print query results.
272,15 → 274,15
'''
# Note the XML is in UTF-8, and that the extracted fields will be
# either type
if type(s) == unicode:
if type(s) == str:
return s
return unicode(s.decode('utf8'))
return str(s.decode('utf8'))
 
print '-> Search %s: ' % query_desc,
print('-> Search %s: ' % query_desc, end=' ')
if not len(res):
print 'No results'
print('No results')
return False
print '%d matches' % len(res)
print('%d matches' % len(res))
for x in res:
typeName = x.get('type')
name = None
339,7 → 341,7
wr = world_readable(cfg)
if wr and sys.platform != 'win32':
printe('Configuration (~/.relevation.conf) is world-readable!!!')
parser = ConfigParser.ConfigParser()
parser = configparser.ConfigParser()
parser.read(cfg)
ops = parser.options('relevation')
if 'file' in ops:
363,9 → 365,9
''' Checks that the gzip-compressed 'data' is padded correctly.
validate_compressed_padding(str) -> bool
'''
padlen = ord(data[-1])
padlen = data[-1] # XXX: While on Python 2 we were using ord(data[-1]), ord(i), etc.
for i in data[-padlen:]:
if ord(i) != padlen:
if i != padlen:
return False
return True
def validate_cipher_length(self, data):
441,7 → 443,7
if not self.validate_compressed_padding(cleardata_gz):
raise DataFormatError
# Decompress actual data (15 is wbits [ref3] DON'T CHANGE, 2**15 is the (initial) buf size)
padlen = ord(cleardata_gz[-1])
padlen = cleardata_gz[-1]
try:
# Note data is encoded in UTF-8 but not decoded yet (because
# the XML parser is too easy to choke in that case)
488,7 → 490,7
if not self.validate_compressed_padding(cleardata_gz):
raise DataFormatError
# Decompress
padlen = ord(cleardata_gz[-1])
padlen = cleardata_gz[-1]
try:
return zlib.decompress(cleardata_gz[:-padlen])
except zlib.error:
527,13 → 529,13
'''
header = self._data[0:12]
magic = header[0:4]
if magic != "rvl\x00":
if magic != b"rvl\x00":
raise DataFormatError
data_version = header[4]
app_version = header[6:9]
if data_version == '\x01':
if data_version == 0x01: #'\x01':
self._impl = DataReaderV1()
elif data_version == '\x02':
elif data_version == 0x02: #'\x02':
self._impl = DataReaderV2()
else:
raise DataVersionError
554,7 → 556,7
dump_xml = False
mode = None
 
printe('Relevation v%s, (c) 2011-2014 Toni Corvera\n' % __version__)
printe('Relevation v%s, (c) 2011-2020 Toni Corvera\n' % __version__)
 
# ---------- OPTIONS ---------- #
( datafile, password, mode ) = load_config()
565,8 → 567,8
'case-sensitive', 'case-insensitive', 'ask',
'help', 'version', 'type=', 'xml',
'and', 'or' ])
except getopt.GetoptError, err:
print str(err)
except getopt.GetoptError as err:
print(str(err))
usage(sys.stderr)
sys.exit(os.EX_USAGE)
if args:
579,14 → 581,14
release=''
if not RELEASE:
release=' [DEBUG]'
print 'Relevation version %s%s' % ( __version__, release )
print 'Python version %s' % sys.version
print('Relevation version %s%s' % ( __version__, release ))
print('Python version %s' % sys.version)
if USE_PYCRYPTO:
import Crypto
print 'PyCrypto version %s' % Crypto.__version__
print('PyCrypto version %s' % Crypto.__version__)
else:
# AFAIK cryptopy doesn't export version info
print 'cryptopy'
print('cryptopy')
sys.exit(os.EX_OK)
for opt, arg in ops:
643,7 → 645,7
# ---------- QUERIES ---------- #
if dump_xml:
print xmldata
print(xmldata)
sys.exit(os.EX_OK)
# Multiply values to search by type of searches
numhits = 0