MD5 校验值:13e9f681f5bed77188ac69741746def0
hp0.java 文件包含反编译后的源代码,请注意,该内容仅供学习和参考使用,不得用于非法用途。
package libs; import java.io.File; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; import java.net.Inet4Address; import java.net.Inet6Address; import java.net.InetAddress; import java.net.Socket; import java.net.UnknownHostException; import java.util.ArrayList; import java.util.Arrays; import java.util.Iterator; import java.util.List; import java.util.Locale; import java.util.concurrent.atomic.AtomicBoolean; import java.util.regex.Matcher; import java.util.regex.Pattern; import javax.net.ssl.SSLSocket; import javax.net.ssl.SSLSocketFactory; public final class hp0 { public static final Pattern K = Pattern.compile("\"/.*\""); public static final List L = Arrays.asList(ui3.e("abc acgi aip asm asp c c cc cc com conf cpp csh css cxx def el etx f f f77 f90 f90 flx for for g h h hh hh hlb htc htm html htmls htt htx idc jav jav java java js ksh list log lsp lst lsx m m mar mcf p pas php pl pl pm py rexx rt rt rtf rtx s scm scm sdml sgm sgm sgml sgml sh shtml shtml spc ssi talk tcl tcsh text tsv txt uil uni unis uri uris uu uue vcs wml wmls wsc xml zsh", 0, " ")); public static final Pattern M = Pattern.compile("(\\d{1,3},\\d{1,3},\\d{1,3},\\d{1,3}),(\\d{1,3}),(\\d{1,3})"); public String A; public boolean B; public InetAddress C; public InetAddress D; public boolean F; public np0 G; public int H; public String I; public boolean d; public boolean e; public AtomicBoolean f; public boolean g; public boolean h; public SSLSocketFactory j; public qp0 l; public InputStream w; public OutputStream x; public String z; public int a = 0; public final Object b = new Object(); public final Object c = new Object(); public final j10 i = new j10(); public final ArrayList k = new ArrayList(); public String m = null; public boolean n = false; public boolean o = false; public boolean p = false; public boolean q = true; public boolean r = false; public String s = null; public boolean t = false; public boolean u = false; public boolean v = false; public e y = null; public boolean E = true; public final gp0 J = new gp0(this); public static int f(String str) { int lastIndexOf = str.lastIndexOf(46) + 1; int length = str.length(); if (lastIndexOf > 0 && lastIndexOf < length - 1) { String substring = str.substring(lastIndexOf, length); List list = L; synchronized (list) { try { if (list.contains(substring.toLowerCase(vf3.c))) { return 1; } return 2; } finally { } } } return 2; } public final void A(boolean z) { synchronized (this.b) { this.q = z; this.I = null; this.H = -1; } } public final void B(int i) { if (i != 0 && i != 2 && i != 1) { throw new IllegalArgumentException("Invalid type"); } synchronized (this.b) { this.a = i; } } public final SSLSocket C(Socket socket, String str, int i) { e eVar; SSLSocket sSLSocket = (SSLSocket) k(this.G).createSocket(socket, str, i, true); if (this.F && (eVar = this.y) != null) { Socket socket2 = (Socket) eVar.c; if (socket2 instanceof SSLSocket) { x8.g.c(sSLSocket, ((SSLSocket) socket2).getSession()); } } return sSLSocket; } public final boolean D() { boolean z; synchronized (this.b) { z = this.r; } return z; } public final void a(mp0 mp0Var) { synchronized (this.b) { this.k.add(mp0Var); e eVar = this.y; if (eVar != null) { ((ArrayList) eVar.b).add(mp0Var); } } } public final void b(String str) { synchronized (this.b) { try { if (str.equals(this.z)) { return; } if (this.n) { if (this.p) { this.y.t("CWD ".concat(str)); up0 q = this.y.q(); if (q.c()) { this.z = str; return; } throw new lp0(q); } throw new IllegalStateException("Client not authenticated"); } throw new IllegalStateException("Client not connected"); } catch (Throwable th) { throw th; } } } public final String[] c(String str, int i, boolean z, np0 np0Var) { InetAddress inetAddress; String[] strArr; boolean z2; this.G = np0Var; this.o = z; synchronized (this.b) { try { if (!this.n) { if (this.f == null) { if (this.e && (i < 0 || i == 21)) { z2 = true; } else { z2 = false; } this.f = new AtomicBoolean(z2); } if (i < 0) { if (this.e && !this.f.get()) { i = 990; } else { i = 21; } } Socket socket = null; try { Socket a = this.i.a(i, str); try { if (this.e && !this.f.get()) { a = C(a, str, i); } try { this.C = a.getLocalAddress(); } catch (Throwable unused) { Pattern pattern = zz1.a; try { try { inetAddress = InetAddress.getLocalHost(); } catch (UnknownHostException unused2) { inetAddress = InetAddress.getByName("127.0.0.1"); } } catch (UnknownHostException unused3) { inetAddress = null; } this.C = inetAddress; } a.getLocalPort(); this.D = a.getInetAddress(); a.getPort(); this.B = this.D instanceof Inet6Address; String str2 = this.s; if (str2 == null) { str2 = "UTF-8"; } this.y = new e(str2, a); Iterator it = this.k.iterator(); while (it.hasNext()) { ((ArrayList) this.y.b).add((mp0) it.next()); } up0 q = this.y.q(); if (q.c()) { this.n = true; this.p = false; this.l = null; this.m = str; this.t = false; this.r = false; this.u = false; this.v = false; strArr = (String[]) q.c; } else { throw new lp0(q); } } catch (Throwable th) { th = th; socket = a; if (!this.n && socket != null) { try { socket.close(); } catch (Throwable unused4) { } } throw th; } } catch (Throwable th2) { th = th2; } } else { throw new IllegalStateException("Client already connected to " + str + " on port " + i); } } finally { } } return strArr; } public final void d(String str) { synchronized (this.b) { try { if (this.n) { if (this.p) { this.y.t("MKD " + str); up0 q = this.y.q(); if (!q.c()) { throw new lp0(q); } } else { throw new IllegalStateException("Client not authenticated"); } } else { throw new IllegalStateException("Client not connected"); } } catch (Throwable th) { throw th; } } } public final void e(String str) { synchronized (this.b) { try { if (this.n) { if (this.p) { this.y.t("DELE " + str); up0 q = this.y.q(); if (!q.c()) { throw new lp0(q); } } else { throw new IllegalStateException("Client not authenticated"); } } else { throw new IllegalStateException("Client not connected"); } } catch (Throwable th) { throw th; } } } public final void g(boolean z) { synchronized (this.b) { try { if (this.n) { if (z) { this.y.t("QUIT"); up0 q = this.y.q(); if (!q.c()) { throw new lp0(q); } } zr0.J((Socket) this.y.c); this.y = null; this.n = false; } else { throw new IllegalStateException("Client not connected"); } } catch (Throwable th) { throw th; } } } public final j10 h() { j10 j10Var; synchronized (this.b) { j10Var = this.i; } return j10Var; } public final sp0 i(long j, long j2, String str) { sp0 sp0Var; synchronized (this.b) { try { if (this.n) { if (this.p) { int i = this.a; if (i == 0) { i = f(str); } if (i == 1) { this.y.t("TYPE A"); } else if (i == 2) { this.y.t("TYPE I"); } up0 q = this.y.q(); if (q.c()) { jp0 s = s(); if (this.r || j2 > 0) { try { this.y.t("REST " + j2); up0 q2 = this.y.q(); int i2 = q2.b; if (i2 != 350 && ((i2 != 501 && i2 != 502) || j2 > 0)) { throw new lp0(q2); } } finally { } } this.y.t("RETR " + str); try { try { Socket b = s.b(); s.a(); synchronized (this.c) { } this.w = b.getInputStream(); sp0Var = new sp0(b, this.w, j, new ep0(this, 1)); up0 q3 = this.y.q(); int i3 = q3.b; if (i3 != 150 && i3 != 125) { throw new lp0(q3); } } catch (Throwable th) { up0 q4 = this.y.q(); int i4 = q4.b; if (i4 != 150 && i4 != 125) { throw new lp0(q4); } throw th; } } finally { } } else { throw new lp0(q); } } else { throw new IllegalStateException("Client not authenticated"); } } else { throw new IllegalStateException("Client not connected"); } } finally { } } return sp0Var; } public final qp0 j(boolean z) { qp0 qp0Var; if (z) { this.l = zo1.a; } else if (this.l == null) { String l = l(); if (l != null) { if (nb0.a.matcher(l).matches()) { try { Class<?> cls = Class.forName(l); try { qp0Var = (qp0) cls.newInstance(); } catch (ClassCastException e) { throw new q12(cls.getName().concat(" does not implement the interface ftp.FTPFileEntryParser."), e); } catch (Exception e2) { throw new q12("Error initializing parser", e2); } catch (ExceptionInInitializerError e3) { throw new q12("Error initializing parser", e3); } } catch (ClassNotFoundException unused) { } if (qp0Var == null) { String upperCase = l.toUpperCase(Locale.ENGLISH); if (upperCase.contains("UNIX_LTRIM")) { xv1.d("FTP_PARSER", "SYST_UNIX_TRIM_LEADING"); qp0Var = new tn3(true); } else if (upperCase.contains("UNIX")) { xv1.d("FTP_PARSER", "SYST_UNIX"); qp0Var = new tn3(false); } else if (upperCase.contains("VMS")) { qp0Var = new l80(2); } else if (upperCase.contains("WINDOWS")) { qp0Var = new oz(new qp0[]{new l80(1), new tn3(false)}); } else if (upperCase.contains("OS/2")) { qp0Var = new uj0(3); } else if (!upperCase.contains("OS/400") && !upperCase.contains("AS/400")) { if (upperCase.contains("MVS")) { qp0Var = new cp1(); } else if (upperCase.contains("NETWARE")) { qp0Var = new uj0(2); } else if (upperCase.contains("MACOS PETER")) { qp0Var = new uj0(1); } else if (!upperCase.contains("DOS") && !upperCase.contains("OWS_NT")) { if (upperCase.contains("EPLF")) { qp0Var = new oz(new qp0[]{new uj0(0), new tn3(false)}); } else if (upperCase.contains("TYPE: L8")) { xv1.d("FTP_PARSER", "SYST_L8"); qp0Var = new tn3(false); } else if (upperCase.contains("EMULATED BY FILEZILLA")) { xv1.d("FTP_PARSER", "FILEZILLA"); qp0Var = new tn3(false); } else if (upperCase.contains("FTPSERVER")) { xv1.d("FTP_PARSER", "FTPSERVER"); qp0Var = new tn3(false); } else { xv1.u("FTP_PARSER", "UNKNOWN TYPE > ", upperCase); qp0Var = new tn3(false); } } else { qp0Var = new oz(new qp0[]{new l80(0), new l80(1), new tn3(false)}); } } else { qp0Var = new oz(new qp0[]{new uj0(4), new tn3(false)}); } } if (qp0Var instanceof g00) { ((g00) qp0Var).a(null); } this.l = qp0Var; } qp0Var = null; if (qp0Var == null) { } if (qp0Var instanceof g00) { } this.l = qp0Var; } else { throw new q12(3); } } return this.l; } public final SSLSocketFactory k(np0 np0Var) { SSLSocketFactory sSLSocketFactory; im3 im3Var; synchronized (this.b) { try { if (this.j == null) { if (this.e) { try { if (!this.E) { im3Var = jm3.c; } else { im3Var = jm3.b; } this.j = new o33(im3Var, np0Var, this.o); } catch (Throwable th) { xv1.j("FTPClient", "SF", ui3.A(th)); } } if (this.j == null) { this.j = (SSLSocketFactory) SSLSocketFactory.getDefault(); } } sSLSocketFactory = this.j; } catch (Throwable th2) { throw th2; } } return sSLSocketFactory; } public final String l() { if (this.A == null) { this.y.t("SYST"); up0 q = this.y.q(); if (q.c()) { this.A = ((String[]) q.c)[r0.length - 1].substring(4).trim(); xv1.o("FTPClient", "System Type > " + this.A); } else { throw new lp0(q); } } return this.A; } public final boolean m() { boolean z; synchronized (this.b) { z = this.p; } return z; } public final boolean n() { boolean z; synchronized (this.b) { if (this.y == null) { z = true; } else { z = false; } } return z; } public final boolean o() { boolean z; synchronized (this.b) { z = this.n; } return z; } public final pp0[] p(String str) { String str2; String concat; pp0[] M2; synchronized (this.b) { try { if (this.n) { if (this.p) { jp0 s = s(); boolean z = this.u; if (z) { concat = "MLSD"; } else { if (this.g) { str2 = " -al"; } else { str2 = ""; } concat = "LIST".concat(str2); } fg fgVar = new fg(j(z)); if (this.h) { String parent = new File(str).getParent(); if (ui3.x(parent)) { parent = "/"; } b(parent); concat = concat + " " + ui3.C(str, false, false); } else { b(str); } this.y.t(concat); try { try { Socket b = s.b(); s.a(); synchronized (this.c) { } try { try { InputStream inputStream = b.getInputStream(); this.w = inputStream; String str3 = this.s; if (str3 == null) { str3 = "UTF-8"; } fgVar.Y(inputStream, str3); InputStream inputStream2 = this.w; if (inputStream2 != null) { try { inputStream2.close(); } catch (Throwable unused) { } this.w = null; } try { b.close(); } catch (Throwable unused2) { } synchronized (this.c) { } up0 q = this.y.q(); int i = q.b; if (i != 150 && i != 125) { throw new lp0(q); } up0 q2 = this.y.q(); if (q2.b == 226) { M2 = fgVar.M(); if (M2 == null) { throw new IOException("Couldn't parse the list"); } } else { throw new lp0(q2); } } catch (IOException e) { synchronized (this.c) { throw new kp0("I/O error in data transfer", e); } } } catch (Throwable th) { InputStream inputStream3 = this.w; if (inputStream3 != null) { try { inputStream3.close(); } catch (Throwable unused3) { } this.w = null; } try { b.close(); } catch (Throwable unused4) { } synchronized (this.c) { throw th; } } } catch (Throwable th2) { up0 q3 = this.y.q(); int i2 = q3.b; if (i2 != 150 && i2 != 125) { throw new lp0(q3); } up0 q4 = this.y.q(); if (q4.b == 226) { throw th2; } throw new lp0(q4); } } catch (Throwable th3) { s.a(); throw th3; } } else { throw new IllegalStateException("Client not authenticated"); } } else { throw new IllegalStateException("Client not connected"); } } catch (Throwable th4) { throw th4; } } return M2; } public final void q(String str, String str2, String str3) { boolean z; boolean z2; synchronized (this.b) { try { if (this.n) { if (this.e && this.f.get()) { this.y.t("AUTH TLS"); if (this.y.q().c()) { this.y.v(k(this.G)); } else { this.y.t("AUTH SSL"); up0 q = this.y.q(); if (q.c()) { this.y.v(k(this.G)); } else { throw new lp0(q.b, "FTPES failed > Server refused AUTH TLS/SSL."); } } } boolean z3 = false; this.p = false; this.y.t("USER " + str); up0 q2 = this.y.q(); int i = q2.b; if (i != 230) { if (i != 331) { if (i == 332) { z = false; z2 = true; if (!z) { if (str2 != null) { this.y.t("PASS ".concat(str2)); up0 q3 = this.y.q(); int i2 = q3.b; if (i2 != 230) { if (i2 == 332) { z3 = true; } else { throw new lp0(q3); } } } else { throw new lp0(331); } } else { z3 = z2; } if (z3) { if (str3 != null) { this.y.t("ACCT ".concat(str3)); up0 q4 = this.y.q(); if (q4.b != 230) { throw new lp0(q4); } } else { throw new lp0(332); } } this.p = true; } else { throw new lp0(q2); } } else { z = true; } } else { z = false; } z2 = false; if (!z) { } if (z3) { } this.p = true; } else { throw new IllegalStateException("Client not connected"); } } finally { } } t(); } public final void r() { synchronized (this.b) { try { if (this.n) { if (this.p) { this.y.t("REIN"); up0 q = this.y.q(); if (q.c()) { this.p = false; } else { throw new lp0(q); } } else { throw new IllegalStateException("Client not authenticated"); } } else { throw new IllegalStateException("Client not connected"); } } catch (Throwable th) { throw th; } } } public final jp0 s() { if (this.q) { if (this.B) { this.y.t("EPSV"); up0 q = this.y.q(); if (q.b == 229) { String b = q.b(); String trim = b.substring(b.indexOf(40) + 1, b.indexOf(41)).trim(); char charAt = trim.charAt(0); char charAt2 = trim.charAt(1); char charAt3 = trim.charAt(2); char charAt4 = trim.charAt(trim.length() - 1); if (charAt == charAt2 && charAt2 == charAt3 && charAt3 == charAt4) { try { int parseInt = Integer.parseInt(trim.substring(3, trim.length() - 1)); this.I = this.D.getHostAddress(); this.H = parseInt; return new gp0(this); } catch (NumberFormatException unused) { throw new lp0(209, "Could not parse extended passive host information.\nServer Reply: ".concat(trim)); } } throw new lp0(209, "Could not parse extended passive host information.\nServer Reply: ".concat(trim)); } } if (!this.B) { this.y.t("PASV"); up0 q2 = this.y.q(); if (q2.c()) { if (q2.b == 227) { String b2 = q2.b(); Matcher matcher = M.matcher(b2); if (matcher.find()) { this.I = matcher.group(1).replace(',', '.'); try { this.H = Integer.parseInt(matcher.group(3)) | (Integer.parseInt(matcher.group(2)) << 8); gp0 gp0Var = this.J; if (gp0Var != null) { try { String str = this.I; if (InetAddress.getByName(str).isSiteLocalAddress()) { InetAddress inetAddress = gp0Var.X.D; if (!inetAddress.isSiteLocalAddress()) { str = inetAddress.getHostAddress(); } } if (!this.I.equals(str)) { this.I = str; } } catch (UnknownHostException unused2) { throw new lp0(207, u41.w("Could not parse passive host information.\nServer Reply: ", b2)); } } return new gp0(this); } catch (NumberFormatException unused3) { throw new lp0(207, u41.w("Could not parse passive port information.\nServer Reply: ", b2)); } } throw new lp0(207, u41.w("Could not parse passive host information.\nServer Reply: ", b2)); } throw new lp0(229, "Must use EPSV for IPV6."); } throw new lp0(q2); } throw new lp0(229, "Must use EPSV for IPV6."); } fp0 fp0Var = new fp0(this); int localPort = fp0Var.X.getLocalPort(); InetAddress inetAddress2 = this.C; if (this.B) { String hostAddress = inetAddress2.getHostAddress(); int indexOf = hostAddress.indexOf("%"); if (indexOf > 0) { hostAddress = hostAddress.substring(0, indexOf); } StringBuilder sb = new StringBuilder("|"); if (inetAddress2 instanceof Inet4Address) { sb.append("1"); } else if (inetAddress2 instanceof Inet6Address) { sb.append("2"); } sb.append("|"); sb.append(hostAddress); sb.append("|"); sb.append(localPort); sb.append("|"); this.y.t("EPRT " + sb.toString()); } else { StringBuilder sb2 = new StringBuilder(24); sb2.append(inetAddress2.getHostAddress().replace('.', ',')); sb2.append(','); sb2.append(localPort >>> 8); sb2.append(','); sb2.append(localPort & 255); this.y.t("PORT " + sb2.toString()); } up0 q3 = this.y.q(); if (q3.c()) { return fp0Var; } fp0Var.a(); try { fp0Var.b().close(); } catch (Throwable unused4) { } throw new lp0(q3); } public final void t() { synchronized (this.b) { try { this.t = false; this.r = false; this.u = false; this.v = false; this.y.t("FEAT"); up0 q = this.y.q(); if (q.b == 211) { String[] strArr = (String[]) q.c; for (int i = 1; i < strArr.length - 1; i++) { String trim = strArr[i].trim(); Locale locale = vf3.c; String upperCase = trim.toUpperCase(locale); if ("REST STREAM".equalsIgnoreCase(upperCase)) { this.r = true; } else if (rp.X.equalsIgnoreCase(upperCase)) { this.t = true; this.y.f("UTF-8"); } else { if (!upperCase.toUpperCase(locale).startsWith("MLSD") && !upperCase.toUpperCase(locale).startsWith("MLST")) { if (!"MODE Z".equalsIgnoreCase(upperCase)) { upperCase.startsWith("MODE Z "); } } this.u = true; } } } if (this.t) { this.y.t("OPTS UTF8 ON"); this.y.q(); } if (this.e) { this.y.t("PBSZ 0"); this.y.q(); this.y.t("PROT P"); if (this.y.q().c()) { this.v = true; } } } catch (Throwable th) { throw th; } } } public final String u() { String i; synchronized (this.b) { try { if (this.n) { if (this.p) { this.y.t("PWD"); up0 q = this.y.q(); if (q.c()) { String[] strArr = (String[]) q.c; if (strArr.length == 1) { Matcher matcher = K.matcher(strArr[0]); if (matcher.find()) { i = ui3.i(strArr[0].substring(matcher.start() + 1, matcher.end() - 1)); this.z = i; } else { throw new rp0(); } } else { throw new rp0(); } } else { throw new lp0(q); } } else { throw new IllegalStateException("Client not authenticated"); } } else { throw new IllegalStateException("Client not connected"); } } catch (Throwable th) { throw th; } } return i; } public final void v(String str, String str2) { synchronized (this.b) { try { if (this.n) { if (this.p) { this.y.t("RNFR " + str); up0 q = this.y.q(); if (q.b == 350) { this.y.t("RNTO " + str2); up0 q2 = this.y.q(); if (!q2.c()) { throw new lp0(q2); } } else { throw new lp0(q); } } else { throw new IllegalStateException("Client not authenticated"); } } else { throw new IllegalStateException("Client not connected"); } } catch (Throwable th) { throw th; } } } public final up0 w(String str) { up0 q; synchronized (this.b) { try { if (this.n) { this.y.t(str); q = this.y.q(); } else { throw new IllegalStateException("Client not connected"); } } catch (Throwable th) { throw th; } } return q; } public final void x(String str) { synchronized (this.b) { try { this.s = str; if (this.n) { try { e eVar = this.y; if (str == null) { str = "UTF-8"; } eVar.f(str); } catch (Throwable th) { xv1.j("FTPClient", "ENC", ui3.A(th)); } } } catch (Throwable th2) { throw th2; } } } public final void y(boolean z) { if (this.f == null) { this.f = new AtomicBoolean(); } this.f.set(z); } public final boolean z(String str, String str2) { synchronized (this.b) { try { if (this.n) { if (this.p) { this.y.t("MFMT " + str2 + " " + str); up0 q = this.y.q(); if (q.c()) { String[] strArr = (String[]) q.c; if (strArr.length == 1) { String str3 = strArr[0]; if (!"true".equalsIgnoreCase(str3) && !str3.equalsIgnoreCase("UTIME OK")) { xv1.s("FTP", "Result: ".concat(str3)); return false; } return true; } throw new rp0(); } throw new lp0(q); } throw new IllegalStateException("Client not authenticated"); } throw new IllegalStateException("Client not connected"); } finally { } } } }