Skip to content

Commit

Permalink
Merge pull request #4 from aldostools/master
Browse files Browse the repository at this point in the history
ps3netsrv 20240210a
  • Loading branch information
jhonathanc authored Mar 19, 2024
2 parents c1e401e + cfff19b commit cea6cbe
Show file tree
Hide file tree
Showing 9 changed files with 312 additions and 34 deletions.
4 changes: 2 additions & 2 deletions LICENSE.TXT
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
## License
### 2014-2022 webMAN MOD / ps3netsrv
### 2014-2024 webMAN MOD / ps3netsrv

webMAN MOD is a FREE software and all its components (ps3netsrv included) are
distributed and protected under GNU General Public License version 3 (GPL v3)
Expand Down Expand Up @@ -48,7 +48,7 @@ the software.



(C) 2010-2022 multiMAN / webMAN / sMAN / sLaunch / prepNTFS by DeanK
(C) 2010-2024 multiMAN / webMAN / sMAN / sLaunch / prepNTFS by DeanK

Permission is hereby granted, free of charge, to any person
obtaining a copy of this software and associated documentation files
Expand Down
4 changes: 4 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@ CPPFLAGS += -Wall -Wno-format -I./include -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_B
#CFLAGS += -DOPT_FILE_SEEK
#CPPFLAGS += -DOPT_FILE_SEEK

#OUTPUT := makeiso
#CFLAGS += -DMAKEISO
#CPPFLAGS += -DMAKEISO

#CFLAGS += -DNOSSL
#CPPFLAGS +=-DNOSSL
#OBJS = src/main.o src/compat.o src/mem.o src/File.o src/VIsoFile.o
Expand Down
4 changes: 4 additions & 0 deletions Makefile.linux
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@ CPPFLAGS += -Wall -I./include -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -DPOL
CFLAGS += -Doff64_t=off_t
CPPFLAGS += -Doff64_t=off_t

#OUTPUT := makeiso
#CFLAGS += -DMAKEISO
#CPPFLAGS += -DMAKEISO

#CFLAGS += -DNOSSL
#CPPFLAGS +=-DNOSSL
#OBJS = src/main.o src/compat.o src/mem.o src/File.o src/VIsoFile.o
Expand Down
4 changes: 4 additions & 0 deletions Makefile.macos
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@ CPPFLAGS += -Wall -I./include -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -DPOL
CFLAGS += -Doff64_t=off_t
CPPFLAGS += -Doff64_t=off_t

#OUTPUT := makeiso
#CFLAGS += -DMAKEISO
#CPPFLAGS += -DMAKEISO

#CFLAGS += -DNOSSL
#CPPFLAGS +=-DNOSSL
#OBJS = src/main.o src/compat.o src/mem.o src/File.o src/VIsoFile.o
Expand Down
47 changes: 46 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,46 @@
# ps3netsrv

ps3netsrv is a server application used to stream content from a remote server to the PS3.

Supports automatic decryption of encrypted PS3 ISO and folder conversion to PS3 ISO or standard ISO.

For more information: https://github.com/aldostools/webMAN-MOD/wiki/~-PS3-NET-Server

Command line syntax:
```
ps3netsrv [rootdirectory] [port] [whitelist]
Default port: 38008
Whitelist: x.x.x.x, where x is 0-255 or *
(e.g 192.168.1.* to allow only connections from 192.168.1.0-192.168.1.255)
```

ISO conversion / decryption command line syntax:
```
ps3netsrv [game directory / encrypted iso] [PS3/ISO]
```

## Features

