How to use khash.exe?

  • Hi, guys.
    Can someone help me to understand the use of the program khash.exe? It's not clear for me from CREAD, CWRITE manual.



    1. I can't find cmdk.exe in the system. I so understand I can use cmd.exe? Ok. I execute khash.exe on the Windows shell cmd.exe (see the attached image). Where should I look for the encrypted password.


    2. Which password should I use? For example, I have two robots in my network (rob1 and rob2). I want to have an access from rob1 to the file on the D drive of the rob2 (by CWRITE). On which robot should I execute khash.exe to get the encrypted password? Or it makes no differance?

  • use command prompt (cmd.exe) and do not use START command here - it runs process in separate space and output will not be visible here.



    And navigate to correct folder where khash.exe is:


    C:\
    CD C:\KRC\UTIL\KHASH
    HASH


    last line will run program without parameters and just display help. [/size][size=small]this is common for all command line programs. but more importantly it shows if you can get something useful here. note that when launching program, extension of executables do not needed so .EXE, .COM, .CMD or .BAT can be omitted.


    then use it according to help (in case that differs from documentation)


    then type


    HASH 68kuka1secpw59


    and you sill see the password encrypted...

  • Hi, panic mode
    Thanks, it works.
    But now I have another issue.
    I have two robots. I want to have access to the files on Rob2 from Rob1 (using KRL program). The both robots are connected to the company network and I have access to them from my office laptop.
    I executed khash.exe on Rob2 and got the encrypted password (For encryption I used the standard kuka password: 68kuka1secpw59)
    Now I try to create a mount point by calling krl_mount() function:


    Code
    CWRITE($FCT_CALL, State, Mode, "krl_mount", "/TestMount", "//192.168.200.155/D/Backup", "KUKAUser", "0E76390E88C27932C9816D326AF12CEA2B")


    But CWRITE returns the error: Operation failed: invalid user, incorrect password, mount point
    not available, file not available, etc.


    Don't understand what I do wrong. Maybe I should use the other data for USERNAME and PASSWORD? ???

  • i would say do it in incremental steps.... before attempting to mount something on another machine, try to map something that is on existing machine, maybeon C:\ then on D:\
    And try to make external drive mapped to your robot, maybe as E:\ in which case it should be same to use as previous point.

    1) read pinned topic: READ FIRST...

    2) if you have an issue with robot, post question in the correct forum section... do NOT contact me directly

    3) read 1 and 2

  • Quote

    try to map something that is on existing machine, maybeon C:\ then on D:\


    Do you mean trying to get access to the machine on which I execute KRL program?
    If yes, I did this way. Firstly on D:\ and then on C:\. I executed the program on Rob1 (ip 192.168.200.154) and used the code:


    Code
    CWRITE($FCT_CALL, State, Mode, "krl_mount", "/TestMount", "//192.168.200.154/D/Backup", "KUKAUser", "0E76390E88C27932C9816D326AF12CEA2B")


    Is that right?

  • good idea but i don't think that will work... if you are trying to access local drive you need to use local IP address and - that is NOT the KLI address. in fact you cannot even ping your own KLI port from the controller.... well, not from Windows at least and that is where file sharing takes place.


    1. login and minimize HMI
    2. create folder such as D:\test
    3. make sure to SHARE this folder with the specific user account you plan on using, such as KukaUser
    4. return to HMI
    5. create test program using LOCAL network address such as 192.168.0.1. For example:


    CWRITE($FCT_CALL, State, Mode, "krl_mount", "/test", "//192.168.0.1/test", "KukaUser", "0E76390E88C27932C9816D326AF12CEA2B")



    Try and see if you get OK

    1) read pinned topic: READ FIRST...

    2) if you have an issue with robot, post question in the correct forum section... do NOT contact me directly

    3) read 1 and 2

  • Code
    CWRITE($FCT_CALL, State, Mode, "krl_mount", "/test", "//192.168.0.1/test", "KukaUser", "0E76390E88C27932C9816D326AF12CEA2B")


    It works. The command was executed without any error. Then I try opening a file:


    Code
    CWRITE ($FCT_CALL, State, Mode, "krl_fopen", "/test/test.txt", "w", nHandle, #FULL_BUFF)


    but have an error: Mount point not found :hmmm:

    Edited once, last by lomaxe ().

  • After the first command (krl_mount):

    Code
    STATE={STATE_T: RET1 #DATA_OK, MSG_NO 0, HITS 0, LENGTH 0}


    After the second command (krl_fopen):

    Code
    STATE={STATE_T: RET1 #CMD_ABORT, MSG_NO -32, MSG_TYPE "D", HITS 0, LENGTH 0}
  • KSS8.3.34 complains with MSG_NO value -2
    (Operation failed, e.g. because the file was opened outside a KRL program or the mode is “r”, “r+”, “rb” or “rb+”, but the file does not exist.")


    KSS8.5.6 shows MSG_NO value -32
    (Mount point not found)



    KSS8.3 response is a nonsense since attempt is to create new file using "w" mode.I would guess that CWRITE in KSS8.5 was modified to provide less ambiguous message of the problem. Still does not explain why mount command was reporting success....

    1) read pinned topic: READ FIRST...

    2) if you have an issue with robot, post question in the correct forum section... do NOT contact me directly

    3) read 1 and 2

  • Hey all,


    KSS 8.5.7 HF1. Tested this both on a compact controller for an Agilus, and on a full size controller for a KR16.


    Running into a similar issue as lomaxe with krl_fopen. I'm presently trying to write to the D:/ drive (for logs), after ensuring sharing privileges have been activated. Ultimately, I'm trying to get CWRITE commands to create, and write to a file inside of the D:/ drive under a specified directory. At present, I'm not using the krl_mount command to mount the D:/ drive as lomaxe did. From what I can tell from this thread, it doesn't appear to matter as they ran into the same issue I'm seeing. I'm going to attempt to mount the D:/ drive using the local IP per Panic_Mode (credentials "KukaUser" and the "68kuka1secpw59" password hash), but at present I'm not sure this will change the end result.


    Things that we've checked:

    - External PC connected via KLI, able to ping the IP address of the KRC controller (172.31.1.147, for reference)

    - External PC can access, and write, to D:/. Meaning create directories and files, along with deletion.

    - Error value for the STATE_T structure comes out to -2, indicating "Operation failed, e.g. because the file was opened outside a KRL program or the mode is “r”, “r+”, “rb” or “rb+”, but the file does not exist.". I've ensured that my code uses the append command ("a") with krl_fopen.


    Any recommendation / direction / feedback would be greatly appreciated.


    Some portion of my code shown below:


  • Including a snippet of code for drive mounting the local D:/, per PanicMode. Unfortunately I'm receiving a STATE.RET1 = #CMD_ABORT on this (MSG_NO -2, Operation failed: mount point not (or no longer) available.).


    I don't see any indication for why this would happen. I've tried the following iterations for mounting address:

    - //192.168.0.1/Log

    - //192.168.0.1/d/Log

    - //192.168.0.1/d

    - //192.168.0.1/


    I receive a MSG_NO: -2 in each of those cases.

  • looks like lomaxe made couple of mistakes. for example the user name and password are case sensitive and he was using "KUKAUser" instead of "KukaUser" in his code. also it seems he did not generate password hash correctly.


    about that...


    i have shown how to run khash to get result displayed but i did not test if the hash actually works... his pursuit of this thread stopped so i assumed he spotted the typos and got it working eventually.


    but today, after seeing your post, i decided to give a try and found that it does not work for me either... well i may need to use this feature so .... this was ...not acceptable.


    so i tried few things and concluded that problem is khash itself. info about using khash is actually completely WRONG... and that is both in manuals and as displayed on a command line by khash.exe itself. it looks like programmers at some point changed behaviour and this wasn't communicated to technical writers. and you know that writers would just take it as presented rather than try things out for themselves to see if their manuals are actually usable.


    so this is what happened:

    1. created folder D:\test2

    2. shared it

    3. gave everyone full access (no time to experiment)

    4. tried to reach the shared folder -> it worked

    5. created crude program using "KukaUser" and generated hash, triple checked it ... and it failed to run... until i tried to generate hash using USER NAME instead of PASSWORD. and vila... then it worked.


    i created new standard user (purposely not Admin) and with new password of course.

    generated hash and tested it again - all is fine at least when it comes to krl_mount.


    1) read pinned topic: READ FIRST...

    2) if you have an issue with robot, post question in the correct forum section... do NOT contact me directly

    3) read 1 and 2

  • Panic Mode,


    Thanks for looking into it.


    Still running into the frustrating result of getting a STAT.RET1 = #CMD_ABORT and MSG_NO = -32 (Mount point not found.) Code below...



    Truncated the rest of the code, as STAT.RET1 returns #CMD_ABORT at this point.

  • your line 26 is wrong. you are trying to use password in both fields, first as hashed and then as plain text.

    that is wrong. check manual and my screenshot.

    user name is not hashed - password is.


    HASH.EXE utility generates password hash but rather than passing password, one need to pass user name as parameter. but what comes out scrambled is a password.

    1) read pinned topic: READ FIRST...

    2) if you have an issue with robot, post question in the correct forum section... do NOT contact me directly

    3) read 1 and 2

  • ...Hold on. You run khash USERNAME, and get the hash for the password? How does khash know the password, to create the hash from, in that case?


    If you're running it to get "local" access to an account on the robot, khash could be accessing the password for that account somehow. But if the account you're trying to access only exists on a remote computer, khas would have no way of generating a valid SMB password hash for that remote account.

  • So I reached out to KUKA directly on this issue, wanted to follow up on couple of things:


    1. I'd originally tested this on KSS 8.5.7 HF1, which it turns out has a lot to do with the problems I've been tracking. It will successfully mount the local drive (in this instance, a directory on the shared D:/ drive). After mounting, if you try to run the "krl_fopen" command on HF1, it will fail. I attempted this same code with KSS 8.5.8 with no issues (unmount and mount D:/, make a new directory on the mounted drive, fopen, fprintf, etc). So it appears the KSS has something to do with this bug. My recommendation to anyone running into this issue w/ HF1 is to upgrade your software to the next stable version.


    2. The documentation per KUKA on the khash.exe is correct (based on a reliable POC at KUKA Robotics in Detroit). I think this got a little confused, and I wanted to be clear. I'm able to successfully unmount / mount D:/ with the following on KSS 8.5.8:

    Code
    CWRITE($FCT_CALL,STAT,MODE,"krl_unmount","/MountDrive")
    CWRITE($FCT_CALL,STAT,MODE,"krl_mount","/MountDrive","//192.168.0.1/d","kukauser","0E76390E88C27932C9816D326AF12CEA2B")

    Note that "kukauser" is case sensitive. Hashed password is "68kuka1secpw59"


    Everything else that followed worked successfully after the drive mount, including using:

    - krl_fopen

    - krl_mkdir

    - krl_fprintf

Advertising from our partners