pax_global_header00006660000000000000000000000064111252015360014506gustar00rootroot0000000000000052 comment=b34179023d9cd2d366886400b5a23c341d602b0f nxscramble-0.1/000075500000000000000000000000001112520153600135025ustar00rootroot00000000000000nxscramble-0.1/.gear-rules000075500000000000000000000000061112520153600155500ustar00rootroot00000000000000tar: .nxscramble-0.1/CMakeLists.txt000075500000000000000000000007321112520153600162470ustar00rootroot00000000000000PROJECT(nxscramble) SET(CMAKE_VERBOSE_MAKEFILE OFF) SET(CMAKE_INSTALL_PREFIX "/") SET(CMAKE_SKIP_RPATH OFF) FIND_PACKAGE(LibXml2 REQUIRED) FIND_PACKAGE(Qt4 REQUIRED) add_definitions(${QT_DEFINITIONS} ${LIBXML2_DEFINITIONS}) include_directories(${QT_INCLUDE_DIR} ${LIBXML2_INCLUDE_DIR}) add_executable(nxscramble nxscramble.cpp) TARGET_LINK_LIBRARIES(nxscramble ${QT_QTCORE_LIBRARY_RELEASE} ${LIBXML2_LIBRARIES}) INSTALL(TARGETS nxscramble RUNTIME DESTINATION usr/bin) nxscramble-0.1/build/000075500000000000000000000000001112520153600146015ustar00rootroot00000000000000nxscramble-0.1/build/.gitignore000075500000000000000000000000011112520153600165630ustar00rootroot00000000000000*nxscramble-0.1/nxscramble.cpp000075500000000000000000000074721112520153600163610ustar00rootroot00000000000000/*************************************************************************** * Copyright (C) 2008 by Максим Иванов * * ivanov@cg.ru * * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation; either version 2 of the License, or * * (at your option) any later version. * * * * This program is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU General Public License for more details. * * * * You should have received a copy of the GNU General Public License * * along with this program; if not, write to the * * Free Software Foundation, Inc., * * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * ***************************************************************************/ #include #include #include #include #include #include const int numValidCharList = 85; const QString dummyString = "{{{{"; QString encodePassword(const QString& p) { QString sPass = ":"; QString sTmp = ""; if (p.isEmpty()) { return ""; } for (unsigned int i = 0; i < p.length(); i++) { char c = p.at(i).toAscii(); sTmp.sprintf("%d:", (c + i + 1)); sPass += sTmp; sTmp = ""; } return sPass; } static char validCharList[numValidCharList] = { '!', '#', '$', '%', '&', '(', ')', '*', '+', '-', '.', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', ':', ';', '<', '>', '?', '@', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', '[', ']', '_', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', '{', '|', '}' }; static int findCharInList(char c) { int i = -1; for (int j = 0; j < numValidCharList; j++) { if (validCharList[j] == c) { i = j; return i; } } return i; } static char getRandomValidCharFromList() { int k = QTime::currentTime().second(); return validCharList[k]; } const char* scrambleString(const QString& s) { QString sRet = ""; if (s.isNull() || s.isEmpty()) { return s.toAscii().data(); } QString str = encodePassword(s); if (str.length() < 32) { str += dummyString; } for (int iR = (str.length() - 1); iR >= 0; iR--) { // // Reverse string // sRet += str.at(iR); } if (sRet.length() < 32) { sRet += dummyString; } int k = getRandomValidCharFromList(); int l = k + sRet.length() - 2; sRet.insert(0, k); for (int i1 = 1; i1 < (int)sRet.length(); i1++) { int j = findCharInList(sRet.at(i1).toLatin1()); if (j == -1) { return s.toAscii().data(); } int i = (j + l * (i1 + 1)) % numValidCharList; sRet[i1]=validCharList[i]; } char c = getRandomValidCharFromList() + 2; sRet.append(c); return (const char *) xmlEncodeEntitiesReentrant(NULL,xmlCharStrdup(sRet.toAscii().data())); } int main (int ac, char *av[]) { if (2 == ac) { printf("%s\n",scrambleString(QString(av[1]))); } else { error(1, errno, "Invalid number of arguments"); } return 0; } nxscramble-0.1/nxscramble.spec000075500000000000000000000014471112520153600165250ustar00rootroot00000000000000Name: nxscramble Version: 0.1 Release: alt3 Summary: Utility which scrambles password string same way as Nomachine NX client Group: Text tools License: GPL Source: %name-%version.tar Packager: Lenar Shakirov BuildRequires: libxml2-devel libqt4-devel cmake gcc-c++ qt4-settings %description Small tool which scrambles an plain text string the same way as Nomachine NX Client does it. %prep %setup %build cd build cmake .. %make %install cd build %makeinstall DESTDIR=%buildroot %files %_bindir/nxscramble %changelog * Fri Dec 26 2008 Lenar Shakirov 0.1-alt3 - BuildRequires updated * Fri Dec 26 2008 Lenar Shakirov 0.1-alt2 - New packager * Wed Mar 26 2008 Maxim Ivanov 0.1-alt1 - Initial build for Sisyphus