* Support up to 5 PS3 clients concurrently
* Configurable shared root directory (uses ps3netsrv path if the root directory is omitted)
* Configurable port (38008 is used by default if port is omitted)
* Start without command line parameters if GAMES, PS3ISO, PSXISO folders are found in ps3netsrv folder
* List local server IP addresses
* Remote IP address filtering: Whitelist IP addresses using wildcards
* Remote file operations (stat, open, create, read, close, delete, mkdir, rmdir)
* Remote directory listing (whole directory at once or by file) / include subdirectories
* List files in specified directory and all subdirectories if the path ends with //
* Merge multiple paths into a single directory (list paths in folder_name.INI)
* Streaming of ISO images (CD-ROM, CD-ROM XA, DVD, Bluray or PS3 Blurays)
* Detection of standard & non-standard CD sector sizes: 2048, 2352, 2336, 2448, 2328, 2368, 2340
* Multi-part ISO support (ISO images split as *.iso.0, *.iso.1, etc.)
* Realtime decryption of PS3 ISO images (3k3y & redump encrypted images)
* Realtime conversion of mounted folder to virtual ISO (vISO)
* Convert game folder or directory to local ISO file (drag & drop the ISO or folder for easy conversion)
* Decrypt encrypted PS3 ISO (using redump/3k3y encryption) into a new decrypted ISO

## Requirements

* A C/C++ compiler
Expand Down Expand Up @@ -66,6 +107,9 @@ OpenWrt<br>
All platforms (arm, arc, mips, mipsel, i386, powerpc, x86): https://github.com/jhonathanc/ps3netsrv/releases<br>
SRC: https://github.com/jhonathanc/ps3netsrv-openwrt<br>

QNAP NAS<br>
https://www.myqnap.org/product/ps3netsrv-ng/ <br>

Xcode (macOS / Linux / FreeBSD 10):<br>
https://github.com/klahjn/ps3netsrvXCODE <br>
https://github.com/klahjn/macOSPS3NetServerGUI
Expand All @@ -74,7 +118,8 @@ Google Go: https://github.com/xakep666/ps3netsrv-go

ps3netsrv modified for encrypted (3k3y/redump) isos: http://forum.redump.org/topic/14472

ps3netsrv modified for multiMAN: http://deanbg.com/ps3netsrv.zip
ps3netsrv modified for multiMAN:
https://github.com/aldostools/webMAN-MOD/blob/master/_Projects_/ps3netsrv/bins/old/ps3netsrv-src-deank.7z

Original ps3netsrv by Cobra for Linux / Windows:<br>
https://github.com/Joonie86/Cobra-7.00/tree/master/446/PC/ps3netsrv
4 changes: 4 additions & 0 deletions include/VIsoFile.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@

#include <sys/types.h>

#if defined(__APPLE__)
#define off64_t off_t
#endif

#include "AbstractFile.h"
#include "File.h"
#include "compat.h"
Expand Down
2 changes: 2 additions & 0 deletions include/color.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ static void set_red_text(void)
#endif
}

#ifndef MAKEISO
static void set_gray_text(void)
{
#ifdef WIN32
Expand All @@ -56,5 +57,6 @@ static void set_gray_text(void)
printf("\033[1;30m");
#endif
}
#endif

#endif
70 changes: 56 additions & 14 deletions src/File.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
#include "common.h"
#include "compat.h"

extern int make_iso;

static const int FAILED = -1;
static const int SUCCEEDED = 0;

Expand Down Expand Up @@ -62,7 +64,7 @@ File::~File()

