-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy pathinstall.sh
More file actions
249 lines (221 loc) · 8.64 KB
/
install.sh
File metadata and controls
249 lines (221 loc) · 8.64 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
#!/bin/bash
# Build script for Improved Pywallet
# This script sets up the environment and installs dependencies
echo "=== Installing Improved Pywallet ==="
# Check if Python 3 is available
if ! command -v python3 &> /dev/null; then
echo "Error: Python 3 is not installed"
exit 1
fi
echo "✓ Python 3 found: $(python3 --version)"
# Install system dependencies first
echo "Installing system dependencies..."
if command -v apt-get &> /dev/null; then
echo "Detected apt-get (Ubuntu/Debian). Installing system dependencies..."
sudo apt-get update
sudo apt-get install -y libdb-dev python3-dev build-essential python3-venv libssl-dev libffi-dev
echo "✓ System dependencies installed"
elif command -v yum &> /dev/null; then
echo "Detected yum (CentOS/RHEL). Installing system dependencies..."
sudo yum install -y db-devel python3-devel gcc gcc-c++ make python3-venv openssl-devel libffi-devel
echo "✓ System dependencies installed"
elif command -v brew &> /dev/null; then
echo "Detected brew (macOS). Installing system dependencies..."
brew install berkeley-db python@3 openssl libffi
echo "✓ System dependencies installed"
else
echo "Warning: Could not detect package manager. Please install these dependencies manually:"
echo " - Berkeley DB development libraries (libdb-dev)"
echo " - Python 3 development headers (python3-dev)"
echo " - Build tools (build-essential, gcc, make)"
echo " - SSL development libraries (libssl-dev)"
echo " - FFI development libraries (libffi-dev)"
echo "Press Enter to continue or Ctrl+C to abort..."
read
fi
# Check if we're in the right directory
if [ ! -f "pywallet.py" ] && [ ! -f "pywallet/pywallet.py" ]; then
echo "Error: pywallet.py not found. Please run this script from the project root."
exit 1
fi
# Create virtual environment if it doesn't exist
if [ ! -d "pywallet_build_env" ]; then
echo "Creating virtual environment..."
python3 -m venv pywallet_build_env
if [ $? -ne 0 ]; then
echo "Error: Failed to create virtual environment"
exit 1
fi
echo "✓ Virtual environment created"
else
echo "✓ Virtual environment already exists"
fi
# Activate virtual environment and install dependencies
echo "Installing dependencies..."
source pywallet_build_env/bin/activate
# Upgrade pip
pip install --upgrade pip
# Install required dependencies
echo "Installing bsddb3 (Berkeley DB support)..."
pip install bsddb3
if [ $? -ne 0 ]; then
echo "Error: Failed to install bsddb3"
exit 1
fi
echo "Installing cryptographic libraries..."
# Remove any existing conflicting crypto packages first
echo "Cleaning up any existing crypto packages..."
pip uninstall -y pycrypto pycryptodome cryptography 2>/dev/null || true
# Install cryptography first (has fewer dependency conflicts)
echo "Installing cryptography library..."
pip install --upgrade cryptography
if [ $? -ne 0 ]; then
echo "Error: Failed to install cryptography"
echo "This is often due to missing system dependencies."
echo "Please ensure libssl-dev, libffi-dev, and build-essential are installed."
exit 1
fi
echo "✓ Installed cryptography"
# Install pycryptodome (recommended over pycrypto for better Python 3 support)
echo "Installing pycryptodome (improved cryptographic support)..."
pip install --upgrade pycryptodome
if [ $? -ne 0 ]; then
echo "Warning: Failed to install pycryptodome, trying alternative installation methods..."
# Try installing with no cache
echo "Trying installation with --no-cache-dir..."
pip install --no-cache-dir pycryptodome
if [ $? -ne 0 ]; then
echo "Warning: pycryptodome failed, trying fallback pycrypto..."
pip install pycrypto
if [ $? -ne 0 ]; then
echo "Error: Failed to install both pycryptodome and pycrypto"
echo "Crypto operations may not work properly."
echo "Please manually install: pip install pycryptodome"
exit 1
fi
echo "✓ Installed pycrypto as fallback"
else
echo "✓ Installed pycryptodome (second attempt)"
fi
else
echo "✓ Installed pycryptodome"
fi
# Install ecdsa for elliptic curve operations
echo "Installing ecdsa (elliptic curve cryptography)..."
pip install ecdsa
if [ $? -ne 0 ]; then
echo "Warning: Failed to install ecdsa"
echo "Some wallet operations may not work properly."
else
echo "✓ Installed ecdsa"
fi
echo "✓ All dependencies installed successfully (bsddb3, cryptographic libraries, ecdsa)"
# Test the installation
echo "Testing installation..."
# Determine which pywallet.py to use
if [ -f "pywallet.py" ]; then
PYWALLET_PATH="pywallet.py"
elif [ -f "pywallet/pywallet.py" ]; then
PYWALLET_PATH="pywallet/pywallet.py"
fi
# Test basic pywallet functionality
python3 "$PYWALLET_PATH" --help > /dev/null 2>&1
if [ $? -ne 0 ]; then
echo "Error: Build test failed"
exit 1
fi
# Test cryptographic libraries availability
echo "Testing cryptographic library availability..."
python3 -c "
import sys
# Test Cipher modules
cipher_available = False
cipher_source = ''
try:
from Crypto.Cipher import AES
print('✓ Crypto.Cipher (AES) is available')
cipher_available = True
cipher_source = 'pycrypto/pycryptodome'
except ImportError as e1:
try:
from Cryptodome.Cipher import AES
print('✓ Cryptodome.Cipher (AES) is available')
cipher_available = True
cipher_source = 'pycryptodome'
except ImportError as e2:
print('✗ ERROR: Neither Crypto.Cipher nor Cryptodome.Cipher could be imported')
print('This WILL cause \"Cipher is not defined\" errors during wallet extraction')
print('Crypto.Cipher error:', str(e1))
print('Cryptodome.Cipher error:', str(e2))
cipher_available = False
# Test other required crypto modules
try:
from cryptography.hazmat.primitives.ciphers import Cipher, algorithms, modes
print('✓ cryptography.hazmat.primitives.ciphers is available')
except ImportError as e:
print('✗ WARNING: cryptography.hazmat.primitives.ciphers not available:', str(e))
# Test hashlib
try:
import hashlib
print('✓ hashlib is available')
except ImportError as e:
print('✗ ERROR: hashlib not available:', str(e))
if not cipher_available:
print()
print('CRITICAL ERROR: Cipher modules are not available!')
print('This will cause wallet extraction to fail with \"Cipher is not defined\" errors.')
print()
print('TROUBLESHOOTING STEPS:')
print('1. Try: pip install --force-reinstall pycryptodome')
print('2. If that fails: pip uninstall pycrypto pycryptodome && pip install pycryptodome')
print('3. Check system dependencies: sudo apt-get install libssl-dev libffi-dev python3-dev')
print('4. Try in a fresh virtual environment')
sys.exit(1)
else:
print(f'✓ Cipher modules available from: {cipher_source}')
"
if [ $? -eq 0 ]; then
echo "✓ Cryptographic libraries test passed!"
else
echo "✗ CRITICAL: Cryptographic library test failed"
echo "This WILL cause 'Cipher is not defined' errors during wallet operations"
echo ""
echo "IMMEDIATE FIXES TO TRY:"
echo "1. source pywallet_build_env/bin/activate"
echo "2. pip install --force-reinstall pycryptodome"
echo "3. If still failing: pip uninstall pycrypto pycryptodome && pip install pycryptodome"
echo ""
echo "SYSTEM DEPENDENCY FIXES:"
echo "sudo apt-get install libssl-dev libffi-dev python3-dev build-essential"
echo ""
exit 1
fi
echo "✓ Build successful!"
echo ""
echo "To use the improved pywallet:"
echo "1. Use the run_pywallet.sh script: ./run_pywallet.sh [options]"
echo " or"
echo "2. Activate the virtual environment: source pywallet_build_env/bin/activate"
echo "3. Run pywallet: python3 $PYWALLET_PATH [options]"
echo ""
echo "New features:"
echo "- Full Python 3 support"
echo "- Enhanced cryptographic library support (pycryptodome + cryptography)"
echo "- --output_keys option for text file output"
echo "- Support for MB/GB size formats"
echo "- Automatic system dependency installation"
echo ""
echo "Cryptographic Libraries Installed:"
echo "- pycryptodome/pycrypto: For wallet decryption (AES, etc.)"
echo "- cryptography: For additional crypto operations"
echo "- System libraries: libssl-dev, libffi-dev for crypto compilation"
echo ""
echo "Installation completed successfully!"
echo ""
echo "TROUBLESHOOTING 'Cipher is not defined' errors:"
echo "If you still get this error after installation:"
echo "1. source pywallet_build_env/bin/activate"
echo "2. pip install --force-reinstall pycryptodome"
echo "3. python3 -c \"from Crypto.Cipher import AES; print('Cipher test passed!')\""
echo ""
echo "For more troubleshooting, refer to README.md"