int File::open(const char *path, int flags)
{
init_region_info();
if(flags == O_RDONLY) init_region_info();

if(!path)
{
Expand Down Expand Up @@ -98,15 +100,17 @@ int File::open(const char *path, int flags)
path_ps3iso_loc = strstr((char *)path, (char *)"ps3iso");

char *path_ext_loc = NULL;
if (path_ps3iso_loc)
if (path_ps3iso_loc || make_iso)
{
path_ext_loc = strstr((char *)(path + flen), (char *)".iso");
if (path_ext_loc == NULL)
path_ext_loc = strstr((char *)(path + flen), (char *)".ISO");
}

// Encryption only makes sense for .iso or .ISO files in the .../PS3ISO/ folder so exit quick if req is is not related.
if (is_multipart || (path_ps3iso_loc == NULL) || (path_ext_loc == NULL) || (path_ext_loc < path_ps3iso_loc))
if(make_iso && (flags == O_RDONLY))
;
else if (is_multipart || (path_ps3iso_loc == NULL) || (path_ext_loc == NULL) || (path_ext_loc < path_ps3iso_loc))
{
// Clean-up old region_info_ (even-though it shouldn't be needed).
if (region_info_ != NULL)
Expand Down Expand Up @@ -161,30 +165,61 @@ int File::open(const char *path, int flags)
key_path[path_ext_loc - path + 4] = 'y';
key_path[path_ext_loc - path + 5] = '\0';

key_fd = open_file(key_path, flags);
if (!FD_OK(key_fd))
key_fd = open_file(key_path, O_RDONLY);

if (!FD_OK(key_fd) && (path_ext_loc > path))
{
// Check for redump encrypted mode by looking for the ".dkey" file in the "REDKEY" folder.
// Check for redump encrypted mode by looking for the ".key" is the same path of the ".iso".
key_path[path_ext_loc - path + 1] = 'k';
key_path[path_ext_loc - path + 2] = 'e';
key_path[path_ext_loc - path + 3] = 'y';
key_path[path_ext_loc - path + 4] = '\0';

key_fd = open_file(key_path, O_RDONLY);
}

if (!FD_OK(key_fd) && (path_ps3iso_loc > path))
{
// Check for redump encrypted mode by looking for the ".key" or ".dkey" file in the "REDKEY" folder.
key_path[path_ps3iso_loc - path + 0] = 'R';
key_path[path_ps3iso_loc - path + 1] = 'E';
key_path[path_ps3iso_loc - path + 2] = 'D';
key_path[path_ps3iso_loc - path + 3] = 'K';
key_path[path_ps3iso_loc - path + 4] = 'E';
key_path[path_ps3iso_loc - path + 5] = 'Y';

key_fd = open_file(key_path, flags);
key_fd = open_file(key_path, O_RDONLY);

if (!FD_OK(key_fd))
{
// Check for redump encrypted mode by looking for the ".dkey" is the same path of the ".iso".
key_path[path_ext_loc - path + 1] = 'd';
key_path[path_ext_loc - path + 2] = 'k';
key_path[path_ext_loc - path + 3] = 'e';
key_path[path_ext_loc - path + 4] = 'y';
key_path[path_ext_loc - path + 5] = '\0';

key_fd = open_file(key_path, O_RDONLY);
}
}

if (FD_OK(key_fd))
printf("key: %s\n", key_path);

delete[] key_path;

// Check if key_path exists, and create the aes_dec_ context if so.
if (FD_OK(key_fd))
{
char keystr[32];
if (read_file(key_fd, keystr, sizeof(keystr)) == sizeof(keystr))
unsigned char key[16];
int klen = read_file(key_fd, keystr, sizeof(keystr));
if (klen == sizeof(keystr) || klen == sizeof(key))
{
unsigned char key[16];
keystr_to_keyarr(keystr, key);
if(klen == sizeof(key))
memcpy(key, keystr, sizeof(key));
else
keystr_to_keyarr(keystr, key);
#ifdef POLARSSL
if (aes_setkey_dec(&aes_dec_, key, 128) == SUCCEEDED)
enc_type_ = kDiscTypeRedump; // SET ENCRYPTION TYPE: Redump
Expand Down Expand Up @@ -270,8 +305,15 @@ int File::open(const char *path, int flags)
}
}

if(enc_type_ == kDiscTypeRedump)
printf("Redump key found.\n");
else if(enc_type_ == kDiscType3k3yEnc)
printf("3K3YEnc key found.\n");
else if(enc_type_ == kDiscType3k3yDec)
printf("3K3YDec key found.\n");

return SUCCEEDED;
#endif
#endif //#ifndef NOSSL
}

int File::close(void)
Expand Down Expand Up @@ -383,7 +425,7 @@ ssize_t File::read(void *buf, size_t nbyte)
(unsigned long long int)((region_count_ > 0) ? region_info_[region_count_ - 1].regions_first_addr : 0),
(unsigned long long int)((region_count_ > 0) ? region_info_[region_count_ - 1].regions_last_addr : 0));
return ret;
#endif
#endif //#ifdef NOSSL
}

// read multi part iso (2015 AV)
Expand Down Expand Up @@ -519,5 +561,5 @@ void File::decrypt_data(mbedtls_aes_context &aes, unsigned char *data, int secto
}
}
}
#endif
#endif
#endif //#ifdef POLARSSL
#endif //#ifndef NOSSL
Loading

0 comments on commit cea6cbe

Please sign in to comment.